use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method getCaseInstances.
@Override
public List<CaseInstance> getCaseInstances(List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
CaseInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
String queryString = getPagingQueryString("", page, pageSize);
queryString = getAdditionalParams(queryString, "status", status);
queryString = getSortingQueryString(queryString, sort, sortOrder);
queryString = getAdditionalParams(queryString, "withData", Collections.singletonList(withData));
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_QUERY_URI + "/" + CASE_ALL_INSTANCES_GET_URI, valuesMap) + queryString, CaseInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseInstancesAnyRole", new Object[] { safeList(status), page, pageSize, sort, sortOrder, withData })));
ServiceResponse<CaseInstanceList> response = (ServiceResponse<CaseInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null) {
return list.getItems();
}
return Collections.emptyList();
}
use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.
the class CaseAdminServicesClientImpl method getCaseInstances.
@Override
public List<CaseInstance> getCaseInstances(List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
CaseInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
String queryString = getPagingQueryString("", page, pageSize);
queryString = getAdditionalParams(queryString, "status", status);
queryString = getSortingQueryString(queryString, sort, sortOrder);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_CASE_URI + "/" + ADMIN_CASE_ALL_INSTANCES_GET_URI, valuesMap) + queryString, CaseInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseInstances", new Object[] { safeList(status), page, pageSize, sort, sortOrder })));
ServiceResponse<CaseInstanceList> response = (ServiceResponse<CaseInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null) {
return list.getItems();
}
return Collections.emptyList();
}
use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.
the class PrometheusKieServerExtension method init.
@Override
public void init(KieServerImpl kieServer, KieServerRegistry registry) {
this.context = registry;
customMetrics = new PrometheusCustomMetricsSupport(this);
registerDefaultDescriptor();
// Prometheus Monitoring
KieServerExtension jBPMExtension = context.getServerExtension(JbpmKieServerExtension.EXTENSION_NAME);
if (jBPMExtension != null) {
final KModuleDeploymentService deploymentService = jBPMExtension.getAppComponents(KModuleDeploymentService.class);
if (deploymentService != null) {
List<DeploymentEventListener> metrics = customMetrics.getDeploymentEventListener();
if (!metrics.isEmpty()) {
List<DeploymentEventListener> listeners = new ArrayList<>(metrics);
listeners.forEach(l -> deploymentService.addListener(l));
}
deploymentService.addListener(new PrometheusDeploymentEventListener());
}
final ExecutorServiceImpl executorService = jBPMExtension.getAppComponents(ExecutorServiceImpl.class);
if (executorService != null) {
List<AsynchronousJobListener> metrics = customMetrics.getAsynchronousJobListener();
if (!metrics.isEmpty()) {
List<AsynchronousJobListener> listeners = new ArrayList<>(metrics);
listeners.forEach(l -> executorService.addAsyncJobListener(l));
}
executorService.addAsyncJobListener(new PrometheusJobListener());
}
final QueryServiceImpl queryService = jBPMExtension.getAppComponents(QueryServiceImpl.class);
if (queryService != null) {
final DataSetDefRegistry dataSetDefRegistry = queryService.getDataSetDefRegistry();
final PrometheusDataSetListener listener = new PrometheusDataSetListener(dataSetDefRegistry);
listener.init();
dataSetDefRegistry.addListener(listener);
}
final RuntimeDataService dataService = jBPMExtension.getAppComponents(RuntimeDataService.class);
if (dataService != null) {
final Collection<ProcessInstanceDesc> processInstances = dataService.getProcessInstances(asList(ProcessInstance.STATE_ACTIVE), null, new QueryContext(0, Integer.MAX_VALUE));
processInstances.forEach(pi -> recordRunningProcessInstance(pi.getDeploymentId(), pi.getProcessId()));
}
}
KieServerExtension caseExtension = context.getServerExtension(CaseKieServerExtension.EXTENSION_NAME);
if (caseExtension != null) {
final CaseManagementRuntimeDataServiceBase caseRuntime = caseExtension.getAppComponents(CaseManagementRuntimeDataServiceBase.class);
if (caseRuntime != null) {
final CaseInstanceList caseInstances = caseRuntime.getCaseInstances(asList(CaseStatus.OPEN.getName()), 0, Integer.MAX_VALUE, null, false);
for (CaseInstance instance : caseInstances.getCaseInstances()) {
recordRunningCaseInstance(instance.getCaseDefinitionId());
}
}
}
initialized = true;
if (!customMetrics.hasCustomMetrics()) {
LOGGER.info("{} started", toString());
} else {
LOGGER.info("{} started with custom Prometheus metrics provider(s): {}", toString(), customMetrics.customMetricsProviders());
}
}
use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.
the class CaseQueryResource method getCaseInstancesByRole.
@ApiOperation(value = "Returns cases instances that involve the querying user in a specified role.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = CaseInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_INSTANCES_JSON) })) })
@GET
@Path(CASE_INSTANCES_BY_ROLE_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstancesByRole(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "case role that instances should be found for", required = true, example = "owner") @PathParam(CASE_ROLE_NAME) String roleName, @ApiParam(value = "optional case instance status (open, closed, canceled) - defaults ot open (1) only", required = false, allowableValues = "open,closed,cancelled") @QueryParam("status") List<String> status, @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 flag to load data when loading case instance", required = false) @QueryParam("withData") @DefaultValue("false") boolean withData) {
return invokeCaseOperation(headers, "", null, (Variant v, String type, Header... customHeaders) -> {
logger.debug("About to look for case instances with status {}", status);
CaseInstanceList responseObject = this.caseManagementRuntimeDataServiceBase.getCaseInstancesByRole(roleName, status, page, pageSize, sort, sortOrder, withData);
logger.debug("Returning OK response with content '{}'", responseObject);
return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
});
}
use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.
the class CaseAdminResource method getCaseInstances.
@ApiOperation(value = "Returns case instances without authentication checks.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = CaseInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_INSTANCES_JSON) })) })
@GET
@Path(ADMIN_CASE_ALL_INSTANCES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstances(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "optional case instance status (open, closed, canceled) - defaults ot open (1) only", required = false, allowableValues = "open,closed,cancelled") @QueryParam("status") List<String> status, @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 flag to load data when loading case instance", required = false) @QueryParam("withData") @DefaultValue("false") boolean withData) {
return invokeCaseOperation(headers, "", null, (Variant v, String type, Header... customHeaders) -> {
CaseInstanceList responseObject = null;
logger.debug("About to look for case instances with status {}", status);
responseObject = this.caseManagementRuntimeDataServiceBase.getCaseInstances(status, page, pageSize, sort, sortOrder, withData);
logger.debug("Returning OK response with content '{}'", responseObject);
return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
});
}
Aggregations