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);
}
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);
}
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");
}
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);
}
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");
}
Aggregations