Search in sources :

Example 1 with CaseExecutionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.

the class DefaultHistoryEventProducer method initActivityInstanceEvent.

protected void initActivityInstanceEvent(HistoricActivityInstanceEventEntity evt, ExecutionEntity execution, PvmScope eventSource, String activityInstanceId, String parentActivityInstanceId, HistoryEventType eventType) {
    evt.setId(activityInstanceId);
    evt.setEventType(eventType.getEventName());
    evt.setActivityInstanceId(activityInstanceId);
    evt.setParentActivityInstanceId(parentActivityInstanceId);
    evt.setProcessDefinitionId(execution.getProcessDefinitionId());
    evt.setProcessInstanceId(execution.getProcessInstanceId());
    evt.setExecutionId(execution.getId());
    evt.setTenantId(execution.getTenantId());
    ProcessDefinitionEntity definition = execution.getProcessDefinition();
    if (definition != null) {
        evt.setProcessDefinitionKey(definition.getKey());
    }
    evt.setActivityId(eventSource.getId());
    evt.setActivityName((String) eventSource.getProperty("name"));
    evt.setActivityType((String) eventSource.getProperty("type"));
    // update sub process reference
    ExecutionEntity subProcessInstance = execution.getSubProcessInstance();
    if (subProcessInstance != null) {
        evt.setCalledProcessInstanceId(subProcessInstance.getId());
    }
    // update sub case reference
    CaseExecutionEntity subCaseInstance = execution.getSubCaseInstance();
    if (subCaseInstance != null) {
        evt.setCalledCaseInstanceId(subCaseInstance.getId());
    }
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 2 with CaseExecutionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.

the class ExecutionEntity method createSubCaseInstance.

@Override
public CaseExecutionEntity createSubCaseInstance(CmmnCaseDefinition caseDefinition, String businessKey) {
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) caseDefinition.createCaseInstance(businessKey);
    // inherit the tenant-id from the case definition
    String tenantId = ((CaseDefinitionEntity) caseDefinition).getTenantId();
    if (tenantId != null) {
        subCaseInstance.setTenantId(tenantId);
    } else {
        // if case definition has no tenant id, inherit this process instance's tenant id
        subCaseInstance.setTenantId(this.tenantId);
    }
    // manage bidirectional super-process-sub-case-instances relation
    subCaseInstance.setSuperExecution(this);
    setSubCaseInstance(subCaseInstance);
    fireHistoricActivityInstanceUpdate();
    return subCaseInstance;
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)

Example 3 with CaseExecutionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.

the class CaseCallActivityTest method testCallCaseAsExpressionStartsWithDollar.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseAsExpressionStartsWithDollar.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallCaseAsExpressionStartsWithDollar() {
    // given
    // a deployed process definition and case definition
    // when
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, Variables.createVariables().putValue(ONE_TASK_CASE, ONE_TASK_CASE)).getId();
    // then
    String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());
    // complete
    String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
    complete(humanTaskId);
    close(subCaseInstance.getId());
    assertProcessEnded(superProcessInstanceId);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with CaseExecutionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.

the class CaseCallActivityTest method testCallCaseWithCompositeExpression.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseWithCompositeExpression.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallCaseWithCompositeExpression() {
    // given
    // a deployed process definition and case definition
    // when
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
    // then
    String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());
    // complete
    String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
    complete(humanTaskId);
    close(subCaseInstance.getId());
    assertProcessEnded(superProcessInstanceId);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with CaseExecutionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.

the class CaseCallActivityTest method testInputSourceExpression.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputSourceExpression.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputSourceExpression() {
    // given
    VariableMap parameters = Variables.createVariables().putValue("aVariable", "abc").putValue("anotherVariable", 999);
    // when
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, parameters).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 ("aVariable".equals(name)) {
            assertEquals("aVariable", name);
            assertEquals("abc", variable.getValue());
        } else if ("anotherVariable".equals(name)) {
            assertEquals("anotherVariable", name);
            assertEquals((long) 1000, variable.getValue());
        } else {
            fail("Found an unexpected variable: '" + name + "'");
        }
    }
    // complete ////////////////////////////////////////////////////////
    String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
    complete(humanTaskId);
    close(subCaseInstance.getId());
    assertProcessEnded(superProcessInstanceId);
}
Also used : 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