Search in sources :

Example 66 with LiteralExpression

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

the class DecisionTableEditorDefinitionEnricher method enrichOutputClauses.

void enrichOutputClauses(final DecisionTable dtable) {
    if (dtable.getParent() instanceof ContextEntry && dtable.getOutput().isEmpty()) {
        final ContextEntry contextEntry = (ContextEntry) dtable.getParent();
        final OutputClause outputClause = new OutputClause();
        outputClause.setName(getOutputClauseName(contextEntry).orElse(DecisionTableDefaultValueUtilities.getNewOutputClauseName(dtable)));
        outputClause.setTypeRef(getOutputClauseTypeRef(contextEntry).orElse(BuiltInType.UNDEFINED.asQName()));
        dtable.getOutput().add(outputClause);
        dtable.getRule().stream().forEach(decisionRule -> {
            final LiteralExpression decisionRuleLiteralExpression = new LiteralExpression();
            decisionRuleLiteralExpression.getText().setValue(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT);
            decisionRule.getOutputEntry().add(decisionRuleLiteralExpression);
            decisionRuleLiteralExpression.setParent(decisionRule);
        });
        outputClause.setParent(dtable);
    }
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Example 67 with LiteralExpression

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

the class DecisionTableEditorDefinitionEnricher method populateOutputEntries.

private void populateOutputEntries(final DecisionRule decisionRule) {
    final LiteralExpression decisionRuleLiteralExpression = new LiteralExpression();
    decisionRuleLiteralExpression.getText().setValue(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT);
    decisionRuleLiteralExpression.setParent(decisionRule);
    decisionRule.getOutputEntry().add(decisionRuleLiteralExpression);
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression)

Example 68 with LiteralExpression

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

the class DecisionRuleFactory method duplicateDecisionRule.

public static DecisionRule duplicateDecisionRule(final int index, final DecisionTable dtable) {
    final DecisionRule rule = new DecisionRule();
    final DecisionRule source = dtable.getRule().get(index);
    for (UnaryTests ie : source.getInputEntry()) {
        final UnaryTests ut = new UnaryTests();
        ut.getText().setValue(ie.getText().getValue());
        ut.setConstraintType(ie.getConstraintType());
        rule.getInputEntry().add(ut);
        ut.setParent(rule);
    }
    for (LiteralExpression oe : source.getOutputEntry()) {
        final LiteralExpression le = new LiteralExpression();
        le.getText().setValue(oe.getText().getValue());
        rule.getOutputEntry().add(le);
        le.setParent(rule);
    }
    for (final RuleAnnotationClauseText text : source.getAnnotationEntry()) {
        final RuleAnnotationClauseText copy = new RuleAnnotationClauseText();
        copy.getText().setValue(text.getText().getValue());
        copy.setParent(rule);
        rule.getAnnotationEntry().add(copy);
    }
    rule.setParent(dtable);
    return rule;
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule)

Example 69 with LiteralExpression

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

the class InvocationEditorDefinition method enrich.

@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<Invocation> expression) {
    expression.ifPresent(invocation -> {
        final LiteralExpression literalExpression = new LiteralExpression();
        invocation.setExpression(literalExpression);
        final InformationItem parameter = new InformationItem();
        parameter.getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
        final Binding binding = new Binding();
        binding.setParameter(parameter);
        invocation.getBinding().add(binding);
        // Setup parent relationships
        literalExpression.setParent(invocation);
        binding.setParent(invocation);
        parameter.setParent(binding);
    });
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem)

Example 70 with LiteralExpression

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

the class DecisionTableGrid method doAfterSelectionChange.

@Override
public void doAfterSelectionChange(final int uiRowIndex, final int uiColumnIndex) {
    if (hasAnyHeaderCellSelected() || hasMultipleCellsSelected()) {
        super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
        return;
    }
    if (getExpression().get().isPresent()) {
        final DecisionTable dtable = getExpression().get().get();
        final DecisionTableUIModelMapperHelper.DecisionTableSection section = DecisionTableUIModelMapperHelper.getSection(dtable, uiColumnIndex);
        switch(section) {
            case INPUT_CLAUSES:
                final int icIndex = DecisionTableUIModelMapperHelper.getInputEntryIndex(dtable, uiColumnIndex);
                final UnaryTests unaryTests = dtable.getRule().get(uiRowIndex).getInputEntry().get(icIndex);
                fireDomainObjectSelectionEvent(unaryTests);
                return;
            case OUTPUT_CLAUSES:
                final int ocIndex = DecisionTableUIModelMapperHelper.getOutputEntryIndex(dtable, uiColumnIndex);
                final LiteralExpression literalExpression = dtable.getRule().get(uiRowIndex).getOutputEntry().get(ocIndex);
                fireDomainObjectSelectionEvent(literalExpression);
                return;
        }
    }
    super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests)

Aggregations

LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)113 Test (org.junit.Test)64 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)25 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)25 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)23 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)21 List (org.kie.workbench.common.dmn.api.definition.model.List)20 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)16 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)15 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)14 Before (org.junit.Before)13 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)12 Optional (java.util.Optional)11 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)11 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)11 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)11 Context (org.kie.workbench.common.dmn.api.definition.model.Context)10 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)10 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)9 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)9