Search in sources :

Example 56 with Expression

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

the class FunctionDefinitionPropertyConverter method convertPMMLFunctionExpression.

private static void convertPMMLFunctionExpression(final FunctionDefinition function) {
    final Expression expression = function.getExpression();
    if (expression instanceof Context) {
        final Context context = (Context) expression;
        context.getContextEntry().forEach(FunctionDefinitionPropertyConverter::convertContextEntryExpression);
    }
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression)

Example 57 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 JSITList dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    final java.util.List<HasExpression> expression = new ArrayList<>();
    final List result = new List(id, description, typeRef, expression);
    final java.util.List<JSITExpression> jsiExpressions = dmn.getExpression();
    for (int i = 0; i < jsiExpressions.size(); i++) {
        final JSITExpression jsitExpression = Js.uncheckedCast(jsiExpressions.get(i));
        final Expression eConverted = ExpressionPropertyConverter.wbFromDMN(jsitExpression, Js.uncheckedCast(dmn), 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) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ArrayList(java.util.ArrayList) List(org.kie.workbench.common.dmn.api.definition.model.List) ArrayList(java.util.ArrayList) JSITList(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)

Example 58 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 JSITList dmnFromWB(final List wb, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
    final JSITList result = new JSITList();
    result.setId(wb.getId().getValue());
    final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    description.ifPresent(result::setDescription);
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (HasExpression hasExpression : wb.getExpression()) {
        final Expression e = hasExpression.getExpression();
        final JSITExpression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer);
        result.addExpression(eConverted);
    }
    return result;
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) JSITList(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITList) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)

Example 59 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 NodeEntry nodeEntry) {
    final JSITDecision dmn = Js.uncheckedCast(nodeEntry.getDmnElement());
    @SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(nodeEntry.getId(), getDefinitionId(Decision.class)).asNode();
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
    Expression expression = null;
    final JSITExpression jsiWrapped = dmn.getExpression();
    if (Objects.nonNull(jsiWrapped)) {
        final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
        expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), nodeEntry.getComponentWidthsConsumer());
    }
    final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new StylingSet(), new GeneralRectangleDimensionsSet());
    decision.setDiagramId(nodeEntry.getDiagramId());
    decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion()));
    decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers()));
    node.getContent().setDefinition(decision);
    if (Objects.nonNull(informationItem)) {
        informationItem.setParent(decision);
    }
    if (Objects.nonNull(expression)) {
        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) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) 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) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) 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) IdUtils.getRawId(org.kie.workbench.common.dmn.client.marshaller.common.IdUtils.getRawId) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)

Example 60 with Expression

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

the class DecisionNavigatorNestedItemFactoryTest method testGetUUID.

@Test
public void testGetUUID() {
    final Expression expression = mock(Expression.class);
    final Id id = mock(Id.class);
    final String expectedUUID = "uuid";
    when(boxedExpressionHelper.getExpression(node)).thenReturn(expression);
    when(expression.getId()).thenReturn(id);
    when(id.getValue()).thenReturn(expectedUUID);
    final String actualUUID = factory.getUUID(node);
    assertEquals(expectedUUID, actualUUID);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Test(org.junit.Test)

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