1 17 package org.alfresco.repo.action.executer; 18 19 import java.io.Serializable ; 20 import java.util.HashMap ; 21 import java.util.List ; 22 import java.util.Map ; 23 24 import org.alfresco.model.ContentModel; 25 import org.alfresco.repo.action.ParameterDefinitionImpl; 26 import org.alfresco.service.cmr.action.Action; 27 import org.alfresco.service.cmr.action.ParameterDefinition; 28 import org.alfresco.service.cmr.dictionary.DataTypeDefinition; 29 import org.alfresco.service.cmr.repository.NodeRef; 30 import org.alfresco.service.cmr.repository.NodeService; 31 import org.alfresco.service.namespace.QName; 32 33 38 public class SimpleWorkflowActionExecuter extends ActionExecuterAbstractBase 39 { 40 public static final String NAME = "simple-workflow"; 41 public static final String PARAM_APPROVE_STEP = "approve-step"; 42 public static final String PARAM_APPROVE_FOLDER = "approve-folder"; 43 public static final String PARAM_APPROVE_MOVE = "approve-move"; 44 public static final String PARAM_REJECT_STEP = "reject-step"; 45 public static final String PARAM_REJECT_FOLDER = "reject-folder"; 46 public static final String PARAM_REJECT_MOVE = "reject-move"; 47 48 private NodeService nodeService; 49 50 public void setNodeService(NodeService nodeService) 51 { 52 this.nodeService = nodeService; 53 } 54 55 @Override 56 protected void addParameterDefintions(List <ParameterDefinition> paramList) 57 { 58 paramList.add(new ParameterDefinitionImpl(PARAM_APPROVE_STEP, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_APPROVE_STEP))); 59 paramList.add(new ParameterDefinitionImpl(PARAM_APPROVE_FOLDER, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_APPROVE_FOLDER))); 60 paramList.add(new ParameterDefinitionImpl(PARAM_APPROVE_MOVE, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_APPROVE_MOVE))); 61 paramList.add(new ParameterDefinitionImpl(PARAM_REJECT_STEP, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_REJECT_STEP))); 62 paramList.add(new ParameterDefinitionImpl(PARAM_REJECT_FOLDER, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_REJECT_FOLDER))); 63 paramList.add(new ParameterDefinitionImpl(PARAM_REJECT_MOVE, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_REJECT_MOVE))); 64 } 65 66 69 @Override 70 protected void executeImpl( 71 Action ruleAction, 72 NodeRef actionedUponNodeRef) 73 { 74 if (this.nodeService.exists(actionedUponNodeRef) == true) 75 { 76 String approveStep = (String )ruleAction.getParameterValue(PARAM_APPROVE_STEP); 78 NodeRef approveFolder = (NodeRef)ruleAction.getParameterValue(PARAM_APPROVE_FOLDER); 79 Boolean approveMove = (Boolean )ruleAction.getParameterValue(PARAM_APPROVE_MOVE); 80 String rejectStep = (String )ruleAction.getParameterValue(PARAM_REJECT_STEP); 81 NodeRef rejectFolder = (NodeRef)ruleAction.getParameterValue(PARAM_REJECT_FOLDER); 82 Boolean rejectMove = (Boolean )ruleAction.getParameterValue(PARAM_REJECT_MOVE); 83 84 Map <QName, Serializable > propertyValues = new HashMap <QName, Serializable >(); 86 propertyValues.put(ContentModel.PROP_APPROVE_STEP, approveStep); 87 propertyValues.put(ContentModel.PROP_APPROVE_FOLDER, approveFolder); 88 if (approveMove != null) 89 { 90 propertyValues.put(ContentModel.PROP_APPROVE_MOVE, approveMove.booleanValue()); 91 } 92 propertyValues.put(ContentModel.PROP_REJECT_STEP, rejectStep); 93 propertyValues.put(ContentModel.PROP_REJECT_FOLDER, rejectFolder); 94 if (rejectMove != null) 95 { 96 propertyValues.put(ContentModel.PROP_REJECT_MOVE, rejectMove.booleanValue()); 97 } 98 99 this.nodeService.addAspect(actionedUponNodeRef, ContentModel.ASPECT_SIMPLE_WORKFLOW, propertyValues); 101 } 102 } 103 } 104 | Popular Tags |