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 JSITInvocation dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (Objects.isNull(dmn)) {
return null;
}
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
final Invocation result = new Invocation();
result.setId(id);
result.setDescription(description);
result.setTypeRef(typeRef);
Expression expression = null;
final JSITExpression jsiWrapped = dmn.getExpression();
if (Objects.nonNull(jsiWrapped)) {
final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), hasComponentWidthsConsumer);
}
result.setExpression(expression);
if (Objects.nonNull(expression)) {
expression.setParent(result);
}
final List<JSITBinding> jsiBindings = dmn.getBinding();
for (int i = 0; i < jsiBindings.size(); i++) {
final JSITBinding jsiBinding = Js.uncheckedCast(jsiBindings.get(i));
final Binding bConverted = BindingPropertyConverter.wbFromDMN(jsiBinding, hasComponentWidthsConsumer);
if (Objects.nonNull(bConverted)) {
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 AddParameterBindingCommandTest method testGraphCommandUndoFromStart.
@Test
public void testGraphCommandUndoFromStart() {
final Binding firstBinding = new Binding();
final Binding secondBinding = new Binding();
invocation.getBinding().add(firstBinding);
invocation.getBinding().add(secondBinding);
makeCommand(0);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
// Add parameter and then undo
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
assertBindingDefinitions(firstBinding, secondBinding);
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class AddParameterBindingCommandTest method testGraphCommandExecuteInsertToFirstPlace.
@Test
public void testGraphCommandExecuteInsertToFirstPlace() {
final Binding firstBinding = new Binding();
final Binding secondBinding = new Binding();
invocation.getBinding().add(firstBinding);
invocation.getBinding().add(secondBinding);
makeCommand(0);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertBindingDefinitions(binding, firstBinding, secondBinding);
assertEquals(invocation, binding.getParent());
assertEquals(binding, binding.getParameter().getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class DeleteParameterBindingCommandTest method testGraphCommandExecuteRemoveFromMiddle.
@Test
public void testGraphCommandExecuteRemoveFromMiddle() {
final Binding firstBinding = new Binding();
final Binding lastBinding = new Binding();
invocation.getBinding().add(0, firstBinding);
invocation.getBinding().add(lastBinding);
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
Assertions.assertThat(invocation.getBinding()).containsExactly(firstBinding, lastBinding);
}
use of org.kie.workbench.common.dmn.api.definition.model.Binding in project kie-wb-common by kiegroup.
the class DeleteParameterBindingCommandTest method makeBinding.
private Binding makeBinding(final String bindingName) {
final Binding newBinding = new Binding();
final InformationItem parameter = new InformationItem();
parameter.setName(new Name(bindingName));
newBinding.setParameter(parameter);
return newBinding;
}
Aggregations