use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues in project kie-wb-common by kiegroup.
the class ImportedValuesConverter method wbFromDMN.
public static ImportedValues wbFromDMN(final JSITImportedValues dmn) {
if (Objects.isNull(dmn)) {
return null;
}
final String namespace = dmn.getNamespace();
final LocationURI locationURI = new LocationURI(dmn.getLocationURI());
final String importType = dmn.getImportType();
final String importedElement = dmn.getImportedElement();
final ExpressionLanguage expressionLanguage = ExpressionLanguagePropertyConverter.wbFromDMN(dmn.getExpressionLanguage());
final ImportedValues wb = new ImportedValues(namespace, locationURI, importType, importedElement, expressionLanguage);
final String name = dmn.getName();
final String description = dmn.getDescription();
wb.setId(IdPropertyConverter.wbFromDMN(dmn.getId()));
wb.setName(new Name(Objects.nonNull(name) ? name : wb.getId().getValue()));
wb.setDescription(DescriptionPropertyConverter.wbFromDMN(description));
return wb;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues in project kie-wb-common by kiegroup.
the class LiteralExpressionPropertyConverterTest method testWBFromDMN.
@Test
public void testWBFromDMN() {
when(literalExpression.getId()).thenReturn(UUID);
when(literalExpression.getDescription()).thenReturn(DESCRIPTION);
when(literalExpression.getTypeRef()).thenReturn(TYPE_REF);
when(literalExpression.getText()).thenReturn(TEXT);
when(literalExpression.getExpressionLanguage()).thenReturn(EXPRESSION_LANGUAGE);
when(literalExpression.getImportedValues()).thenReturn(jsitImportedValues);
when(jsitImportedValues.getImportedElement()).thenReturn(IMPORTED_ELEMENT);
final LiteralExpression result = LiteralExpressionPropertyConverter.wbFromDMN(literalExpression);
assertThat(result.getId().getValue()).isEqualTo(UUID);
assertThat(result.getDescription().getValue()).isEqualTo(DESCRIPTION);
assertThat(result.getTypeRef().getNamespaceURI()).isEmpty();
assertThat(result.getTypeRef().getLocalPart()).isEqualTo(TYPE_REF);
assertThat(result.getText().getValue()).isEqualTo(TEXT);
assertThat(result.getExpressionLanguage().getValue()).isEqualTo(EXPRESSION_LANGUAGE);
assertThat(result.getImportedValues().getImportedElement()).isEqualTo(IMPORTED_ELEMENT);
assertThat(result.getImportedValues().getParent()).isEqualTo(result);
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues in project kie-wb-common by kiegroup.
the class LiteralExpressionPropertyConverter method dmnFromWB.
public static JSITLiteralExpression dmnFromWB(final IsLiteralExpression wb) {
if (Objects.isNull(wb)) {
return null;
}
final JSITLiteralExpression result = LITERAL_EXPRESSION_PROVIDER.make();
result.setId(wb.getId().getValue());
final String description = wb.getDescription().getValue();
if (StringUtils.nonEmpty(description)) {
result.setDescription(description);
}
if (wb instanceof LiteralExpression) {
final String expressionLanguage = ((LiteralExpression) wb).getExpressionLanguage().getValue();
if (StringUtils.nonEmpty(expressionLanguage)) {
result.setExpressionLanguage(expressionLanguage);
}
}
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
result.setText(wb.getText().getValue());
final JSITImportedValues importedValues = ImportedValuesConverter.dmnFromWB(wb.getImportedValues());
if (Objects.nonNull(importedValues)) {
result.setImportedValues(importedValues);
}
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues in project kie-wb-common by kiegroup.
the class ImportedValuesConverter method dmnFromWB.
public static JSITImportedValues dmnFromWB(final ImportedValues wb) {
if (Objects.isNull(wb)) {
return null;
}
final JSITImportedValues dmn = new JSITImportedValues();
dmn.setNamespace(wb.getNamespace());
dmn.setLocationURI(wb.getLocationURI().getValue());
dmn.setImportType(wb.getImportType());
dmn.setImportedElement(wb.getImportedElement());
dmn.setId(wb.getId().getValue());
dmn.setName(wb.getName().getValue());
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
description.ifPresent(dmn::setDescription);
dmn.setExpressionLanguage(ExpressionLanguagePropertyConverter.dmnFromWB(wb.getExpressionLanguage()));
return dmn;
}
Aggregations