Search in sources :

Example 21 with CaseExecutionEntity

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;
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) HistoricCaseActivityInstanceEventEntity(org.camunda.bpm.engine.impl.history.event.HistoricCaseActivityInstanceEventEntity)

Example 22 with CaseExecutionEntity

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;
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) DelegateCaseExecution(org.camunda.bpm.engine.delegate.DelegateCaseExecution)

Example 23 with CaseExecutionEntity

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());
        }
    }
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution)

Example 24 with CaseExecutionEntity

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);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 25 with CaseExecutionEntity

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);
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) VariableMap(org.camunda.bpm.engine.variable.VariableMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)57 Deployment (org.camunda.bpm.engine.test.Deployment)36 VariableMap (org.camunda.bpm.engine.variable.VariableMap)13 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)11 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)11 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)7 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)5 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 Task (org.camunda.bpm.engine.task.Task)5 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)4 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)3 HistoricCaseActivityInstanceEventEntity (org.camunda.bpm.engine.impl.history.event.HistoricCaseActivityInstanceEventEntity)3 HistoricCaseInstanceEventEntity (org.camunda.bpm.engine.impl.history.event.HistoricCaseInstanceEventEntity)3 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 DelegateCaseExecution (org.camunda.bpm.engine.delegate.DelegateCaseExecution)1 CmmnExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)1 MigratingCalledCaseInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingCalledCaseInstance)1 ExternalTaskEntity (org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity)1 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)1