use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory 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.common.RestResponseFactory in project carbon-business-process by wso2.
the class HistoricProcessInstanceService method getProcessIdentityLinks.
@GET
@Path("/{processInstanceId}/identitylinks")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessIdentityLinks(@PathParam("processInstanceId") String processInstanceId) {
HistoryService historyService = BPMNOSGIService.getHistoryService();
List<HistoricIdentityLink> identityLinks = historyService.getHistoricIdentityLinksForProcessInstance(processInstanceId);
if (identityLinks != null) {
List<HistoricIdentityLinkResponse> historicIdentityLinkResponses = new RestResponseFactory().createHistoricIdentityLinkResponseList(identityLinks, uriInfo.getBaseUri().toString());
HistoricIdentityLinkResponseCollection historicIdentityLinkResponseCollection = new HistoricIdentityLinkResponseCollection();
historicIdentityLinkResponseCollection.setHistoricIdentityLinkResponses(historicIdentityLinkResponses);
return Response.ok().entity(historicIdentityLinkResponseCollection).build();
}
return Response.ok().build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class HistoricProcessInstanceService method getComment.
@GET
@Path("/{processInstanceId}/comments/{commentId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getComment(@PathParam("processInstanceId") String processInstanceId, @PathParam("commentId") String commentId) {
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
TaskService taskService = BPMNOSGIService.getTaskService();
Comment comment = taskService.getComment(commentId);
if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) {
throw new ActivitiObjectNotFoundException("Process instance '" + instance.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class);
}
CommentResponse commentResponse = new RestResponseFactory().createRestComment(comment, uriInfo.getBaseUri().toString());
return Response.ok().entity(commentResponse).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class HistoricTaskInstanceService method getTaskIdentityLinks.
@GET
@Path("/{taskId}/identitylinks")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTaskIdentityLinks(@PathParam("taskId") String taskId) {
HistoryService historyService = BPMNOSGIService.getHistoryService();
List<HistoricIdentityLink> identityLinks = historyService.getHistoricIdentityLinksForTask(taskId);
List<HistoricIdentityLinkResponse> historicIdentityLinkResponseList = new ArrayList<>();
if (identityLinks != null) {
historicIdentityLinkResponseList = new RestResponseFactory().createHistoricIdentityLinkResponseList(identityLinks, uriInfo.getBaseUri().toString());
}
HistoricIdentityLinkResponseCollection historicIdentityLinkResponseCollection = new HistoricIdentityLinkResponseCollection();
historicIdentityLinkResponseCollection.setHistoricIdentityLinkResponses(historicIdentityLinkResponseList);
return Response.ok().entity(historicIdentityLinkResponseCollection).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class HistoricVariableInstanceService method getVariableFromRequest.
protected RestVariable getVariableFromRequest(boolean includeBinary, String varInstanceId) {
HistoryService historyService = BPMNOSGIService.getHistoryService();
HistoricVariableInstance varObject = historyService.createHistoricVariableInstanceQuery().id(varInstanceId).singleResult();
if (varObject == null) {
throw new ActivitiObjectNotFoundException("Historic variable instance '" + varInstanceId + "' couldn't be found.", VariableInstanceEntity.class);
} else {
return new RestResponseFactory().createRestVariable(varObject.getVariableName(), varObject.getValue(), null, varInstanceId, RestResponseFactory.VARIABLE_HISTORY_VARINSTANCE, includeBinary, uriInfo.getBaseUri().toString());
}
}
Aggregations