1 17 package org.alfresco.repo.action.executer; 18 19 import java.util.List ; 20 21 import org.alfresco.repo.action.ParameterDefinitionImpl; 22 import org.alfresco.service.cmr.action.Action; 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 SpecialiseTypeActionExecuter extends ActionExecuterAbstractBase 36 { 37 40 public static final String NAME = "specialise-type"; 41 public static final String PARAM_TYPE_NAME = "type-name"; 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 void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) 77 { 78 if (this.nodeService.exists(actionedUponNodeRef) == true) 79 { 80 QName currentType = this.nodeService.getType(actionedUponNodeRef); 82 QName destinationType = (QName)ruleAction.getParameterValue(PARAM_TYPE_NAME); 83 84 if (currentType.equals(destinationType) == false && 86 this.dictionaryService.isSubClass(destinationType, currentType) == true) 87 { 88 this.nodeService.setType(actionedUponNodeRef, destinationType); 90 } 91 } 92 } 93 94 97 @Override 98 protected void addParameterDefintions(List <ParameterDefinition> paramList) 99 { 100 paramList.add(new ParameterDefinitionImpl(PARAM_TYPE_NAME, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_TYPE_NAME))); 101 } 102 103 } 104 | Popular Tags |