use of org.jumpmind.symmetric.model.TriggerHistory in project symmetric-ds by JumpMind.
the class TriggerRouterService method findTriggerHistories.
public List<TriggerHistory> findTriggerHistories(String catalogName, String schemaName, String tableName) {
List<TriggerHistory> listToReturn = new ArrayList<TriggerHistory>();
List<TriggerHistory> triggerHistories = getActiveTriggerHistories();
if (triggerHistories != null && triggerHistories.size() > 0) {
for (TriggerHistory triggerHistory : triggerHistories) {
boolean matches = true;
if (StringUtils.isNotBlank(catalogName)) {
matches = catalogName.equals(triggerHistory.getSourceCatalogName());
}
if (matches && StringUtils.isNotBlank(schemaName)) {
matches = schemaName.equals(triggerHistory.getSourceSchemaName());
}
if (matches && StringUtils.isNotBlank(tableName)) {
boolean ignoreCase = parameterService.is(ParameterConstants.DB_METADATA_IGNORE_CASE) && !FormatUtils.isMixedCase(tableName);
matches = ignoreCase ? triggerHistory.getSourceTableName().equalsIgnoreCase(tableName) : triggerHistory.getSourceTableName().equals(tableName);
}
if (matches) {
listToReturn.add(triggerHistory);
}
}
}
return listToReturn;
}
use of org.jumpmind.symmetric.model.TriggerHistory in project symmetric-ds by JumpMind.
the class SymmetricAdmin method sendSchema.
private void sendSchema(CommandLine line, List<String> args) {
String catalog = line.getOptionValue(OPTION_CATALOG);
String schema = line.getOptionValue(OPTION_SCHEMA);
Collection<Node> nodes = getNodes(line);
if (args.size() == 0) {
for (TriggerHistory hist : engine.getTriggerRouterService().getActiveTriggerHistories()) {
for (Node node : nodes) {
if ((catalog == null || catalog.equals(hist.getSourceCatalogName())) && (schema == null || schema.equals(hist.getSourceSchemaName()))) {
getSymmetricEngine().getDataService().sendSchema(node.getNodeId(), hist.getSourceCatalogName(), hist.getSourceSchemaName(), hist.getSourceTableName(), false);
}
}
}
} else {
for (String tableName : args) {
for (Node node : nodes) {
getSymmetricEngine().getDataService().sendSchema(node.getNodeId(), catalog, schema, tableName, false);
}
}
}
}
use of org.jumpmind.symmetric.model.TriggerHistory in project symmetric-ds by JumpMind.
the class AbstractFileParsingRouter method getTriggerHistory.
protected TriggerHistory getTriggerHistory(String tableName, String columnNames) {
List<TriggerHistory> triggerHistories = getEngine().getTriggerRouterService().getActiveTriggerHistories(tableName);
for (TriggerHistory history : triggerHistories) {
if (history.getTriggerId().equals(TRIGGER_ID_FILE_PARSER)) {
return history;
}
}
TriggerHistory newTriggerHist = new TriggerHistory(tableName, "", columnNames);
newTriggerHist.setTriggerId(TRIGGER_ID_FILE_PARSER);
newTriggerHist.setTableHash(0);
newTriggerHist.setTriggerRowHash(0);
newTriggerHist.setTriggerTemplateHash(0);
newTriggerHist.setLastTriggerBuildReason(TriggerReBuildReason.NEW_TRIGGERS);
newTriggerHist.setColumnNames(columnNames);
getEngine().getTriggerRouterService().insert(newTriggerHist);
return newTriggerHist;
}
use of org.jumpmind.symmetric.model.TriggerHistory in project symmetric-ds by JumpMind.
the class ColumnMatchDataRouterTest method testExpressionExternalData.
@Test
public void testExpressionExternalData() {
ColumnMatchDataRouter router = new ColumnMatchDataRouter();
SimpleRouterContext routingContext = new SimpleRouterContext();
HashSet<Node> nodes = new HashSet<Node>();
nodes.add(new Node("100", "client"));
nodes.add(new Node("200", "client"));
nodes.add(new Node("300", "client"));
TriggerHistory triggerHist = new TriggerHistory("mytable", "ID", "ID,NODE_ID,COLUMN2");
Data data = new Data();
data.setDataId(1);
data.setDataEventType(DataEventType.INSERT);
data.setRowData("1,100,Super Dooper");
data.setExternalData("100");
data.setTriggerHistory(triggerHist);
Table table = new Table();
NodeChannel nodeChannel = new NodeChannel();
Router route = new Router();
route.setRouterExpression("EXTERNAL_DATA = :NODE_ID");
route.setRouterId("route1");
DataMetaData dataMetaData = new DataMetaData(data, table, route, nodeChannel);
Set<String> result = router.routeToNodes(routingContext, dataMetaData, nodes, false, false, null);
assertEquals(1, result.size());
assertEquals(true, result.contains("100"));
}
use of org.jumpmind.symmetric.model.TriggerHistory in project symmetric-ds by JumpMind.
the class ColumnMatchDataRouterTest method testExpressionNotEqualsNull.
@Test
public void testExpressionNotEqualsNull() {
ColumnMatchDataRouter router = new ColumnMatchDataRouter();
SimpleRouterContext routingContext = new SimpleRouterContext();
HashSet<Node> nodes = new HashSet<Node>();
nodes.add(new Node("100", "client"));
nodes.add(new Node("200", "client"));
TriggerHistory triggerHist = new TriggerHistory("mytable", "ID", "ID,NODE_ID,COLUMN2");
Data data = new Data();
data.setDataId(1);
data.setDataEventType(DataEventType.INSERT);
data.setRowData("1,100,");
data.setTriggerHistory(triggerHist);
Table table = new Table();
NodeChannel nodeChannel = new NodeChannel();
Router route = new Router();
route.setRouterExpression("COLUMN2 != NULL");
route.setRouterId("route1");
DataMetaData dataMetaData = new DataMetaData(data, table, route, nodeChannel);
Set<String> result = router.routeToNodes(routingContext, dataMetaData, nodes, false, false, null);
assertEquals(0, result.size());
}
Aggregations