This is an automated email from the git hooks/post-receive script. New commit to branch feature/6714 in repository tutti. See http://git.codelutin.com/tutti.git commit 16e04e19591b1b5536dd7d7570c13f0ff62b4d74 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Jan 6 10:43:51 2016 +0100 Recopie de l'intégralité de la table des transcribing item (après suppression locale) (See #6714) --- .../TuttiReferentialSynchroServiceImpl.java | 68 +++++++++++++++++++--- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/synchro/TuttiReferentialSynchroServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/synchro/TuttiReferentialSynchroServiceImpl.java index b258b93..e453cfd 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/synchro/TuttiReferentialSynchroServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/referential/synchro/TuttiReferentialSynchroServiceImpl.java @@ -25,13 +25,23 @@ package fr.ifremer.tutti.persistence.service.referential.synchro; */ import com.google.common.collect.Maps; -import fr.ifremer.adagio.core.service.technical.synchro.*; +import fr.ifremer.adagio.core.service.technical.synchro.ReferentialSynchroDatabaseMetadata; +import fr.ifremer.adagio.core.service.technical.synchro.ReferentialSynchroResult; +import fr.ifremer.adagio.core.service.technical.synchro.ReferentialSynchroServiceImpl; +import fr.ifremer.adagio.core.service.technical.synchro.ReferentialSynchroTableMetadata; +import fr.ifremer.adagio.core.service.technical.synchro.ReferentialSynchroTableTool; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import java.sql.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Timestamp; +import java.util.List; import java.util.Map; import java.util.ServiceLoader; @@ -70,18 +80,62 @@ public class TuttiReferentialSynchroServiceImpl extends ReferentialSynchroServic Connection remoteConnection, ReferentialSynchroResult result) throws SQLException { - Timestamp lastUpdate = getLastUpdateDate(localConnection, table); + Timestamp lastUpdate; - super.synchronizeTable(dbMetas, table, localConnection, remoteConnection, result); + log.info("Synchronize table " + table); + + if (table.getName().toLowerCase().equals("transcribing_item")) { + + // Specific synchronize logic + + ReferentialSynchroTableTool localDao = new ReferentialSynchroTableTool(localConnection, table); + ReferentialSynchroTableTool remoteDao = new ReferentialSynchroTableTool(remoteConnection, table); + + // get all data to insert from remote db + ResultSet dataToUpdate = remoteDao.getDataToUpdate(null); + + String tableName = localDao.getTable().getName(); + + result.addTableName(tableName); + + String tablePrefix = table.getTableLogPrefix() + " - " + result.getNbRows(tableName); + + // delete table + localDao.deleteAll(); + + int countR = 0; + + // add all data from remote + while (dataToUpdate.next()) { + + List<Object> pk = table.getPk(dataToUpdate); + + localDao.executeInsert(pk, dataToUpdate); + + countR++; + + reportProgress(result, localDao, countR, tablePrefix); + } + + // No data in local + lastUpdate = new Timestamp(0); + + } else { + + lastUpdate = getLastUpdateDate(localConnection, table); + + super.synchronizeTable(dbMetas, table, localConnection, remoteConnection, result); + + } String tableName = table.getName(); ReferentialUpdateTask updateTask = getUpdateTasks().get(tableName); - if (updateTask != null && log.isInfoEnabled()) { - log.info(table.getTableLogPrefix() + " - " + result.getNbRows(tableName) + " Will use specific update task: " + updateTask); - } if (updateTask != null) { + if (log.isInfoEnabled()) { + log.info(table.getTableLogPrefix() + " - " + result.getNbRows(tableName) + " Will use specific update task: " + updateTask); + } updateTask.update(localConnection, lastUpdate); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.