use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method findTasksOwned.
@Override
public List<TaskSummary> findTasksOwned(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_OWNED_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksOwnedByStatus", 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 findTasks.
@Override
public List<TaskSummary> findTasks(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_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getAllAuditTask", new Object[] { 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 RuntimeDataResource method getTasksOwnedByStatus.
@ApiOperation(value = "Returns task instances that the querying user owns.")
@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_OWNED_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTasksOwnedByStatus(@Context HttpHeaders headers, @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.getTasksOwnedByStatus(status, userId, 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);
}
}
use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getTasksAssignedAsPotentialOwner.
@ApiOperation(value = "Returns tasks with a user defined as a potential owner.")
@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_ASSIGN_POT_OWNERS_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTasksAssignedAsPotentialOwner(@Context HttpHeaders headers, @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 group names to include in the query", required = false, allowMultiple = true) @QueryParam("groups") List<String> groupIds, @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, @ApiParam(value = "optional custom filter for task data", required = false) @QueryParam("filter") String filter) {
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.getTasksAssignedAsPotentialOwner(status, groupIds, userId, page, pageSize, sort, sortOrder, filter);
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);
}
}
use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method convertToTaskSummaryList.
public static TaskSummaryList convertToTaskSummaryList(Collection<TaskSummary> tasks) {
if (tasks == null) {
return new TaskSummaryList(new org.kie.server.api.model.instance.TaskSummary[0]);
}
org.kie.server.api.model.instance.TaskSummary[] instances = new org.kie.server.api.model.instance.TaskSummary[tasks.size()];
int counter = 0;
for (TaskSummary taskSummary : tasks) {
instances[counter] = convertToTaskSummary(taskSummary);
counter++;
}
return new TaskSummaryList(instances);
}
Aggregations