Search in sources :

Example 6 with RuleAnnotationClause

use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.

the class DecisionTableEditorDefinitionEnricher method enrich.

@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<DecisionTable> expression) {
    expression.ifPresent(dtable -> {
        dtable.setHitPolicy(HitPolicy.UNIQUE);
        dtable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW);
        final InputClause inputClause = new InputClause();
        final InputClauseLiteralExpression literalExpression = new InputClauseLiteralExpression();
        literalExpression.getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable));
        inputClause.setInputExpression(literalExpression);
        dtable.getInput().add(inputClause);
        final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause();
        ruleAnnotationClause.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable));
        dtable.getAnnotations().add(ruleAnnotationClause);
        final DecisionRule decisionRule = new DecisionRule();
        final UnaryTests decisionRuleUnaryTest = new UnaryTests();
        decisionRuleUnaryTest.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT);
        decisionRule.getInputEntry().add(decisionRuleUnaryTest);
        buildOutputClausesByDataType(hasExpression, dtable, decisionRule);
        final RuleAnnotationClauseText ruleAnnotationEntry = new RuleAnnotationClauseText();
        ruleAnnotationEntry.getText().setValue(DecisionTableDefaultValueUtilities.RULE_DESCRIPTION);
        decisionRule.getAnnotationEntry().add(ruleAnnotationEntry);
        dtable.getRule().add(decisionRule);
        // Setup parent relationships
        inputClause.setParent(dtable);
        decisionRule.setParent(dtable);
        literalExpression.setParent(inputClause);
        decisionRuleUnaryTest.setParent(decisionRule);
        ruleAnnotationEntry.setParent(dtable);
        if (nodeUUID.isPresent()) {
            enrichInputClauses(nodeUUID.get(), dtable);
        } else {
            enrichOutputClauses(dtable);
        }
    });
}
Also used : InputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression) RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule)

Example 7 with RuleAnnotationClause

use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.

the class RuleAnnotationClauseConverterTest method testWbFromDMNWhenIsNull.

@Test
public void testWbFromDMNWhenIsNull() {
    final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(null);
    assertNull(converted);
}
Also used : RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) Test(org.junit.Test)

Example 8 with RuleAnnotationClause

use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.

the class RuleAnnotationClauseConverterTest method testWbFromDMN.

@Test
public void testWbFromDMN() {
    final String name = "name";
    when(ruleAnnotationClause.getName()).thenReturn(name);
    final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(ruleAnnotationClause);
    assertEquals(name, converted.getName().getValue());
}
Also used : RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) Test(org.junit.Test)

Example 9 with RuleAnnotationClause

use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.

the class DecisionTableGrid method addRuleAnnotationClause.

void addRuleAnnotationClause(final int index) {
    getExpression().get().ifPresent(dtable -> {
        final RuleAnnotationClause clause = new RuleAnnotationClause();
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddRuleAnnotationClauseCommand(dtable, clause, model, () -> makeRuleAnnotationClauseColumn(index, clause), index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING), () -> resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM)));
    });
}
Also used : RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) AddRuleAnnotationClauseCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddRuleAnnotationClauseCommand)

Example 10 with RuleAnnotationClause

use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.

the class RuleAnnotationClauseConverter method wbFromDMN.

public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) {
    if (ruleAnnotationClause == null) {
        return null;
    }
    final RuleAnnotationClause rule = new RuleAnnotationClause();
    rule.setName(new Name(ruleAnnotationClause.getName()));
    return rule;
}
Also used : RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) TRuleAnnotationClause(org.kie.dmn.model.v1_2.TRuleAnnotationClause) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Aggregations

RuleAnnotationClause (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause)18 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)9 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)9 Test (org.junit.Test)8 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)8 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)5 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)4 JSITRuleAnnotationClause (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRuleAnnotationClause)3 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)3 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)3 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)3 Before (org.junit.Before)2 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)2 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)2 JSITDecisionRule (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionRule)2 JSITDecisionTable (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable)2 JSITInputClause (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause)2