cancel
Showing results for 
Search instead for 
Did you mean: 

[solved] Package not attached to Workflow started with Java

mccarthymp
Confirmed Champ
Confirmed Champ
I am attempting to kick off a workflow in a Java webscript.  I have succeeded in starting the workflow but I can not get the package/resource attached to the task when I start the workflow.  Here is my code:

        NodeRef temp = new NodeRef("workspace://SpacesStore/"+id);
        WorkflowDefinition workflowDef = workflowService.getDefinitionByName("jbpm$adwf:approveContent");
        ChildAssociationRef childAssoc = nodeService.getPrimaryParent(temp);
        NodeRef pack = workflowService.createPackage(null);
        nodeService.addChild(pack, temp, ContentModel.ASSOC_CONTAINS, childAssoc.getQName());
        Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
        parameters.put(WorkflowModel.ASSOC_PACKAGE, pack);
        parameters.put(WorkflowModel.PROP_CONTEXT, childAssoc.getParentRef());
        WorkflowPath path = workflowService.startWorkflow(workflowDef.getId(), parameters);
        workflowService.signal(path.id, null);

I am trying to attache the NodeRef "temp" to the workflow.  I get the task but no resource is attached to it.

Thanks!
1 REPLY 1

mccarthymp
Confirmed Champ
Confirmed Champ
I have found the solution.  Instead of signaling the workflow you must end the task.


        List tasks = workflowService.getTasksForWorkflowPath(path.id);
        for(int i = 0; i < tasks.size(); i++) {
            String taskId = ((WorkflowTask)tasks.get(i)).id;
            workflowService.endTask(taskId, null);
        }