Search in sources :

Example 1 with ConditionExpression

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

the class ConditionExpressionImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(ConditionExpression.class, CMMN_ELEMENT_CONDITION).namespaceUri(CMMN11_NS).extendsType(Expression.class).instanceProvider(new ModelElementTypeBuilder.ModelTypeInstanceProvider<ConditionExpression>() {

        public ConditionExpression newInstance(ModelTypeInstanceContext instanceContext) {
            return new ConditionExpressionImpl(instanceContext);
        }
    });
    typeBuilder.build();
}
Also used : ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) Expression(org.camunda.bpm.model.cmmn.instance.Expression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Example 2 with ConditionExpression

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

the class Cmmn10Test method shouldGetMultipleIfPartConditions.

@Test
public void shouldGetMultipleIfPartConditions() {
    CmmnModelInstance modelInstance = getCmmnModelInstance();
    Sentry sentry = modelInstance.getModelElementsByType(Sentry.class).iterator().next();
    IfPart ifPart = sentry.getIfPart();
    assertThat(ifPart).isNotNull();
    Collection<ConditionExpression> conditions = ifPart.getConditions();
    assertThat(conditions).hasSize(2);
    ConditionExpression condition = ifPart.getCondition();
    assertThat(condition).isNotNull();
}
Also used : IfPart(org.camunda.bpm.model.cmmn.instance.IfPart) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Test(org.junit.Test)

Example 3 with ConditionExpression

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

the class Cmmn10Test method shouldGetExpressionTextContent.

@Test
public void shouldGetExpressionTextContent() {
    CmmnModelInstance modelInstance = getCmmnModelInstance();
    ConditionExpression expression = modelInstance.getModelElementsByType(ConditionExpression.class).iterator().next();
    assertThat(expression.getBody()).isEqualTo("${value >= 100}");
    assertThat(expression.getText()).isEqualTo("${value >= 100}");
}
Also used : ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Test(org.junit.Test)

Example 4 with ConditionExpression

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

the class ItemHandler method initializeRepetitionRule.

protected void initializeRepetitionRule(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    PlanItemControl itemControl = getItemControl(element);
    PlanItemControl defaultControl = getDefaultControl(element);
    RepetitionRule repetitionRule = null;
    if (itemControl != null) {
        repetitionRule = itemControl.getRepetitionRule();
    }
    if (repetitionRule == null && defaultControl != null) {
        repetitionRule = defaultControl.getRepetitionRule();
    }
    if (repetitionRule != null) {
        ConditionExpression condition = repetitionRule.getCondition();
        CaseControlRule caseRule = initializeCaseControlRule(condition, context);
        activity.setProperty(PROPERTY_REPETITION_RULE, caseRule);
        List<String> events = Arrays.asList(TERMINATE, COMPLETE);
        String repeatOnStandardEvent = repetitionRule.getCamundaRepeatOnStandardEvent();
        if (repeatOnStandardEvent != null && !repeatOnStandardEvent.isEmpty()) {
            events = Arrays.asList(repeatOnStandardEvent);
        }
        activity.getProperties().set(CmmnProperties.REPEAT_ON_STANDARD_EVENTS, events);
    }
}
Also used : RepetitionRule(org.camunda.bpm.model.cmmn.instance.RepetitionRule) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule)

Example 5 with ConditionExpression

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

the class SentryHandler method initializeIfPart.

protected void initializeIfPart(IfPart ifPart, CmmnSentryDeclaration sentryDeclaration, CmmnHandlerContext context) {
    if (ifPart == null) {
        return;
    }
    Collection<ConditionExpression> conditions = ifPart.getConditions();
    if (conditions.size() > 1) {
        String id = sentryDeclaration.getId();
        LOG.multipleIgnoredConditions(id);
    }
    ExpressionManager expressionManager = context.getExpressionManager();
    ConditionExpression condition = conditions.iterator().next();
    Expression conditionExpression = expressionManager.createExpression(condition.getText());
    CmmnIfPartDeclaration ifPartDeclaration = new CmmnIfPartDeclaration();
    ifPartDeclaration.setCondition(conditionExpression);
    sentryDeclaration.setIfPart(ifPartDeclaration);
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) CmmnIfPartDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration) Expression(org.camunda.bpm.engine.delegate.Expression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression)

Aggregations

ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)108 Test (org.junit.Test)104 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)100 PlanItemControl (org.camunda.bpm.model.cmmn.instance.PlanItemControl)65 CaseControlRule (org.camunda.bpm.engine.impl.cmmn.CaseControlRule)45 IfPart (org.camunda.bpm.model.cmmn.instance.IfPart)39 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)38 Sentry (org.camunda.bpm.model.cmmn.instance.Sentry)37 SentryHandler (org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler)35 CasePlanModelHandler (org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler)34 ItemControl (org.camunda.bpm.model.cmmn.instance.ItemControl)32 RepetitionRule (org.camunda.bpm.model.cmmn.instance.RepetitionRule)29 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 RequiredRule (org.camunda.bpm.model.cmmn.instance.RequiredRule)20 ManualActivationRule (org.camunda.bpm.model.cmmn.instance.ManualActivationRule)16 Expression (org.camunda.bpm.engine.delegate.Expression)4 CmmnIfPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration)3 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)2