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.dictionary.DictionaryService; 26 import org.alfresco.service.cmr.repository.NodeRef; 27 import org.alfresco.service.cmr.repository.NodeService; 28 import org.alfresco.service.namespace.QName; 29 30 35 public class IsSubTypeEvaluator extends ActionConditionEvaluatorAbstractBase 36 { 37 40 public static final String NAME = "is-subtype"; 41 public static final String PARAM_TYPE = "type"; 42 43 46 private NodeService nodeService; 47 48 51 private DictionaryService dictionaryService; 52 53 58 public void setNodeService(NodeService nodeService) 59 { 60 this.nodeService = nodeService; 61 } 62 63 68 public void setDictionaryService(DictionaryService dictionaryService) 69 { 70 this.dictionaryService = dictionaryService; 71 } 72 73 76 public boolean evaluateImpl(ActionCondition ruleCondition, NodeRef actionedUponNodeRef) 77 { 78 boolean result = false; 79 80 if (this.nodeService.exists(actionedUponNodeRef) == true) 81 { 82 QName nodeType = nodeService.getType(actionedUponNodeRef); 84 if (dictionaryService.isSubClass(nodeType, (QName)ruleCondition.getParameterValue(PARAM_TYPE))) 85 { 86 result = true; 87 } 88 } 89 90 return result; 91 } 92 93 96 @Override 97 protected void addParameterDefintions(List <ParameterDefinition> paramList) 98 { 99 paramList.add(new ParameterDefinitionImpl(PARAM_TYPE, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_TYPE))); 100 } 101 102 } 103 | Popular Tags |