Search in sources :

Example 1 with JSITImportedValues

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;
}
Also used : LocationURI(org.kie.workbench.common.dmn.api.property.dmn.LocationURI) JSITImportedValues(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues) ImportedValues(org.kie.workbench.common.dmn.api.definition.model.ImportedValues) ExpressionLanguage(org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 2 with JSITImportedValues

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);
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) Test(org.junit.Test)

Example 3 with JSITImportedValues

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;
}
Also used : JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) IsLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) JSITImportedValues(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues)

Example 4 with JSITImportedValues

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;
}
Also used : JSITImportedValues(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues)

Aggregations

JSITImportedValues (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues)3 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)2 JSITLiteralExpression (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression)2 Test (org.junit.Test)1 ImportedValues (org.kie.workbench.common.dmn.api.definition.model.ImportedValues)1 IsLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression)1 ExpressionLanguage (org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage)1 LocationURI (org.kie.workbench.common.dmn.api.property.dmn.LocationURI)1 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)1