use of org.jumpmind.symmetric.model.Grouplet.GroupletLinkPolicy in project symmetric-ds by JumpMind.
the class GroupletService method isSourceEnabled.
public boolean isSourceEnabled(TriggerRouter triggerRouter) {
boolean enabled = true;
Node node = engine.getNodeService().findIdentity();
if (node == null) {
enabled = false;
} else {
List<Grouplet> grouplets = getGroupletsFor(triggerRouter, AppliesWhen.S, false);
if (grouplets != null && grouplets.size() > 0) {
enabled = false;
for (Grouplet grouplet : grouplets) {
GroupletLinkPolicy policy = grouplet.getGroupletLinkPolicy();
List<GroupletLink> links = grouplet.getGroupletLinks();
boolean foundMatch = false;
for (GroupletLink groupletLink : links) {
if (groupletLink.getExternalId().equals(node.getExternalId())) {
foundMatch = true;
}
}
if ((foundMatch && policy == GroupletLinkPolicy.I) || (!foundMatch && policy == GroupletLinkPolicy.E)) {
enabled = true;
}
}
}
}
return enabled;
}
use of org.jumpmind.symmetric.model.Grouplet.GroupletLinkPolicy in project symmetric-ds by JumpMind.
the class GroupletService method getTargetEnabled.
public Set<Node> getTargetEnabled(TriggerRouter triggerRouter, Set<Node> nodes) {
List<Grouplet> grouplets = getGroupletsFor(triggerRouter, AppliesWhen.T, false);
if (grouplets != null && grouplets.size() > 0) {
Set<Node> matchedNodes = new HashSet<Node>();
Set<Node> excludedNodes = new HashSet<Node>();
for (Grouplet grouplet : grouplets) {
GroupletLinkPolicy policy = grouplet.getGroupletLinkPolicy();
List<GroupletLink> links = grouplet.getGroupletLinks();
for (GroupletLink groupletLink : links) {
for (Node node : nodes) {
if (groupletLink.getExternalId().equals(node.getExternalId())) {
if (policy == GroupletLinkPolicy.I) {
matchedNodes.add(node);
} else {
excludedNodes.add(node);
}
}
}
}
}
Set<Node> toReturn = new HashSet<Node>();
excludedNodes.removeAll(matchedNodes);
if (excludedNodes.size() > 0) {
toReturn.addAll(nodes);
toReturn.removeAll(excludedNodes);
} else {
toReturn.addAll(matchedNodes);
}
return toReturn;
} else {
return nodes;
}
}
Aggregations