Search in sources :

Example 21 with NodeGroupLink

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

the class AbstractRouterServiceTest method getTestRoutingTableTrigger.

protected TriggerRouter getTestRoutingTableTrigger(String tableName) {
    TriggerRouter trigger = null;
    Set<TriggerRouter> triggerRouters = getTriggerRouterService().getTriggerRouterForTableForCurrentNode(null, null, tableName, true);
    if (triggerRouters == null || triggerRouters.size() == 0) {
        trigger = new TriggerRouter();
        trigger.getTrigger().setSourceTableName(tableName);
        trigger.getTrigger().setTriggerId(tableName);
        trigger.getRouter().setNodeGroupLink(new NodeGroupLink(TestConstants.TEST_ROOT_NODE_GROUP, TestConstants.TEST_CLIENT_NODE_GROUP));
        if (tableName.equals(TEST_TABLE_2)) {
            trigger.getTrigger().setChannelId(TestConstants.TEST_CHANNEL_ID_OTHER);
        } else {
            trigger.getTrigger().setChannelId(TestConstants.TEST_CHANNEL_ID);
        }
    } else {
        trigger = triggerRouters.iterator().next();
    }
    return trigger;
}
Also used : TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) NodeGroupLink(org.jumpmind.symmetric.model.NodeGroupLink)

Example 22 with NodeGroupLink

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

the class InfoUriHandler method handle.

public void handle(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
    res.setContentType("text/plain");
    Node node = nodeService.findIdentity();
    List<NodeGroupLink> nodeGroupLinks = configurationService.getNodeGroupLinks(true);
    Properties properties = new Properties();
    properties.setProperty(ParameterConstants.EXTERNAL_ID, parameterService.getExternalId());
    properties.setProperty(ParameterConstants.NODE_GROUP_ID, parameterService.getNodeGroupId());
    properties.setProperty(ParameterConstants.EXTERNAL_ID, parameterService.getExternalId());
    if (nodeGroupLinks != null) {
        Set<String> groups = new HashSet<String>();
        StringBuilder b = new StringBuilder();
        for (NodeGroupLink nodeGroupLink : nodeGroupLinks) {
            if (nodeGroupLink.getSourceNodeGroupId().equals(node.getNodeGroupId())) {
                groups.add(nodeGroupLink.getTargetNodeGroupId());
            } else if (nodeGroupLink.getTargetNodeGroupId().equals(node.getNodeGroupId())) {
                groups.add(nodeGroupLink.getSourceNodeGroupId());
            }
        }
        for (String group : groups) {
            b.append(group).append(",");
        }
        properties.setProperty(InfoConstants.NODE_GROUP_IDS, b.substring(0, b.length() > 0 ? b.length() - 1 : 0));
    }
    if (node != null) {
        properties.setProperty(InfoConstants.NODE_ID, node.getNodeId());
        if (node.getDatabaseType() != null) {
            properties.setProperty(InfoConstants.DATABASE_TYPE, node.getDatabaseType());
        }
        if (node.getDatabaseVersion() != null) {
            properties.setProperty(InfoConstants.DATABASE_VERSION, node.getDatabaseVersion());
        }
        if (node.getDeploymentType() != null) {
            properties.setProperty(InfoConstants.DEPLOYMENT_TYPE, node.getDeploymentType());
        }
        if (node.getSymmetricVersion() != null) {
            properties.setProperty(InfoConstants.SYMMETRIC_VERSION, node.getSymmetricVersion());
        }
    }
    properties.store(res.getOutputStream(), "SymmetricDS");
    res.flushBuffer();
}
Also used : Node(org.jumpmind.symmetric.model.Node) NodeGroupLink(org.jumpmind.symmetric.model.NodeGroupLink) Properties(java.util.Properties) HashSet(java.util.HashSet)

Aggregations

NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)22 Node (org.jumpmind.symmetric.model.Node)11 ArrayList (java.util.ArrayList)9 TriggerRouter (org.jumpmind.symmetric.model.TriggerRouter)7 IConfigurationService (org.jumpmind.symmetric.service.IConfigurationService)5 TransformTableNodeGroupLink (org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink)5 List (java.util.List)4 NetworkedNode (org.jumpmind.symmetric.model.NetworkedNode)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 TransformTable (org.jumpmind.symmetric.io.data.transform.TransformTable)3 Trigger (org.jumpmind.symmetric.model.Trigger)3 INodeService (org.jumpmind.symmetric.service.INodeService)3 ITriggerRouterService (org.jumpmind.symmetric.service.ITriggerRouterService)3 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)2 ISymmetricEngine (org.jumpmind.symmetric.ISymmetricEngine)2 CsvData (org.jumpmind.symmetric.io.data.CsvData)2 TransformPoint (org.jumpmind.symmetric.io.data.transform.TransformPoint)2 TransformWriter (org.jumpmind.symmetric.io.data.writer.TransformWriter)2