use of org.kie.workbench.common.dmn.api.definition.model.Invocation 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.Invocation in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.Expression dmnFromWB(final Expression wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
if (Objects.isNull(wb)) {
return null;
}
final String uuid = wb.getId().getValue();
if (Objects.nonNull(uuid)) {
final ComponentWidths componentWidths = new ComponentWidths();
componentWidths.setDmnElementRef(new QName(uuid));
componentWidths.setWidths(new ArrayList<>(wb.getComponentWidths()));
componentWidthsConsumer.accept(componentWidths);
}
if (wb instanceof IsLiteralExpression) {
return LiteralExpressionPropertyConverter.dmnFromWB((IsLiteralExpression) wb);
} else if (wb instanceof Context) {
return ContextPropertyConverter.dmnFromWB((Context) wb, componentWidthsConsumer);
} else if (wb instanceof Relation) {
return RelationPropertyConverter.dmnFromWB((Relation) wb, componentWidthsConsumer);
} else if (wb instanceof List) {
return ListPropertyConverter.dmnFromWB((List) wb, componentWidthsConsumer);
} else if (wb instanceof Invocation) {
return InvocationPropertyConverter.dmnFromWB((Invocation) wb, componentWidthsConsumer);
} else if (wb instanceof FunctionDefinition) {
return FunctionDefinitionPropertyConverter.dmnFromWB((FunctionDefinition) wb, componentWidthsConsumer);
} else if (wb instanceof DecisionTable) {
return DecisionTablePropertyConverter.dmnFromWB((DecisionTable) wb);
}
return null;
}
use of org.kie.workbench.common.dmn.api.definition.model.Invocation in project kie-wb-common by kiegroup.
the class InvocationPropertyConverterTest method testWBFromDMN.
@Test
public void testWBFromDMN() {
final org.kie.dmn.model.api.Invocation dmn = new TInvocation();
final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
literalExpression.setId(EXPRESSION_UUID);
dmn.setId(INVOCATION_UUID);
dmn.setDescription(INVOCATION_DESCRIPTION);
dmn.setTypeRef(new QName(INVOCATION_QNAME_LOCALPART));
dmn.setExpression(literalExpression);
final Invocation wb = InvocationPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
assertThat(wb).isNotNull();
assertThat(wb.getId()).isNotNull();
assertThat(wb.getId().getValue()).isEqualTo(INVOCATION_UUID);
assertThat(wb.getDescription()).isNotNull();
assertThat(wb.getDescription().getValue()).isEqualTo(INVOCATION_DESCRIPTION);
assertThat(wb.getTypeRef()).isNotNull();
assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(INVOCATION_QNAME_LOCALPART);
assertThat(wb.getExpression()).isNotNull();
assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
assertThat(hasComponentWidths).isNotNull();
assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
use of org.kie.workbench.common.dmn.api.definition.model.Invocation in project kie-wb-common by kiegroup.
the class InvocationPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final Invocation wb = new Invocation();
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.getId().setValue(INVOCATION_UUID);
wb.getDescription().setValue(INVOCATION_DESCRIPTION);
wb.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(org.kie.workbench.common.dmn.api.property.dmn.QName.NULL_NS_URI, INVOCATION_QNAME_LOCALPART));
wb.setExpression(literalExpression);
final org.kie.dmn.model.api.Invocation dmn = InvocationPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getId()).isNotNull();
assertThat(dmn.getId()).isEqualTo(INVOCATION_UUID);
assertThat(dmn.getDescription()).isNotNull();
assertThat(dmn.getDescription()).isEqualTo(INVOCATION_DESCRIPTION);
assertThat(dmn.getTypeRef()).isNotNull();
assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(INVOCATION_QNAME_LOCALPART);
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().getId()).isEqualTo(EXPRESSION_UUID);
verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
assertThat(componentWidths).isNotNull();
assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0);
}
use of org.kie.workbench.common.dmn.api.definition.model.Invocation in project kie-wb-common by kiegroup.
the class DeleteParameterBindingCommandTest method setup.
@Before
public void setup() {
this.invocation = new Invocation();
this.binding = makeBinding("p" + invocation.getBinding().size());
this.invocation.getBinding().add(binding);
this.uiModel = new BaseGridData(false);
this.uiGridRow = new BaseGridRow();
this.uiModel.appendRow(uiGridRow);
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
}
Aggregations