use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class TriggerRouterService method fillTriggerRoutersByHistId.
public Map<Integer, List<TriggerRouter>> fillTriggerRoutersByHistId(String sourceNodeGroupId, String targetNodeGroupId, List<TriggerHistory> triggerHistories) {
List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>(getAllTriggerRoutersForReloadForCurrentNode(sourceNodeGroupId, targetNodeGroupId));
Map<Integer, List<TriggerRouter>> triggerRoutersByHistoryId = new HashMap<Integer, List<TriggerRouter>>(triggerHistories.size());
for (TriggerHistory triggerHistory : triggerHistories) {
List<TriggerRouter> triggerRoutersForTriggerHistory = new ArrayList<TriggerRouter>();
triggerRoutersByHistoryId.put(triggerHistory.getTriggerHistoryId(), triggerRoutersForTriggerHistory);
String triggerId = triggerHistory.getTriggerId();
for (TriggerRouter triggerRouter : triggerRouters) {
if (triggerRouter.getTrigger().getTriggerId().equals(triggerId)) {
triggerRoutersForTriggerHistory.add(triggerRouter);
}
}
}
return triggerRoutersByHistoryId;
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class TriggerRouterService method findTriggerRouterById.
public TriggerRouter findTriggerRouterById(String triggerId, String routerId, boolean refreshCache) {
List<TriggerRouter> configs = (List<TriggerRouter>) sqlTemplate.query(getTriggerRouterSql("selectTriggerRouterSql"), new TriggerRouterMapper(), triggerId, routerId);
if (configs.size() > 0) {
TriggerRouter triggerRouter = configs.get(0);
triggerRouter.setRouter(getRouterById(triggerRouter.getRouter().getRouterId(), refreshCache));
triggerRouter.setTrigger(getTriggerById(triggerRouter.getTrigger().getTriggerId(), refreshCache));
return triggerRouter;
} else {
return null;
}
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class TriggerRouterService method getConfigurationTablesTriggerRoutersForCurrentNode.
/**
* Create a list of {@link TriggerRouter} for the SymmetricDS tables that
* should have triggers created for them on the current node.
*/
protected List<TriggerRouter> getConfigurationTablesTriggerRoutersForCurrentNode(String sourceNodeGroupId) {
List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>();
List<NodeGroupLink> links = configurationService.getNodeGroupLinksFor(sourceNodeGroupId, false);
for (NodeGroupLink nodeGroupLink : links) {
triggerRouters.addAll(buildTriggerRoutersForSymmetricTables(Version.version(), nodeGroupLink));
}
return triggerRouters;
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class TriggerRouterService method getTriggerRouterForTableForCurrentNode.
public Set<TriggerRouter> getTriggerRouterForTableForCurrentNode(NodeGroupLink link, String catalogName, String schemaName, String tableName, boolean refreshCache) {
TriggerRoutersCache cache = getTriggerRoutersCacheForCurrentNode(refreshCache);
Collection<List<TriggerRouter>> triggerRouters = cache.triggerRoutersByTriggerId.values();
HashSet<TriggerRouter> returnList = new HashSet<TriggerRouter>();
for (List<TriggerRouter> list : triggerRouters) {
for (TriggerRouter triggerRouter : list) {
if (isMatch(link, triggerRouter) && isMatch(catalogName, schemaName, tableName, triggerRouter.getTrigger())) {
returnList.add(triggerRouter);
}
}
}
return returnList;
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class TriggerRouterService method fillTriggerRoutersByHistIdAndSortHist.
public Map<Integer, List<TriggerRouter>> fillTriggerRoutersByHistIdAndSortHist(String sourceNodeGroupId, String targetNodeGroupId, List<TriggerHistory> triggerHistories) {
final Map<Integer, List<TriggerRouter>> triggerRoutersByHistoryId = fillTriggerRoutersByHistId(sourceNodeGroupId, targetNodeGroupId, triggerHistories);
final List<Table> sortedTables = getSortedTablesFor(triggerHistories);
Comparator<TriggerHistory> comparator = new Comparator<TriggerHistory>() {
public int compare(TriggerHistory o1, TriggerHistory o2) {
List<TriggerRouter> triggerRoutersForTriggerHist1 = triggerRoutersByHistoryId.get(o1.getTriggerHistoryId());
int intialLoadOrder1 = 0;
for (TriggerRouter triggerRouter1 : triggerRoutersForTriggerHist1) {
if (triggerRouter1.getInitialLoadOrder() > intialLoadOrder1) {
intialLoadOrder1 = triggerRouter1.getInitialLoadOrder();
}
}
List<TriggerRouter> triggerRoutersForTriggerHist2 = triggerRoutersByHistoryId.get(o2.getTriggerHistoryId());
int intialLoadOrder2 = 0;
for (TriggerRouter triggerRouter2 : triggerRoutersForTriggerHist2) {
if (triggerRouter2.getInitialLoadOrder() > intialLoadOrder2) {
intialLoadOrder2 = triggerRouter2.getInitialLoadOrder();
}
}
if (intialLoadOrder1 < intialLoadOrder2) {
return -1;
} else if (intialLoadOrder1 > intialLoadOrder2) {
return 1;
}
Table table1 = platform.getTableFromCache(o1.getSourceCatalogName(), o1.getSourceSchemaName(), o1.getSourceTableName(), false);
Table table2 = platform.getTableFromCache(o2.getSourceCatalogName(), o2.getSourceSchemaName(), o2.getSourceTableName(), false);
return new Integer(sortedTables.indexOf(table1)).compareTo(new Integer(sortedTables.indexOf(table2)));
}
;
};
Collections.sort(triggerHistories, comparator);
return triggerRoutersByHistoryId;
}
Aggregations