use of org.jumpmind.symmetric.model.Trigger in project symmetric-ds by JumpMind.
the class TriggerRouterService method buildTriggerRoutersForSymmetricTables.
public List<TriggerRouter> buildTriggerRoutersForSymmetricTables(String version, NodeGroupLink nodeGroupLink, String... tablesToExclude) {
int initialLoadOrder = 1;
List<Trigger> triggers = buildTriggersForSymmetricTables(version, tablesToExclude);
List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>(triggers.size());
for (int j = 0; j < triggers.size(); j++) {
Trigger trigger = triggers.get(j);
TriggerRouter triggerRouter = buildTriggerRoutersForSymmetricTables(version, trigger, nodeGroupLink);
triggerRouter.setInitialLoadOrder(initialLoadOrder++);
triggerRouters.add(triggerRouter);
}
return triggerRouters;
}
use of org.jumpmind.symmetric.model.Trigger in project symmetric-ds by JumpMind.
the class TriggerRouterService method getTriggers.
public List<Trigger> getTriggers(boolean replaceTokens) {
List<Trigger> triggers = sqlTemplate.query("select " + getSql("selectTriggersColumnList", "selectTriggersSql"), new TriggerMapper());
if (replaceTokens) {
@SuppressWarnings({ "rawtypes", "unchecked" }) Map<String, String> replacements = (Map) parameterService.getAllParameters();
for (Trigger trigger : triggers) {
trigger.setSourceCatalogName(FormatUtils.replaceTokens(trigger.getSourceCatalogName(), replacements, true));
trigger.setSourceSchemaName(FormatUtils.replaceTokens(trigger.getSourceSchemaName(), replacements, true));
trigger.setSourceTableName(FormatUtils.replaceTokens(trigger.getSourceTableName(), replacements, true));
}
}
return triggers;
}
use of org.jumpmind.symmetric.model.Trigger in project symmetric-ds by JumpMind.
the class TriggerRouterService method createTriggersOnChannelForTables.
public void createTriggersOnChannelForTables(String channelId, String catalogName, String schemaName, List<String> tables, String lastUpdateBy) {
List<Trigger> createdTriggers = new ArrayList<Trigger>();
List<Trigger> existingTriggers = getTriggers();
for (String table : tables) {
Trigger trigger = new Trigger();
trigger.setChannelId(channelId);
trigger.setSourceCatalogName(catalogName);
trigger.setSourceSchemaName(schemaName);
trigger.setSourceTableName(table);
String triggerId = table;
if (table.length() > 50) {
triggerId = table.substring(0, 13) + "_" + UUID.randomUUID().toString();
}
boolean uniqueNameCreated = false;
int suffix = 0;
while (!uniqueNameCreated) {
String triggerIdPriorToCheck = triggerId;
for (Trigger existingTrigger : existingTriggers) {
if (triggerId.equals(existingTrigger.getTriggerId())) {
String suffixString = "_" + suffix;
if (suffix == 0) {
triggerId = triggerId + suffixString;
} else {
triggerId = triggerId.substring(0, triggerId.length() - ("_" + (suffix - 1)).length()) + suffixString;
}
suffix++;
}
}
if (triggerId.equals(triggerIdPriorToCheck)) {
uniqueNameCreated = true;
}
}
trigger.setTriggerId(triggerId);
trigger.setLastUpdateBy(lastUpdateBy);
trigger.setLastUpdateTime(new Date());
trigger.setCreateTime(new Date());
saveTrigger(trigger);
createdTriggers.add(trigger);
}
}
use of org.jumpmind.symmetric.model.Trigger in project symmetric-ds by JumpMind.
the class RouterServiceTest method testNotProducesCommonBatchesOneTableOneChannelNonDefaultRouter.
@Test
public void testNotProducesCommonBatchesOneTableOneChannelNonDefaultRouter() {
List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>();
triggerRouters.add(new TriggerRouter(new Trigger("a", CHANNEL_2_TEST.getChannelId()), new Router("test", SOURCE_NODE_GROUP, TARGET_NODE_GROUP, "column")));
assertTrue(!routerService.producesCommonBatches(CHANNEL_2_TEST, SOURCE_NODE_GROUP, triggerRouters));
}
use of org.jumpmind.symmetric.model.Trigger in project symmetric-ds by JumpMind.
the class RouterServiceTest method testProducesCommonBatchesSameTablesTwoChannelsMultipleRoutersDifferentTableIncomingOnAnotherChannel.
@Test
public void testProducesCommonBatchesSameTablesTwoChannelsMultipleRoutersDifferentTableIncomingOnAnotherChannel() {
List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>();
Trigger tableTrigger1 = new Trigger("a", CHANNEL_2_TEST.getChannelId(), true);
Trigger tableTrigger2 = new Trigger("b", "anotherchannel");
Trigger tableTrigger3 = new Trigger("c", CHANNEL_2_TEST.getChannelId());
triggerRouters.add(new TriggerRouter(tableTrigger1, new Router("test", SOURCE_NODE_GROUP, TARGET_NODE_GROUP, "default")));
triggerRouters.add(new TriggerRouter(tableTrigger2, new Router("test", TARGET_NODE_GROUP, SOURCE_NODE_GROUP, "default")));
triggerRouters.add(new TriggerRouter(tableTrigger3, new Router("test", TARGET_NODE_GROUP, SOURCE_NODE_GROUP, "default")));
assertTrue(routerService.producesCommonBatches(CHANNEL_2_TEST, SOURCE_NODE_GROUP, triggerRouters));
}
Aggregations