public class TestExecuter extends ActionExecuterAbstractBase{
private NodeService nodeService;
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
NodeRef nodeRef = (NodeRef) action.getParameterValue(PARAM_NOME);
nodeService.XXX
//… }
dove con XXX può fare qualcosa, tipo un get, un set o un'altra cosa.<beans>
<bean id="XXX" class="com.action.executer.TestExecuter" parent="actionexecuter">
<property name="nodeService">
<ref bean="NodeService" />
</property>
</bean>
<bean id="extension.actionResourceBundles" parent="actionResourceBundles">
<property name="resourceBundles">
<list>
<value>alfresco.extension.YYYY</value>
</list>
</property>
</bean>
</beans>
All'interno della SDK di Alfresco trovi un progetto di esempio che si chiama "Custom Action" forse ti aiuterà a comprendere meglio il tutto.
Intendi dentro l' SDK AlfrescoEmbedded?No, intendo il progetto SDK CustomAction che trovi all'interno della SDK di Alfresco come uno dei progetti dell'ambiente di sviluppo.
package org.alfresco.repo.workflow;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowPath;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
public class StartWorkflowActionExecuter extends ActionExecuterAbstractBase
{
public static final String NAME = "start-workflow";
public static final String PARAM_WORKFLOW_NAME = "workflowName";
public static final String PARAM_END_START_TASK = "endStartTask";
public static final String PARAM_START_TASK_TRANSITION = "startTaskTransition";
private NamespaceService namespaceService;
private WorkflowService workflowService;
private NodeService nodeService;
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setWorkflowService(WorkflowService workflowService)
{
this.workflowService = workflowService;
}
@Override
protected boolean getAdhocPropertiesAllowed()
{
return true;
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_WORKFLOW_NAME, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_WORKFLOW_NAME)));
paramList.add(new ParameterDefinitionImpl(PARAM_END_START_TASK, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_END_START_TASK)));
paramList.add(new ParameterDefinitionImpl(PARAM_START_TASK_TRANSITION, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_START_TASK_TRANSITION)));
// TODO: start task node parameter
}
@Override
protected void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
{
// retrieve workflow definition
String workflowName = (String)ruleAction.getParameterValue(PARAM_WORKFLOW_NAME);
WorkflowDefinition def = workflowService.getDefinitionByName(workflowName);
// create workflow package to contain actioned upon node
NodeRef workflowPackage = (NodeRef)ruleAction.getParameterValue(WorkflowModel.ASSOC_PACKAGE.toPrefixString(namespaceService));
workflowPackage = workflowService.createPackage(workflowPackage);
ChildAssociationRef childAssoc = nodeService.getPrimaryParent(actionedUponNodeRef);
nodeService.addChild(workflowPackage, actionedUponNodeRef, WorkflowModel.ASSOC_PACKAGE_CONTAINS, childAssoc.getQName());
// build map of workflow start task parameters
Map<String, Serializable> paramValues = ruleAction.getParameterValues();
Map<QName, Serializable> workflowParameters = new HashMap<QName, Serializable>();
workflowParameters.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage);
for (Map.Entry<String, Serializable> entry : paramValues.entrySet())
{
if (!entry.getKey().equals(PARAM_WORKFLOW_NAME))
{
QName qname = QName.createQName(entry.getKey(), namespaceService);
Serializable value = entry.getValue();
workflowParameters.put(qname, value);
}
}
// provide a default context, if one is not specified
Serializable context = workflowParameters.get(WorkflowModel.PROP_CONTEXT);
if (context == null)
{
workflowParameters.put(WorkflowModel.PROP_CONTEXT, childAssoc.getParentRef());
}
// start the workflow
WorkflowPath path = workflowService.startWorkflow(def.id, workflowParameters);
// determine whether to auto-end the start task
Boolean endStartTask = (Boolean)ruleAction.getParameterValue(PARAM_END_START_TASK);
String startTaskTransition = (String)ruleAction.getParameterValue(PARAM_START_TASK_TRANSITION);
endStartTask = (endStartTask == null) ? true : false;
// auto-end the start task with the provided transition (if one)
if (endStartTask)
{
List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(path.id);
for (WorkflowTask task : tasks)
{
workflowService.endTask(task.id, startTaskTransition);
}
}
}
}
Archive content from product discussions in Italian.
This group is now closed and content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.