use of org.kie.server.api.model.instance.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class ExecutorServiceBase method getRequestsByStatus.
// queries
public RequestInfoInstanceList getRequestsByStatus(List<String> statuses, Integer page, Integer pageSize) {
List<STATUS> statusList = convertStatusList(statuses);
List<RequestInfo> requests = executorService.getRequestsByStatus(statusList, buildQueryContext(page, pageSize));
RequestInfoInstanceList result = convertToRequestInfoList(requests, false, false);
return result;
}
use of org.kie.server.api.model.instance.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class ExecutorResource method getRequestsByContainer.
@ApiOperation(value = "Returns jobs for specified KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = RequestInfoInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_REQUESTS_RESPONSE_JSON) })) })
@GET
@Path(JOB_INSTANCES_BY_CONTAINER_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRequestsByContainer(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "identifier of the container that asynchornous jobs should be found for", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "optional job status (QUEUED, DONE, CANCELLED, ERROR, RETRYING, RUNNING)", required = false, allowableValues = "QUEUED,DONE,CANCELLED,ERROR,RETRYING,RUNNING") @QueryParam("status") List<String> statuses, @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) {
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 {
RequestInfoInstanceList result = executorServiceBase.getRequestsByContainer(containerId, statuses, page, pageSize);
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.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class ExecutorResource method getRequestsByCommand.
@ApiOperation(value = "Returns jobs configured to run job commands, such as a job type org.jbpm.executor.commands.LogCleanupCommand.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = RequestInfoInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_REQUESTS_RESPONSE_JSON) })) })
@GET
@Path(JOB_INSTANCES_BY_CMD_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRequestsByCommand(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "name of the command that asynchornous jobs should be found for", required = true, example = "com.sample.CommandImpl") @PathParam("cmd") String command, @ApiParam(value = "optional job status (QUEUED, DONE, CANCELLED, ERROR, RETRYING, RUNNING)", required = false, allowableValues = "QUEUED,DONE,CANCELLED,ERROR,RETRYING,RUNNING") @QueryParam("status") List<String> statuses, @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) {
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 {
RequestInfoInstanceList result = null;
if (statuses == null || statuses.isEmpty()) {
result = executorServiceBase.getRequestsByCommand(command, page, pageSize);
} else {
result = executorServiceBase.getRequestsByCommand(command, statuses, page, pageSize);
}
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.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class JobServicesClientImpl method getRequestsByProcessInstance.
@Override
public List<RequestInfoInstance> getRequestsByProcessInstance(Long processInstanceId, List<String> statuses, Integer page, Integer pageSize) {
RequestInfoInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(PROCESS_INST_ID, processInstanceId);
String statusQuery = getAdditionalParams("", "status", statuses);
String queryString = getPagingQueryString(statusQuery, page, pageSize);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), JOB_URI + "/" + JOB_INSTANCES_BY_PROCESS_INSTANCE_GET_URI, valuesMap) + queryString, RequestInfoInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("JobService", "getRequestsByProcessInstance", new Object[] { processInstanceId, safeList(statuses), page, pageSize })));
ServiceResponse<RequestInfoInstanceList> response = (ServiceResponse<RequestInfoInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null && list.getRequestInfoInstances() != null) {
return Arrays.asList(list.getRequestInfoInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.RequestInfoInstanceList in project droolsjbpm-integration by kiegroup.
the class JobServicesClientImpl method getRequestsByBusinessKey.
@Override
public List<RequestInfoInstance> getRequestsByBusinessKey(String businessKey, List<String> statuses, Integer page, Integer pageSize) {
RequestInfoInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(JOB_KEY, businessKey);
String statusQuery = getAdditionalParams("", "status", statuses);
String queryString = getPagingQueryString(statusQuery, page, pageSize);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), JOB_URI + "/" + JOB_INSTANCES_BY_KEY_GET_URI, valuesMap) + queryString, RequestInfoInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("JobService", "getRequestsByBusinessKey", new Object[] { businessKey, safeList(statuses), page, pageSize })));
ServiceResponse<RequestInfoInstanceList> response = (ServiceResponse<RequestInfoInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null && list.getRequestInfoInstances() != null) {
return Arrays.asList(list.getRequestInfoInstances());
}
return Collections.emptyList();
}
Aggregations