use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.
the class ContextUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
dmnModel.get().ifPresent(context -> {
final boolean isLastRow = isLastRow(rowIndex);
final ContextUIModelMapperHelper.ContextSection section = ContextUIModelMapperHelper.getSection(columnIndex);
switch(section) {
case ROW_INDEX:
if (!isLastRow) {
uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
} else {
uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new BaseGridCellValue<>((Integer) null)));
}
uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
break;
case NAME:
if (!isLastRow) {
final InformationItem variable = context.getContextEntry().get(rowIndex).getVariable();
uiModel.get().setCell(rowIndex, columnIndex, () -> new InformationItemNameCell(() -> variable, listSelector));
} else {
uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new BaseGridCellValue<>(DEFAULT_ROW_CAPTION)));
}
break;
case EXPRESSION:
final ContextEntry ce = context.getContextEntry().get(rowIndex);
final Optional<Expression> expression = Optional.ofNullable(ce.getExpression());
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(ed -> {
final Optional<BaseExpressionGrid> editor = ed.getEditor(new GridCellTuple(rowIndex, columnIndex, gridWidget), Optional.empty(), ce, expression, Optional.ofNullable(ce.getVariable()), nesting + 1);
if (!isLastRow) {
uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new ExpressionCellValue(editor), listSelector));
} else {
uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new ExpressionCellValue(editor)));
}
});
}
});
}
use of org.eclipse.bpmn2.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.eclipse.bpmn2.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;
}
use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.
the class ListPropertyConverter method wbFromDMN.
public static List wbFromDMN(final org.kie.dmn.model.v1_1.List dmn) {
Id id = new Id(dmn.getId());
Description description = new Description(dmn.getDescription());
QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
java.util.List<Expression> expression = new ArrayList<>();
for (org.kie.dmn.model.v1_1.Expression e : dmn.getExpression()) {
Expression eConverted = ExpressionPropertyConverter.wbFromDMN(e);
expression.add(eConverted);
}
List result = new List(id, description, typeRef, expression);
return result;
}
use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.
the class ListPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.v1_1.List dmnFromWB(final List wb) {
org.kie.dmn.model.v1_1.List result = new org.kie.dmn.model.v1_1.List();
result.setId(wb.getId().getValue());
result.setDescription(wb.getDescription().getValue());
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (Expression e : wb.getExpression()) {
org.kie.dmn.model.v1_1.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e);
result.getExpression().add(eConverted);
}
return result;
}
Aggregations