Search in sources :

Example 1 with Relation

use of org.kie.workbench.common.dmn.api.definition.v1_1.Relation in project voltdb by VoltDB.

the class VoltDBOsmSink method process.

/**
     * {@inheritDoc}
     */
public void process(RelationContainer relationContainer) {
    Relation relation;
    int memberSequenceId;
    relation = relationContainer.getEntity();
    try {
        client.callProcedure(new InsertCallback(), INS_RELATIONS_PROC, relation.getId(), relation.getVersion(), relation.getUser().getId(), relation.getTimestamp(), relation.getChangesetId());
    } catch (NoConnectionsException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    memberSequenceId = 0;
    for (RelationMember member : relation.getMembers()) {
        try {
            client.callProcedure(new InsertCallback(), INS_RELATIONS_MEMBER_PROC, relation.getId(), member.getMemberId(), member.getMemberType().ordinal(), member.getMemberRole(), memberSequenceId);
        } catch (NoConnectionsException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        memberSequenceId++;
    }
    for (Tag tag : relation.getTags()) {
        try {
            client.callProcedure(new InsertCallback(), INS_RELATION_TAGS_PROC, relation.getId(), tag.getKey(), tag.getValue());
        } catch (NoConnectionsException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) NoConnectionsException(org.voltdb.client.NoConnectionsException) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) IOException(java.io.IOException) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 2 with Relation

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

the class RelationEditorDefinition method getModelClass.

@Override
public Optional<Relation> getModelClass() {
    final Relation relation = new Relation();
    final InformationItem column = new InformationItem();
    final org.kie.workbench.common.dmn.api.definition.v1_1.List row = new org.kie.workbench.common.dmn.api.definition.v1_1.List();
    row.getExpression().add(new LiteralExpression());
    relation.getColumn().add(column);
    relation.getRow().add(row);
    return Optional.of(relation);
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation)

Example 3 with Relation

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

the class RelationGrid method addColumn.

void addColumn(final int index) {
    expression.ifPresent(relation -> {
        final InformationItem informationItem = new InformationItem();
        informationItem.setName(new Name("Column"));
        final RelationColumn relationColumn = makeRelationColumn(informationItem);
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddRelationColumnCommand(relation, informationItem, model, relationColumn, index, uiModelMapper, () -> synchroniseViewWhenExpressionEditorChanged(this)));
    });
}
Also used : AddRelationColumnCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.relation.AddRelationColumnCommand) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) HasName(org.kie.workbench.common.dmn.api.definition.HasName)

Example 4 with Relation

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

the class RelationUIModelMapper method toDMNModel.

@Override
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
    dmnModel.get().ifPresent(relation -> {
        final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, columnIndex);
        switch(section) {
            case ROW_INDEX:
                break;
            case INFORMATION_ITEM:
                final org.kie.workbench.common.dmn.api.definition.v1_1.List row = relation.getRow().get(rowIndex);
                final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, columnIndex);
                final Expression e = row.getExpression().get(iiIndex);
                final Optional<Expression> expression = Optional.ofNullable(e);
                expression.ifPresent(ex -> {
                    // Whilst the DMN 1.1 specification allows for ANY expression to be used we have made the simplification
                    // to limit ourselves to LiteralExpressions. Our Grid-system supports ANY (nested) expression too; however
                    // the simplification has been made for the benefit of USERS.
                    final LiteralExpression le = (LiteralExpression) ex;
                    le.setText(cell.get().orElse(new BaseGridCellValue<>("")).getValue().toString());
                });
        }
    });
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Example 5 with Relation

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

the class RelationUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    dmnModel.get().ifPresent(relation -> {
        final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, columnIndex);
        switch(section) {
            case ROW_INDEX:
                uiModel.get().setCell(rowIndex, columnIndex, () -> new RelationGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
                uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
                break;
            case INFORMATION_ITEM:
                final org.kie.workbench.common.dmn.api.definition.v1_1.List row = relation.getRow().get(rowIndex);
                final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, columnIndex);
                final Expression e = row.getExpression().get(iiIndex);
                final Optional<Expression> expression = Optional.ofNullable(e);
                expression.ifPresent(ex -> {
                    // Whilst the DMN 1.1 specification allows for ANY expression to be used we have made the simplification
                    // to limit ourselves to LiteralExpressions. Our Grid-system supports ANY (nested) expression too; however
                    // the simplification has been made for the benefit of USERS.
                    final LiteralExpression le = (LiteralExpression) ex;
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new RelationGridCell<>(new BaseGridCellValue<>(le.getText()), listSelector));
                });
        }
    });
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

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