use of org.kie.server.api.model.admin.TimerInstanceList in project droolsjbpm-integration by kiegroup.
the class ProcessAdminServiceBase method convertTimerInstances.
protected TimerInstanceList convertTimerInstances(Collection<TimerInstance> timerInstances) {
if (timerInstances == null) {
return new TimerInstanceList();
}
org.kie.server.api.model.admin.TimerInstance[] timerInstancesConverted = new org.kie.server.api.model.admin.TimerInstance[timerInstances.size()];
int index = 0;
for (TimerInstance timerInstance : timerInstances) {
org.kie.server.api.model.admin.TimerInstance instance = convertTimerInstance(timerInstance);
timerInstancesConverted[index] = instance;
index++;
}
return new TimerInstanceList(timerInstancesConverted);
}
use of org.kie.server.api.model.admin.TimerInstanceList in project droolsjbpm-integration by kiegroup.
the class ProcessAdminServiceBase method getTimerInstances.
public TimerInstanceList getTimerInstances(String containerId, Number processInstanceId) {
logger.debug("About to get timers for process instance {} in container {}", processInstanceId, containerId);
Collection<TimerInstance> timerInstances = processInstanceAdminService.getTimerInstances(processInstanceId.longValue());
logger.debug("Found timers {} in process instance {}", timerInstances, processInstanceId);
TimerInstanceList timerInstanceList = convertTimerInstances(timerInstances);
return timerInstanceList;
}
use of org.kie.server.api.model.admin.TimerInstanceList in project droolsjbpm-integration by kiegroup.
the class ProcessAdminResource method getTimerInstances.
@ApiOperation(value = "Returns all timers for a specified process instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process instance or Container Id not found"), @ApiResponse(code = 404, message = "Container Id not found"), @ApiResponse(code = 200, response = TimerInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_TIMERS_RESPONSE_JSON) })) })
@GET
@Path(TIMERS_PROCESS_INST_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTimerInstances(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of process instance that timer instances should be collected for", required = true, example = "123") @PathParam(PROCESS_INST_ID) Long processInstanceId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
TimerInstanceList timerInstanceList = processAdminServiceBase.getTimerInstances(containerId, processInstanceId);
return createCorrectVariant(timerInstanceList, headers, Response.Status.OK, conversationIdHeader);
} catch (ProcessInstanceNotFoundException e) {
return notFound(MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId), v, conversationIdHeader);
} catch (DeploymentNotFoundException e) {
return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), 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.admin.TimerInstanceList in project droolsjbpm-integration by kiegroup.
the class ProcessAdminServicesClientImpl method getTimerInstances.
@Override
public List<TimerInstance> getTimerInstances(String containerId, Long processInstanceId) {
TimerInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_INST_ID, processInstanceId);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_PROCESS_URI + "/" + TIMERS_PROCESS_INST_GET_URI, valuesMap), TimerInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("ProcessAdminService", "getTimerInstances", new Object[] { containerId, processInstanceId })));
ServiceResponse<TimerInstanceList> response = (ServiceResponse<TimerInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getItems() != null) {
return result.getItems();
}
return Collections.emptyList();
}
Aggregations