Search in sources :

Example 1 with CmmnActivityExecution

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

the class PvmAtomicOperationProcessEnd method eventNotificationsCompleted.

@Override
protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
    execution.leaveActivityInstance();
    PvmExecutionImpl superExecution = execution.getSuperExecution();
    CmmnActivityExecution superCaseExecution = execution.getSuperCaseExecution();
    SubProcessActivityBehavior subProcessActivityBehavior = null;
    TransferVariablesActivityBehavior transferVariablesBehavior = null;
    // copy variables before destroying the ended sub process instance
    if (superExecution != null) {
        PvmActivity activity = superExecution.getActivity();
        subProcessActivityBehavior = (SubProcessActivityBehavior) activity.getActivityBehavior();
        try {
            subProcessActivityBehavior.passOutputVariables(superExecution, execution);
        } catch (RuntimeException e) {
            LOG.exceptionWhileCompletingSupProcess(execution, e);
            throw e;
        } catch (Exception e) {
            LOG.exceptionWhileCompletingSupProcess(execution, e);
            throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
        }
    } else if (superCaseExecution != null) {
        CmmnActivity activity = superCaseExecution.getActivity();
        transferVariablesBehavior = (TransferVariablesActivityBehavior) activity.getActivityBehavior();
        try {
            transferVariablesBehavior.transferVariables(execution, superCaseExecution);
        } catch (RuntimeException e) {
            LOG.exceptionWhileCompletingSupProcess(execution, e);
            throw e;
        } catch (Exception e) {
            LOG.exceptionWhileCompletingSupProcess(execution, e);
            throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
        }
    }
    execution.destroy();
    execution.remove();
    // and trigger execution afterwards
    if (superExecution != null) {
        superExecution.setSubProcessInstance(null);
        try {
            subProcessActivityBehavior.completed(superExecution);
        } catch (RuntimeException e) {
            LOG.exceptionWhileCompletingSupProcess(execution, e);
            throw e;
        } catch (Exception e) {
            LOG.exceptionWhileCompletingSupProcess(execution, e);
            throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
        }
    } else if (superCaseExecution != null) {
        superCaseExecution.complete();
    }
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) TransferVariablesActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.TransferVariablesActivityBehavior) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) SubProcessActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.SubProcessActivityBehavior)

Example 2 with CmmnActivityExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution 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)

Example 3 with CmmnActivityExecution

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

the class StageOrTaskActivityBehavior method onResume.

// resume /////////////////////////////////////////////////////////////////
public void onResume(CmmnActivityExecution execution) {
    ensureNotCaseInstance(execution, "resume");
    ensureTransitionAllowed(execution, SUSPENDED, ACTIVE, "resume");
    CmmnActivityExecution parent = execution.getParent();
    if (parent != null) {
        if (!parent.isActive()) {
            String id = execution.getId();
            throw LOG.resumeInactiveCaseException("resume", id);
        }
    }
    resuming(execution);
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)

Example 4 with CmmnActivityExecution

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

the class StageOrTaskActivityBehavior method onParentResume.

public void onParentResume(CmmnActivityExecution execution) {
    ensureNotCaseInstance(execution, "parentResume");
    String id = execution.getId();
    if (!execution.isSuspended()) {
        throw LOG.wrongCaseStateException("parentResume", id, "resume", "suspended", execution.getCurrentState().toString());
    }
    CmmnActivityExecution parent = execution.getParent();
    if (parent != null) {
        if (!parent.isActive()) {
            throw LOG.resumeInactiveCaseException("parentResume", id);
        }
    }
    resuming(execution);
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)

Example 5 with CmmnActivityExecution

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

the class EventListenerOrMilestoneActivityBehavior method onResume.

// resume ////////////////////////////////////////////////////////////////
public void onResume(CmmnActivityExecution execution) {
    ensureTransitionAllowed(execution, SUSPENDED, AVAILABLE, "resume");
    CmmnActivityExecution parent = execution.getParent();
    if (parent != null) {
        if (!parent.isActive()) {
            String id = execution.getId();
            throw LOG.resumeInactiveCaseException("resume", id);
        }
    }
    resuming(execution);
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)

Aggregations

CmmnActivityExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)43 CmmnCaseInstance (org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance)38 CaseDefinitionBuilder (org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)38 CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)38 StageActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior)19 ArrayList (java.util.ArrayList)13 CaseIllegalStateTransitionException (org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException)13 CaseExecutionImpl (org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl)13 Test (org.junit.Test)13 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 MilestoneActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.MilestoneActivityBehavior)1 TransferVariablesActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.TransferVariablesActivityBehavior)1 CmmnExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)1 CmmnOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration)1 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)1 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)1 SubProcessActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.SubProcessActivityBehavior)1 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)1