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;
}
Aggregations