use of org.camunda.bpm.engine.runtime.CaseExecutionQuery in project camunda-bpm-platform by camunda.
the class CaseExecutionRestServiceImpl method queryCaseExecutionsCount.
public CountResultDto queryCaseExecutionsCount(CaseExecutionQueryDto queryDto) {
ProcessEngine engine = getProcessEngine();
queryDto.setObjectMapper(getObjectMapper());
CaseExecutionQuery query = queryDto.toQuery(engine);
long count = query.count();
CountResultDto result = new CountResultDto();
result.setCount(count);
return result;
}
use of org.camunda.bpm.engine.runtime.CaseExecutionQuery in project camunda-bpm-platform by camunda.
the class CaseExecutionRestServiceImpl method queryCaseExecutions.
public List<CaseExecutionDto> queryCaseExecutions(CaseExecutionQueryDto queryDto, Integer firstResult, Integer maxResults) {
ProcessEngine engine = getProcessEngine();
queryDto.setObjectMapper(getObjectMapper());
CaseExecutionQuery query = queryDto.toQuery(engine);
List<CaseExecution> matchingExecutions;
if (firstResult != null || maxResults != null) {
matchingExecutions = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingExecutions = query.list();
}
List<CaseExecutionDto> executionResults = new ArrayList<CaseExecutionDto>();
for (CaseExecution execution : matchingExecutions) {
CaseExecutionDto resultExecution = CaseExecutionDto.fromCaseExecution(execution);
executionResults.add(resultExecution);
}
return executionResults;
}
use of org.camunda.bpm.engine.runtime.CaseExecutionQuery in project camunda-bpm-platform by camunda.
the class CaseServiceHumanTaskTest method testManualStartWithLocalVariable.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testManualStartWithLocalVariable() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
// an enabled child case execution of
// the case instance
String caseExecutionId = caseExecutionQuery.activityId("PI_HumanTask_1").singleResult().getId();
// when
// activate child case execution
caseService.withCaseExecution(caseExecutionId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).manualStart();
// then
// the child case execution is active...
CaseExecution caseExecution = caseExecutionQuery.singleResult();
assertTrue(caseExecution.isActive());
// ... and not enabled
assertFalse(caseExecution.isEnabled());
// there exists a task
Task task = taskService.createTaskQuery().caseExecutionId(caseExecutionId).singleResult();
assertNotNull(task);
// the case instance has two variables:
// - aVariableName
// - anotherVariableName
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
for (VariableInstance variable : result) {
assertEquals(caseExecutionId, variable.getCaseExecutionId());
assertEquals(caseInstanceId, variable.getCaseInstanceId());
if (variable.getName().equals("aVariableName")) {
assertEquals("aVariableName", variable.getName());
assertEquals("abc", variable.getValue());
} else if (variable.getName().equals("anotherVariableName")) {
assertEquals("anotherVariableName", variable.getName());
assertEquals(999, variable.getValue());
} else {
fail("Unexpected variable: " + variable.getName());
}
}
}
use of org.camunda.bpm.engine.runtime.CaseExecutionQuery in project camunda-bpm-platform by camunda.
the class CaseServiceHumanTaskTest method testReenableNonFluent.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testReenableNonFluent() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
caseService.withCaseDefinition(caseDefinitionId).create();
CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
String caseExecutionId = caseExecutionQuery.activityId("PI_HumanTask_1").singleResult().getId();
// the human task is disabled
caseService.withCaseExecution(caseExecutionId).disable();
// when
caseService.reenableCaseExecution(caseExecutionId);
// then
CaseExecution caseExecution = caseExecutionQuery.singleResult();
// the human task is disabled
assertFalse(caseExecution.isDisabled());
assertFalse(caseExecution.isActive());
assertTrue(caseExecution.isEnabled());
}
use of org.camunda.bpm.engine.runtime.CaseExecutionQuery in project camunda-bpm-platform by camunda.
the class CaseServiceHumanTaskTest method testManualStartWithVariables.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testManualStartWithVariables() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
// an enabled child case execution of
// the case instance
String caseExecutionId = caseExecutionQuery.activityId("PI_HumanTask_1").singleResult().getId();
// variables
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("aVariableName", "abc");
variables.put("anotherVariableName", 999);
// when
// activate child case execution
caseService.withCaseExecution(caseExecutionId).setVariables(variables).manualStart();
// then
// the child case execution is active...
CaseExecution caseExecution = caseExecutionQuery.singleResult();
assertTrue(caseExecution.isActive());
// ... and not enabled
assertFalse(caseExecution.isEnabled());
// there exists a task
Task task = taskService.createTaskQuery().caseExecutionId(caseExecutionId).singleResult();
assertNotNull(task);
// the case instance has two variables:
// - aVariableName
// - anotherVariableName
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
for (VariableInstance variable : result) {
assertEquals(caseInstanceId, variable.getCaseExecutionId());
assertEquals(caseInstanceId, variable.getCaseInstanceId());
if (variable.getName().equals("aVariableName")) {
assertEquals("aVariableName", variable.getName());
assertEquals("abc", variable.getValue());
} else if (variable.getName().equals("anotherVariableName")) {
assertEquals("anotherVariableName", variable.getName());
assertEquals(999, variable.getValue());
} else {
fail("Unexpected variable: " + variable.getName());
}
}
}
Aggregations