Search in sources :

Example 1 with CmmnSentryDeclaration

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

the class ItemHandler method initializeEntryCriterias.

protected void initializeEntryCriterias(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    Collection<Sentry> entryCriterias = getEntryCriterias(element);
    if (!entryCriterias.isEmpty()) {
        CmmnActivity parent = activity.getParent();
        if (parent != null) {
            for (Sentry sentry : entryCriterias) {
                String sentryId = sentry.getId();
                CmmnSentryDeclaration sentryDeclaration = parent.getSentry(sentryId);
                if (sentryDeclaration != null) {
                    activity.addEntryCriteria(sentryDeclaration);
                }
            }
        }
    }
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)

Example 2 with CmmnSentryDeclaration

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

the class ItemHandler method initializeExitCriterias.

protected void initializeExitCriterias(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    Collection<Sentry> exitCriterias = getExitCriterias(element);
    if (!exitCriterias.isEmpty()) {
        CmmnActivity parent = activity.getParent();
        if (parent != null) {
            for (Sentry sentry : exitCriterias) {
                String sentryId = sentry.getId();
                CmmnSentryDeclaration sentryDeclaration = parent.getSentry(sentryId);
                if (sentryDeclaration != null) {
                    activity.addExitCriteria(sentryDeclaration);
                }
            }
        }
    }
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)

Example 3 with CmmnSentryDeclaration

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

the class SentryHandler method handleElement.

public CmmnSentryDeclaration handleElement(Sentry element, CmmnHandlerContext context) {
    String id = element.getId();
    Collection<OnPart> onParts = element.getOnParts();
    IfPart ifPart = element.getIfPart();
    List<CamundaVariableOnPart> variableOnParts = queryExtensionElementsByClass(element, CamundaVariableOnPart.class);
    if ((ifPart == null || ifPart.getConditions().isEmpty()) && variableOnParts.isEmpty()) {
        if (onParts == null || onParts.isEmpty()) {
            LOG.ignoredSentryWithMissingCondition(id);
            return null;
        } else {
            boolean atLeastOneOnPartsValid = false;
            for (OnPart onPart : onParts) {
                if (onPart instanceof PlanItemOnPart) {
                    PlanItemOnPart planItemOnPart = (PlanItemOnPart) onPart;
                    if (planItemOnPart.getSource() != null && planItemOnPart.getStandardEvent() != null) {
                        atLeastOneOnPartsValid = true;
                        break;
                    }
                }
            }
            if (!atLeastOneOnPartsValid) {
                LOG.ignoredSentryWithInvalidParts(id);
                return null;
            }
        }
    }
    CmmnSentryDeclaration sentryDeclaration = new CmmnSentryDeclaration(id);
    // the ifPart will be initialized immediately
    initializeIfPart(ifPart, sentryDeclaration, context);
    // the variableOnParts will be initialized immediately as it does not have any dependency
    initializeVariableOnParts(element, sentryDeclaration, context, variableOnParts);
    // ...whereas the onParts will be initialized later because the
    // the reference to the plan items (sourceRef) and the reference
    // to the sentry (sentryRef) cannot be set in this step. To set
    // the corresponding reference (sourceRef or sentryRef) on the
    // transformed sentry all planned items and all sentries inside
    // the current stage should be already transformed.
    CmmnActivity parent = context.getParent();
    if (parent != null) {
        parent.addSentry(sentryDeclaration);
    }
    return sentryDeclaration;
}
Also used : CamundaVariableOnPart(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart) PlanItemOnPart(org.camunda.bpm.model.cmmn.instance.PlanItemOnPart) OnPart(org.camunda.bpm.model.cmmn.instance.OnPart) CaseFileItemOnPart(org.camunda.bpm.model.cmmn.instance.CaseFileItemOnPart) PlanItemOnPart(org.camunda.bpm.model.cmmn.instance.PlanItemOnPart) CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) IfPart(org.camunda.bpm.model.cmmn.instance.IfPart) CamundaVariableOnPart(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)

Example 4 with CmmnSentryDeclaration

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

the class SentryHandler method initializeOnPart.

protected void initializeOnPart(PlanItemOnPart onPart, Sentry sentry, CmmnHandlerContext context) {
    CmmnActivity parent = context.getParent();
    String sentryId = sentry.getId();
    CmmnSentryDeclaration sentryDeclaration = parent.getSentry(sentryId);
    PlanItem source = onPart.getSource();
    PlanItemTransition standardEvent = onPart.getStandardEvent();
    if (source != null && standardEvent != null) {
        CmmnOnPartDeclaration onPartDeclaration = new CmmnOnPartDeclaration();
        // initialize standardEvent
        String standardEventName = standardEvent.name();
        onPartDeclaration.setStandardEvent(standardEventName);
        // initialize sourceRef
        String sourceId = source.getId();
        CmmnActivity sourceActivity = parent.findActivity(sourceId);
        if (sourceActivity != null) {
            onPartDeclaration.setSource(sourceActivity);
        }
        // initialize sentryRef
        Sentry sentryRef = onPart.getSentry();
        if (sentryRef != null) {
            String sentryRefId = sentryRef.getId();
            CmmnSentryDeclaration sentryRefDeclaration = parent.getSentry(sentryRefId);
            onPartDeclaration.setSentry(sentryRefDeclaration);
        }
        // add onPartDeclaration to sentryDeclaration
        sentryDeclaration.addOnPart(onPartDeclaration);
    }
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CmmnOnPartDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) PlanItemTransition(org.camunda.bpm.model.cmmn.PlanItemTransition)

Example 5 with CmmnSentryDeclaration

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

the class CmmnTransform method transformSentryOnParts.

protected void transformSentryOnParts(Stage stage) {
    Collection<Sentry> sentries = stage.getSentrys();
    if (sentries != null && !sentries.isEmpty()) {
        SentryHandler handler = getSentryHandler();
        for (Sentry sentry : sentries) {
            handler.initializeOnParts(sentry, context);
            // sentry fully transformed -> call transform listener
            CmmnSentryDeclaration sentryDeclaration = context.getParent().getSentry(sentry.getId());
            for (CmmnTransformListener transformListener : transformListeners) {
                transformListener.transformSentry(sentry, sentryDeclaration);
            }
        }
    }
}
Also used : SentryHandler(org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler) CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry)

Aggregations

CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)56 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)47 Test (org.junit.Test)45 Sentry (org.camunda.bpm.model.cmmn.instance.Sentry)41 IfPart (org.camunda.bpm.model.cmmn.instance.IfPart)39 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)38 SentryHandler (org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler)36 CasePlanModelHandler (org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler)35 Body (org.camunda.bpm.model.cmmn.instance.Body)25 EntryCriterion (org.camunda.bpm.model.cmmn.instance.EntryCriterion)21 ExitCriterion (org.camunda.bpm.model.cmmn.instance.ExitCriterion)21 CmmnOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration)5 CmmnVariableOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration)5 CamundaVariableOnPart (org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart)5 CmmnIfPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration)4 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)4 Expression (org.camunda.bpm.engine.delegate.Expression)3 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)2 MilestoneActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.MilestoneActivityBehavior)1 CaseExecutionImpl (org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl)1