Search code examples
jbpm

jbpm - query all unassigned tasks


I'm using jbpm 6.2 and I'm trying to query all tasks that have not been assigned yet. The TaskService doesn't seem to help (or at least I have not found the proper method).

How can it be done?


Solution

  • I did it using the BAMTASKSUMMARY table, not sure if it was the only way to do it.

    To do that I first tried the BAMTaskEventListener at the RuntimeManager (so it started recording into the table):

    DefaultRegisterableItemsFactory registerableItemsFactory = new DefaultRegisterableItemsFactory();
    registerableItemsFactory.addTaskListener(BAMTaskEventListener.class);
    emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
    RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.Factory.get()
            .newDefaultBuilder().entityManagerFactory(emf).registerableItemsFactory(registerableItemsFactory)
            .knowledgeBase(kbase);
    

    With that code I had a problem, the BAMTaskEventListener didnt have an empty constructor in jbpm 6.2 and there was a problem in the instantiation...I extended it to add an empty constructor and it worked fine:

    public class BAMTaskEventListenerExt extends BAMTaskEventListener{
    
        public BAMTaskEventListenerExt() {
            super(null);
            // TODO Auto-generated constructor stub
        }
    
        public BAMTaskEventListenerExt(boolean flag) {
            super(flag);
            // TODO Auto-generated constructor stub
        }
    
        public BAMTaskEventListenerExt(EntityManagerFactory emf) {
            super(emf);
            // TODO Auto-generated constructor stub
        }
    
    }
    

    And then registeded:

    DefaultRegisterableItemsFactory registerableItemsFactory = new DefaultRegisterableItemsFactory();
    registerableItemsFactory.addTaskListener(BAMTaskEventListenerExt.class);