use of org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink in project symmetric-ds by JumpMind.
the class DbCompare method getTransformFor.
protected TransformTableNodeGroupLink getTransformFor(Table sourceTable) {
String sourceNodeGroupId = sourceEngine.getNodeService().findIdentity().getNodeGroupId();
String targetNodeGroupId = targetEngine.getNodeService().findIdentity().getNodeGroupId();
List<TransformTableNodeGroupLink> transforms = sourceEngine.getTransformService().findTransformsFor(sourceNodeGroupId, targetNodeGroupId, sourceTable.getName());
if (!CollectionUtils.isEmpty(transforms)) {
// Only can operate on a single table transform for now.
TransformTableNodeGroupLink transform = transforms.get(0);
if (!StringUtils.isEmpty(transform.getFullyQualifiedTargetTableName())) {
return transform;
}
}
return null;
}
use of org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink in project symmetric-ds by JumpMind.
the class DbCompare method loadTargetTable.
protected Table loadTargetTable(DbCompareTables tables) {
Table targetTable = null;
String catalog = targetEngine.getDatabasePlatform().getDefaultCatalog();
String schema = targetEngine.getDatabasePlatform().getDefaultSchema();
if (config.isUseSymmetricConfig()) {
TransformTableNodeGroupLink transform = getTransformFor(tables.getSourceTable());
if (transform != null) {
targetTable = loadTargetTableUsingTransform(transform);
tables.setTargetTable(targetTable);
tables.setTransform(transform);
return targetTable;
}
TriggerRouter triggerRouter = getTriggerRouterFor(tables.getSourceTable());
if (triggerRouter != null) {
catalog = triggerRouter.getTargetCatalog(catalog);
schema = triggerRouter.getTargetSchema(schema);
}
}
targetTable = targetEngine.getDatabasePlatform().getTableFromCache(catalog, schema, tables.getSourceTable().getName(), true);
tables.setTargetTable(targetTable);
return targetTable;
}
use of org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink in project symmetric-ds by JumpMind.
the class AbstractSymmetricDialect method createPurgeSqlFor.
@Override
public String createPurgeSqlFor(Node node, TriggerRouter triggerRouter, TriggerHistory triggerHistory, List<TransformTableNodeGroupLink> transforms, String deleteSql) {
String sql = null;
if (StringUtils.isEmpty(triggerRouter.getInitialLoadDeleteStmt())) {
List<String> tableNames = new ArrayList<String>();
if (transforms != null) {
for (TransformTableNodeGroupLink transform : transforms) {
tableNames.add(transform.getFullyQualifiedTargetTableName());
}
} else {
tableNames.add(triggerRouter.qualifiedTargetTableName(triggerHistory));
}
StringBuilder statements = new StringBuilder(128);
for (String tableName : tableNames) {
if (deleteSql == null) {
if (tableName.startsWith(parameterService.getTablePrefix())) {
deleteSql = "delete from %s";
} else {
deleteSql = parameterService.getString(ParameterConstants.INITIAL_LOAD_DELETE_FIRST_SQL);
}
}
statements.append(String.format(deleteSql, tableName)).append(";");
}
// Lose the last ;
statements.setLength(statements.length() - 1);
sql = statements.toString();
} else {
sql = triggerRouter.getInitialLoadDeleteStmt();
}
return sql;
}
use of org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink 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.TransformService.TransformTableNodeGroupLink in project symmetric-ds by JumpMind.
the class DataLoaderService method buildDataWriter.
protected IDataWriter buildDataWriter(ProcessInfo processInfo, String sourceNodeId, String channelId, long batchId, boolean isRetry) {
TransformTable[] transforms = null;
NodeGroupLink link = null;
List<ResolvedData> resolvedDatas = new ArrayList<ResolvedData>();
List<IDatabaseWriterFilter> filters = extensionService.getExtensionPointList(IDatabaseWriterFilter.class);
List<IDatabaseWriterFilter> dynamicFilters = filters;
List<IDatabaseWriterErrorHandler> errorHandlers = extensionService.getExtensionPointList(IDatabaseWriterErrorHandler.class);
List<IDatabaseWriterErrorHandler> dynamicErrorHandlers = errorHandlers;
if (sourceNodeId != null) {
Node sourceNode = nodeService.findNode(sourceNodeId, true);
if (sourceNode != null) {
link = new NodeGroupLink(sourceNode.getNodeGroupId(), parameterService.getNodeGroupId());
}
Map<LoadFilterType, Map<String, List<LoadFilter>>> loadFilters = loadFilterService.findLoadFiltersFor(link, true);
List<DynamicDatabaseWriterFilter> databaseWriterFilters = DynamicDatabaseWriterFilter.getDatabaseWriterFilters(engine, loadFilters);
if (loadFilters != null && loadFilters.size() > 0) {
dynamicFilters = new ArrayList<IDatabaseWriterFilter>(filters.size() + 1);
dynamicFilters.addAll(filters);
dynamicFilters.addAll(databaseWriterFilters);
dynamicErrorHandlers = new ArrayList<IDatabaseWriterErrorHandler>(errorHandlers.size() + 1);
dynamicErrorHandlers.addAll(errorHandlers);
dynamicErrorHandlers.addAll(databaseWriterFilters);
}
List<TransformTableNodeGroupLink> transformsList = transformService.findTransformsFor(link, TransformPoint.LOAD);
transforms = transformsList != null ? transformsList.toArray(new TransformTable[transformsList.size()]) : null;
if (isRetry) {
List<IncomingError> incomingErrors = getIncomingErrors(batchId, sourceNodeId);
for (IncomingError incomingError : incomingErrors) {
if (incomingError.isResolveIgnore() || StringUtils.isNotBlank(incomingError.getResolveData())) {
resolvedDatas.add(new ResolvedData(incomingError.getFailedRowNumber(), incomingError.getResolveData(), incomingError.isResolveIgnore()));
}
}
}
}
TransformWriter transformWriter = new TransformWriter(platform, TransformPoint.LOAD, null, transformService.getColumnTransforms(), transforms);
IDataWriter targetWriter = getFactory(channelId).getDataWriter(sourceNodeId, symmetricDialect, transformWriter, dynamicFilters, dynamicErrorHandlers, getConflictSettingsNodeGroupLinks(link, false), resolvedDatas);
transformWriter.setNestedWriter(new ProcessInfoDataWriter(targetWriter, processInfo));
return transformWriter;
}
Aggregations