public boolean hasUserPendingOrAssignedTasks(long userId, Long processInstanceId) throws SExecutionException { final ActivityInstanceService activityInstanceService = getTenantServiceAccessor().getActivityInstanceService(); // is user assigned or has pending tasks on this process instance: final QueryOptions queryOptions = new QueryOptions(0, 1, Collections.EMPTY_LIST, Arrays.asList(new FilterOption(SHumanTaskInstance.class, "logicalGroup2", processInstanceId)), null); try { return activityInstanceService.getNumberOfPendingOrAssignedTasks(userId, queryOptions) > 0; } catch (SBonitaReadException e) { throw new SExecutionException(e); } }
public boolean hasUserPendingOrAssignedTasks(long userId, Long processInstanceId) throws SExecutionException { final ActivityInstanceService activityInstanceService = getTenantServiceAccessor().getActivityInstanceService(); // is user assigned or has pending tasks on this process instance: final QueryOptions queryOptions = new QueryOptions(0, 1, Collections.EMPTY_LIST, Arrays.asList(new FilterOption(SHumanTaskInstance.class, "logicalGroup2", processInstanceId)), null); try { return activityInstanceService.getNumberOfPendingOrAssignedTasks(userId, queryOptions) > 0; } catch (SBonitaReadException e) { throw new SExecutionException(e); } }
public boolean isExecutorOfArchivedTaskOfProcess(long userId, Long rootProcessInstanceId) throws SBonitaReadException { final ActivityInstanceService activityInstanceService = getTenantServiceAccessor().getActivityInstanceService(); QueryOptions archivedQueryOptions = buildArchivedTasksQueryOptions(rootProcessInstanceId); List<SAHumanTaskInstance> sArchivedHumanTasks = activityInstanceService.searchArchivedTasks(archivedQueryOptions); while (!sArchivedHumanTasks.isEmpty()) { for (final SAHumanTaskInstance sArchivedHumanTask : sArchivedHumanTasks) { if (userId == sArchivedHumanTask.getExecutedBy()) { return true; } } archivedQueryOptions = QueryOptions.getNextPage(archivedQueryOptions); sArchivedHumanTasks = activityInstanceService.searchArchivedTasks(archivedQueryOptions); } return false; }
public boolean isExecutorOfArchivedTaskOfProcess(long userId, Long rootProcessInstanceId) throws SBonitaReadException { final ActivityInstanceService activityInstanceService = getTenantServiceAccessor().getActivityInstanceService(); QueryOptions archivedQueryOptions = buildArchivedTasksQueryOptions(rootProcessInstanceId); List<SAHumanTaskInstance> sArchivedHumanTasks = activityInstanceService.searchArchivedTasks(archivedQueryOptions); while (!sArchivedHumanTasks.isEmpty()) { for (final SAHumanTaskInstance sArchivedHumanTask : sArchivedHumanTasks) { if (userId == sArchivedHumanTask.getExecutedBy()) { return true; } } archivedQueryOptions = QueryOptions.getNextPage(archivedQueryOptions); sArchivedHumanTasks = activityInstanceService.searchArchivedTasks(archivedQueryOptions); } return false; }
public boolean isInvolvedInHumanTaskInstance(long userId, long humanTaskInstanceId) throws ActivityInstanceNotFoundException { final ActivityInstanceService activityInstanceService = getTenantServiceAccessor().getActivityInstanceService(); try { long assigneeId; final SHumanTaskInstance humanTaskInstance = activityInstanceService.getHumanTaskInstance(humanTaskInstanceId); assigneeId = humanTaskInstance.getAssigneeId(); if (assigneeId > 0) { //check if the user is the assigned user return userId == assigneeId; } else { //if the task is not assigned check if the user is mapped to the actor of the task return activityInstanceService.isTaskPendingForUser(humanTaskInstanceId, userId); } } catch (SActivityInstanceNotFoundException e) { throw new ActivityInstanceNotFoundException(humanTaskInstanceId); } catch (SBonitaReadException | SActivityReadException e) { throw new RetrieveException(e); } }
public SearchResult<HumanTaskInstance> searchPendingTasksManagedBy(final long managerUserId, final SearchOptions searchOptions) throws SearchException { final TenantServiceAccessor tenantServiceAccessor = getTenantServiceAccessor(); final ActivityInstanceService activityInstanceService = tenantServiceAccessor.getActivityInstanceService(); final SearchEntitiesDescriptor searchEntitiesDescriptor = tenantServiceAccessor.getSearchEntitiesDescriptor(); final FlowNodeStateManager flowNodeStateManager = tenantServiceAccessor.getFlowNodeStateManager(); return AbstractHumanTaskInstanceSearchEntity.searchHumanTaskInstance(searchEntitiesDescriptor.getSearchHumanTaskInstanceDescriptor(), searchOptions, flowNodeStateManager, (queryOptions) -> activityInstanceService.searchNumberOfPendingTasksManagedBy(managerUserId, queryOptions), (queryOptions) -> activityInstanceService.searchPendingTasksManagedBy(managerUserId, queryOptions)).search(); }
public boolean isInvolvedInHumanTaskInstance(long userId, long humanTaskInstanceId) throws ActivityInstanceNotFoundException { final ActivityInstanceService activityInstanceService = getTenantServiceAccessor().getActivityInstanceService(); try { long assigneeId; final SHumanTaskInstance humanTaskInstance = activityInstanceService.getHumanTaskInstance(humanTaskInstanceId); assigneeId = humanTaskInstance.getAssigneeId(); if (assigneeId > 0) { //check if the user is the assigned user return userId == assigneeId; } else { //if the task is not assigned check if the user is mapped to the actor of the task return activityInstanceService.isTaskPendingForUser(humanTaskInstanceId, userId); } } catch (SActivityInstanceNotFoundException e) { throw new ActivityInstanceNotFoundException(humanTaskInstanceId); } catch (SBonitaReadException | SActivityReadException e) { throw new RetrieveException(e); } }
public SearchResult<HumanTaskInstance> searchPendingTasksManagedBy(final long managerUserId, final SearchOptions searchOptions) throws SearchException { final TenantServiceAccessor tenantServiceAccessor = getTenantServiceAccessor(); final ActivityInstanceService activityInstanceService = tenantServiceAccessor.getActivityInstanceService(); final SearchEntitiesDescriptor searchEntitiesDescriptor = tenantServiceAccessor.getSearchEntitiesDescriptor(); final FlowNodeStateManager flowNodeStateManager = tenantServiceAccessor.getFlowNodeStateManager(); return AbstractHumanTaskInstanceSearchEntity.searchHumanTaskInstance(searchEntitiesDescriptor.getSearchHumanTaskInstanceDescriptor(), searchOptions, flowNodeStateManager, (queryOptions) -> activityInstanceService.searchNumberOfPendingTasksManagedBy(managerUserId, queryOptions), (queryOptions) -> activityInstanceService.searchPendingTasksManagedBy(managerUserId, queryOptions)).search(); }