Search in sources :

Example 31 with CaseExecutionEntity

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

the class CaseTaskTest method testInputSourceNullValue.

/**
 * assertion on default execution - take manual start out
 */
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testInputSource.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputSourceNullValue() {
    // given
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE).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 ("aVariable".equals(name)) {
            assertEquals("aVariable", name);
        } else if ("anotherVariable".equals(name)) {
            assertEquals("anotherVariable", name);
        } else {
            fail("Found an unexpected variable: '" + name + "'");
        }
        assertNull(variable.getValue());
    }
    // 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) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 32 with CaseExecutionEntity

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

the class CaseCallActivityBehavior method onParseMigratingInstance.

@Override
public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) {
    ActivityImpl callActivity = (ActivityImpl) migratingInstance.getSourceScope();
    // must be maintained throughout migration
    if (!callActivity.isScope()) {
        ExecutionEntity callActivityExecution = migratingInstance.resolveRepresentativeExecution();
        CaseExecutionEntity calledCaseInstance = callActivityExecution.getSubCaseInstance();
        migratingInstance.addMigratingDependentInstance(new MigratingCalledCaseInstance(calledCaseInstance));
    }
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) MigratingCalledCaseInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingCalledCaseInstance)

Example 33 with CaseExecutionEntity

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

the class DefaultHistoryEventProducer method initHistoricVariableUpdateEvt.

protected void initHistoricVariableUpdateEvt(HistoricVariableUpdateEventEntity evt, VariableInstanceEntity variableInstance, HistoryEventType eventType) {
    // init properties
    evt.setEventType(eventType.getEventName());
    evt.setTimestamp(ClockUtil.getCurrentTime());
    evt.setVariableInstanceId(variableInstance.getId());
    evt.setProcessInstanceId(variableInstance.getProcessInstanceId());
    evt.setExecutionId(variableInstance.getExecutionId());
    evt.setCaseInstanceId(variableInstance.getCaseInstanceId());
    evt.setCaseExecutionId(variableInstance.getCaseExecutionId());
    evt.setTaskId(variableInstance.getTaskId());
    evt.setRevision(variableInstance.getRevision());
    evt.setVariableName(variableInstance.getName());
    evt.setSerializerName(variableInstance.getSerializerName());
    evt.setTenantId(variableInstance.getTenantId());
    evt.setUserOperationId(Context.getCommandContext().getOperationId());
    ExecutionEntity execution = variableInstance.getExecution();
    if (execution != null) {
        ProcessDefinitionEntity definition = execution.getProcessDefinition();
        if (definition != null) {
            evt.setProcessDefinitionId(definition.getId());
            evt.setProcessDefinitionKey(definition.getKey());
        }
    }
    CaseExecutionEntity caseExecution = variableInstance.getCaseExecution();
    if (caseExecution != null) {
        CaseDefinitionEntity definition = (CaseDefinitionEntity) caseExecution.getCaseDefinition();
        if (definition != null) {
            evt.setCaseDefinitionId(definition.getId());
            evt.setCaseDefinitionKey(definition.getKey());
        }
    }
    // copy value
    evt.setTextValue(variableInstance.getTextValue());
    evt.setTextValue2(variableInstance.getTextValue2());
    evt.setDoubleValue(variableInstance.getDoubleValue());
    evt.setLongValue(variableInstance.getLongValue());
    if (variableInstance.getByteArrayValueId() != null) {
        evt.setByteValue(variableInstance.getByteArrayValue());
    }
}
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) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 34 with CaseExecutionEntity

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

the class DefaultHistoryEventProducer method createHistoricVariableEvent.

protected HistoryEvent createHistoricVariableEvent(VariableInstanceEntity variableInstance, VariableScope sourceVariableScope, HistoryEventType eventType) {
    String scopeActivityInstanceId = null;
    String sourceActivityInstanceId = null;
    if (variableInstance.getExecutionId() != null) {
        ExecutionEntity scopeExecution = Context.getCommandContext().getDbEntityManager().selectById(ExecutionEntity.class, variableInstance.getExecutionId());
        if (variableInstance.getTaskId() == null && !variableInstance.isConcurrentLocal()) {
            scopeActivityInstanceId = scopeExecution.getParentActivityInstanceId();
        } else {
            scopeActivityInstanceId = scopeExecution.getActivityInstanceId();
        }
    } else if (variableInstance.getCaseExecutionId() != null) {
        scopeActivityInstanceId = variableInstance.getCaseExecutionId();
    }
    ExecutionEntity sourceExecution = null;
    CaseExecutionEntity sourceCaseExecution = null;
    if (sourceVariableScope instanceof ExecutionEntity) {
        sourceExecution = (ExecutionEntity) sourceVariableScope;
        sourceActivityInstanceId = sourceExecution.getActivityInstanceId();
    } else if (sourceVariableScope instanceof TaskEntity) {
        sourceExecution = ((TaskEntity) sourceVariableScope).getExecution();
        if (sourceExecution != null) {
            sourceActivityInstanceId = sourceExecution.getActivityInstanceId();
        } else {
            sourceCaseExecution = ((TaskEntity) sourceVariableScope).getCaseExecution();
            if (sourceCaseExecution != null) {
                sourceActivityInstanceId = sourceCaseExecution.getId();
            }
        }
    } else if (sourceVariableScope instanceof CaseExecutionEntity) {
        sourceCaseExecution = (CaseExecutionEntity) sourceVariableScope;
        sourceActivityInstanceId = sourceCaseExecution.getId();
    }
    // create event
    HistoricVariableUpdateEventEntity evt = newVariableUpdateEventEntity(sourceExecution);
    // initialize
    initHistoricVariableUpdateEvt(evt, variableInstance, eventType);
    // initialize sequence counter
    initSequenceCounter(variableInstance, evt);
    // set scope activity instance id
    evt.setScopeActivityInstanceId(scopeActivityInstanceId);
    // set source activity instance id
    evt.setActivityInstanceId(sourceActivityInstanceId);
    return evt;
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ExternalTaskEntity(org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)

Example 35 with CaseExecutionEntity

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

the class DefaultCmmnHistoryEventProducer method createCaseInstanceUpdateEvt.

public HistoryEvent createCaseInstanceUpdateEvt(DelegateCaseExecution caseExecution) {
    final CaseExecutionEntity caseExecutionEntity = (CaseExecutionEntity) caseExecution;
    // create event instance
    HistoricCaseInstanceEventEntity evt = loadCaseInstanceEventEntity(caseExecutionEntity);
    // initialize event
    initCaseInstanceEvent(evt, caseExecutionEntity, HistoryEventTypes.CASE_INSTANCE_UPDATE);
    return evt;
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) HistoricCaseInstanceEventEntity(org.camunda.bpm.engine.impl.history.event.HistoricCaseInstanceEventEntity)

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