Search in sources :

Example 16 with 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));
}
Also used : Trigger(org.jumpmind.symmetric.model.Trigger) ArrayList(java.util.ArrayList) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Router(org.jumpmind.symmetric.model.Router) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Test(org.junit.Test)

Example 17 with Trigger

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));
}
Also used : Trigger(org.jumpmind.symmetric.model.Trigger) ArrayList(java.util.ArrayList) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Router(org.jumpmind.symmetric.model.Router) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Test(org.junit.Test)

Example 18 with Trigger

use of org.jumpmind.symmetric.model.Trigger in project symmetric-ds by JumpMind.

the class RouterServiceTest method testProducesCommonBatchesMultipleTablesTwoChannelsMultipleRoutersBidirectional.

@Test
public void testProducesCommonBatchesMultipleTablesTwoChannelsMultipleRoutersBidirectional() {
    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, "default")));
    triggerRouters.add(new TriggerRouter(new Trigger("a", CHANNEL_2_TEST.getChannelId()), new Router("test", TARGET_NODE_GROUP, SOURCE_NODE_GROUP, "default")));
    assertTrue(routerService.producesCommonBatches(CHANNEL_2_TEST, SOURCE_NODE_GROUP, triggerRouters));
}
Also used : Trigger(org.jumpmind.symmetric.model.Trigger) ArrayList(java.util.ArrayList) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Router(org.jumpmind.symmetric.model.Router) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Test(org.junit.Test)

Example 19 with Trigger

use of org.jumpmind.symmetric.model.Trigger in project symmetric-ds by JumpMind.

the class RouterServiceTest method testProducesCommonBatchesMultipleTablesTwoChannelsMultipleRouters.

@Test
public void testProducesCommonBatchesMultipleTablesTwoChannelsMultipleRouters() {
    List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>();
    triggerRouters.add(new TriggerRouter(new Trigger("a", CHANNEL_2_TEST.getChannelId()), new Router("test1", SOURCE_NODE_GROUP, TARGET_NODE_GROUP, "default")));
    triggerRouters.add(new TriggerRouter(new Trigger("b", "anotherchannel"), new Router("test2", SOURCE_NODE_GROUP, TARGET_NODE_GROUP, "column")));
    assertTrue(routerService.producesCommonBatches(CHANNEL_2_TEST, SOURCE_NODE_GROUP, triggerRouters));
}
Also used : Trigger(org.jumpmind.symmetric.model.Trigger) ArrayList(java.util.ArrayList) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Router(org.jumpmind.symmetric.model.Router) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Test(org.junit.Test)

Example 20 with Trigger

use of org.jumpmind.symmetric.model.Trigger in project symmetric-ds by JumpMind.

the class RouterService method getTriggerRoutersForData.

protected List<TriggerRouter> getTriggerRoutersForData(Data data) {
    List<TriggerRouter> triggerRouters = null;
    if (data != null) {
        if (data.getTriggerHistory() != null) {
            triggerRouters = engine.getTriggerRouterService().getTriggerRoutersForCurrentNode(false).get((data.getTriggerHistory().getTriggerId()));
            if (triggerRouters == null && data.getTriggerHistory().getTriggerId() != null && data.getTriggerHistory().getTriggerId().equals(AbstractFileParsingRouter.TRIGGER_ID_FILE_PARSER)) {
                TriggerRouter dynamicTriggerRouter = new TriggerRouter();
                String routerId = AbstractFileParsingRouter.getRouterIdFromExternalData(data.getExternalData());
                dynamicTriggerRouter.setRouter(engine.getTriggerRouterService().getRouterById(routerId));
                dynamicTriggerRouter.setTrigger(new Trigger());
                triggerRouters = new ArrayList<TriggerRouter>();
                triggerRouters.add(dynamicTriggerRouter);
                data.setDataEventType(DataEventType.INSERT);
            }
            if (triggerRouters == null || triggerRouters.size() == 0) {
                triggerRouters = engine.getTriggerRouterService().getTriggerRoutersForCurrentNode(true).get((data.getTriggerHistory().getTriggerId()));
            }
        } else {
            log.warn("Could not find a trigger hist record for recorded data {}.  Was the trigger hist record deleted manually?", data.getDataId());
        }
    }
    return triggerRouters;
}
Also used : Trigger(org.jumpmind.symmetric.model.Trigger) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter)

Aggregations

Trigger (org.jumpmind.symmetric.model.Trigger)42 TriggerRouter (org.jumpmind.symmetric.model.TriggerRouter)20 ArrayList (java.util.ArrayList)17 TriggerHistory (org.jumpmind.symmetric.model.TriggerHistory)14 Router (org.jumpmind.symmetric.model.Router)13 ITriggerRouterService (org.jumpmind.symmetric.service.ITriggerRouterService)11 Test (org.junit.Test)11 Date (java.util.Date)5 Table (org.jumpmind.db.model.Table)5 CsvData (org.jumpmind.symmetric.io.data.CsvData)5 Data (org.jumpmind.symmetric.model.Data)5 Node (org.jumpmind.symmetric.model.Node)5 HashSet (java.util.HashSet)4 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)4 HashMap (java.util.HashMap)3 Set (java.util.Set)3 ISymmetricDialect (org.jumpmind.symmetric.db.ISymmetricDialect)3 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)3 INodeService (org.jumpmind.symmetric.service.INodeService)3 List (java.util.List)2