use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class ContextEntryPropertyConverter method wbFromDMN.
public static ContextEntry wbFromDMN(final org.kie.dmn.model.api.ContextEntry dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
final InformationItem variable = InformationItemPropertyConverter.wbFromDMN(dmn.getVariable());
final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
final ContextEntry result = new ContextEntry();
if (Objects.nonNull(variable)) {
variable.setParent(result);
}
result.setVariable(variable);
if (Objects.nonNull(expression)) {
expression.setParent(result);
}
result.setExpression(expression);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverter method wbFromDMN.
public static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition 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 Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression);
if (expression != null) {
expression.setParent(result);
}
final FunctionKind kind = dmn.getKind();
switch(kind) {
case FEEL:
result.setKind(Kind.FEEL);
break;
case JAVA:
result.setKind(Kind.JAVA);
break;
case PMML:
result.setKind(Kind.PMML);
convertPMMLFunctionExpression(result);
break;
default:
result.setKind(Kind.FEEL);
break;
}
for (org.kie.dmn.model.api.InformationItem ii : dmn.getFormalParameter()) {
final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(ii);
if (iiConverted != null) {
iiConverted.setParent(result);
}
result.getFormalParameter().add(iiConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.FunctionDefinition dmnFromWB(final FunctionDefinition wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
if (wb == null) {
return null;
}
final org.kie.dmn.model.api.FunctionDefinition result = new org.kie.dmn.model.v1_2.TFunctionDefinition();
result.setId(wb.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
result.setExpression(ExpressionPropertyConverter.dmnFromWB(wb.getExpression(), componentWidthsConsumer));
final Kind kind = wb.getKind();
switch(kind) {
case FEEL:
result.setKind(FunctionKind.FEEL);
break;
case JAVA:
result.setKind(FunctionKind.JAVA);
break;
case PMML:
result.setKind(FunctionKind.PMML);
break;
default:
result.setKind(FunctionKind.FEEL);
break;
}
for (InformationItem ii : wb.getFormalParameter()) {
final org.kie.dmn.model.api.InformationItem iiConverted = InformationItemPropertyConverter.dmnFromWB(ii);
if (iiConverted != null) {
iiConverted.setParent(result);
}
result.getFormalParameter().add(iiConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class FunctionDefaultValueUtilitiesTest method testGetNewParameterName.
@Test
public void testGetNewParameterName() {
final InformationItem informationItem1 = new InformationItem();
function.getFormalParameter().add(informationItem1);
informationItem1.getName().setValue(FunctionDefaultValueUtilities.getNewParameterName(function));
assertThat(informationItem1.getName().getValue()).isEqualTo(FunctionDefaultValueUtilities.PREFIX + "1");
final InformationItem informationItem2 = new InformationItem();
function.getFormalParameter().add(informationItem2);
informationItem2.getName().setValue(FunctionDefaultValueUtilities.getNewParameterName(function));
assertThat(informationItem2.getName().getValue()).isEqualTo(FunctionDefaultValueUtilities.PREFIX + "2");
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class InformationItemCellInformationItemTest method testHasNameAndDataTypeCellGetHasTypeRefs.
@Test
public void testHasNameAndDataTypeCellGetHasTypeRefs() {
final InformationItem informationItem = mock(InformationItem.class);
final HasNameAndDataTypeCell hasNameAndDataTypeCell = HasNameAndDataTypeCell.wrap(informationItem);
final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class);
final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class);
final List<HasTypeRef> expectedHasTypeRefs = asList(hasTypeRef1, hasTypeRef2);
when(informationItem.getHasTypeRefs()).thenReturn(expectedHasTypeRefs);
final List<HasTypeRef> actualHasTypeRefs = hasNameAndDataTypeCell.getHasTypeRefs();
assertEquals(expectedHasTypeRefs, actualHasTypeRefs);
}
Aggregations