@Test public void executeFindTaskQueryReadInputsForAll() { Map<String, Object> params = prepareQuery(TaskInputVariablesReadMode.READ_FOR_ALL); List<TaskData> result = helper.executeFindTasksQuery(params); verifyQueryWasExecuted(); assertEquals(TASK1_INPUTS_SANITIZED, result.get(0).getInputData()); assertEquals(TASK2_INPUTS_SANITIZED, result.get(1).getInputData()); assertEquals(TASK3_INPUTS_SANITIZED, result.get(2).getInputData()); }
public List<TaskData> executeFindTasksQuery(Map<String, Object> params) { List<QueryParam> queryParams = buildQueryParams(params); Integer page = params.containsKey(PAGE) ? (Integer) params.get(PAGE) : 0; Integer pageSize = params.containsKey(PAGE_SIZE) ? (Integer) params.get(PAGE_SIZE) : 10; String loadVariablesMode = (String) params.get(TASK_INPUT_VARIABLES_MODE); QueryContext queryContext = new QueryContext(page * pageSize, pageSize, AbstractTaskAssigningQueryMapper.TASK_QUERY_COLUMN.TASK_ID.columnName(), true); AbstractTaskAssigningQueryMapper<TaskData> resultMapper = (AbstractTaskAssigningQueryMapper<TaskData>) QueryMapperRegistry.get() .mapperFor(TaskAssigningTaskDataWithPotentialOwnersQueryMapper.NAME, null); List<TaskData> result = executeQuery(queryService, TASK_ASSIGNING_TASKS_WITH_POTENTIAL_OWNERS_AND_PLANNING_TASK, resultMapper, queryContext, queryParams.toArray(new QueryParam[0])); Optional<Predicate<TaskData>> loadInputVariables = Optional.empty(); if (TaskInputVariablesReadMode.READ_FOR_ALL.name().equals(loadVariablesMode)) { loadInputVariables = Optional.of(taskData -> true); } else if (TaskInputVariablesReadMode.READ_FOR_ACTIVE_TASKS_WITH_NO_PLANNING_ENTITY.name().equals(loadVariablesMode)) { final Predicate<TaskData> isActive = taskData -> { if (taskData.getPlanningTask() != null) { return false; } Status taskStatus = StatusConverter.convertFromString(taskData.getStatus()); return taskStatus == Created || taskStatus == Ready || taskStatus == Reserved || taskStatus == InProgress || taskStatus == Suspended; }; loadInputVariables = Optional.of(isActive); } loadInputVariables.ifPresent(taskDataPredicate -> result.stream() .filter(taskDataPredicate) .forEach(taskData -> taskData.setInputData(readTaskVariables(taskData)))); return result; }
TaskAssigningRuntimeServiceQueryHelper { public List<TaskData> executeFindTasksQuery(Map<String, Object> params) { List<QueryParam> queryParams = buildQueryParams(params); Integer page = params.containsKey(PAGE) ? (Integer) params.get(PAGE) : 0; Integer pageSize = params.containsKey(PAGE_SIZE) ? (Integer) params.get(PAGE_SIZE) : 10; String loadVariablesMode = (String) params.get(TASK_INPUT_VARIABLES_MODE); QueryContext queryContext = new QueryContext(page * pageSize, pageSize, AbstractTaskAssigningQueryMapper.TASK_QUERY_COLUMN.TASK_ID.columnName(), true); AbstractTaskAssigningQueryMapper<TaskData> resultMapper = (AbstractTaskAssigningQueryMapper<TaskData>) QueryMapperRegistry.get() .mapperFor(TaskAssigningTaskDataWithPotentialOwnersQueryMapper.NAME, null); List<TaskData> result = executeQuery(queryService, TASK_ASSIGNING_TASKS_WITH_POTENTIAL_OWNERS_AND_PLANNING_TASK, resultMapper, queryContext, queryParams.toArray(new QueryParam[0])); Optional<Predicate<TaskData>> loadInputVariables = Optional.empty(); if (TaskInputVariablesReadMode.READ_FOR_ALL.name().equals(loadVariablesMode)) { loadInputVariables = Optional.of(taskData -> true); } else if (TaskInputVariablesReadMode.READ_FOR_ACTIVE_TASKS_WITH_NO_PLANNING_ENTITY.name().equals(loadVariablesMode)) { final Predicate<TaskData> isActive = taskData -> { if (taskData.getPlanningTask() != null) { return false; } Status taskStatus = StatusConverter.convertFromString(taskData.getStatus()); return taskStatus == Created || taskStatus == Ready || taskStatus == Reserved || taskStatus == InProgress || taskStatus == Suspended; }; loadInputVariables = Optional.of(isActive); } loadInputVariables.ifPresent(taskDataPredicate -> result.stream() .filter(taskDataPredicate) .forEach(taskData -> taskData.setInputData(readTaskVariables(taskData)))); return result; } }
TaskAssigningRuntimeServiceQueryHelper { public List<TaskData> executeFindTasksQuery(Map<String, Object> params) { List<QueryParam> queryParams = buildQueryParams(params); Integer page = params.containsKey(PAGE) ? (Integer) params.get(PAGE) : 0; Integer pageSize = params.containsKey(PAGE_SIZE) ? (Integer) params.get(PAGE_SIZE) : 10; String loadVariablesMode = (String) params.get(TASK_INPUT_VARIABLES_MODE); QueryContext queryContext = new QueryContext(page * pageSize, pageSize, AbstractTaskAssigningQueryMapper.TASK_QUERY_COLUMN.TASK_ID.columnName(), true); AbstractTaskAssigningQueryMapper<TaskData> resultMapper = (AbstractTaskAssigningQueryMapper<TaskData>) QueryMapperRegistry.get() .mapperFor(TaskAssigningTaskDataWithPotentialOwnersQueryMapper.NAME, null); List<TaskData> result = executeQuery(queryService, TASK_ASSIGNING_TASKS_WITH_POTENTIAL_OWNERS_AND_PLANNING_TASK, resultMapper, queryContext, queryParams.toArray(new QueryParam[0])); Optional<Predicate<TaskData>> loadInputVariables = Optional.empty(); if (TaskInputVariablesReadMode.READ_FOR_ALL.name().equals(loadVariablesMode)) { loadInputVariables = Optional.of(taskData -> true); } else if (TaskInputVariablesReadMode.READ_FOR_ACTIVE_TASKS_WITH_NO_PLANNING_ENTITY.name().equals(loadVariablesMode)) { final Predicate<TaskData> isActive = taskData -> { if (taskData.getPlanningTask() != null) { return false; } Status taskStatus = StatusConverter.convertFromString(taskData.getStatus()); return taskStatus == Created || taskStatus == Ready || taskStatus == Reserved || taskStatus == InProgress || taskStatus == Suspended; }; loadInputVariables = Optional.of(isActive); } loadInputVariables.ifPresent(taskDataPredicate -> result.stream() .filter(taskDataPredicate) .forEach(taskData -> taskData.setInputData(readTaskVariables(taskData)))); return result; } TaskAssigningRuntimeServiceQueryHelper(KieServerRegistry registry, UserTaskService userTaskService, QueryService queryService); }
TaskAssigningRuntimeServiceQueryHelper { public List<TaskData> executeFindTasksQuery(Map<String, Object> params) { List<QueryParam> queryParams = buildQueryParams(params); Integer page = params.containsKey(PAGE) ? (Integer) params.get(PAGE) : 0; Integer pageSize = params.containsKey(PAGE_SIZE) ? (Integer) params.get(PAGE_SIZE) : 10; String loadVariablesMode = (String) params.get(TASK_INPUT_VARIABLES_MODE); QueryContext queryContext = new QueryContext(page * pageSize, pageSize, AbstractTaskAssigningQueryMapper.TASK_QUERY_COLUMN.TASK_ID.columnName(), true); AbstractTaskAssigningQueryMapper<TaskData> resultMapper = (AbstractTaskAssigningQueryMapper<TaskData>) QueryMapperRegistry.get() .mapperFor(TaskAssigningTaskDataWithPotentialOwnersQueryMapper.NAME, null); List<TaskData> result = executeQuery(queryService, TASK_ASSIGNING_TASKS_WITH_POTENTIAL_OWNERS_AND_PLANNING_TASK, resultMapper, queryContext, queryParams.toArray(new QueryParam[0])); Optional<Predicate<TaskData>> loadInputVariables = Optional.empty(); if (TaskInputVariablesReadMode.READ_FOR_ALL.name().equals(loadVariablesMode)) { loadInputVariables = Optional.of(taskData -> true); } else if (TaskInputVariablesReadMode.READ_FOR_ACTIVE_TASKS_WITH_NO_PLANNING_ENTITY.name().equals(loadVariablesMode)) { final Predicate<TaskData> isActive = taskData -> { if (taskData.getPlanningTask() != null) { return false; } Status taskStatus = StatusConverter.convertFromString(taskData.getStatus()); return taskStatus == Created || taskStatus == Ready || taskStatus == Reserved || taskStatus == InProgress || taskStatus == Suspended; }; loadInputVariables = Optional.of(isActive); } loadInputVariables.ifPresent(taskDataPredicate -> result.stream() .filter(taskDataPredicate) .forEach(taskData -> taskData.setInputData(readTaskVariables(taskData)))); return result; } TaskAssigningRuntimeServiceQueryHelper(KieServerRegistry registry, UserTaskService userTaskService, QueryService queryService); List<TaskData> executeFindTasksQuery(Map<String, Object> params); List<TaskData> readTasksDataSummary(long fromTaskId, List<String> status, int pageSize); }
TaskAssigningRuntimeServiceQueryHelper { public List<TaskData> executeFindTasksQuery(Map<String, Object> params) { List<QueryParam> queryParams = buildQueryParams(params); Integer page = params.containsKey(PAGE) ? (Integer) params.get(PAGE) : 0; Integer pageSize = params.containsKey(PAGE_SIZE) ? (Integer) params.get(PAGE_SIZE) : 10; String loadVariablesMode = (String) params.get(TASK_INPUT_VARIABLES_MODE); QueryContext queryContext = new QueryContext(page * pageSize, pageSize, AbstractTaskAssigningQueryMapper.TASK_QUERY_COLUMN.TASK_ID.columnName(), true); AbstractTaskAssigningQueryMapper<TaskData> resultMapper = (AbstractTaskAssigningQueryMapper<TaskData>) QueryMapperRegistry.get() .mapperFor(TaskAssigningTaskDataWithPotentialOwnersQueryMapper.NAME, null); List<TaskData> result = executeQuery(queryService, TASK_ASSIGNING_TASKS_WITH_POTENTIAL_OWNERS_AND_PLANNING_TASK, resultMapper, queryContext, queryParams.toArray(new QueryParam[0])); Optional<Predicate<TaskData>> loadInputVariables = Optional.empty(); if (TaskInputVariablesReadMode.READ_FOR_ALL.name().equals(loadVariablesMode)) { loadInputVariables = Optional.of(taskData -> true); } else if (TaskInputVariablesReadMode.READ_FOR_ACTIVE_TASKS_WITH_NO_PLANNING_ENTITY.name().equals(loadVariablesMode)) { final Predicate<TaskData> isActive = taskData -> { if (taskData.getPlanningTask() != null) { return false; } Status taskStatus = StatusConverter.convertFromString(taskData.getStatus()); return taskStatus == Created || taskStatus == Ready || taskStatus == Reserved || taskStatus == InProgress || taskStatus == Suspended; }; loadInputVariables = Optional.of(isActive); } loadInputVariables.ifPresent(taskDataPredicate -> result.stream() .filter(taskDataPredicate) .forEach(taskData -> taskData.setInputData(readTaskVariables(taskData)))); return result; } TaskAssigningRuntimeServiceQueryHelper(KieServerRegistry registry, UserTaskService userTaskService, QueryService queryService); List<TaskData> executeFindTasksQuery(Map<String, Object> params); List<TaskData> readTasksDataSummary(long fromTaskId, List<String> status, int pageSize);  }