use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class HistoricProcessInstanceQueryService method queryProcessInstances.
@POST
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response queryProcessInstances(HistoricProcessInstanceQueryRequest queryRequest) {
Map<String, String> allRequestParams = new HashMap<>();
for (String property : allPropertiesList) {
String value = uriInfo.getQueryParameters().getFirst(property);
if (value != null) {
allRequestParams.put(property, value);
}
}
HistoryService historyService = BPMNOSGIService.getHistoryService();
org.activiti.engine.history.HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
// Populate query based on request
if (queryRequest.getProcessInstanceId() != null) {
query.processInstanceId(queryRequest.getProcessInstanceId());
}
if (queryRequest.getProcessInstanceIds() != null && !queryRequest.getProcessInstanceIds().isEmpty()) {
query.processInstanceIds(new HashSet<>(queryRequest.getProcessInstanceIds()));
}
if (queryRequest.getProcessDefinitionKey() != null) {
query.processDefinitionKey(queryRequest.getProcessDefinitionKey());
}
if (queryRequest.getProcessDefinitionId() != null) {
query.processDefinitionId(queryRequest.getProcessDefinitionId());
}
if (queryRequest.getProcessBusinessKey() != null) {
query.processInstanceBusinessKey(queryRequest.getProcessBusinessKey());
}
if (queryRequest.getInvolvedUser() != null) {
query.involvedUser(queryRequest.getInvolvedUser());
}
if (queryRequest.getSuperProcessInstanceId() != null) {
query.superProcessInstanceId(queryRequest.getSuperProcessInstanceId());
}
if (queryRequest.getExcludeSubprocesses() != null) {
query.excludeSubprocesses(queryRequest.getExcludeSubprocesses());
}
if (queryRequest.getFinishedAfter() != null) {
query.finishedAfter(queryRequest.getFinishedAfter());
}
if (queryRequest.getFinishedBefore() != null) {
query.finishedBefore(queryRequest.getFinishedBefore());
}
if (queryRequest.getStartedAfter() != null) {
query.startedAfter(queryRequest.getStartedAfter());
}
if (queryRequest.getStartedBefore() != null) {
query.startedBefore(queryRequest.getStartedBefore());
}
if (queryRequest.getStartedBy() != null) {
query.startedBy(queryRequest.getStartedBy());
}
if (queryRequest.getFinished() != null) {
if (queryRequest.getFinished()) {
query.finished();
} else {
query.unfinished();
}
}
if (queryRequest.getIncludeProcessVariables() != null) {
if (queryRequest.getIncludeProcessVariables()) {
query.includeProcessVariables();
}
}
if (queryRequest.getVariables() != null) {
addVariables(query, queryRequest.getVariables());
}
if (queryRequest.getTenantId() != null) {
query.processInstanceTenantId(queryRequest.getTenantId());
}
if (queryRequest.getTenantIdLike() != null) {
query.processInstanceTenantIdLike(queryRequest.getTenantIdLike());
}
if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
query.processInstanceWithoutTenantId();
}
DataResponse dataResponse = new HistoricProcessInstancePaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
return Response.ok().entity(dataResponse).build();
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class HistoricVariableInstanceQueryService method queryVariableInstances.
@POST
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response queryVariableInstances(HistoricVariableInstanceQueryRequest queryRequest) {
Map<String, String> allRequestParams = new HashMap<>();
for (String property : allPropertiesList) {
String value = uriInfo.getQueryParameters().getFirst(property);
if (value != null) {
allRequestParams.put(property, value);
}
}
DataResponse dataResponse = getQueryResponse(queryRequest, allRequestParams);
return Response.ok().entity(dataResponse).build();
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class DeploymentService method getDeployments.
@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getDeployments() {
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery();
// Apply filters
Map<String, String> allRequestParams = new HashMap<>();
for (String property : allPropertiesList) {
String value = uriInfo.getQueryParameters().getFirst(property);
if (value != null) {
allRequestParams.put(property, value);
}
}
String name = uriInfo.getQueryParameters().getFirst("name");
if (name != null) {
deploymentQuery.deploymentName(name);
}
String nameLike = uriInfo.getQueryParameters().getFirst("nameLike");
if (nameLike != null) {
deploymentQuery.deploymentNameLike(nameLike);
}
String category = uriInfo.getQueryParameters().getFirst("category");
if (category != null) {
deploymentQuery.deploymentCategory(category);
}
String categoryNotEquals = uriInfo.getQueryParameters().getFirst("categoryNotEquals");
if (categoryNotEquals != null) {
deploymentQuery.deploymentCategoryNotEquals(categoryNotEquals);
}
String tenantId = uriInfo.getQueryParameters().getFirst("tenantId");
if (tenantId != null) {
deploymentQuery.deploymentTenantId(tenantId);
}
String tenantIdLike = uriInfo.getQueryParameters().getFirst("tenantIdLike");
if (tenantIdLike != null) {
deploymentQuery.deploymentTenantIdLike(tenantIdLike);
}
String sWithoutTenantId = uriInfo.getQueryParameters().getFirst("withoutTenantId");
if (sWithoutTenantId != null) {
Boolean withoutTenantId = Boolean.valueOf(sWithoutTenantId);
if (withoutTenantId) {
deploymentQuery.deploymentWithoutTenantId();
}
}
DeploymentsPaginateList deploymentsPaginateList = new DeploymentsPaginateList(new RestResponseFactory(), uriInfo);
DataResponse dataResponse = deploymentsPaginateList.paginateList(allRequestParams, deploymentQuery, "id", allowedSortProperties);
return Response.ok().entity(dataResponse).build();
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class ManagementService method getTableData.
@GET
@Path("/tables/{tableName}/data")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public DataResponse getTableData(@PathParam("tableName") String tableName) {
Map<String, String> allRequestParams = new HashMap<>();
// Check if table exists before continuing
if (managementService.getTableMetaData(tableName) == null) {
throw new ActivitiObjectNotFoundException("Could not find a table with name '" + tableName + "'.", String.class);
}
String orderAsc = uriInfo.getQueryParameters().getFirst("orderAscendingColumn");
String orderDesc = uriInfo.getQueryParameters().getFirst("orderDescendingColumn");
if (orderAsc != null && orderDesc != null) {
throw new ActivitiIllegalArgumentException("Only one of 'orderAscendingColumn' or 'orderDescendingColumn' can be supplied.");
}
allRequestParams = Utils.prepareCommonParameters(allRequestParams, uriInfo);
Integer start = null;
if (allRequestParams.containsKey("start")) {
start = Integer.valueOf(allRequestParams.get("start"));
}
if (start == null) {
start = 0;
}
Integer size = null;
if (allRequestParams.containsKey("size")) {
size = Integer.valueOf(allRequestParams.get("size"));
}
if (size == null) {
size = DEFAULT_RESULT_SIZE;
}
DataResponse response = new DataResponse();
TablePageQuery tablePageQuery = managementService.createTablePageQuery().tableName(tableName);
if (orderAsc != null) {
allRequestParams.put("orderAscendingColumn", orderAsc);
tablePageQuery.orderAsc(orderAsc);
response.setOrder("asc");
response.setSort(orderAsc);
}
if (orderDesc != null) {
allRequestParams.put("orderDescendingColumn", orderDesc);
tablePageQuery.orderDesc(orderDesc);
response.setOrder("desc");
response.setSort(orderDesc);
}
TablePage listPage = tablePageQuery.listPage(start, size);
response.setSize(((Long) listPage.getSize()).intValue());
response.setStart(((Long) listPage.getFirstResult()).intValue());
response.setTotal(listPage.getTotal());
response.setData((List) listPage.getRows());
return response;
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class HistoricDetailQueryService method queryHistoricDetail.
@POST
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response queryHistoricDetail(HistoricDetailQueryRequest queryRequest) {
Map<String, String> allRequestParams = new HashMap<>();
for (String property : allPropertiesList) {
String value = uriInfo.getQueryParameters().getFirst(property);
if (value != null) {
allRequestParams.put(property, value);
}
}
DataResponse dataResponse = getQueryResponse(queryRequest, allRequestParams, uriInfo);
return Response.ok().entity(dataResponse).build();
}
Aggregations