Search in sources :

Example 31 with RuntimeService

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;
}
Also used : Execution(org.activiti.engine.runtime.Execution) RuntimeService(org.activiti.engine.RuntimeService) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 32 with RuntimeService

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);
}
Also used : ProcessInstanceQuery(org.activiti.engine.runtime.ProcessInstanceQuery) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) RuntimeService(org.activiti.engine.RuntimeService) ProcessInstancePaginateList(org.wso2.carbon.bpmn.rest.model.runtime.ProcessInstancePaginateList)

Example 33 with RuntimeService

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);
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 34 with RuntimeService

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;
}
Also used : BPMNConflictException(org.wso2.carbon.bpmn.rest.common.exception.BPMNConflictException) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) RuntimeService(org.activiti.engine.RuntimeService) ProcessInstanceResponse(org.wso2.carbon.bpmn.rest.model.runtime.ProcessInstanceResponse)

Example 35 with RuntimeService

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;
}
Also used : Execution(org.activiti.engine.runtime.Execution) RuntimeService(org.activiti.engine.RuntimeService) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Aggregations

RuntimeService (org.activiti.engine.RuntimeService)92 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)35 Test (org.junit.Test)25 ProcessEngine (org.activiti.engine.ProcessEngine)16 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)15 TaskService (org.activiti.engine.TaskService)14 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)14 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)13 Deployment (org.activiti.engine.test.Deployment)13 RestVariable (org.wso2.carbon.bpmn.rest.engine.variable.RestVariable)12 RepositoryService (org.activiti.engine.RepositoryService)10 HashMap (java.util.HashMap)8 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)8 Task (org.activiti.engine.task.Task)8 ArrayList (java.util.ArrayList)7 Path (javax.ws.rs.Path)7 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)7 Execution (org.activiti.engine.runtime.Execution)7 Produces (javax.ws.rs.Produces)6 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6