public class DatabaseConnector extends Connector
Connector.ConnectorNameThreadFactory
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ADD_MODIFED_ONLY_SCAN |
static java.lang.String |
CHECK_FOR_MISSING |
DatabaseConnectorConfig |
config |
static java.lang.String |
CURRENT_SQL_TYPE_CHECKPOINT |
static java.lang.String |
CURRENT_TIME_CHECKPOINT |
DatabaseFetcher |
fetcher |
static java.lang.String |
FULL_RESCAN_FROM_CHECKPOINT |
CheckpointValue |
lastUpdateStamp |
protected com.exalead.connector.InterConnectorServiceImpl |
service |
static java.lang.String |
SYNCHRONISATION_OCCURED |
DEFAULT_SCAN_MODE, papi
Constructor and Description |
---|
DatabaseConnector(DatabaseConnectorConfig config) |
Modifier and Type | Method and Description |
---|---|
void |
callBeforeDestruction()
Override this method to do some task before the destruction of the
connector
|
void |
compareAgainstDatabaseConnected(PushAPI papi,
java.lang.String mode,
java.sql.Connection connection,
CheckpointValue startTimeStamp) |
java.sql.Connection |
connect()
connects to a database with the configured credentials (if supplied).
|
java.lang.String[] |
contextualizeIncrementalQueries(java.lang.String[] queries,
PushAPI papi,
CheckpointValue startTimeStamp,
VariableReplacementMode substitutionMode) |
ContextualizedQuery |
contextualizeIncrementalQuery(java.lang.String query,
PushAPI papi,
CheckpointValue checkpointValue,
VariableReplacementMode substitutionMode) |
java.sql.PreparedStatement |
createDeleteStatement(java.sql.Connection connection,
java.lang.String query)
creates the statement used for delete.
|
java.sql.PreparedStatement |
createFetchStatement(java.sql.Connection connection,
java.lang.String query)
creates the statement used for fetch.
|
java.sql.PreparedStatement |
createStatement(java.sql.Connection connection,
java.lang.String query)
creates a statement from a connection
|
java.sql.PreparedStatement |
createTimeStampStatement(java.sql.Connection connection,
java.lang.String query)
creates the statement used for timestamp retrieval.
|
void |
deleteOnceConnected(PushAPI papi,
java.lang.String mode,
java.sql.Connection connection,
CheckpointValue startTimeStamp,
CheckpointValue forceFullRescanCheckPointValue)
remove deleted documents from index if allUrisQuery is supplied in configuration.
|
void |
disconnect(java.sql.Connection connection)
disconnects from a database.
|
void |
executeQueries(java.sql.Connection cnx,
java.lang.String[] queries,
java.lang.String verboseMessage) |
Document |
fetch(java.lang.String uri)
This method is used to retrieve document from the source when CloudView
product needs it.
|
Document |
fetchOnceConnected(java.sql.Connection connection,
java.lang.String uri)
builds an html document describing extracted metas
|
CheckpointValue |
fetchUpdateCheckpoint(PushAPI papi)
retrieve the date of the last synchronization (if CurrentTimeQuery is supplied)
|
static java.lang.String |
formatSqlError(java.sql.SQLException sqle)
Format an SQL error message
|
CheckpointValue |
getCurrentTimeStamp(java.sql.Connection connection)
fetches the current date and time from the database.
|
MetaContainer |
getDocumentSecurityTokens(java.lang.String s)
This method is used to retrieve security tokens of a document.
|
java.sql.ResultSet |
getResultSet(java.sql.Statement statement) |
boolean |
hasAlreadySynchronized(PushAPI papi)
checks whether a synchronization has been performed.
|
void |
scan(PushAPI papi,
java.lang.String mode,
java.lang.Object modeConfig)
This method is used to push (or synchronize) all documents from the source
to CloudView product.
|
void |
scratch(PushAPI papi)
Clear connector state, default implementation:
removes documents previously sent by the connector from CloudView index.
clears checkpoints of the connector.
Unless the connector is persisting additional data, there is not point to
override this method.
|
boolean |
sendDateCheckpoint(PushAPI papi,
boolean incrementalMode)
saves the given timestamp as a checkpoint.
|
void |
sendSynchronizationCheckpoint(PushAPI papi,
boolean incremental)
saves that a synchronization has been performed.
|
void |
setUpdateCheckpoint(CheckpointValue checkpointValue)
override the value of the update checkpoint (used by the incremental synchronization)
|
int |
synchronizeOnceConnected(PushAPI papi,
java.lang.String mode,
java.sql.Connection connection,
CheckpointValue startTimeStamp,
CheckpointValue forceFullRescanCheckPointValue)
pushes document from a database.
|
void |
verbose(java.lang.String msg) |
checkAbortingOperation, checkAbortingOperation, checkDataSourceAvailability, checkSecurityTokens, fetch, getConnectorConfig, getConnectorName, getEndpointBuilder, getLogger, getLogger, getScanModes, getState, getState, getStatus, getStatus, getStatusException, init, init, onScanAborted, onScanAborted, onScanResumed, onScanResumed, onScanSuspended, onScanSuspended, selfAbortScan, selfAbortScan, synchronizeDocuments
public static final java.lang.String FULL_RESCAN_FROM_CHECKPOINT
public static final java.lang.String CHECK_FOR_MISSING
public static final java.lang.String ADD_MODIFED_ONLY_SCAN
public static final java.lang.String CURRENT_TIME_CHECKPOINT
public static final java.lang.String CURRENT_SQL_TYPE_CHECKPOINT
public static final java.lang.String SYNCHRONISATION_OCCURED
public DatabaseConnectorConfig config
public CheckpointValue lastUpdateStamp
public DatabaseFetcher fetcher
protected com.exalead.connector.InterConnectorServiceImpl service
public DatabaseConnector(DatabaseConnectorConfig config) throws java.lang.Exception
java.lang.Exception
public void verbose(java.lang.String msg)
public MetaContainer getDocumentSecurityTokens(java.lang.String s)
Connector
getDocumentSecurityTokens
in class Connector
s
- Uri of documentpublic Document fetch(java.lang.String uri) throws java.lang.Exception
Connector
public static java.lang.String formatSqlError(java.sql.SQLException sqle)
sqle
- The error/warning to formatpublic void scan(PushAPI papi, java.lang.String mode, java.lang.Object modeConfig) throws java.lang.Exception
Connector
scan
in class Connector
papi
- PushAPI used to dialog with CloudViewmode
- Type of scan to perform. Is always Connector.DEFAULT_SCAN_MODE
unless
the connector declares additional scan modes with ConnectorCapabilities
annotation.modeConfig
- Optional configuration given to the scanMode, according to ScanModeDefinition
annotation.java.lang.Exception
- Upon errorpublic void scratch(PushAPI papi) throws java.lang.Exception
Connector
public void callBeforeDestruction() throws java.lang.Exception
Connector
callBeforeDestruction
in class Connector
java.lang.Exception
public java.sql.Connection connect() throws java.sql.SQLException
java.sql.SQLException
public void disconnect(java.sql.Connection connection) throws java.sql.SQLException
connection
- java.sql.SQLException
public java.sql.PreparedStatement createStatement(java.sql.Connection connection, java.lang.String query) throws java.sql.SQLException
connection
- the connection to build the statement fromthe
- SQL query to be executedjava.sql.SQLException
public java.sql.ResultSet getResultSet(java.sql.Statement statement) throws java.sql.SQLException
java.sql.SQLException
public java.sql.PreparedStatement createFetchStatement(java.sql.Connection connection, java.lang.String query) throws java.sql.SQLException
connection
- java.sql.SQLException
public Document fetchOnceConnected(java.sql.Connection connection, java.lang.String uri) throws java.lang.Exception
connection
- uri
- PushAPIException
java.sql.SQLException
java.lang.Exception
public java.sql.PreparedStatement createDeleteStatement(java.sql.Connection connection, java.lang.String query) throws java.sql.SQLException
connection
- query
- The SQL query yo executejava.sql.SQLException
public void deleteOnceConnected(PushAPI papi, java.lang.String mode, java.sql.Connection connection, CheckpointValue startTimeStamp, CheckpointValue forceFullRescanCheckPointValue) throws java.lang.Exception
connection
- java.sql.SQLException
PushAPIException
java.lang.Exception
public void compareAgainstDatabaseConnected(PushAPI papi, java.lang.String mode, java.sql.Connection connection, CheckpointValue startTimeStamp) throws java.lang.Exception
papi
- mode
- connection
- startTimeStamp
- forceFullRescan
- forceFullRescanCheckPointValue
- java.lang.Exception
public void executeQueries(java.sql.Connection cnx, java.lang.String[] queries, java.lang.String verboseMessage) throws java.sql.SQLException
java.sql.SQLException
public int synchronizeOnceConnected(PushAPI papi, java.lang.String mode, java.sql.Connection connection, CheckpointValue startTimeStamp, CheckpointValue forceFullRescanCheckPointValue) throws java.lang.Exception
papi
- mode
- connection
- startTimeStamp
- forceFullRescan
- forceFullRescanCheckPointValue
- java.lang.Exception
public java.lang.String[] contextualizeIncrementalQueries(java.lang.String[] queries, PushAPI papi, CheckpointValue startTimeStamp, VariableReplacementMode substitutionMode) throws PushAPIException
PushAPIException
public ContextualizedQuery contextualizeIncrementalQuery(java.lang.String query, PushAPI papi, CheckpointValue checkpointValue, VariableReplacementMode substitutionMode) throws PushAPIException
PushAPIException
public CheckpointValue fetchUpdateCheckpoint(PushAPI papi) throws PushAPIException
papi
- The PushAPi to query for the checkpointPushAPIException
#sendDateCheckpoint(PushAPI, boolean)}
public java.sql.PreparedStatement createTimeStampStatement(java.sql.Connection connection, java.lang.String query) throws java.sql.SQLException
connection
- java.sql.SQLException
public CheckpointValue getCurrentTimeStamp(java.sql.Connection connection) throws java.sql.SQLException
connection
- java.sql.SQLException
public boolean sendDateCheckpoint(PushAPI papi, boolean incrementalMode) throws PushAPIException
connection
- timestamp
- true
if there was a incremental checkpoint to setPushAPIException
#fetchUpdateCheckpoint(PushAPI)}
public boolean hasAlreadySynchronized(PushAPI papi) throws PushAPIException
PushAPIException
sendSynchronizationCheckpoint(PushAPI, boolean)
public void sendSynchronizationCheckpoint(PushAPI papi, boolean incremental) throws PushAPIException
connection
- PushAPIException
hasAlreadySynchronized(PushAPI)
public void setUpdateCheckpoint(CheckpointValue checkpointValue)
checkpointValue
- Copyright © 2013 Dassault Systèmes, All Rights Reserved.