Class WorkflowTaskFinder

java.lang.Object
fr.becpg.repo.workflow.WorkflowTaskFinder

@Service("workflowTaskFinder") public class WorkflowTaskFinder extends Object
Answers whether a user holds an in-progress task on a given set of workflows.

Assigned tasks are asked of Activiti workflow by workflow: WorkflowTaskQuery accepts both processId and actorId, so the returned tasks belong to the right workflow by construction and nothing has to be filtered in memory. Scanning every task of the account and reading task.getPath().getInstance().getId() on each would lazily load the path and the workflow instance once per task, for a cost driven by the size of the user's task list rather than by the one or two workflows actually asked about.

Pooled tasks cannot be expressed that way — WorkflowTaskQuery has no setting for candidate groups — so they are scanned, but only as a fallback once the bounded query came back empty.

Version:
$Id: $Id
Author:
matthieu
  • Field Details

    • workflowService

      @Autowired @Qualifier("WorkflowService") private org.alfresco.service.cmr.workflow.WorkflowService workflowService
  • Constructor Details

    • WorkflowTaskFinder

      public WorkflowTaskFinder()
  • Method Details

    • hasTaskOn

      public boolean hasTaskOn(String actorId, Collection<String> workflowIds, Predicate<org.alfresco.service.cmr.workflow.WorkflowTask> accept)
      Whether the user holds an in-progress task on one of these workflows.

      Assigned tasks are queried first; pooled tasks are only scanned when the query found nothing.

      Parameters:
      actorId - the user, as Activiti knows it
      workflowIds - the workflow instances carried by the content
      accept - an extra filter on the task, or null to accept them all. It is only evaluated on the tasks already retained, so a costly predicate stays cheap.
      Returns:
      true on the first matching task
    • hasPooledTaskOn

      private boolean hasPooledTaskOn(String actorId, Collection<String> workflowIds, Predicate<org.alfresco.service.cmr.workflow.WorkflowTask> filter)
      The fallback: pooled tasks, for want of an API to query them by workflow.

      Filtering on the instance is still needed here, with its lazy loading, but it is only paid by the accounts holding no assigned task on these workflows.

      Parameters:
      actorId - the user
      workflowIds - the workflow instances looked for
      filter - an extra filter, never null
      Returns:
      true on the first matching task