Search in sources :

Example 71 with LiteralExpression

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

the class FunctionEditorDefinition method enrich.

@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<FunctionDefinition> expression) {
    expression.ifPresent(function -> {
        KindUtilities.setKind(function, FunctionDefinition.Kind.FEEL);
        final LiteralExpression le = new LiteralExpression();
        function.setExpression(le);
        le.setParent(function);
    });
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)

Example 72 with LiteralExpression

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

the class DecisionRulePropertyConverter method dmnFromWB.

public static org.kie.dmn.model.api.DecisionRule dmnFromWB(final DecisionRule wb) {
    final org.kie.dmn.model.api.DecisionRule result = new org.kie.dmn.model.v1_2.TDecisionRule();
    result.setId(wb.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    for (final RuleAnnotationClauseText ruleAnnotationClauseText : wb.getAnnotationEntry()) {
        final org.kie.dmn.model.api.RuleAnnotation ruleAnnotation = RuleAnnotationClauseTextConverter.dmnFromWB(ruleAnnotationClauseText);
        if (ruleAnnotation != null) {
            ruleAnnotation.setParent(result);
        }
        result.getAnnotationEntry().add(ruleAnnotation);
    }
    for (final UnaryTests ie : wb.getInputEntry()) {
        final org.kie.dmn.model.api.UnaryTests inputEntryConverted = UnaryTestsPropertyConverter.dmnFromWB(ie);
        if (inputEntryConverted != null) {
            inputEntryConverted.setParent(result);
        }
        result.getInputEntry().add(inputEntryConverted);
    }
    for (final LiteralExpression oe : wb.getOutputEntry()) {
        final org.kie.dmn.model.api.LiteralExpression outputEntryConverted = LiteralExpressionPropertyConverter.dmnFromWB(oe);
        if (outputEntryConverted != null) {
            outputEntryConverted.setParent(result);
        }
        result.getOutputEntry().add(outputEntryConverted);
    }
    return result;
}
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)

Example 73 with LiteralExpression

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

the class DecisionRulePropertyConverter method wbFromDMN.

public static DecisionRule wbFromDMN(final org.kie.dmn.model.api.DecisionRule dmn) {
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final DecisionRule result = new DecisionRule();
    result.setId(id);
    if (!(dmn instanceof org.kie.dmn.model.v1_1.TDecisionRule)) {
        for (final org.kie.dmn.model.api.RuleAnnotation ruleAnnotation : dmn.getAnnotationEntry()) {
            final RuleAnnotationClauseText annotationEntryConverted = RuleAnnotationClauseTextConverter.wbFromDMN(ruleAnnotation);
            if (annotationEntryConverted != null) {
                annotationEntryConverted.setParent(result);
            }
            result.getAnnotationEntry().add(annotationEntryConverted);
        }
    }
    if (result.getAnnotationEntry().isEmpty()) {
        // If it's empty, then there is none RuleAnnotation and the description was not converted yet to RuleAnnotation.
        final RuleAnnotationClauseText annotationEntryText = new RuleAnnotationClauseText();
        annotationEntryText.getText().setValue(description.getValue());
        annotationEntryText.setParent(result);
        result.getAnnotationEntry().add(annotationEntryText);
    }
    for (final org.kie.dmn.model.api.UnaryTests ie : dmn.getInputEntry()) {
        final UnaryTests inputEntryConverted = UnaryTestsPropertyConverter.wbFromDMN(ie);
        if (inputEntryConverted != null) {
            inputEntryConverted.setParent(result);
        }
        result.getInputEntry().add(inputEntryConverted);
    }
    for (final org.kie.dmn.model.api.LiteralExpression oe : dmn.getOutputEntry()) {
        final LiteralExpression outputEntryConverted = LiteralExpressionPropertyConverter.wbFromDMN(oe);
        if (outputEntryConverted != null) {
            outputEntryConverted.setParent(result);
        }
        result.getOutputEntry().add(outputEntryConverted);
    }
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests)

Example 74 with LiteralExpression

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

the class FunctionDefinitionPropertyConverter method convertContextEntryExpression.

private static void convertContextEntryExpression(final ContextEntry contextEntry) {
    final Expression expression = contextEntry.getExpression();
    if (expression instanceof LiteralExpression) {
        final LiteralExpression le = (LiteralExpression) expression;
        final String variableName = contextEntry.getVariable().getName().getValue();
        if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, variableName)) {
            contextEntry.setExpression(convertLiteralExpressionToPMMLDocument(le));
        } else if (Objects.equals(LiteralExpressionPMMLDocumentModel.VARIABLE_MODEL, variableName)) {
            contextEntry.setExpression(convertLiteralExpressionToPMMLDocumentModel(le));
        }
    }
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)

Example 75 with LiteralExpression

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

the class ExpressionPropertyConverter method wbFromDMN.

public static Expression wbFromDMN(final org.kie.dmn.model.api.Expression dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    if (dmn instanceof org.kie.dmn.model.api.LiteralExpression) {
        final LiteralExpression e = LiteralExpressionPropertyConverter.wbFromDMN((org.kie.dmn.model.api.LiteralExpression) dmn);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (dmn instanceof org.kie.dmn.model.api.Context) {
        final Context e = ContextPropertyConverter.wbFromDMN((org.kie.dmn.model.api.Context) dmn, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (dmn instanceof org.kie.dmn.model.api.Relation) {
        final Relation e = RelationPropertyConverter.wbFromDMN((org.kie.dmn.model.api.Relation) dmn, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (dmn instanceof org.kie.dmn.model.api.List) {
        final List e = ListPropertyConverter.wbFromDMN((org.kie.dmn.model.api.List) dmn, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (dmn instanceof org.kie.dmn.model.api.Invocation) {
        final Invocation e = InvocationPropertyConverter.wbFromDMN((org.kie.dmn.model.api.Invocation) dmn, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (dmn instanceof org.kie.dmn.model.api.FunctionDefinition) {
        final FunctionDefinition e = FunctionDefinitionPropertyConverter.wbFromDMN((org.kie.dmn.model.api.FunctionDefinition) dmn, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (dmn instanceof org.kie.dmn.model.api.DecisionTable) {
        final DecisionTable e = DecisionTablePropertyConverter.wbFromDMN((org.kie.dmn.model.api.DecisionTable) dmn);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    }
    return null;
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) IsLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) List(org.kie.workbench.common.dmn.api.definition.model.List) ArrayList(java.util.ArrayList) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)

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