/** * Adds a knowledge group. Legacy method, replaced by setForbidden, setRequired with patterns. * Needed for the interface. */ public void addKnowledgeGroup(KnowledgeGroup group) { this.knowledgeGroups.add(group); OrderedPair<Set<MyNode>> o = getGroupRule(group); knowledgeGroupRules.put(group, o); if (group.getType() == KnowledgeGroup.FORBIDDEN) { forbiddenRulesSpecs.add(o); } else if (group.getType() == KnowledgeGroup.REQUIRED) { requiredRulesSpecs.add(o); } }
/** Legacy, do not use. */ public void setKnowledgeGroup(int index, KnowledgeGroup group) { OrderedPair<Set<MyNode>> o = getGroupRule(group); OrderedPair<Set<MyNode>> old = knowledgeGroupRules.get(knowledgeGroups.get(index)); forbiddenRulesSpecs.remove(old); requiredRulesSpecs.remove(old); if (group.getType() == KnowledgeGroup.FORBIDDEN) { forbiddenRulesSpecs.add(o); } else if (group.getType() == KnowledgeGroup.REQUIRED) { requiredRulesSpecs.add(o); } knowledgeGroups.set(index, group); }
/** Legacy. */ public final boolean isForbiddenByGroups(String var1, String var2) { Set<OrderedPair<Set<MyNode>>> s = new HashSet<>(); for (KnowledgeGroup group : knowledgeGroups) { if (group.getType() == KnowledgeGroup.FORBIDDEN) { OrderedPair<Set<MyNode>> o = getGroupRule(group); s.add(o); } } for (OrderedPair<Set<MyNode>> rule : s) { if (rule.getFirst().contains(namesToVars.get(var1))) { if (rule.getSecond().contains(namesToVars.get(var2))) { return true; } } } return false; }
/** Legacy. */ public final boolean isRequiredByGroups(String var1, String var2) { Set<OrderedPair<Set<MyNode>>> s = new HashSet<>(); for (KnowledgeGroup group : knowledgeGroups) { if (group.getType() == KnowledgeGroup.REQUIRED) { OrderedPair<Set<MyNode>> o = getGroupRule(group); s.add(o); } } for (OrderedPair<Set<MyNode>> rule : s) { if (rule.getFirst().contains(getVar(var1))) { if (rule.getSecond().contains(getVar(var2))) { return true; } } } return false; }