use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method findTasksByStatusByProcessInstanceId.
@Override
public List<TaskSummary> findTasksByStatusByProcessInstanceId(Long processInstanceId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
TaskSummaryList taskSummaryList = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(PROCESS_INST_ID, processInstanceId);
String statusQuery = getAdditionalParams("", "status", status);
String queryString = getPagingQueryString(statusQuery, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASK_BY_PROCESS_INST_ID_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksByStatusByProcessInstanceId", new Object[] { processInstanceId, safeList(status), page, pageSize, sort, sortOrder })));
ServiceResponse<TaskSummaryList> response = (ServiceResponse<TaskSummaryList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
taskSummaryList = response.getResult();
}
if (taskSummaryList != null && taskSummaryList.getTasks() != null) {
return Arrays.asList(taskSummaryList.getTasks());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method findTasksAssignedAsBusinessAdministrator.
@Override
public List<TaskSummary> findTasksAssignedAsBusinessAdministrator(String userId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
TaskSummaryList taskSummaryList = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
String userQuery = getUserQueryStr(userId);
String statusQuery = getAdditionalParams(userQuery, "status", status);
String queryString = getPagingQueryString(statusQuery, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_ASSIGN_BUSINESS_ADMINS_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksAssignedAsBusinessAdministratorByStatus", new Object[] { safeList(status), userId, page, pageSize, sort, sortOrder })));
ServiceResponse<TaskSummaryList> response = (ServiceResponse<TaskSummaryList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
taskSummaryList = response.getResult();
}
if (taskSummaryList != null && taskSummaryList.getTasks() != null) {
return Arrays.asList(taskSummaryList.getTasks());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method findTasksAssignedAsPotentialOwner.
@Override
public List<TaskSummary> findTasksAssignedAsPotentialOwner(String userId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
TaskSummaryList taskSummaryList = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
String queryString = getUserAndPagingQueryString(userId, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_ASSIGN_POT_OWNERS_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksAssignedAsPotentialOwner", new Object[] { new ArrayList(), new ArrayList(), userId, page, pageSize, sort, sortOrder })));
ServiceResponse<TaskSummaryList> response = (ServiceResponse<TaskSummaryList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
taskSummaryList = response.getResult();
}
if (taskSummaryList != null && taskSummaryList.getTasks() != null) {
return Arrays.asList(taskSummaryList.getTasks());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method findTasksByVariableAndValue.
@Override
public List<TaskSummary> findTasksByVariableAndValue(String userId, String variableName, String variableValue, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
TaskSummaryList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(VAR_NAME, variableName);
String userQuery = getUserQueryStr(userId);
String statusQuery = getAdditionalParams(userQuery, "status", status);
String queryString = getPagingQueryString(statusQuery, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_BY_VAR_NAME_GET_URI, valuesMap) + queryString + "&varValue=" + variableValue, TaskSummaryList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksByVariables", new Object[] { userId, variableName, variableValue, safeList(status), page, pageSize, sort, sortOrder })));
ServiceResponse<TaskSummaryList> response = (ServiceResponse<TaskSummaryList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getTasks() != null) {
return Arrays.asList(result.getTasks());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getTasksByVariables.
@ApiOperation(value = "Returns task instances with a specified variable.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = TaskSummaryList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_TASK_SUMMARY_RESPONSE_JSON) })) })
@GET
@Path(TASKS_BY_VAR_NAME_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTasksByVariables(@Context HttpHeaders headers, @ApiParam(value = "name of the variable used to fiter tasks", required = true) @PathParam("varName") String variableName, @ApiParam(value = "value of the variable used to fiter tasks, optional when filtering only by name, required when filtering by both name and value", required = false) @QueryParam("varValue") String variableValue, @ApiParam(value = "optional task status (Created, Ready, Reserved, InProgress, Suspended, Completed, Failed, Error, Exited, Obsolete)", required = false, allowableValues = "Created, Ready, Reserved,InProgress,Suspended,Completed,Failed,Error,Exited,Obsolete") @QueryParam("status") List<String> status, @ApiParam(value = "optional user id to be used instead of authenticated user - only when bypass authenticated user is enabled", required = false) @QueryParam("user") String userId, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize, @ApiParam(value = "optional sort column, no default", required = false) @QueryParam("sort") String sort, @ApiParam(value = "optional sort direction (asc, desc) - defaults to asc", required = false) @QueryParam("sortOrder") @DefaultValue("true") boolean sortOrder) {
Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
try {
TaskSummaryList result = runtimeDataServiceBase.getTasksByVariables(userId, variableName, variableValue, status, page, pageSize, sort, sortOrder);
return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
Aggregations