Search in sources :

Example 1 with DatabaseParameter

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

the class NodeCommunicationService method getNodesToCommunicateWithOffline.

protected List<Node> getNodesToCommunicateWithOffline(CommunicationType communicationType) {
    List<Node> nodesToCommunicateWith = null;
    if (parameterService.is(ParameterConstants.NODE_OFFLINE) || (communicationType.equals(CommunicationType.PULL) && parameterService.is(ParameterConstants.NODE_OFFLINE_INCOMING_ACCEPT_ALL))) {
        if (communicationType.equals(CommunicationType.PUSH)) {
            nodesToCommunicateWith = nodeService.findTargetNodesFor(NodeGroupLinkAction.W);
            nodesToCommunicateWith.addAll(nodeService.findNodesToPushTo());
        } else if (communicationType.equals(CommunicationType.PULL)) {
            nodesToCommunicateWith = nodeService.findSourceNodesFor(NodeGroupLinkAction.P);
            nodesToCommunicateWith.addAll(nodeService.findNodesToPull());
        }
    } else {
        List<DatabaseParameter> parms = parameterService.getOfflineNodeParameters();
        nodesToCommunicateWith = new ArrayList<Node>(parms.size());
        if (parms.size() > 0) {
            List<Node> sourceNodes = null;
            if (communicationType.equals(CommunicationType.PUSH)) {
                sourceNodes = nodeService.findTargetNodesFor(NodeGroupLinkAction.W);
                sourceNodes.addAll(nodeService.findNodesToPushTo());
            } else if (communicationType.equals(CommunicationType.PULL)) {
                sourceNodes = nodeService.findSourceNodesFor(NodeGroupLinkAction.P);
                sourceNodes.addAll(nodeService.findNodesToPull());
            }
            if (sourceNodes != null && sourceNodes.size() > 0) {
                for (DatabaseParameter parm : parms) {
                    for (Node node : sourceNodes) {
                        if ((parm.getNodeGroupId().equals(ParameterConstants.ALL) || parm.getNodeGroupId().equals(node.getNodeGroupId()) && (parm.getExternalId().equals(ParameterConstants.ALL) || parm.getExternalId().equals(node.getExternalId())))) {
                            nodesToCommunicateWith.add(node);
                        }
                    }
                }
            }
        }
    }
    return nodesToCommunicateWith;
}
Also used : DatabaseParameter(org.jumpmind.symmetric.model.DatabaseParameter) Node(org.jumpmind.symmetric.model.Node)

Aggregations

DatabaseParameter (org.jumpmind.symmetric.model.DatabaseParameter)1 Node (org.jumpmind.symmetric.model.Node)1