public ArrayList<Long> getExceptionIdsByAppliedRule(long parentRuleId) {
   AppliedRule parentRule = SoftwareArchitecture.getInstance().getAppliedRuleById(parentRuleId);
   ArrayList<AppliedRule> exceptionRules = parentRule.getExceptions();
   ArrayList<Long> exceptionIds = new ArrayList<Long>();
   for (AppliedRule exception : exceptionRules) {
     exceptionIds.add(exception.getId());
   }
   return exceptionIds;
 }
  public void addExceptionToAppliedRule(
      long parentRuleId, String ruleType, String description, long moduleFromId, long moduleToId) {
    Module moduleFrom = SoftwareArchitecture.getInstance().getModuleById(moduleFromId);
    Module moduleTo = SoftwareArchitecture.getInstance().getModuleById(moduleToId);

    AppliedRule exceptionRule = new AppliedRule(ruleType, description, moduleFrom, moduleTo);

    AppliedRule parentRule = SoftwareArchitecture.getInstance().getAppliedRuleById(parentRuleId);
    parentRule.addException(exceptionRule);
  }
 public void removeAllAppliedRuleExceptions(long appliedRuleId) {
   AppliedRule parentRule = SoftwareArchitecture.getInstance().getAppliedRuleById(appliedRuleId);
   parentRule.removeAllExceptions();
 }
 public void removeAppliedRuleException(long parentRuleId, long exceptionRuleId) {
   AppliedRule parentRule = SoftwareArchitecture.getInstance().getAppliedRuleById(parentRuleId);
   parentRule.removeExceptionById(exceptionRuleId);
 }
예제 #5
0
  public Element getAppliedRuleInXML(AppliedRule AR) {
    Element XMLAppliedRule = new Element("AppliedRule");

    Element ruleRegex = new Element("regex");
    ruleRegex.addContent(AR.getRegex());
    XMLAppliedRule.addContent(ruleRegex);

    Element ruleDescription = new Element("description");
    ruleDescription.addContent(AR.getDescription());
    XMLAppliedRule.addContent(ruleDescription);

    Element ruleEnabled = new Element("enabled");
    if (AR.isEnabled()) {
      ruleEnabled.addContent("true");
    } else {
      ruleEnabled.addContent("false");
    }
    XMLAppliedRule.addContent(ruleEnabled);

    Element ruleId = new Element("id");
    ruleId.addContent(Long.toString(AR.getId()));
    XMLAppliedRule.addContent(ruleId);

    Element ruleType = new Element("type");
    ruleType.addContent(AR.getRuleType());
    XMLAppliedRule.addContent(ruleType);

    if (AR.getModuleFrom() instanceof Module) {
      Element moduleFrom = new Element("moduleFrom");
      moduleFrom.addContent(this.getModuleInXML(AR.getModuleFrom()));
      XMLAppliedRule.addContent(moduleFrom);
    }

    if (AR.getModuleTo() instanceof Module) {
      Element moduleTo = new Element("moduleTo");
      moduleTo.addContent(this.getModuleInXML(AR.getModuleTo()));
      XMLAppliedRule.addContent(moduleTo);
    }

    Element dependencies = new Element("dependencies");
    if (AR.getDependencies().length > 0) {
      for (int i = 0; i < AR.getDependencies().length; i++) {
        Element dependency = new Element("dependency");
        dependency.addContent(AR.getDependencies()[i].toString());
        dependencies.addContent(dependency);
      }
    }
    XMLAppliedRule.addContent(dependencies);

    if (AR.getExceptions().size() > 0) {
      Element ruleExceptions = new Element("exceptions");
      for (AppliedRule ap : AR.getExceptions()) {
        ruleExceptions.addContent(this.getAppliedRuleInXML(ap));
      }
      XMLAppliedRule.addContent(ruleExceptions);
    }

    return XMLAppliedRule;
  }