use of org.kie.server.api.model.instance.TaskEventInstanceList in project droolsjbpm-integration by kiegroup.
the class UserTaskResource method getTaskEvents.
@ApiOperation(value = "Returns all events for a specified task instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task with given id not found"), @ApiResponse(code = 200, response = TaskEventInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_TASK_EVENTS_RESPONSE_JSON) })) })
@GET
@Path(TASK_INSTANCE_EVENTS_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTaskEvents(@Context HttpHeaders headers, @ApiParam(value = "container id that task instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the task instance that events should be loaded for", required = true, example = "123") @PathParam(TASK_INSTANCE_ID) Long taskId, @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 {
TaskEventInstanceList result = runtimeDataServiceBase.getTaskEvents(taskId, page, pageSize, sort, sortOrder);
return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
} catch (TaskNotFoundException e) {
return notFound(errorMessage(e, MessageFormat.format(TASK_INSTANCE_NOT_FOUND, taskId)), v, 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.TaskEventInstanceList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getTaskEvents.
@ApiOperation(value = "Returns events for a specified task instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = TaskEventInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_TASK_EVENTS_RESPONSE_JSON) })) })
@GET
@Path(TASKS_EVENTS_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTaskEvents(@Context HttpHeaders headers, @ApiParam(value = "task id to load task events for", required = true) @PathParam(TASK_INSTANCE_ID) Long taskId, @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 {
TaskEventInstanceList result = runtimeDataServiceBase.getTaskEvents(taskId, page, pageSize, sort, sortOrder);
return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
} catch (TaskNotFoundException e) {
return notFound(MessageFormat.format(TASK_INSTANCE_NOT_FOUND, taskId), v, 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.TaskEventInstanceList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataServiceBase method getTaskEvents.
public TaskEventInstanceList getTaskEvents(long taskId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
if (sort == null || sort.isEmpty()) {
sort = "Id";
}
logger.debug("About to search for task {} events", taskId);
List<TaskEvent> tasks = runtimeDataService.getTaskEvents(taskId, buildQueryFilter(page, pageSize, sort, sortOrder));
logger.debug("Found {} task events available for task '{}'", tasks.size(), taskId);
TaskEventInstanceList result = null;
if (tasks == null) {
result = new TaskEventInstanceList(new TaskEventInstance[0]);
} else {
TaskEventInstance[] instances = new TaskEventInstance[tasks.size()];
int counter = 0;
for (TaskEvent taskSummary : tasks) {
TaskEventInstance task = TaskEventInstance.builder().id(taskSummary.getTaskId()).taskId(taskSummary.getTaskId()).date(taskSummary.getLogTime()).processInstanceId(taskSummary.getProcessInstanceId()).type(taskSummary.getType().toString()).user(taskSummary.getUserId()).workItemId(taskSummary.getWorkItemId()).message(taskSummary.getMessage()).correlationKey(taskSummary.getCorrelationKey()).processType(taskSummary.getProcessType()).assignedOwner(taskSummary.getCurrentOwner()).build();
instances[counter] = task;
counter++;
}
result = new TaskEventInstanceList(instances);
}
return result;
}
use of org.kie.server.api.model.instance.TaskEventInstanceList in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method findTaskEvents.
@Override
public List<TaskEventInstance> findTaskEvents(String containerId, Long taskId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
TaskEventInstanceList taskSummaryList = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
String queryString = getPagingQueryString("?sort=" + sort + "&sortOrder=" + sortOrder, page, pageSize);
taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_EVENTS_GET_URI, valuesMap) + queryString, TaskEventInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTaskEvents", new Object[] { taskId, page, pageSize, sort, sortOrder })));
ServiceResponse<TaskEventInstanceList> response = (ServiceResponse<TaskEventInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
taskSummaryList = response.getResult();
}
if (taskSummaryList != null && taskSummaryList.getTaskEvents() != null) {
return Arrays.asList(taskSummaryList.getTaskEvents());
}
return Collections.emptyList();
}
Aggregations