1 17 package org.alfresco.repo.action.evaluator; 18 19 import java.util.List ; 20 21 import org.alfresco.repo.action.ParameterDefinitionImpl; 22 import org.alfresco.service.cmr.action.ActionCondition; 23 import org.alfresco.service.cmr.action.ParameterDefinition; 24 import org.alfresco.service.cmr.dictionary.DataTypeDefinition; 25 import org.alfresco.service.cmr.repository.NodeRef; 26 import org.alfresco.service.cmr.repository.NodeService; 27 import org.alfresco.service.namespace.QName; 28 29 34 public class HasAspectEvaluator extends ActionConditionEvaluatorAbstractBase 35 { 36 39 public static final String NAME = "has-aspect"; 40 public static final String PARAM_ASPECT = "aspect"; 41 42 45 private NodeService nodeService; 46 47 52 public void setNodeService(NodeService nodeService) 53 { 54 this.nodeService = nodeService; 55 } 56 57 60 public boolean evaluateImpl(ActionCondition ruleCondition, NodeRef actionedUponNodeRef) 61 { 62 boolean result = false; 63 64 if (this.nodeService.exists(actionedUponNodeRef) == true) 65 { 66 if (this.nodeService.hasAspect(actionedUponNodeRef, (QName)ruleCondition.getParameterValue(PARAM_ASPECT)) == true) 67 { 68 result = true; 69 } 70 } 71 72 return result; 73 } 74 75 78 @Override 79 protected void addParameterDefintions(List <ParameterDefinition> paramList) 80 { 81 paramList.add(new ParameterDefinitionImpl(PARAM_ASPECT, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_ASPECT))); 82 } 83 84 } 85 | Popular Tags |