Search in sources :

Example 1 with RuleType

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

Example 2 with RuleType

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;
}
Also used : SelectItem(javax.faces.model.SelectItem) RuleType(org.alfresco.service.cmr.rule.RuleType)

Example 3 with RuleType

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;
}
Also used : RuleRef(org.alfresco.repo.web.scripts.rule.ruleset.RuleRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RuleType(org.alfresco.service.cmr.rule.RuleType) Rule(org.alfresco.service.cmr.rule.Rule)

Example 4 with RuleType

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;
}
Also used : RuleRef(org.alfresco.repo.web.scripts.rule.ruleset.RuleRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RuleType(org.alfresco.service.cmr.rule.RuleType) Rule(org.alfresco.service.cmr.rule.Rule)

Aggregations

RuleType (org.alfresco.service.cmr.rule.RuleType)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 RuleRef (org.alfresco.repo.web.scripts.rule.ruleset.RuleRef)3 NodeRef (org.alfresco.service.cmr.repository.NodeRef)3 Rule (org.alfresco.service.cmr.rule.Rule)3 SelectItem (javax.faces.model.SelectItem)1 RuleSet (org.alfresco.repo.web.scripts.rule.ruleset.RuleSet)1