Search in sources :

Example 16 with ExecutionQuery

use of org.activiti.engine.runtime.ExecutionQuery in project carbon-business-process by wso2.

the class BaseRuntimeService method getQueryResponse.

protected DataResponse getQueryResponse(ExecutionQueryRequest queryRequest, Map<String, String> requestParams, String serverRootUrl) {
    ExecutionQuery query = runtimeService.createExecutionQuery();
    // Populate query based on request
    if (queryRequest.getId() != null) {
        query.executionId(queryRequest.getId());
        requestParams.put("id", queryRequest.getId());
    }
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
        requestParams.put("processInstanceId", queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessDefinitionKey() != null) {
        query.processDefinitionKey(queryRequest.getProcessDefinitionKey());
        requestParams.put("processDefinitionKey", queryRequest.getProcessDefinitionKey());
    }
    if (queryRequest.getProcessDefinitionId() != null) {
        query.processDefinitionId(queryRequest.getProcessDefinitionId());
        requestParams.put("processDefinitionId", queryRequest.getProcessDefinitionId());
    }
    if (queryRequest.getProcessBusinessKey() != null) {
        query.processInstanceBusinessKey(queryRequest.getProcessBusinessKey());
        requestParams.put("processInstanceBusinessKey", queryRequest.getProcessBusinessKey());
    }
    if (queryRequest.getActivityId() != null) {
        query.activityId(queryRequest.getActivityId());
        requestParams.put("activityId", queryRequest.getActivityId());
    }
    if (queryRequest.getParentId() != null) {
        query.parentId(queryRequest.getParentId());
        requestParams.put("parentId", queryRequest.getParentId());
    }
    if (queryRequest.getMessageEventSubscriptionName() != null) {
        query.messageEventSubscriptionName(queryRequest.getMessageEventSubscriptionName());
        requestParams.put("messageEventSubscriptionName", queryRequest.getMessageEventSubscriptionName());
    }
    if (queryRequest.getSignalEventSubscriptionName() != null) {
        query.signalEventSubscriptionName(queryRequest.getSignalEventSubscriptionName());
        requestParams.put("signalEventSubscriptionName", queryRequest.getSignalEventSubscriptionName());
    }
    if (queryRequest.getVariables() != null) {
        addVariables(query, queryRequest.getVariables(), false);
    }
    if (queryRequest.getProcessInstanceVariables() != null) {
        addVariables(query, queryRequest.getProcessInstanceVariables(), true);
    }
    if (queryRequest.getTenantId() != null) {
        query.executionTenantId(queryRequest.getTenantId());
        requestParams.put("tenantId", queryRequest.getTenantId());
    }
    if (queryRequest.getTenantIdLike() != null) {
        query.executionTenantIdLike(queryRequest.getTenantIdLike());
        requestParams.put("tenantIdLike", queryRequest.getTenantIdLike());
    }
    if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
        query.executionWithoutTenantId();
        requestParams.put("withoutTenantId", queryRequest.getWithoutTenantId().toString());
    }
    return new ExecutionPaginateList(new RestResponseFactory(), uriInfo).paginateList(requestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) ExecutionPaginateList(org.wso2.carbon.bpmn.rest.model.runtime.ExecutionPaginateList) ExecutionQuery(org.activiti.engine.runtime.ExecutionQuery)

Example 17 with ExecutionQuery

use of org.activiti.engine.runtime.ExecutionQuery in project Activiti by Activiti.

the class ExecutionQueryTest method testQueryByInvalidProcessDefinitionCategory.

public void testQueryByInvalidProcessDefinitionCategory() {
    ExecutionQuery query = runtimeService.createExecutionQuery().processDefinitionCategory("invalid");
    assertThat(query.singleResult()).isNull();
    assertThat(query.list()).hasSize(0);
    assertThat(query.count()).isEqualTo(0);
}
Also used : ExecutionQuery(org.activiti.engine.runtime.ExecutionQuery)

Example 18 with ExecutionQuery

use of org.activiti.engine.runtime.ExecutionQuery in project Activiti by Activiti.

the class ExecutionQueryTest method testQueryByActivityIdAndBusinessKeyWithChildren.

/**
 * Validate fix for ACT-1896
 */
public void testQueryByActivityIdAndBusinessKeyWithChildren() {
    ExecutionQuery query = runtimeService.createExecutionQuery().activityId("receivePayment").processInstanceBusinessKey("BUSINESS-KEY-1", true);
    assertThat(query.list()).hasSize(1);
    assertThat(query.count()).isEqualTo(1);
    Execution execution = query.singleResult();
    assertThat(execution).isNotNull();
    assertThat(execution.getActivityId()).isEqualTo("receivePayment");
}
Also used : Execution(org.activiti.engine.runtime.Execution) ExecutionQuery(org.activiti.engine.runtime.ExecutionQuery)

Example 19 with ExecutionQuery

use of org.activiti.engine.runtime.ExecutionQuery in project Activiti by Activiti.

the class ExecutionQueryTest method testQueryByProcessInstanceId.

public void testQueryByProcessInstanceId() {
    for (String processInstanceId : concurrentProcessInstanceIds) {
        ExecutionQuery query = runtimeService.createExecutionQuery().processInstanceId(processInstanceId);
        assertThat(query.list()).hasSize(3);
        assertThat(query.count()).isEqualTo(3);
    }
    assertThat(runtimeService.createExecutionQuery().processInstanceId(sequentialProcessInstanceIds.get(0)).list()).hasSize(2);
}
Also used : ExecutionQuery(org.activiti.engine.runtime.ExecutionQuery)

Example 20 with ExecutionQuery

use of org.activiti.engine.runtime.ExecutionQuery in project Activiti by Activiti.

the class ExecutionQueryTest method testQueryAllVariableTypes.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryAllVariableTypes() throws Exception {
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("nullVar", null);
    vars.put("stringVar", "string");
    vars.put("longVar", 10L);
    vars.put("doubleVar", 1.2);
    vars.put("integerVar", 1234);
    vars.put("booleanVar", true);
    vars.put("shortVar", (short) 123);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    ExecutionQuery query = runtimeService.createExecutionQuery().variableValueEquals("nullVar", null).variableValueEquals("stringVar", "string").variableValueEquals("longVar", 10L).variableValueEquals("doubleVar", 1.2).variableValueEquals("integerVar", 1234).variableValueEquals("booleanVar", true).variableValueEquals("shortVar", (short) 123);
    List<Execution> executions = query.list();
    assertThat(executions).isNotNull();
    assertThat(executions).hasSize(1);
    assertThat(executions.get(0).getId()).isEqualTo(processInstance.getId());
    runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
Also used : Execution(org.activiti.engine.runtime.Execution) HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ExecutionQuery(org.activiti.engine.runtime.ExecutionQuery) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ExecutionQuery (org.activiti.engine.runtime.ExecutionQuery)26 Execution (org.activiti.engine.runtime.Execution)14 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)9 Deployment (org.activiti.engine.test.Deployment)9 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)7 Date (java.util.Date)2 RuntimeService (org.activiti.engine.RuntimeService)2 DelegateExecution (org.activiti.engine.delegate.DelegateExecution)2 Test (org.junit.Test)2 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 Response (javax.ws.rs.core.Response)1 ActivitiException (org.activiti.engine.ActivitiException)1 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 AbstractQuery (org.activiti.engine.impl.AbstractQuery)1 QueryProperty (org.activiti.engine.query.QueryProperty)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1