use of org.kie.workbench.common.dmn.api.definition.v1_1.Expression 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);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Expression 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());
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Expression in project kie-wb-common by kiegroup.
the class InvocationUIModelMapper method toDMNModel.
@Override
@SuppressWarnings("unchecked")
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
dmnModel.get().ifPresent(invocation -> {
switch(columnIndex) {
case ROW_NUMBER_COLUMN_INDEX:
break;
case BINDING_PARAMETER_COLUMN_INDEX:
invocation.getBinding().get(rowIndex).getParameter().getName().setValue(cell.get().orElse(new BaseGridCellValue<>("")).getValue().toString());
break;
case BINDING_EXPRESSION_COLUMN_INDEX:
cell.get().ifPresent(v -> {
final ExpressionCellValue ecv = (ExpressionCellValue) v;
ecv.getValue().ifPresent(beg -> {
beg.getExpression().ifPresent(e -> invocation.getBinding().get(rowIndex).setExpression((Expression) e));
});
});
}
});
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Expression in project kie-wb-common by kiegroup.
the class InvocationPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.v1_1.Invocation dmnFromWB(final Invocation wb) {
if (wb == null) {
return null;
}
org.kie.dmn.model.v1_1.Invocation result = new org.kie.dmn.model.v1_1.Invocation();
result.setId(wb.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
org.kie.dmn.model.v1_1.Expression convertedExpression = ExpressionPropertyConverter.dmnFromWB(wb.getExpression());
result.setExpression(convertedExpression);
for (Binding b : wb.getBinding()) {
org.kie.dmn.model.v1_1.Binding bConverted = BindingPropertyConverter.dmnFromWB(b);
result.getBinding().add(bConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Expression in project kie-wb-common by kiegroup.
the class InvocationPropertyConverter method wbFromDMN.
public static Invocation wbFromDMN(final org.kie.dmn.model.v1_1.Invocation dmn) {
if (dmn == null) {
return null;
}
Id id = new Id(dmn.getId());
Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
Invocation result = new Invocation();
result.setId(id);
result.setDescription(description);
result.setTypeRef(typeRef);
Expression convertedExpression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression());
result.setExpression(convertedExpression);
for (org.kie.dmn.model.v1_1.Binding b : dmn.getBinding()) {
Binding bConverted = BindingPropertyConverter.wbFromDMN(b);
result.getBinding().add(bConverted);
}
return result;
}
Aggregations