JBoss Community

Re: Active tasks for process instance

created by jnorris in jBPM - View the full discussion

Hi Esteban,

 

I implemented code which appears to work for a simple test case:

 

List<Task> activeTasks = new ArrayList<Task>();

StatefulKnowledgeSession ksession = createKnowledgeSession();

org.jbpm.task.TaskService localTaskService = this.getTaskService();

JPAWorkingMemoryDbLogger jpaLogger = new JPAWorkingMemoryDbLogger( ksession );

KnowledgeRuntimeLoggerFactory.newConsoleLogger( ksession );

WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.getProcessInstance( piId );

Collection<NodeInstance> nodes = processInstance.getNodeInstances();

Task jbpmTask;

for ( NodeInstance nodeInstance : nodes )

{

    if( nodeInstance instanceof HumanTaskNodeInstance )

    {

        jbpmTask = localTaskService.getTaskByWorkItemId( ((HumanTaskNodeInstance) nodeInstance ).getWorkItemId() );

        activeTasks.add( bpmTask );

    }

}

 

Regards,

Jim

Reply to this message by going to Community

Start a new discussion in jBPM at Community