use of org.alfresco.service.cmr.rule.RuleType 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;
}
use of org.alfresco.service.cmr.rule.RuleType in project acs-community-packaging by Alfresco.
the class CreateRuleWizard method getTypes.
/**
* @return Returns the types of rules that can be defined
*/
public List<SelectItem> getTypes() {
if (this.types == null) {
List<RuleType> ruleTypes = this.getRuleService().getRuleTypes();
this.types = new ArrayList<SelectItem>(ruleTypes.size());
for (RuleType ruleType : ruleTypes) {
this.types.add(new SelectItem(ruleType.getName(), ruleType.getDisplayLabel()));
}
}
return shouldFilterTypes() ? filterTypes(this.types) : this.types;
}
use of org.alfresco.service.cmr.rule.RuleType in project alfresco-remote-api by Alfresco.
the class InheritedRulesGet 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;
}
// get all rules (including inherited) filtered by rule type
List<Rule> inheritedRules = ruleService.getRules(nodeRef, true, ruleType);
// get owned rules (excluding inherited) filtered by rule type
List<Rule> ownedRules = ruleService.getRules(nodeRef, false, ruleType);
// remove owned rules
inheritedRules.removeAll(ownedRules);
List<RuleRef> inheritedRuleRefs = new ArrayList<RuleRef>();
for (Rule rule : inheritedRules) {
inheritedRuleRefs.add(new RuleRef(rule, fileFolderService.getFileInfo(ruleService.getOwningNodeRef(rule))));
}
model.put("inheritedRuleRefs", inheritedRuleRefs);
return model;
}
use of org.alfresco.service.cmr.rule.RuleType in project alfresco-remote-api by Alfresco.
the class RulesGet 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;
}
// get all rules (excluding inherited) filtered by rule type
List<Rule> rules = ruleService.getRules(nodeRef, false, ruleType);
List<RuleRef> ruleRefs = new ArrayList<RuleRef>();
for (Rule rule : rules) {
ruleRefs.add(new RuleRef(rule, fileFolderService.getFileInfo(ruleService.getOwningNodeRef(rule))));
}
model.put("ruleRefs", ruleRefs);
return model;
}
Aggregations