Search in sources :

Example 26 with Relation

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

the class RelationEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    final Optional<Relation> expression = definition.getModelClass();
    final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
    assertThat(oEditor).isPresent();
    final GridWidget editor = oEditor.get();
    assertThat(editor).isInstanceOf(RelationGrid.class);
}
Also used : Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Test(org.junit.Test)

Example 27 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 testInitialiseUiColumns.

@Test
public void testInitialiseUiColumns() throws Exception {
    final String columnHeader = "first column";
    relation.getColumn().add(new InformationItem() {

        {
            getName().setValue(columnHeader);
        }
    });
    expression = Optional.of(relation);
    setupGrid(0);
    assertEquals(2, grid.getModel().getColumns().size());
    assertTrue(grid.getModel().getColumns().get(0) instanceof RowNumberColumn);
    assertEquals(columnHeader, grid.getModel().getColumns().get(1).getHeaderMetaData().get(0).getTitle());
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 28 with Relation

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

the class DeleteRelationColumnCommandTest method setup.

@Before
public void setup() {
    this.relation = new Relation();
    this.informationItem = new InformationItem();
    this.relation.getColumn().add(informationItem);
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiModelColumn);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiModelColumn).getIndex();
    this.uiModelMapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector);
}
Also used : RelationUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapper) Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 29 with Relation

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

the class RelationConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Relation r = (Relation) parent;
    for (InformationItem c : r.getColumn()) {
        writeChildrenNode(writer, context, c, COLUMN);
    }
    for (org.kie.dmn.model.v1_1.List row : r.getRow()) {
        writeChildrenNode(writer, context, row, ROW);
    }
}
Also used : Relation(org.kie.dmn.model.v1_1.Relation) InformationItem(org.kie.dmn.model.v1_1.InformationItem)

Example 30 with Relation

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

the class DMNEvaluatorCompiler method compileRelation.

private DMNExpressionEvaluator compileRelation(DMNCompilerContext ctx, DMNModelImpl model, DMNBaseNode node, String relationName, Relation expression) {
    Relation relationDef = expression;
    DMNRelationEvaluator relationEval = new DMNRelationEvaluator(node.getName(), node.getSource(), relationDef);
    for (InformationItem col : relationDef.getColumn()) {
        DMNCompilerHelper.checkVariableName(model, col, col.getName());
        relationEval.addColumn(col.getName());
    }
    for (org.kie.dmn.model.v1_1.List row : relationDef.getRow()) {
        java.util.List<DMNExpressionEvaluator> values = new ArrayList<>();
        for (Expression expr : row.getExpression()) {
            values.add(compileExpression(ctx, model, node, relationName, expr));
        }
        relationEval.addRow(values);
    }
    return relationEval;
}
Also used : Relation(org.kie.dmn.model.v1_1.Relation) DMNExpressionEvaluator(org.kie.dmn.core.api.DMNExpressionEvaluator) LiteralExpression(org.kie.dmn.model.v1_1.LiteralExpression) CompiledExpression(org.kie.dmn.feel.lang.CompiledExpression) Expression(org.kie.dmn.model.v1_1.Expression) DMNRelationEvaluator(org.kie.dmn.core.ast.DMNRelationEvaluator) ArrayList(java.util.ArrayList) InformationItem(org.kie.dmn.model.v1_1.InformationItem)

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