Search in sources :

Example 1 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class AbstractAtomicOperationCaseExecutionComplete method postTransitionNotification.

protected void postTransitionNotification(CmmnExecution execution) {
    if (!execution.isCaseInstanceExecution()) {
        execution.remove();
    } else {
        CmmnExecution superCaseExecution = execution.getSuperCaseExecution();
        PvmExecutionImpl superExecution = execution.getSuperExecution();
        if (superCaseExecution != null) {
            TransferVariablesActivityBehavior behavior = (TransferVariablesActivityBehavior) getActivityBehavior(superCaseExecution);
            behavior.transferVariables(execution, superCaseExecution);
            superCaseExecution.complete();
        } else if (superExecution != null) {
            SubProcessActivityBehavior behavior = (SubProcessActivityBehavior) getActivityBehavior(superExecution);
            try {
                behavior.passOutputVariables(superExecution, execution);
            } catch (RuntimeException e) {
                LOG.completingSubCaseError(execution, e);
                throw e;
            } catch (Exception e) {
                LOG.completingSubCaseError(execution, e);
                throw LOG.completingSubCaseErrorException(execution, e);
            }
            // set sub case instance to null
            superExecution.setSubCaseInstance(null);
            try {
                behavior.completed(superExecution);
            } catch (RuntimeException e) {
                LOG.completingSubCaseError(execution, e);
                throw e;
            } catch (Exception e) {
                LOG.completingSubCaseError(execution, e);
                throw LOG.completingSubCaseErrorException(execution, e);
            }
        }
        execution.setSuperCaseExecution(null);
        execution.setSuperExecution(null);
    }
    CmmnExecution parent = execution.getParent();
    if (parent != null) {
        CmmnActivityBehavior behavior = getActivityBehavior(parent);
        if (behavior instanceof CmmnCompositeActivityBehavior) {
            CmmnCompositeActivityBehavior compositeBehavior = (CmmnCompositeActivityBehavior) behavior;
            compositeBehavior.handleChildCompletion(parent, execution);
        }
    }
}
Also used : CmmnCompositeActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.CmmnCompositeActivityBehavior) TransferVariablesActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.TransferVariablesActivityBehavior) CmmnActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) SubProcessActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.SubProcessActivityBehavior)

Example 2 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class AtomicOperationCaseExecutionDeleteCascade method execute.

public void execute(CmmnExecution execution) {
    CmmnExecution firstLeaf = findFirstLeaf(execution);
    firstLeaf.remove();
    CmmnExecution parent = firstLeaf.getParent();
    if (parent != null) {
        parent.deleteCascade();
    }
}
Also used : CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)

Example 3 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class CaseCallActivityTest method testSuspendSubCaseInstance.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseAsConstant.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testSuspendSubCaseInstance() {
    // given
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
    String subCaseInstanceId = queryOneTaskCaseInstance().getId();
    // when
    suspend(subCaseInstanceId);
    // then
    CmmnExecution subCaseInstance = (CmmnExecution) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    assertTrue(subCaseInstance.isSuspended());
    Execution callActivity = queryExecutionByActivityId(CALL_ACTIVITY_ID);
    assertNotNull(callActivity);
    // complete ////////////////////////////////////////////////////////
    close(subCaseInstanceId);
    assertCaseEnded(subCaseInstanceId);
    runtimeService.deleteProcessInstance(superProcessInstanceId, null);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) Execution(org.camunda.bpm.engine.runtime.Execution) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class CaseCallActivityTest method testTerminateSubCaseInstance.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseAsConstant.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testTerminateSubCaseInstance() {
    // given
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
    String subCaseInstanceId = queryOneTaskCaseInstance().getId();
    // when
    terminate(subCaseInstanceId);
    // then
    CmmnExecution subCaseInstance = (CmmnExecution) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    assertTrue(subCaseInstance.isTerminated());
    Execution callActivity = queryExecutionByActivityId(CALL_ACTIVITY_ID);
    assertNotNull(callActivity);
    // complete ////////////////////////////////////////////////////////
    close(subCaseInstanceId);
    assertCaseEnded(subCaseInstanceId);
    runtimeService.deleteProcessInstance(superProcessInstanceId, null);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) Execution(org.camunda.bpm.engine.runtime.Execution) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class PlanItemDefinitionActivityBehavior method repeat.

// repetition ///////////////////////////////////////////////////////////////
public void repeat(CmmnActivityExecution execution, String standardEvent) {
    CmmnActivity activity = execution.getActivity();
    boolean repeat = false;
    if (activity.getEntryCriteria().isEmpty()) {
        List<String> events = activity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
        if (events != null && events.contains(standardEvent)) {
            repeat = evaluateRepetitionRule(execution);
        }
    } else {
        if (ENABLE.equals(standardEvent) || START.equals(standardEvent) || OCCUR.equals(standardEvent)) {
            repeat = evaluateRepetitionRule(execution);
        }
    }
    if (repeat) {
        CmmnActivityExecution parent = execution.getParent();
        // instantiate a new instance of given activity
        List<CmmnExecution> children = parent.createChildExecutions(Arrays.asList(activity));
        // start the lifecycle of the new instance
        parent.triggerChildExecutionsLifecycle(children);
    }
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)

Aggregations

CmmnExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)16 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)4 Deployment (org.camunda.bpm.engine.test.Deployment)4 CmmnActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior)2 CmmnCompositeActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CmmnCompositeActivityBehavior)2 StageActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior)2 CaseExecutionImpl (org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl)2 CmmnCaseInstance (org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance)2 CaseDefinitionBuilder (org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)2 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)2 CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)2 Execution (org.camunda.bpm.engine.runtime.Execution)2 Test (org.junit.Test)2 TransferVariablesActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.TransferVariablesActivityBehavior)1 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)1 CaseExecutionState (org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState)1 CmmnActivityExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)1 HistoricCaseInstanceEventEntity (org.camunda.bpm.engine.impl.history.event.HistoricCaseInstanceEventEntity)1 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)1 SubProcessActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.SubProcessActivityBehavior)1