Search in sources :

Example 1 with Expression

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

the class ContextEntryPropertyConverter method wbFromDMN.

public static ContextEntry wbFromDMN(final org.kie.dmn.model.api.ContextEntry dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    final InformationItem variable = InformationItemPropertyConverter.wbFromDMN(dmn.getVariable());
    final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
    final ContextEntry result = new ContextEntry();
    if (Objects.nonNull(variable)) {
        variable.setParent(result);
    }
    result.setVariable(variable);
    if (Objects.nonNull(expression)) {
        expression.setParent(result);
    }
    result.setExpression(expression);
    return result;
}
Also used : Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Example 2 with Expression

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

the class DecisionConverter method nodeFromDMN.

@Override
public Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.api.Decision dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    @SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(Decision.class)).asNode();
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
    final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
    final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new StylingSet(), new GeneralRectangleDimensionsSet());
    decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion()));
    decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers()));
    node.getContent().setDefinition(decision);
    if (informationItem != null) {
        informationItem.setParent(decision);
    }
    if (expression != null) {
        expression.setParent(decision);
    }
    DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decision);
    return node;
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Node(org.kie.workbench.common.stunner.core.graph.Node) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) AllowedAnswers(org.kie.workbench.common.dmn.api.property.dmn.AllowedAnswers) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) Question(org.kie.workbench.common.dmn.api.property.dmn.Question) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)

Example 3 with Expression

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

the class FunctionDefinitionPropertyConverter method wbFromDMN.

public static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    if (dmn == null) {
        return null;
    }
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn);
    final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
    final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression);
    if (expression != null) {
        expression.setParent(result);
    }
    final FunctionKind kind = dmn.getKind();
    switch(kind) {
        case FEEL:
            result.setKind(Kind.FEEL);
            break;
        case JAVA:
            result.setKind(Kind.JAVA);
            break;
        case PMML:
            result.setKind(Kind.PMML);
            convertPMMLFunctionExpression(result);
            break;
        default:
            result.setKind(Kind.FEEL);
            break;
    }
    for (org.kie.dmn.model.api.InformationItem ii : dmn.getFormalParameter()) {
        final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(ii);
        if (iiConverted != null) {
            iiConverted.setParent(result);
        }
        result.getFormalParameter().add(iiConverted);
    }
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) FunctionKind(org.kie.dmn.model.api.FunctionKind)

Example 4 with Expression

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

the class ListPropertyConverter method dmnFromWB.

public static org.kie.dmn.model.api.List dmnFromWB(final List wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
    final org.kie.dmn.model.api.List result = new org.kie.dmn.model.v1_2.TList();
    result.setId(wb.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (HasExpression hasExpression : wb.getExpression()) {
        final Expression e = hasExpression.getExpression();
        final org.kie.dmn.model.api.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer);
        if (Objects.nonNull(eConverted)) {
            eConverted.setParent(result);
        }
        result.getExpression().add(eConverted);
    }
    return result;
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression)

Example 5 with Expression

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

the class ListPropertyConverter method wbFromDMN.

public static List wbFromDMN(final org.kie.dmn.model.api.List dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn);
    final java.util.List<HasExpression> expression = new ArrayList<>();
    final List result = new List(id, description, typeRef, expression);
    for (org.kie.dmn.model.api.Expression e : dmn.getExpression()) {
        final Expression eConverted = ExpressionPropertyConverter.wbFromDMN(e, hasComponentWidthsConsumer);
        final HasExpression hasExpression = HasExpression.wrap(result, eConverted);
        expression.add(hasExpression);
    }
    for (HasExpression hasExpression : expression) {
        final Expression e = hasExpression.getExpression();
        if (Objects.nonNull(e)) {
            e.setParent(result);
        }
    }
    return result;
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ArrayList(java.util.ArrayList) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) List(org.kie.workbench.common.dmn.api.definition.model.List) ArrayList(java.util.ArrayList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Aggregations

Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)75 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)41 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)29 Test (org.junit.Test)27 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)26 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)26 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)25 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)14 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)14 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)12 View (org.kie.workbench.common.stunner.core.graph.content.view.View)12 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)11 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)9 ArrayList (java.util.ArrayList)8 Context (org.kie.workbench.common.dmn.api.definition.model.Context)8 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)8 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)7 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)7 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)7