use of org.activiti.engine.RuntimeService in project carbon-business-process by wso2.
the class BaseExecutionService method getExecutionFromRequest.
protected Execution getExecutionFromRequest(String executionId) {
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();
if (execution == null) {
throw new ActivitiObjectNotFoundException("Could not find an execution with id '" + executionId + "'.", Execution.class);
}
return execution;
}
use of org.activiti.engine.RuntimeService 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);
}
use of org.activiti.engine.RuntimeService in project carbon-business-process by wso2.
the class BaseProcessInstanceService method getIdentityLink.
protected IdentityLink getIdentityLink(String identityId, String type, String processInstanceId) {
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
// Perhaps it would be better to offer getting a single identity link from the API
List<IdentityLink> allLinks = runtimeService.getIdentityLinksForProcessInstance(processInstanceId);
for (IdentityLink link : allLinks) {
if (identityId.equals(link.getUserId()) && link.getType().equals(type)) {
return link;
}
}
throw new ActivitiObjectNotFoundException("Could not find the requested identity link.", IdentityLink.class);
}
use of org.activiti.engine.RuntimeService in project carbon-business-process by wso2.
the class BaseProcessInstanceService method activateProcessInstance.
protected ProcessInstanceResponse activateProcessInstance(ProcessInstance processInstance, UriInfo uriInfo) {
if (!processInstance.isSuspended()) {
throw new BPMNConflictException("Process instance with id '" + processInstance.getId() + "' is already active.");
}
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
runtimeService.activateProcessInstanceById(processInstance.getId());
ProcessInstanceResponse response = new RestResponseFactory().createProcessInstanceResponse(processInstance, uriInfo.getBaseUri().toString());
// No need to re-fetch the instance, just alter the suspended state of the result-object
response.setSuspended(false);
return response;
}
use of org.activiti.engine.RuntimeService in project carbon-business-process by wso2.
the class BaseProcessInstanceService method getExecutionInstanceFromRequest.
protected Execution getExecutionInstanceFromRequest(String processInstanceId) {
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
Execution execution = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (execution == null) {
throw new ActivitiObjectNotFoundException("Could not find a process instance with id '" + processInstanceId + "'.", ProcessInstance.class);
}
return execution;
}
Aggregations