use of org.jumpmind.symmetric.service.impl.DataLoaderService.ConflictNodeGroupLink in project symmetric-ds by JumpMind.
the class AbstractSymmetricEngine method uninstall.
public synchronized void uninstall() {
log.warn("Attempting an uninstall of all SymmetricDS database objects from the database");
stop();
log.info("Just cleaned {} files in the staging area during the uninstall.", getStagingManager().clean(0));
try {
Table table = platform.readTableFromDatabase(null, null, TableConstants.getTableName(parameterService.getTablePrefix(), TableConstants.SYM_TRIGGER_ROUTER));
if (table != null) {
List<Grouplet> grouplets = groupletService.getGrouplets(true);
for (Grouplet grouplet : grouplets) {
groupletService.deleteGrouplet(grouplet);
}
List<TriggerRouter> triggerRouters = triggerRouterService.getTriggerRouters(false, true);
for (TriggerRouter triggerRouter : triggerRouters) {
triggerRouterService.deleteTriggerRouter(triggerRouter);
}
List<FileTriggerRouter> fileTriggerRouters = fileSyncService.getFileTriggerRouters();
for (FileTriggerRouter fileTriggerRouter : fileTriggerRouters) {
fileSyncService.deleteFileTriggerRouter(fileTriggerRouter);
}
List<Router> routers = triggerRouterService.getRouters(true);
for (Router router : routers) {
triggerRouterService.deleteRouter(router);
}
}
table = platform.readTableFromDatabase(null, null, TableConstants.getTableName(parameterService.getTablePrefix(), TableConstants.SYM_CONFLICT));
if (table != null) {
// need to remove all conflicts before we can remove the node
// group links
List<ConflictNodeGroupLink> conflicts = dataLoaderService.getConflictSettingsNodeGroupLinks();
for (ConflictNodeGroupLink conflict : conflicts) {
dataLoaderService.delete(conflict);
}
}
table = platform.readTableFromDatabase(null, null, TableConstants.getTableName(parameterService.getTablePrefix(), TableConstants.SYM_TRANSFORM_TABLE));
if (table != null) {
// need to remove all transforms before we can remove the node
// group links
List<TransformTableNodeGroupLink> transforms = transformService.getTransformTables(false);
for (TransformTableNodeGroupLink transformTable : transforms) {
transformService.deleteTransformTable(transformTable.getTransformId());
}
}
table = platform.readTableFromDatabase(null, null, TableConstants.getTableName(parameterService.getTablePrefix(), TableConstants.SYM_ROUTER));
if (table != null) {
List<Router> objects = triggerRouterService.getRouters(true);
for (Router router : objects) {
triggerRouterService.deleteRouter(router);
}
}
table = platform.readTableFromDatabase(null, null, TableConstants.getTableName(parameterService.getTablePrefix(), TableConstants.SYM_CONFLICT));
if (table != null) {
List<ConflictNodeGroupLink> objects = dataLoaderService.getConflictSettingsNodeGroupLinks();
for (ConflictNodeGroupLink obj : objects) {
dataLoaderService.delete(obj);
}
}
table = platform.readTableFromDatabase(null, null, TableConstants.getTableName(parameterService.getTablePrefix(), TableConstants.SYM_NODE_GROUP_LINK));
if (table != null) {
// remove the links so the symmetric table trigger will be
// removed
List<NodeGroupLink> links = configurationService.getNodeGroupLinks(false);
for (NodeGroupLink nodeGroupLink : links) {
configurationService.deleteNodeGroupLink(nodeGroupLink);
}
}
if (table != null) {
// this should remove all triggers because we have removed all the
// trigger configuration
triggerRouterService.syncTriggers();
}
} catch (SqlException ex) {
log.warn("Error while trying remove triggers on tables", ex);
}
// remove any additional triggers that may remain because they were not in trigger history
symmetricDialect.cleanupTriggers();
symmetricDialect.dropTablesAndDatabaseObjects();
// force cache to be cleared
nodeService.deleteIdentity();
parameterService.setDatabaseHasBeenInitialized(false);
log.warn("Finished uninstalling SymmetricDS database objects from the database");
}
use of org.jumpmind.symmetric.service.impl.DataLoaderService.ConflictNodeGroupLink in project symmetric-ds by JumpMind.
the class AbstractDataLoaderServiceTest method test07DataIntregrityError.
@Test
public void test07DataIntregrityError() throws Exception {
Level old = setLoggingLevelForTest(Level.OFF);
String[] values = { getNextId(), "string3", "string not null3", "char3", "char not null3", "2007-01-02 00:00:00.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "0.474" };
ConflictNodeGroupLink conflictSettings = new ConflictNodeGroupLink();
conflictSettings.setNodeGroupLink(TestConstants.TEST_2_ROOT);
conflictSettings.setConflictId("dont_fallback");
conflictSettings.setResolveType(ResolveConflict.MANUAL);
getSymmetricEngine().getDataLoaderService().save(conflictSettings);
ByteArrayOutputStream out = new ByteArrayOutputStream();
CsvWriter writer = getWriter(out);
writer.writeRecord(new String[] { CsvConstants.NODEID, TestConstants.TEST_CLIENT_EXTERNAL_ID });
writer.writeRecord(new String[] { CsvConstants.CHANNEL, TestConstants.TEST_CHANNEL_ID });
writer.writeRecord(new String[] { CsvConstants.BATCH, getNextBatchId() });
writeTable(writer, TEST_TABLE, TEST_KEYS, TEST_COLUMNS);
writer.write(CsvConstants.INSERT);
writer.writeRecord(values, true);
writer.write(CsvConstants.INSERT);
writer.writeRecord(values, true);
writer.writeRecord(new String[] { CsvConstants.COMMIT, getBatchId() });
writer.close();
load(out);
assertEquals(findIncomingBatchStatus(batchId, TestConstants.TEST_CLIENT_EXTERNAL_ID), IncomingBatch.Status.ER, "Wrong status");
IncomingBatch batch = getIncomingBatchService().findIncomingBatch(batchId, TestConstants.TEST_CLIENT_EXTERNAL_ID);
assertNotNull(batch);
assertEquals(batch.getStatus(), IncomingBatch.Status.ER, "Wrong status");
assertEquals(batch.getFailedRowNumber(), 2l, "Wrong failed row number");
assertEquals(batch.getStatementCount(), 2l, "Wrong statement count");
load(out);
assertEquals(findIncomingBatchStatus(batchId, TestConstants.TEST_CLIENT_EXTERNAL_ID), IncomingBatch.Status.ER, "Wrong status");
batch = getIncomingBatchService().findIncomingBatch(batchId, TestConstants.TEST_CLIENT_EXTERNAL_ID);
assertNotNull(batch);
assertEquals(batch.getStatus(), IncomingBatch.Status.ER, "Wrong status");
assertEquals(batch.getFailedRowNumber(), 2l, "Wrong failed row number");
assertEquals(batch.getStatementCount(), 2l, "Wrong statement count");
getSymmetricEngine().getDataLoaderService().delete(conflictSettings);
setLoggingLevelForTest(old);
}
Aggregations