@Override public List<Task> getAllTaskInstances(String processId, CoreSession session) { return getTasks(TaskQueryConstant.GET_TASKS_FOR_PROCESS_PP, session, true, null, processId); }
/** * @deprecated since 6.0, use {@link #wrapDocModelInTask(List)} instead. */ @Deprecated public static List<Task> wrapDocModelInTask(DocumentModelList taskDocuments) { return wrapDocModelInTask(taskDocuments, false); }
@Override public List<Task> getCurrentTaskInstances(CoreSession coreSession) { // Get tasks for current user // We need to build the task actors list: prefixed and unprefixed names // of the principal and all its groups NuxeoPrincipal principal = coreSession.getPrincipal(); List<String> actors = TaskActorsHelper.getTaskActors(principal); return getCurrentTaskInstances(actors, coreSession); }
@Override public List<Task> getAllTaskInstances(String processId, NuxeoPrincipal user, CoreSession session) { List<String> actors = TaskActorsHelper.getTaskActors(user); return getAllTaskInstances(processId, actors, session); }
/** * Provide @param sortInfo to handle sort page-provider contributions (see {@link #getCurrentTaskInstances}) * * @since 5.9.3 */ @Override public List<Task> getCurrentTaskInstances(CoreSession coreSession, List<SortInfo> sortInfos) { // Get tasks for current user // We need to build the task actors list: prefixed and unprefixed names // of the principal and all its groups NuxeoPrincipal principal = coreSession.getPrincipal(); List<String> actors = TaskActorsHelper.getTaskActors(principal); return getCurrentTaskInstances(actors, coreSession, sortInfos); }
@Override public List<Task> getAllTaskInstances(String processId, String nodeId, CoreSession session) { return getTasks(TaskQueryConstant.GET_TASKS_FOR_PROCESS_AND_NODE_PP, session, true, null, processId, nodeId); }
/** * @since 6.0 */ @SuppressWarnings("unchecked") public static List<Task> getTasks(String pageProviderName, CoreSession session, boolean unrestricted, List<SortInfo> sortInfos, Object... params) { PageProviderService ppService = Framework.getService(PageProviderService.class); if (ppService == null) { throw new RuntimeException("Missing PageProvider service"); } Map<String, Serializable> props = new HashMap<>(); // first retrieve potential props from definition PageProviderDefinition def = ppService.getPageProviderDefinition(pageProviderName); if (def != null) { Map<String, String> defProps = def.getProperties(); if (defProps != null) { props.putAll(defProps); } } props.put(CoreQueryDocumentPageProvider.CORE_SESSION_PROPERTY, (Serializable) session); if (unrestricted) { props.put(CoreQueryDocumentPageProvider.USE_UNRESTRICTED_SESSION_PROPERTY, Boolean.TRUE); } PageProvider<DocumentModel> pp = (PageProvider<DocumentModel>) ppService.getPageProvider(pageProviderName, sortInfos, null, null, props, params); if (pp == null) { throw new NuxeoException("Page provider not found: " + pageProviderName); } return wrapDocModelInTask(pp.getCurrentPage()); }
@Override public List<Task> getAllTaskInstances(String processId, List<String> actors, CoreSession session) { return getTasks(TaskQueryConstant.GET_TASKS_FOR_PROCESS_AND_ACTORS_PP, session, true, null, processId, actors); }
/** * Provide @param sortInfo to handle sort page-provider contributions (see {@link #getCurrentTaskInstances}) * * @since 5.9.3 */ @Override public List<Task> getCurrentTaskInstances(List<String> actors, CoreSession coreSession, List<SortInfo> sortInfos) { if (actors == null || actors.isEmpty()) { return new ArrayList<>(); } return getTasks(TaskQueryConstant.GET_TASKS_FOR_ACTORS_PP, coreSession, true, sortInfos, actors); }
/** * Returns a list of task instances assigned to one of the actors in the list or to its pool. * * @param actors a list used as actorId to retrieve the tasks. */ @Override public List<Task> getCurrentTaskInstances(List<String> actors, CoreSession coreSession) { if (actors == null || actors.isEmpty()) { return new ArrayList<>(); } return getTasks(TaskQueryConstant.GET_TASKS_FOR_ACTORS_PP, coreSession, true, null, actors); }
/** * Get task by name for current document. * * @param taskName * @param session * @param document * @return task given name and current doc * @throws NuxeoException */ public static Task getTaskByName(String taskName, CoreSession session, DocumentModel currentDoc) throws NuxeoException { Task searchedTask = null; Object[] params = {taskName, currentDoc.getId()}; List<Task> tasks = DocumentTaskProvider.getTasks(GET_TASKS_BY_NAME_PROVIDER, session, true, null, params); if (CollectionUtils.isNotEmpty(tasks)) { searchedTask = tasks.get(0); } return searchedTask; }
@Override public List<Task> getTaskInstances(DocumentModel dm, List<String> actors, CoreSession coreSession) { if (actors == null || actors.isEmpty()) { return new ArrayList<>(); } return getTasks(TaskQueryConstant.GET_TASKS_FOR_TARGET_DOCUMENTS_AND_ACTORS_PP, coreSession, true, null, dm.getId(), dm.getId(), actors); }
@Override public List<Task> getTaskInstances(DocumentModel dm, List<String> actors, boolean includeDelegatedTasks, CoreSession session) { if (includeDelegatedTasks) { return getTasks(TaskQueryConstant.GET_TASKS_FOR_TARGET_DOCUMENTS_AND_ACTORS_OR_DELEGATED_ACTORS_PP, session, true, null, dm.getId(), dm.getId(), actors, actors); } else { return getTasks(TaskQueryConstant.GET_TASKS_FOR_TARGET_DOCUMENTS_AND_ACTORS_PP, session, true, null, dm.getId(), dm.getId(), actors); } }
@Override public List<Task> getAllCurrentTaskInstances(CoreSession session, List<SortInfo> sortInfos) { // Get tasks for current user // We need to build the task actors list: prefixed and unprefixed names // of the principal and all its groups NuxeoPrincipal principal = session.getPrincipal(); List<String> actors = TaskActorsHelper.getTaskActors(principal); return getTasks(TaskQueryConstant.GET_TASKS_FOR_ACTORS_OR_DELEGATED_ACTORS_PP, session, true, sortInfos, actors, actors); }
@Override public List<Task> getTaskInstances(DocumentModel dm, NuxeoPrincipal user, CoreSession coreSession) { if (user == null) { return getTasks(TaskQueryConstant.GET_TASKS_FOR_TARGET_DOCUMENTS_PP, coreSession, true, null, dm.getId(), dm.getId()); } else { List<String> actors = TaskActorsHelper.getTaskActors(user); return getTasks(TaskQueryConstant.GET_TASKS_FOR_TARGET_DOCUMENTS_AND_ACTORS_PP, coreSession, true, null, dm.getId(), dm.getId(), actors); } }