Alfresco · Lanzar flujo de trabajo desde Java

Alfresco start workflow

private static final String GROUP_NAME = "REVIEW_GROUP";
private static final String WORKFLOW_DESCRIPTION = "Request for approval";
private static final String TASK_DESCRIPTION = "Check contents and review.";
private static final String ACTIVITI_PARALLEL_GROUP_REVIEW_NAME = "activiti$activitiParallelGroupReview";

protected void startWorkflow(NodeRef contentNodeRef, ServiceRegistry serviceRegistry) {

	// Required repo services should be injected by using Spring beans
	AuthorityService authorityService = serviceRegistry.getAuthorityService();
	NodeService nodeService = serviceRegistry.getNodeService();
	WorkflowService workflowService = serviceRegistry.getWorkflowService();
	
	NodeRef workflowNodeRef = workflowService.createPackage(null);
	
	// Set WF properties: don't forget to start group short name with 'GROUP_'
	Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
	parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowNodeRef);
	parameters.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, WORKFLOW_DESCRIPTION);
	parameters.put(WorkflowModel.PROP_DESCRIPTION, TASK_DESCRIPTION);
	parameters.put(WorkflowModel.ASSOC_GROUP_ASSIGNEE, authorityService.getAuthorityNodeRef("GROUP_" + GROUP_NAME));
	parameters.put(WorkflowModel.PROP_PERCENT_COMPLETE, 50);
	
	// Add zero or more items
	nodeService.addChild(
    		workflowNodeRef, 
            contentNodeRef, 
            WorkflowModel.ASSOC_PACKAGE_CONTAINS, 
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
                QName.createValidLocalName(nodeService.getProperty(contentNodeRef, ContentModel.PROP_NAME).toString())));
	
	// Start workflow
	WorkflowDefinition wfDefinition = workflowService.getDefinitionByName(ACTIVITI_PARALLEL_GROUP_REVIEW_NAME);
	workflowService.startWorkflow(wfDefinition.getId(), parameters);

}

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s