use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class InvocationPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.Invocation dmnFromWB(final Invocation wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
if (wb == null) {
return null;
}
final org.kie.dmn.model.api.Invocation result = new org.kie.dmn.model.v1_2.TInvocation();
result.setId(wb.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
final org.kie.dmn.model.api.Expression convertedExpression = ExpressionPropertyConverter.dmnFromWB(wb.getExpression(), componentWidthsConsumer);
if (convertedExpression != null) {
convertedExpression.setParent(result);
}
result.setExpression(convertedExpression);
for (Binding b : wb.getBinding()) {
final org.kie.dmn.model.api.Binding bConverted = BindingPropertyConverter.dmnFromWB(b, componentWidthsConsumer);
if (bConverted != null) {
bConverted.setParent(result);
}
result.getBinding().add(bConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class InvocationPropertyConverter method wbFromDMN.
public static Invocation wbFromDMN(final org.kie.dmn.model.api.Invocation dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (dmn == null) {
return null;
}
final Id id = new Id(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn);
final Invocation result = new Invocation();
result.setId(id);
result.setDescription(description);
result.setTypeRef(typeRef);
final Expression convertedExpression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
result.setExpression(convertedExpression);
if (convertedExpression != null) {
convertedExpression.setParent(result);
}
for (org.kie.dmn.model.api.Binding b : dmn.getBinding()) {
final Binding bConverted = BindingPropertyConverter.wbFromDMN(b, hasComponentWidthsConsumer);
if (bConverted != null) {
bConverted.setParent(result);
}
result.getBinding().add(bConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class InvocationDefaultValueUtilitiesTest method testGetNewParameterNameWithDeletion.
@Test
public void testGetNewParameterNameWithDeletion() {
final Binding binding1 = new Binding() {
{
setParameter(new InformationItem());
}
};
invocation.getBinding().add(binding1);
binding1.getParameter().getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
assertThat(binding1.getParameter().getName().getValue()).isEqualTo(InvocationDefaultValueUtilities.PREFIX + "1");
final Binding binding2 = new Binding() {
{
setParameter(new InformationItem());
}
};
invocation.getBinding().add(binding2);
binding2.getParameter().getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
assertThat(binding2.getParameter().getName().getValue()).isEqualTo(InvocationDefaultValueUtilities.PREFIX + "2");
invocation.getBinding().remove(binding1);
final Binding binding3 = new Binding() {
{
setParameter(new InformationItem());
}
};
invocation.getBinding().add(binding3);
binding3.getParameter().getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
assertThat(binding3.getParameter().getName().getValue()).isEqualTo(InvocationDefaultValueUtilities.PREFIX + "3");
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class InvocationPropertyConverter method dmnFromWB.
public static JSITInvocation dmnFromWB(final Invocation wb, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
if (Objects.isNull(wb)) {
return null;
}
final JSITInvocation result = new JSITInvocation();
result.setId(wb.getId().getValue());
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
description.ifPresent(result::setDescription);
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
final JSITExpression convertedExpression = ExpressionPropertyConverter.dmnFromWB(wb.getExpression(), componentWidthsConsumer);
result.setExpression(convertedExpression);
for (Binding b : wb.getBinding()) {
final JSITBinding bConverted = BindingPropertyConverter.dmnFromWB(b, componentWidthsConsumer);
result.addBinding(bConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class InvocationUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
dmnModel.get().ifPresent(invocation -> {
switch(columnIndex) {
case ROW_NUMBER_COLUMN_INDEX:
uiModel.get().setCell(rowIndex, columnIndex, () -> new InvocationGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
break;
case BINDING_PARAMETER_COLUMN_INDEX:
final InformationItem variable = invocation.getBinding().get(rowIndex).getParameter();
uiModel.get().setCell(rowIndex, columnIndex, () -> new InformationItemCell(() -> InformationItemCell.HasNameAndDataTypeCell.wrap(variable), listSelector));
break;
case BINDING_EXPRESSION_COLUMN_INDEX:
final Binding binding = invocation.getBinding().get(rowIndex);
final Optional<Expression> expression = Optional.ofNullable(binding.getExpression());
final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get();
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(ed -> {
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ed.getEditor(new GridCellTuple(rowIndex, columnIndex, gridWidget), Optional.empty(), binding, Optional.ofNullable(binding.getParameter()), isOnlyVisualChangeAllowed, nesting + 1);
uiModel.get().setCell(rowIndex, columnIndex, () -> new InvocationGridCell<>(new ExpressionCellValue(editor), listSelector));
});
}
});
}
Aggregations