05-17-2011 05:06 AM
05-18-2011 07:47 PM
05-23-2011 05:12 AM
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.cmr.workflow.WorkflowTaskDefinition;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.TransientNode;
import org.alfresco.web.bean.workflow.WorkflowUtil;
WorkflowService ws = ServicesUtilsGP.getServiceRegistry().getWorkflowService();
// Create full workflow id (with 'jbpm$' prefix)
String workflowFullId = "jbpm$" + relatedWfId;
// we find the workflow instance
List<WorkflowPath> listeWfPaths = ws.getWorkflowPaths(workflowFullId);
for (WorkflowPath workflowPath : listeWfPaths)
{
List<WorkflowTask> listWfTasks = ws.getTasksForWorkflowPath(workflowPath.id);
for (WorkflowTask workflowTask : listWfTasks)
{
Map<QName, Serializable> workflowProperties = ws.getPathProperties(workflowPath.id);
Map<QName, Serializable> taskProperties = workflowTask.properties;
// Here wa can get workflow or task properties
String wfPropValue = (String) workflowProperties.get(QName.createQName("namespaceUri", "wfPropName"));
String taskPropValue = (String) taskProperties.get(QName.createQName("namespaceUri", "taskPropName"));
// And set task properties
// setup a transient node to represent the task we're managing
WorkflowTaskDefinition taskDef = workflowTask.definition;
Node taskNode = new TransientNode(taskDef.metadata.getName(), "task_"
+ System.currentTimeMillis(), taskProperties);
Map<QName, Serializable> properties = WorkflowUtil.prepareTaskParams(taskNode);
properties.put(QName.createQName("namespaceUri", "taskPropName", "value");
// execute update
ws.updateTask(workflowTask.id, properties, null, null);
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.