Search in sources :

Example 1 with ExpressionLanguage

use of org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage in project kie-wb-common by kiegroup.

the class ImportedValuesConverter method wbFromDMN.

public static ImportedValues wbFromDMN(final org.kie.dmn.model.api.ImportedValues dmn) {
    if (dmn == null) {
        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 id = dmn.getId();
    final String name = dmn.getName();
    final String description = dmn.getDescription();
    final String fallbackUUID = UUID.randomUUID().toString();
    wb.setId(new Id(id != null ? id : fallbackUUID));
    wb.setName(new Name(name != null ? name : fallbackUUID));
    wb.setDescription(DescriptionPropertyConverter.wbFromDMN(description));
    return wb;
}
Also used : LocationURI(org.kie.workbench.common.dmn.api.property.dmn.LocationURI) ImportedValues(org.kie.workbench.common.dmn.api.definition.model.ImportedValues) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) ExpressionLanguage(org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 2 with ExpressionLanguage

use of org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage in project kie-wb-common by kiegroup.

the class UnaryTestsPropertyConverter method wbFromDMN.

public static UnaryTests wbFromDMN(final org.kie.dmn.model.api.UnaryTests dmn) {
    if (dmn == null) {
        return null;
    }
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final ExpressionLanguage expressionLanguage = ExpressionLanguagePropertyConverter.wbFromDMN(dmn.getExpressionLanguage());
    final ConstraintType constraintTypeField;
    final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
    if (dmn.getAdditionalAttributes().containsKey(key)) {
        constraintTypeField = ConstraintTypeFieldPropertyConverter.wbFromDMN(dmn.getAdditionalAttributes().get(key));
    } else {
        constraintTypeField = NONE;
    }
    final UnaryTests result = new UnaryTests(id, description, new Text(dmn.getText()), expressionLanguage, constraintTypeField);
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(javax.xml.namespace.QName) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) ExpressionLanguage(org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) IsUnaryTests(org.kie.workbench.common.dmn.api.definition.model.IsUnaryTests)

Example 3 with ExpressionLanguage

use of org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage in project kie-wb-common by kiegroup.

the class LiteralExpressionPropertyConverter method wbFromDMN.

public static LiteralExpression wbFromDMN(final org.kie.dmn.model.api.LiteralExpression dmn) {
    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 Text text = new Text(dmn.getText() != null ? dmn.getText() : "");
    final ExpressionLanguage expressionLanguage = ExpressionLanguagePropertyConverter.wbFromDMN(dmn.getExpressionLanguage());
    final ImportedValues importedValues = ImportedValuesConverter.wbFromDMN(dmn.getImportedValues());
    final LiteralExpression result = new LiteralExpression(id, description, typeRef, text, importedValues, expressionLanguage);
    if (importedValues != null) {
        importedValues.setParent(result);
    }
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ImportedValues(org.kie.workbench.common.dmn.api.definition.model.ImportedValues) IsLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) ExpressionLanguage(org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage)

Example 4 with ExpressionLanguage

use of org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage 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 5 with ExpressionLanguage

use of org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage in project kie-wb-common by kiegroup.

the class UnaryTestsPropertyConverter method wbFromDMN.

public static UnaryTests wbFromDMN(final JSITUnaryTests dmn) {
    if (Objects.isNull(dmn)) {
        return null;
    }
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final ExpressionLanguage expressionLanguage = ExpressionLanguagePropertyConverter.wbFromDMN(dmn.getExpressionLanguage());
    final ConstraintType constraintTypeField;
    final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
    final Map<QName, String> otherAttributes = JSITUnaryTests.getOtherAttributesMap(dmn);
    if (otherAttributes.containsKey(key)) {
        constraintTypeField = ConstraintTypeFieldPropertyConverter.wbFromDMN(otherAttributes.get(key));
    } else {
        constraintTypeField = NONE;
    }
    final UnaryTests result = new UnaryTests(id, description, new Text(dmn.getText()), expressionLanguage, constraintTypeField);
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(javax.xml.namespace.QName) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) ExpressionLanguage(org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) IsUnaryTests(org.kie.workbench.common.dmn.api.definition.model.IsUnaryTests) JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests)

Aggregations

ExpressionLanguage (org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage)12 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)8 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)8 Test (org.junit.Test)5 ImportedValues (org.kie.workbench.common.dmn.api.definition.model.ImportedValues)4 LocationURI (org.kie.workbench.common.dmn.api.property.dmn.LocationURI)4 IsLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression)3 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)3 QName (javax.xml.namespace.QName)2 ConstraintType (org.kie.workbench.common.dmn.api.definition.model.ConstraintType)2 IsUnaryTests (org.kie.workbench.common.dmn.api.definition.model.IsUnaryTests)2 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)2 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)2 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)2 JSITImportedValues (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues)2 JSITLiteralExpression (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression)2 ImportedValues (org.kie.dmn.model.api.ImportedValues)1 LiteralExpression (org.kie.dmn.model.api.LiteralExpression)1 TImportedValues (org.kie.dmn.model.v1_2.TImportedValues)1