@Service(value="referentialSynchroService") @Lazy public class ReferentialSynchroServiceImpl extends Object implements ReferentialSynchroService
Modifier and Type | Field and Description |
---|---|
protected DriverManagerDataSource |
dataSource
Deprecated.
|
protected Properties |
dbconnexionProperties
Deprecated.
|
protected Map<String,ReferentialSynchroSpecificTableTask> |
extraTasks
Deprecated.
|
protected Dialect |
localDialect
Deprecated.
|
protected SessionFactory |
sessionFactory
Deprecated.
|
Constructor and Description |
---|
ReferentialSynchroServiceImpl()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkSchemas(ReferentialSynchroDatabaseMetadata schema1,
ReferentialSynchroDatabaseMetadata schema2)
Deprecated.
Check that the tow given datasource shemas are compatible for a
synchronize operation (same tables with same columns).
|
Map<String,ReferentialSynchroSpecificTableTask> |
getExtraTasks()
Deprecated.
|
Properties |
getLocalConnectionProperties()
Deprecated.
Get the db connexion informations for the internal data source.
|
Dialect |
getLocalDialect()
Deprecated.
Gets the dialect used by the local database.
|
void |
prepare(ReferentialSynchroContext synchroContext)
Deprecated.
Prepare the synchronize operation from the local data database supported
by this service, says just compute nb rows to update for each table and
update the result model.
|
protected void |
prepareTable(ReferentialSynchroTableMetadata table,
Connection localConnection,
Connection remoteConnection,
ReferentialSynchroResult result)
Deprecated.
|
protected void |
reportProgress(ReferentialSynchroResult result,
ReferentialSynchroTableTool dao,
int countR,
String tablePrefix)
Deprecated.
|
void |
synchronize(ReferentialSynchroContext synchroContext)
Deprecated.
Launch the synchronize operation from the local data database supported
by this service.
|
protected void |
synchronizeTable(ReferentialSynchroDatabaseMetadata dbMetas,
ReferentialSynchroTableMetadata table,
Connection localConnection,
Connection remoteConnection,
ReferentialSynchroSpecificTableTask extraTask,
ReferentialSynchroResult result)
Deprecated.
|
protected void |
updateBigTable(ReferentialSynchroDatabaseMetadata dbMetas,
ReferentialSynchroTableTool localDao,
ReferentialSynchroTableTool remoteDao,
ResultSet incomingData,
ReferentialSynchroSpecificTableTask extraTask,
ReferentialSynchroResult result)
Deprecated.
To update the content of the given
table (with a lot of rows) on
the local db, from the given incomingData of the remote db. |
protected void |
updateTable(ReferentialSynchroTableTool localDao,
ResultSet incomingData,
ReferentialSynchroResult result)
Deprecated.
To update the content of the given
table on the local db,
from the given incomingData of the remote db. |
@Autowired protected DriverManagerDataSource dataSource
@Autowired protected SessionFactory sessionFactory
protected Dialect localDialect
protected Properties dbconnexionProperties
protected Map<String,ReferentialSynchroSpecificTableTask> extraTasks
public ReferentialSynchroServiceImpl()
public Properties getLocalConnectionProperties()
ReferentialSynchroService
getLocalConnectionProperties
in interface ReferentialSynchroService
public Dialect getLocalDialect()
ReferentialSynchroService
getLocalDialect
in interface ReferentialSynchroService
public Map<String,ReferentialSynchroSpecificTableTask> getExtraTasks()
public void prepare(ReferentialSynchroContext synchroContext)
ReferentialSynchroService
prepare
in interface ReferentialSynchroService
synchroContext
- context of synchro operationpublic void synchronize(ReferentialSynchroContext synchroContext)
ReferentialSynchroService
synchronize
in interface ReferentialSynchroService
synchroContext
- context of synchro operationprotected void checkSchemas(ReferentialSynchroDatabaseMetadata schema1, ReferentialSynchroDatabaseMetadata schema2)
DataRetrievalFailureException
exception will be thrown.schema1
- schema 1 to checkschema2
- schema 2 to checkprotected void prepareTable(ReferentialSynchroTableMetadata table, Connection localConnection, Connection remoteConnection, ReferentialSynchroResult result) throws SQLException
SQLException
protected void synchronizeTable(ReferentialSynchroDatabaseMetadata dbMetas, ReferentialSynchroTableMetadata table, Connection localConnection, Connection remoteConnection, ReferentialSynchroSpecificTableTask extraTask, ReferentialSynchroResult result) throws SQLException
SQLException
protected void updateTable(ReferentialSynchroTableTool localDao, ResultSet incomingData, ReferentialSynchroResult result) throws SQLException
table
on the local db,
from the given incomingData
of the remote db.
The algorithm is pretty simple, for each row of the incomingData
, if exists on local table, then do an
update, otherwise do a insert.
As an update query is more expensive, we won't use this method for table with a lot of rows, we will prefer to
use the updateBigTable
method instead.localDao
- connection on the local dbincomingData
- data to update from the remote dbresult
- where to store operation resultsSQLException
- if any sql errorsprotected void updateBigTable(ReferentialSynchroDatabaseMetadata dbMetas, ReferentialSynchroTableTool localDao, ReferentialSynchroTableTool remoteDao, ResultSet incomingData, ReferentialSynchroSpecificTableTask extraTask, ReferentialSynchroResult result) throws SQLException
table
(with a lot of rows) on
the local db, from the given incomingData
of the remote db.
We can't use the simple algorithm, since update queries cost too much and is not acceptable when talking on huge
numbers of rows.
Here is what to do :
dbMetas
- localDao
- connection on the local dbremoteDao
- connection on the local dbincomingData
- data to update from the remote dbextraTask
- result
- where to store operation results @throws SQLException if any sql errorsSQLException
protected void reportProgress(ReferentialSynchroResult result, ReferentialSynchroTableTool dao, int countR, String tablePrefix)
Copyright © 2012–2014 IFREMER. All rights reserved.