use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class ModelService method getModels.
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getModels() {
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
// 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);
}
}
ModelQuery modelQuery = repositoryService.createModelQuery();
String id = uriInfo.getQueryParameters().getFirst("id");
if (id != null) {
modelQuery.modelId(id);
}
String category = uriInfo.getQueryParameters().getFirst("category");
if (category != null) {
modelQuery.modelCategory(category);
}
String categoryLike = uriInfo.getQueryParameters().getFirst("categoryLike");
if (categoryLike != null) {
modelQuery.modelCategoryLike(categoryLike);
}
String categoryNotEquals = uriInfo.getQueryParameters().getFirst("categoryNotEquals");
if (categoryNotEquals != null) {
modelQuery.modelCategoryNotEquals(categoryNotEquals);
}
String name = uriInfo.getQueryParameters().getFirst("name");
if (name != null) {
modelQuery.modelName(name);
}
String nameLike = uriInfo.getQueryParameters().getFirst("nameLike");
if (nameLike != null) {
modelQuery.modelNameLike(nameLike);
}
String key = uriInfo.getQueryParameters().getFirst("key");
if (key != null) {
modelQuery.modelKey(key);
}
String version = uriInfo.getQueryParameters().getFirst("version");
if (version != null) {
modelQuery.modelVersion(Integer.valueOf(version));
}
String latestVersion = uriInfo.getQueryParameters().getFirst("latestVersion");
if (latestVersion != null) {
boolean isLatestVersion = Boolean.valueOf(latestVersion);
if (isLatestVersion) {
modelQuery.latestVersion();
}
}
String deploymentId = uriInfo.getQueryParameters().getFirst("deploymentId");
if (deploymentId != null) {
modelQuery.deploymentId(deploymentId);
}
String deployed = uriInfo.getQueryParameters().getFirst("deployed");
if (deployed != null) {
boolean isDeployed = Boolean.valueOf(deployed);
if (isDeployed) {
modelQuery.deployed();
} else {
modelQuery.notDeployed();
}
}
String tenantId = uriInfo.getQueryParameters().getFirst("tenantId");
if (tenantId != null) {
modelQuery.modelTenantId(tenantId);
}
String tenantIdLike = uriInfo.getQueryParameters().getFirst("tenantIdLike");
if (tenantIdLike != null) {
modelQuery.modelTenantIdLike(tenantIdLike);
}
String sWithoutTenantId = uriInfo.getQueryParameters().getFirst("withoutTenantId");
if (sWithoutTenantId != null) {
boolean withoutTenantId = Boolean.valueOf(sWithoutTenantId);
if (withoutTenantId) {
modelQuery.modelWithoutTenantId();
}
}
DataResponse response = new ModelsPaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, modelQuery, "id", allowedSortProperties);
List<ModelResponse> modelResponseList = (List<ModelResponse>) response.getData();
if (log.isDebugEnabled()) {
log.debug("modelResponseList: " + modelResponseList.size());
}
return Response.ok().entity(response).build();
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class HistoricDetailService method getHistoricDetailInfo.
@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getHistoricDetailInfo() {
Map<String, String> allRequestParams = new HashMap<>();
for (String property : allPropertiesList) {
String value = uriInfo.getQueryParameters().getFirst(property);
if (value != null) {
allRequestParams.put(property, value);
}
}
// Populate query based on request
HistoricDetailQueryRequest queryRequest = new HistoricDetailQueryRequest();
if (allRequestParams.get("id") != null) {
queryRequest.setId(allRequestParams.get("id"));
}
if (allRequestParams.get("processInstanceId") != null) {
queryRequest.setProcessInstanceId(allRequestParams.get("processInstanceId"));
}
if (allRequestParams.get("executionId") != null) {
queryRequest.setExecutionId(allRequestParams.get("executionId"));
}
if (allRequestParams.get("activityInstanceId") != null) {
queryRequest.setActivityInstanceId(allRequestParams.get("activityInstanceId"));
}
if (allRequestParams.get("taskId") != null) {
queryRequest.setTaskId(allRequestParams.get("taskId"));
}
if (allRequestParams.get("selectOnlyFormProperties") != null) {
queryRequest.setSelectOnlyFormProperties(Boolean.valueOf(allRequestParams.get("selectOnlyFormProperties")));
}
if (allRequestParams.get("selectOnlyVariableUpdates") != null) {
queryRequest.setSelectOnlyVariableUpdates(Boolean.valueOf(allRequestParams.get("selectOnlyVariableUpdates")));
}
DataResponse dataResponse = getQueryResponse(queryRequest, allRequestParams, uriInfo);
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 HistoricProcessInstanceService method getQueryResponse.
protected DataResponse getQueryResponse(HistoricProcessInstanceQueryRequest queryRequest, Map<String, String> allRequestParams) {
HistoryService historyService = BPMNOSGIService.getHistoryService();
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<String>(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();
}
RestResponseFactory restResponseFactory = new RestResponseFactory();
DataResponse dataResponse = new HistoricProcessInstancePaginateList(restResponseFactory, uriInfo).paginateList(allRequestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
return dataResponse;
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class IdentityService method getUsers.
/**
* Get all the users that match the filters given by query parameters of the request.
* @return DataResponse
*/
@GET
@Path("/users")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public DataResponse getUsers() {
UserQuery query = identityService.createUserQuery();
Map<String, String> allRequestParams = new HashMap<>();
String id = uriInfo.getQueryParameters().getFirst("id");
if (id != null) {
query.userId(id);
allRequestParams.put("id", id);
}
String firstName = uriInfo.getQueryParameters().getFirst("firstName");
if (firstName != null) {
query.userFirstName(firstName);
allRequestParams.put("firstName", firstName);
}
String lastName = uriInfo.getQueryParameters().getFirst("lastName");
if (lastName != null) {
query.userLastName(lastName);
allRequestParams.put("lastName", lastName);
}
String email = uriInfo.getQueryParameters().getFirst("email");
if (email != null) {
query.userEmail(email);
allRequestParams.put("email", email);
}
String firstNameLike = uriInfo.getQueryParameters().getFirst("firstNameLike");
if (firstNameLike != null) {
query.userFirstNameLike(firstNameLike);
allRequestParams.put("firstNameLike", firstNameLike);
}
String lastNameLike = uriInfo.getQueryParameters().getFirst("lastNameLike");
if (lastNameLike != null) {
query.userLastNameLike(lastNameLike);
allRequestParams.put("lastNameLike", lastNameLike);
}
String emailLike = uriInfo.getQueryParameters().getFirst("emailLike");
if (emailLike != null) {
query.userEmailLike(emailLike);
allRequestParams.put("emailLike", emailLike);
}
String memberOfGroup = uriInfo.getQueryParameters().getFirst("memberOfGroup");
if (memberOfGroup != null) {
query.memberOfGroup(memberOfGroup);
allRequestParams.put("memberOfGroup", memberOfGroup);
}
String potentialStarter = uriInfo.getQueryParameters().getFirst("potentialStarter");
if (potentialStarter != null) {
query.potentialStarter(potentialStarter);
allRequestParams.put("potentialStarter", potentialStarter);
}
allRequestParams = Utils.prepareCommonParameters(allRequestParams, uriInfo);
return new UserPaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, query, "id", userProperties);
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class BaseProcessInstanceService method getQueryResponse.
protected DataResponse getQueryResponse(ProcessInstanceQueryRequest queryRequest, Map<String, String> requestParams, UriInfo uriInfo) {
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
// Populate query based on request
if (queryRequest.getProcessInstanceId() != null) {
query.processInstanceId(queryRequest.getProcessInstanceId());
}
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.getSuspended() != null) {
if (queryRequest.getSuspended()) {
query.suspended();
} else {
query.active();
}
}
if (queryRequest.getSubProcessInstanceId() != null) {
query.subProcessInstanceId(queryRequest.getSubProcessInstanceId());
}
if (queryRequest.getSuperProcessInstanceId() != null) {
query.superProcessInstanceId(queryRequest.getSuperProcessInstanceId());
}
if (queryRequest.getExcludeSubprocesses() != null) {
query.excludeSubprocesses(queryRequest.getExcludeSubprocesses());
}
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();
}
return new ProcessInstancePaginateList(new RestResponseFactory(), uriInfo).paginateList(requestParams, queryRequest, query, "id", allowedSortProperties);
}
Aggregations