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();
}
}
}
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);
}
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)));
});
}
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());
});
}
});
}
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));
});
}
});
}
Aggregations