Search in sources :

Example 11 with CaseExecutionEntity

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

the class CaseCallActivityTest method testSubProcessLocalOutputAllVariables.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivity.testSubProcessLocalOutputAllVariables.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testSubProcessLocalOutputAllVariables() {
    ProcessInstance processInstance = startProcessInstanceByKey("subProcessLocalOutputAllVariables");
    Task beforeCallActivityTask = taskService.createTaskQuery().singleResult();
    // when setting a variable in a process instance
    runtimeService.setVariable(processInstance.getId(), "callingProcessVar1", "val1");
    // and executing the call activity
    taskService.complete(beforeCallActivityTask.getId());
    // then all variables have been mapped into the called instance
    CaseExecutionEntity calledInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(calledInstance);
    Map<String, Object> calledInstanceVariables = caseService.getVariables(calledInstance.getId());
    assertEquals(2, calledInstanceVariables.size());
    assertEquals("val1", calledInstanceVariables.get("callingProcessVar1"));
    assertEquals("val2", calledInstanceVariables.get("inputParameter"));
    // when setting a variable in the called instance
    caseService.setVariable(calledInstance.getId(), "calledCaseVar1", 42L);
    // and completing it
    String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
    manualStart(humanTaskId);
    complete(humanTaskId);
    // then only the output mapping variable has been mapped into the calling process instance
    Map<String, Object> callingInstanceVariables = runtimeService.getVariables(processInstance.getId());
    assertEquals(2, callingInstanceVariables.size());
    assertEquals("val1", callingInstanceVariables.get("callingProcessVar1"));
    assertEquals(43L, callingInstanceVariables.get("outputParameter"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 12 with CaseExecutionEntity

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

the class CaseCallActivityTest method testCallCaseAsExpressionStartsWithHash.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseAsExpressionStartsWithHash.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallCaseAsExpressionStartsWithHash() {
    // 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 13 with CaseExecutionEntity

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

the class CaseCallActivityTest method testInputDifferentBusinessKey.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputDifferentBusinessKey.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputDifferentBusinessKey() {
    // given
    String myBusinessKey = "myBusinessKey";
    String myOwnBusinessKey = "myOwnBusinessKey";
    VariableMap variables = Variables.createVariables().putValue(myOwnBusinessKey, myOwnBusinessKey);
    // when
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, variables, myBusinessKey).getId();
    // then
    String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());
    assertEquals(myOwnBusinessKey, subCaseInstance.getBusinessKey());
    // 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) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with CaseExecutionEntity

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

the class GetCaseExecutionVariablesCmd method execute.

public VariableMap execute(CommandContext commandContext) {
    ensureNotNull("caseExecutionId", caseExecutionId);
    CaseExecutionEntity caseExecution = commandContext.getCaseExecutionManager().findCaseExecutionById(caseExecutionId);
    ensureNotNull(CaseExecutionNotFoundException.class, "case execution " + caseExecutionId + " doesn't exist", "caseExecution", caseExecution);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadCaseInstance(caseExecution);
    }
    VariableMapImpl result = new VariableMapImpl();
    // collect variables
    caseExecution.collectVariables(result, variableNames, isLocal, deserializeValues);
    return result;
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 15 with CaseExecutionEntity

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

the class CaseDefinitionEntity method newCaseInstance.

@Override
protected CmmnExecution newCaseInstance() {
    CaseExecutionEntity caseInstance = new CaseExecutionEntity();
    if (tenantId != null) {
        caseInstance.setTenantId(tenantId);
    }
    Context.getCommandContext().getCaseExecutionManager().insertCaseExecution(caseInstance);
    return caseInstance;
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)

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