Search in sources :

Example 61 with InformationItem

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

the class BindingPropertyConverterTest method testDMNFromWB.

@Test
public void testDMNFromWB() {
    final Binding wb = new Binding();
    final InformationItem informationItem = new InformationItem();
    wb.setParameter(informationItem);
    final LiteralExpression literalExpression = new LiteralExpression();
    literalExpression.getComponentWidths().set(0, 200.0);
    literalExpression.getId().setValue(EXPRESSION_UUID);
    wb.setExpression(literalExpression);
    final org.kie.dmn.model.api.Binding dmn = BindingPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
    assertThat(dmn).isNotNull();
    assertThat(dmn.getParameter()).isNotNull();
    assertThat(dmn.getExpression()).isNotNull();
    assertThat(dmn.getExpression().getId()).isEqualTo(EXPRESSION_UUID);
    verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
    final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
    assertThat(componentWidths).isNotNull();
    assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
    assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
    assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0);
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) TBinding(org.kie.dmn.model.v1_2.TBinding) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) ComponentWidths(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths) Test(org.junit.Test)

Example 62 with InformationItem

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

the class ContextEntryPropertyConverterTest method testDMNFromWBWithNullWBExpression.

@Test
public void testDMNFromWBWithNullWBExpression() {
    final ContextEntry wb = new ContextEntry();
    final InformationItem informationItem = new InformationItem();
    wb.setVariable(informationItem);
    wb.setExpression(null);
    final org.kie.dmn.model.api.ContextEntry dmn = ContextEntryPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
    assertThat(dmn).isNotNull();
    assertThat(dmn.getVariable()).isNotNull();
    assertThat(dmn.getExpression()).isNotNull();
    assertThat(dmn.getExpression()).isInstanceOf(org.kie.dmn.model.api.LiteralExpression.class);
    final org.kie.dmn.model.api.LiteralExpression literalExpression = (org.kie.dmn.model.api.LiteralExpression) dmn.getExpression();
    assertThat(literalExpression.getText()).isEqualTo(ContextEntry.DEFAULT_EXPRESSION_VALUE);
}
Also used : TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) TContextEntry(org.kie.dmn.model.v1_2.TContextEntry) Test(org.junit.Test)

Example 63 with InformationItem

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

the class RelationGrid method doAfterHeaderSelectionChange.

@Override
public void doAfterHeaderSelectionChange(final int uiHeaderRowIndex, final int uiHeaderColumnIndex) {
    if (getExpression().get().isPresent()) {
        final Relation relation = getExpression().get().get();
        final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, uiHeaderColumnIndex);
        if (section == RelationUIModelMapperHelper.RelationSection.INFORMATION_ITEM) {
            final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, uiHeaderColumnIndex);
            final InformationItem domainObject = relation.getColumn().get(iiIndex);
            fireDomainObjectSelectionEvent(domainObject);
            return;
        }
    }
    super.doAfterHeaderSelectionChange(uiHeaderRowIndex, uiHeaderColumnIndex);
}
Also used : Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem)

Example 64 with InformationItem

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

the class RelationEditorDefinition method enrich.

@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<Relation> expression) {
    expression.ifPresent(relation -> {
        final InformationItem column = new InformationItem();
        column.getName().setValue(RelationDefaultValueUtilities.getNewColumnName(relation));
        final org.kie.workbench.common.dmn.api.definition.model.List row = new org.kie.workbench.common.dmn.api.definition.model.List();
        final LiteralExpression literalExpression = new LiteralExpression();
        row.getExpression().add(HasExpression.wrap(relation, literalExpression));
        relation.getColumn().add(column);
        relation.getRow().add(row);
        // Setup parent relationships
        column.setParent(relation);
        row.setParent(relation);
        literalExpression.setParent(row);
    });
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem)

Example 65 with InformationItem

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

the class RelationPropertyConverterTest method testDMNFromWB.

@Test
public void testDMNFromWB() {
    final Relation wb = new Relation();
    final InformationItem informationItem = new InformationItem();
    final List list = new List();
    final LiteralExpression literalExpression = new LiteralExpression();
    final HasExpression hasExpression = HasExpression.wrap(wb, literalExpression);
    literalExpression.getComponentWidths().set(0, 200.0);
    literalExpression.getId().setValue(EXPRESSION_UUID);
    list.getExpression().add(hasExpression);
    wb.getId().setValue(RELATION_UUID);
    wb.getDescription().setValue(RELATION_DESCRIPTION);
    wb.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(org.kie.workbench.common.dmn.api.property.dmn.QName.NULL_NS_URI, RELATION_QNAME_LOCALPART));
    wb.getColumn().add(informationItem);
    wb.getRow().add(list);
    final org.kie.dmn.model.api.Relation dmn = RelationPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
    assertThat(dmn).isNotNull();
    assertThat(dmn.getId()).isNotNull();
    assertThat(dmn.getId()).isEqualTo(RELATION_UUID);
    assertThat(dmn.getDescription()).isNotNull();
    assertThat(dmn.getDescription()).isEqualTo(RELATION_DESCRIPTION);
    assertThat(dmn.getTypeRef()).isNotNull();
    assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(RELATION_QNAME_LOCALPART);
    assertThat(dmn.getColumn()).isNotNull();
    assertThat(dmn.getColumn().size()).isEqualTo(1);
    assertThat(dmn.getColumn().get(0)).isNotNull();
    assertThat(dmn.getRow()).isNotNull();
    assertThat(dmn.getRow().size()).isEqualTo(1);
    assertThat(dmn.getRow().get(0)).isNotNull();
    assertThat(dmn.getRow().get(0).getExpression()).isNotNull();
    assertThat(dmn.getRow().get(0).getExpression().size()).isEqualTo(1);
    assertThat(dmn.getRow().get(0).getExpression().get(0).getId()).isEqualTo(EXPRESSION_UUID);
    verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
    final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
    assertThat(componentWidths).isNotNull();
    assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
    assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
    assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) TRelation(org.kie.dmn.model.v1_2.TRelation) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) List(org.kie.workbench.common.dmn.api.definition.model.List) TList(org.kie.dmn.model.v1_2.TList) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) ComponentWidths(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths) Test(org.junit.Test)

Aggregations

InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)110 Test (org.junit.Test)61 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)24 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)22 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)22 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)20 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)19 Binding (org.kie.workbench.common.dmn.api.definition.model.Binding)13 Context (org.kie.workbench.common.dmn.api.definition.model.Context)11 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)11 Before (org.junit.Before)10 List (org.kie.workbench.common.dmn.api.definition.model.List)10 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)10 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)9 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)9 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)9 HasName (org.kie.workbench.common.dmn.api.definition.HasName)7 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)7 JSITInformationItem (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem)7