Search in sources :

Example 6 with Sentry

use of org.camunda.bpm.model.cmmn.instance.Sentry 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 7 with Sentry

use of org.camunda.bpm.model.cmmn.instance.Sentry 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 8 with Sentry

use of org.camunda.bpm.model.cmmn.instance.Sentry 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)

Example 9 with Sentry

use of org.camunda.bpm.model.cmmn.instance.Sentry in project camunda-bpm-platform by camunda.

the class SentryHandlerTest method testSentryWithOnPartReferencesSentry.

@Test
public void testSentryWithOnPartReferencesSentry() {
    // given
    Sentry exitSentry = createElement(casePlanModel, "anotherSentry", Sentry.class);
    IfPart ifPart = createElement(exitSentry, "IfPart_1", IfPart.class);
    ConditionExpression conditionExpression = createElement(ifPart, "con_1", ConditionExpression.class);
    Body body = createElement(conditionExpression, null, Body.class);
    body.setTextContent("${test}");
    onPart.setSentry(exitSentry);
    CmmnActivity casePlanModelActivity = new CasePlanModelHandler().handleElement(casePlanModel, context);
    context.setParent(casePlanModelActivity);
    CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
    CmmnSentryDeclaration exitSentryDeclaration = sentryHandler.handleElement(exitSentry, context);
    CmmnActivity source = taskItemHandler.handleElement(planItem, context);
    // when
    sentryHandler.initializeOnParts(sentry, context);
    // then
    assertNotNull(sentryDeclaration);
    List<CmmnOnPartDeclaration> onParts = sentryDeclaration.getOnParts();
    assertNotNull(onParts);
    assertFalse(onParts.isEmpty());
    assertEquals(1, onParts.size());
    List<CmmnOnPartDeclaration> onPartsAssociatedWithSource = sentryDeclaration.getOnParts(source.getId());
    assertNotNull(onPartsAssociatedWithSource);
    assertFalse(onPartsAssociatedWithSource.isEmpty());
    assertEquals(1, onParts.size());
    CmmnOnPartDeclaration onPartDeclaration = onPartsAssociatedWithSource.get(0);
    assertNotNull(onPartDeclaration);
    // source
    assertEquals(source, onPartDeclaration.getSource());
    assertEquals(onPart.getSource().getId(), onPartDeclaration.getSource().getId());
    // standardEvent
    assertEquals(onPart.getStandardEvent().name(), onPartDeclaration.getStandardEvent());
    // sentry
    assertNotNull(onPartDeclaration.getSentry());
    assertEquals(exitSentryDeclaration, onPartDeclaration.getSentry());
    assertNull(sentryDeclaration.getIfPart());
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) IfPart(org.camunda.bpm.model.cmmn.instance.IfPart) CasePlanModelHandler(org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnOnPartDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Body(org.camunda.bpm.model.cmmn.instance.Body) Test(org.junit.Test)

Example 10 with Sentry

use of org.camunda.bpm.model.cmmn.instance.Sentry in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testMultipleExitCriteria.

@Test
public void testMultipleExitCriteria() {
    // given
    // create first sentry containing ifPart
    Sentry sentry1 = createElement(casePlanModel, "Sentry_1", Sentry.class);
    IfPart ifPart1 = createElement(sentry1, "abc", IfPart.class);
    ConditionExpression conditionExpression1 = createElement(ifPart1, "def", ConditionExpression.class);
    Body body1 = createElement(conditionExpression1, null, Body.class);
    body1.setTextContent("${test}");
    // set first exitCriteria
    ExitCriterion criterion1 = createElement(planItem, ExitCriterion.class);
    criterion1.setSentry(sentry1);
    // create first sentry containing ifPart
    Sentry sentry2 = createElement(casePlanModel, "Sentry_2", Sentry.class);
    IfPart ifPart2 = createElement(sentry2, "ghi", IfPart.class);
    ConditionExpression conditionExpression2 = createElement(ifPart2, "jkl", ConditionExpression.class);
    Body body2 = createElement(conditionExpression2, null, Body.class);
    body2.setTextContent("${test}");
    // set second exitCriteria
    ExitCriterion criterion2 = createElement(planItem, ExitCriterion.class);
    criterion2.setSentry(sentry2);
    // transform casePlanModel as parent
    CmmnActivity parent = new CasePlanModelHandler().handleElement(casePlanModel, context);
    context.setParent(parent);
    // transform Sentry
    CmmnSentryDeclaration firstSentryDeclaration = new SentryHandler().handleElement(sentry1, context);
    CmmnSentryDeclaration secondSentryDeclaration = new SentryHandler().handleElement(sentry2, context);
    // when
    CmmnActivity newActivity = handler.handleElement(planItem, context);
    // then
    assertTrue(newActivity.getEntryCriteria().isEmpty());
    assertFalse(newActivity.getExitCriteria().isEmpty());
    assertEquals(2, newActivity.getExitCriteria().size());
    assertTrue(newActivity.getExitCriteria().contains(firstSentryDeclaration));
    assertTrue(newActivity.getExitCriteria().contains(secondSentryDeclaration));
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) SentryHandler(org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler) IfPart(org.camunda.bpm.model.cmmn.instance.IfPart) CasePlanModelHandler(org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ExitCriterion(org.camunda.bpm.model.cmmn.instance.ExitCriterion) Body(org.camunda.bpm.model.cmmn.instance.Body) Test(org.junit.Test)

Aggregations

Sentry (org.camunda.bpm.model.cmmn.instance.Sentry)49 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)41 Test (org.junit.Test)40 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)39 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)37 IfPart (org.camunda.bpm.model.cmmn.instance.IfPart)37 SentryHandler (org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler)36 CasePlanModelHandler (org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler)34 ExitCriterion (org.camunda.bpm.model.cmmn.instance.ExitCriterion)25 Body (org.camunda.bpm.model.cmmn.instance.Body)23 EntryCriterion (org.camunda.bpm.model.cmmn.instance.EntryCriterion)23 CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)4 ArrayList (java.util.ArrayList)3 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)3 CmmnOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration)2 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)2 PlanItemTransition (org.camunda.bpm.model.cmmn.PlanItemTransition)1 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1