Search in sources :

Example 6 with Relation

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

the class RelationPropertyConverter method dmnFromWB.

public static org.kie.dmn.model.v1_1.Relation dmnFromWB(final Relation wb) {
    org.kie.dmn.model.v1_1.Relation result = new org.kie.dmn.model.v1_1.Relation();
    result.setId(wb.getId().getValue());
    result.setDescription(wb.getDescription().getValue());
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (InformationItem iitem : wb.getColumn()) {
        org.kie.dmn.model.v1_1.InformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem);
        result.getColumn().add(iitemConverted);
    }
    for (org.kie.workbench.common.dmn.api.definition.v1_1.List list : wb.getRow()) {
        org.kie.dmn.model.v1_1.List listConverted = ListPropertyConverter.dmnFromWB(list);
        result.getRow().add(listConverted);
    }
    return result;
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation)

Example 7 with Relation

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

the class RelationGridTest method testDeleteColumn.

@Test
public void testDeleteColumn() throws Exception {
    relation.getColumn().add(new InformationItem());
    setupGrid(0);
    // Cannot delete column 0 since it is the RowNumber column. The first Relation column is 1.
    grid.deleteColumn(RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
    verify(sessionCommandManager).execute(eq(canvasHandler), deleteColumnCommand.capture());
    deleteColumnCommand.getValue().execute(canvasHandler);
    verify(parent).proposeContainingColumnWidth(grid.getWidth() + grid.getPadding() * 2);
    verify(parentGridColumn).setWidth(grid.getWidth() + grid.getPadding() * 2);
    verify(gridLayer).batch(any(GridLayerRedrawManager.PrioritizedCommand.class));
    verify(gridPanel).refreshScrollPosition();
    verify(gridPanel).updatePanelSize();
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Test(org.junit.Test)

Example 8 with Relation

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

the class RelationGridTest method testOnItemSelectedDeleteColumn.

@Test
public void testOnItemSelectedDeleteColumn() {
    relation.getColumn().add(new InformationItem());
    setupGrid(0);
    // Cannot delete column 0 since it is the RowNumber column. The first Relation column is 1.
    final java.util.List<HasListSelectorControl.ListSelectorItem> items = grid.getItems(0, RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
    final HasListSelectorControl.ListSelectorTextItem ti = (HasListSelectorControl.ListSelectorTextItem) items.get(DELETE_COLUMN);
    grid.onItemSelected(ti);
    verify(cellEditorControls).hide();
    verify(grid).deleteColumn(eq(1));
}
Also used : HasListSelectorControl(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Test(org.junit.Test)

Example 9 with Relation

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

the class RelationUIModelMapperHelperTest method testGetSectionInformationItemColumnIndexEqualToColumnCount.

@Test(expected = IllegalArgumentException.class)
public void testGetSectionInformationItemColumnIndexEqualToColumnCount() {
    relation.getColumn().add(new InformationItem());
    assertEquals(RelationSection.INFORMATION_ITEM, getInformationItemIndex(relation, relation.getColumn().size() + 1));
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Test(org.junit.Test)

Example 10 with Relation

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

the class RelationUIModelMapperHelperTest method testGetSectionInformationItemColumnNegativeIndex.

@Test(expected = IllegalArgumentException.class)
public void testGetSectionInformationItemColumnNegativeIndex() {
    relation.getColumn().add(new InformationItem());
    assertEquals(RelationSection.INFORMATION_ITEM, getInformationItemIndex(relation, -1));
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Test(org.junit.Test)

Aggregations

InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)18 Test (org.junit.Test)12 Relation (org.kie.workbench.common.dmn.api.definition.v1_1.Relation)12 Before (org.junit.Before)7 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)5 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)5 RelationUIModelMapper (org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapper)4 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)4 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)3 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)3 Relation (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.Relation)3 WebcertCertificateRelation (se.inera.intyg.webcert.common.model.WebcertCertificateRelation)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 InformationItem (org.kie.dmn.model.v1_1.InformationItem)2 Relation (org.kie.dmn.model.v1_1.Relation)2 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)2 Matchers.anyString (org.mockito.Matchers.anyString)2 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)2