Search in sources :

Example 51 with CmmnSentryDeclaration

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

the class StagePlanItemHandlerTest method testEntryCriteriaAndExitCriteria.

@Test
public void testEntryCriteriaAndExitCriteria() {
    // given
    // create sentry containing ifPart
    Sentry sentry = createElement(casePlanModel, "Sentry_1", Sentry.class);
    IfPart ifPart = createElement(sentry, "abc", IfPart.class);
    ConditionExpression conditionExpression = createElement(ifPart, "def", ConditionExpression.class);
    Body body = createElement(conditionExpression, null, Body.class);
    body.setTextContent("${test}");
    // set entry-/exitCriteria
    EntryCriterion criterion1 = createElement(planItem, EntryCriterion.class);
    criterion1.setSentry(sentry);
    ExitCriterion criterion2 = createElement(planItem, ExitCriterion.class);
    criterion2.setSentry(sentry);
    // transform casePlanModel as parent
    CmmnActivity parent = new CasePlanModelHandler().handleElement(casePlanModel, context);
    context.setParent(parent);
    // transform Sentry
    CmmnSentryDeclaration sentryDeclaration = new SentryHandler().handleElement(sentry, context);
    // when
    CmmnActivity newActivity = handler.handleElement(planItem, context);
    // then
    assertFalse(newActivity.getExitCriteria().isEmpty());
    assertEquals(1, newActivity.getExitCriteria().size());
    assertEquals(sentryDeclaration, newActivity.getExitCriteria().get(0));
    assertFalse(newActivity.getEntryCriteria().isEmpty());
    assertEquals(1, newActivity.getEntryCriteria().size());
    assertEquals(sentryDeclaration, newActivity.getEntryCriteria().get(0));
}
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) EntryCriterion(org.camunda.bpm.model.cmmn.instance.EntryCriterion) 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)

Example 52 with CmmnSentryDeclaration

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

the class TaskPlanItemHandlerTest method testMultipleEntryCriteria.

@Test
public void testMultipleEntryCriteria() {
    // 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);
    conditionExpression1.setText("${test}");
    // set first entryCriteria
    EntryCriterion criterion1 = createElement(planItem, EntryCriterion.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);
    conditionExpression2.setText("${test}");
    // set second entryCriteria
    EntryCriterion criterion2 = createElement(planItem, EntryCriterion.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.getExitCriteria().isEmpty());
    assertFalse(newActivity.getEntryCriteria().isEmpty());
    assertEquals(2, newActivity.getEntryCriteria().size());
    assertTrue(newActivity.getEntryCriteria().contains(firstSentryDeclaration));
    assertTrue(newActivity.getEntryCriteria().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) EntryCriterion(org.camunda.bpm.model.cmmn.instance.EntryCriterion) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 53 with CmmnSentryDeclaration

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

the class TaskPlanItemHandlerTest 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);
    conditionExpression1.setText("${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);
    conditionExpression2.setText("${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) Test(org.junit.Test)

Example 54 with CmmnSentryDeclaration

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

the class CasePlanModelHandler method initializeExitCriterias.

public void initializeExitCriterias(CasePlanModel casePlanModel, CmmnActivity activity, CmmnHandlerContext context) {
    Collection<Sentry> exitCriterias = casePlanModel.getExitCriteria();
    for (Sentry sentry : exitCriterias) {
        String sentryId = sentry.getId();
        CmmnSentryDeclaration sentryDeclaration = activity.getSentry(sentryId);
        activity.addExitCriteria(sentryDeclaration);
    }
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry)

Example 55 with CmmnSentryDeclaration

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

the class CmmnExecution method checkAndFireExitCriteria.

protected void checkAndFireExitCriteria(List<String> satisfiedSentries) {
    if (isActive()) {
        CmmnActivity activity = getActivity();
        ensureNotNull(PvmException.class, "Case execution '" + getId() + "': has no current activity.", "activity", activity);
        // trigger first exitCriteria
        List<CmmnSentryDeclaration> exitCriteria = activity.getExitCriteria();
        for (CmmnSentryDeclaration sentryDeclaration : exitCriteria) {
            if (sentryDeclaration != null && satisfiedSentries.contains(sentryDeclaration.getId())) {
                fireExitCriteria();
                break;
            }
        }
    }
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)

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