use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class DefaultCmmnHistoryEventProducer method createCaseActivityInstanceEndEvt.
public HistoryEvent createCaseActivityInstanceEndEvt(DelegateCaseExecution caseExecution) {
final CaseExecutionEntity caseExecutionEntity = (CaseExecutionEntity) caseExecution;
// create event instance
HistoricCaseActivityInstanceEventEntity evt = loadCaseActivityInstanceEventEntity(caseExecutionEntity);
// initialize event
initCaseActivityInstanceEvent(evt, caseExecutionEntity, HistoryEventTypes.CASE_ACTIVITY_INSTANCE_END);
// set end time
evt.setEndTime(ClockUtil.getCurrentTime());
// calculate duration
if (evt.getStartTime() != null) {
evt.setDurationInMillis(evt.getEndTime().getTime() - evt.getStartTime().getTime());
}
return evt;
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class TaskEntity method createAndInsert.
/**
* creates and initializes a new persistent task.
*/
public static TaskEntity createAndInsert(VariableScope execution) {
TaskEntity task = create();
if (execution instanceof ExecutionEntity) {
ExecutionEntity executionEntity = (ExecutionEntity) execution;
task.setExecution(executionEntity);
task.skipCustomListeners = executionEntity.isSkipCustomListeners();
task.insert(executionEntity);
return task;
} else if (execution instanceof CaseExecutionEntity) {
task.setCaseExecution((DelegateCaseExecution) execution);
}
task.insert(null);
return task;
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseExecutionQueryTest method testNullBusinessKeyForChildExecutions.
public void testNullBusinessKeyForChildExecutions() {
caseService.createCaseInstanceByKey(CASE_DEFINITION_KEY, "7890");
List<CaseExecution> executions = caseService.createCaseExecutionQuery().caseInstanceBusinessKey("7890").list();
for (CaseExecution e : executions) {
if (((CaseExecutionEntity) e).isCaseInstanceExecution()) {
assertEquals("7890", ((CaseExecutionEntity) e).getBusinessKeyWithoutCascade());
} else {
assertNull(((CaseExecutionEntity) e).getBusinessKeyWithoutCascade());
}
}
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseTaskTest method testInputDifferentBusinessKey.
/**
* variable passed in manual activation - change process definition
*/
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testInputDifferentBusinessKey.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputDifferentBusinessKey() {
// given
String businessKey = "myBusinessKey";
String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, businessKey).getId();
String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
// when
caseService.withCaseExecution(caseTaskId).setVariable("myOwnBusinessKey", "myOwnBusinessKey").manualStart();
// then
CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId();
CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId);
assertEquals(caseTaskId, superCaseExecutionId);
assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId());
assertEquals("myOwnBusinessKey", subCaseInstance.getBusinessKey());
// complete ////////////////////////////////////////////////////////
terminate(subCaseInstance.getId());
close(subCaseInstance.getId());
assertCaseEnded(subCaseInstance.getId());
terminate(caseTaskId);
close(superCaseInstanceId);
assertCaseEnded(superCaseInstanceId);
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseTaskTest method testInputSourceDifferentTarget.
/**
* default manual activation behaviour changed - remove manual activation statement
*/
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testInputSourceDifferentTarget.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputSourceDifferentTarget() {
// given
VariableMap vars = new VariableMapImpl();
vars.putValue("aVariable", "abc");
vars.putValue("anotherVariable", 999);
String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId();
String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
// then
CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(subCaseInstance.getId()).list();
assertFalse(variables.isEmpty());
assertEquals(2, variables.size());
for (VariableInstance variable : variables) {
String name = variable.getName();
if ("myVariable".equals(name)) {
assertEquals("myVariable", name);
assertEquals("abc", variable.getValue());
} else if ("myAnotherVariable".equals(name)) {
assertEquals("myAnotherVariable", name);
assertEquals(999, variable.getValue());
} else {
fail("Found an unexpected variable: '" + name + "'");
}
}
// complete ////////////////////////////////////////////////////////
terminate(subCaseInstance.getId());
close(subCaseInstance.getId());
assertCaseEnded(subCaseInstance.getId());
terminate(caseTaskId);
close(superCaseInstanceId);
assertCaseEnded(superCaseInstanceId);
}
Aggregations