Search in sources :

Example 6 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity 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 7 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.

the class CmmnExecution method isSentryPartsSatisfied.

protected boolean isSentryPartsSatisfied(String sentryId, List<? extends CmmnSentryPart> sentryParts) {
    // if part will be evaluated in the end
    CmmnSentryPart ifPart = null;
    if (sentryParts != null && !sentryParts.isEmpty()) {
        for (CmmnSentryPart sentryPart : sentryParts) {
            if (PLAN_ITEM_ON_PART.equals(sentryPart.getType())) {
                if (!sentryPart.isSatisfied()) {
                    return false;
                }
            } else if (VARIABLE_ON_PART.equals(sentryPart.getType())) {
                if (!sentryPart.isSatisfied()) {
                    return false;
                }
            } else {
                /* IF_PART.equals(sentryPart.getType) == true */
                ifPart = sentryPart;
                // once the ifPart has been satisfied the whole sentry is satisfied
                if (ifPart.isSatisfied()) {
                    return true;
                }
            }
        }
    }
    if (ifPart != null) {
        CmmnExecution execution = ifPart.getCaseExecution();
        ensureNotNull("Case execution of sentry '" + ifPart.getSentryId() + "': is null", execution);
        CmmnActivity activity = ifPart.getCaseExecution().getActivity();
        ensureNotNull("Case execution '" + id + "': has no current activity", "activity", activity);
        CmmnSentryDeclaration sentryDeclaration = activity.getSentry(sentryId);
        ensureNotNull("Case execution '" + id + "': has no declaration for sentry '" + sentryId + "'", "sentryDeclaration", sentryDeclaration);
        CmmnIfPartDeclaration ifPartDeclaration = sentryDeclaration.getIfPart();
        ensureNotNull("Sentry declaration '" + sentryId + "' has no definied ifPart, but there should be one defined for case execution '" + id + "'.", "ifPartDeclaration", ifPartDeclaration);
        Expression condition = ifPartDeclaration.getCondition();
        ensureNotNull("A condition was expected for ifPart of Sentry declaration '" + sentryId + "' for case execution '" + id + "'.", "condition", condition);
        Object result = condition.getValue(this);
        ensureInstanceOf("condition expression returns non-Boolean", "result", result, Boolean.class);
        Boolean booleanResult = (Boolean) result;
        ifPart.setSatisfied(booleanResult);
        return booleanResult;
    }
    // ifPart then the whole sentry is satisfied.
    return true;
}
Also used : CmmnIfPartDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration) CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) Expression(org.camunda.bpm.engine.delegate.Expression) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)

Example 8 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.

the class CmmnExecution method checkAndFireEntryCriteria.

protected void checkAndFireEntryCriteria(List<String> satisfiedSentries) {
    if (isAvailable() || isNew()) {
        // do that only, when this child case execution
        // is available
        CmmnActivity activity = getActivity();
        ensureNotNull(PvmException.class, "Case execution '" + getId() + "': has no current activity.", "activity", activity);
        List<CmmnSentryDeclaration> criteria = activity.getEntryCriteria();
        for (CmmnSentryDeclaration sentryDeclaration : criteria) {
            if (sentryDeclaration != null && satisfiedSentries.contains(sentryDeclaration.getId())) {
                if (isAvailable()) {
                    fireEntryCriteria();
                } else {
                    entryCriterionSatisfied = true;
                }
                break;
            }
        }
    }
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)

Example 9 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.

the class CmmnExecution method createOnPart.

protected CmmnSentryPart createOnPart(CmmnSentryDeclaration sentryDeclaration, CmmnOnPartDeclaration onPartDeclaration) {
    CmmnSentryPart sentryPart = createSentryPart(sentryDeclaration, PLAN_ITEM_ON_PART);
    // set the standard event
    String standardEvent = onPartDeclaration.getStandardEvent();
    sentryPart.setStandardEvent(standardEvent);
    // set source case execution
    CmmnActivity source = onPartDeclaration.getSource();
    ensureNotNull("The source of sentry '" + sentryDeclaration.getId() + "' is null.", "source", source);
    String sourceActivityId = source.getId();
    sentryPart.setSource(sourceActivityId);
    return sentryPart;
}
Also used : CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)

Example 10 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.

the class PlanItemDefinitionActivityBehavior method isAtLeastOneEntryCriterionSatisfied.

// sentries //////////////////////////////////////////////////////////////////////////////
protected boolean isAtLeastOneEntryCriterionSatisfied(CmmnActivityExecution execution) {
    if (execution.isEntryCriterionSatisfied()) {
        return true;
    }
    CmmnActivity activity = getActivity(execution);
    List<CmmnSentryDeclaration> criteria = activity.getEntryCriteria();
    return !(criteria != null && !criteria.isEmpty());
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)

Aggregations

CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)325 Test (org.junit.Test)298 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)112 PlanItemControl (org.camunda.bpm.model.cmmn.instance.PlanItemControl)64 CaseControlRule (org.camunda.bpm.engine.impl.cmmn.CaseControlRule)47 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)47 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)39 Sentry (org.camunda.bpm.model.cmmn.instance.Sentry)39 IfPart (org.camunda.bpm.model.cmmn.instance.IfPart)37 CasePlanModelHandler (org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler)36 SentryHandler (org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler)35 CallableElement (org.camunda.bpm.engine.impl.core.model.CallableElement)34 ItemControl (org.camunda.bpm.model.cmmn.instance.ItemControl)32 HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)29 RepetitionRule (org.camunda.bpm.model.cmmn.instance.RepetitionRule)28 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)26 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)23 Body (org.camunda.bpm.model.cmmn.instance.Body)23 EntryCriterion (org.camunda.bpm.model.cmmn.instance.EntryCriterion)21 ExitCriterion (org.camunda.bpm.model.cmmn.instance.ExitCriterion)21