Search code examples
taskjbpmbusiness-process-management

Unable to get all task from JBPM 6.4


Is there a way to get all task and potential owners for each task from system? I found that there are some method on task service but it returns only a part of the tasks and without potential owners.


Solution

  • This is my solution:

    @Inject
    TaskService taskService;
    
    @Inject
    @PersistenceUnit(unitName = "org.jbpm.domain")
    private EntityManagerFactory emf;
    
    EntityManager em = emf.createEntityManager();
    CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
    
    final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(TaskMinimal.class);
    final Root taskRoot = criteriaQuery.from(TaskImpl.class);
    final TypedQuery query = em.createQuery(criteriaQuery);
    List<TaskMinimal> taskMinimals = query.getResultList();
    List<Task> tasks = taskMinimals.stream()
                    .map(minimal -> taskService.getTaskById(minimal.getId()))
                    .collect(Collectors.toList());
    
    
    
    public class TaskMinimal {
    
         private long id;
    
         public TaskMinimal(long id){
            this.id = id;
         }
    
         public long getId() {
            return id;
         }
    
         public void setId(long id) {
            this.id = id;
         }
    }