Search in sources :

Example 1 with RuleSet

use of org.alfresco.repo.web.scripts.rule.ruleset.RuleSet in project alfresco-remote-api by Alfresco.

the class RulesetGet method executeImpl.

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    Map<String, Object> model = new HashMap<String, Object>();
    // get request parameters
    NodeRef nodeRef = parseRequestForNodeRef(req);
    String ruleType = req.getParameter("ruleType");
    RuleType type = ruleService.getRuleType(ruleType);
    if (type == null) {
        ruleType = null;
    }
    RuleSet ruleset = new RuleSet();
    // get all "owned" rules
    List<Rule> ownedRules = ruleService.getRules(nodeRef, false, ruleType);
    // get all rules (including inherited)
    List<Rule> inheritedRules = ruleService.getRules(nodeRef, true, ruleType);
    // remove "owned" rules
    inheritedRules.removeAll(ownedRules);
    List<RuleRef> rulesToSet = new ArrayList<RuleRef>();
    for (Rule rule : ownedRules) {
        rulesToSet.add(new RuleRef(rule, fileFolderService.getFileInfo(ruleService.getOwningNodeRef(rule))));
    }
    ruleset.setRules(rulesToSet);
    List<RuleRef> inheritedRulesToSet = new ArrayList<RuleRef>();
    for (Rule rule : inheritedRules) {
        inheritedRulesToSet.add(new RuleRef(rule, fileFolderService.getFileInfo(ruleService.getOwningNodeRef(rule))));
    }
    ruleset.setInheritedRules(inheritedRulesToSet);
    ruleset.setLinkedToRuleSet(ruleService.getLinkedToRuleNode(nodeRef));
    ruleset.setLinkedFromRuleSets(ruleService.getLinkedFromRuleNodes(nodeRef));
    ruleset.setRulesetNodeRef(nodeRef);
    model.put("ruleset", ruleset);
    return model;
}
Also used : RuleRef(org.alfresco.repo.web.scripts.rule.ruleset.RuleRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RuleSet(org.alfresco.repo.web.scripts.rule.ruleset.RuleSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RuleType(org.alfresco.service.cmr.rule.RuleType) Rule(org.alfresco.service.cmr.rule.Rule)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 RuleRef (org.alfresco.repo.web.scripts.rule.ruleset.RuleRef)1 RuleSet (org.alfresco.repo.web.scripts.rule.ruleset.RuleSet)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 Rule (org.alfresco.service.cmr.rule.Rule)1 RuleType (org.alfresco.service.cmr.rule.RuleType)1