Search in sources :

Example 1 with InputClauseUnaryTests

use of org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests in project kie-wb-common by kiegroup.

the class InputClauseUnaryTestsPropertyConverter method wbFromDMN.

public static InputClauseUnaryTests wbFromDMN(final org.kie.dmn.model.api.UnaryTests dmn) {
    if (dmn == null) {
        return null;
    }
    final Id id = new Id(dmn.getId());
    final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
    final String constraintString = dmn.getAdditionalAttributes().getOrDefault(key, "");
    final ConstraintType constraint = ConstraintType.fromString(constraintString);
    final InputClauseUnaryTests result = new InputClauseUnaryTests(id, new Text(dmn.getText()), constraint);
    return result;
}
Also used : 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) InputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests)

Example 2 with InputClauseUnaryTests

use of org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests in project kie-wb-common by kiegroup.

the class InputClauseUnaryTestsPropertyConverterTest method testWbFromDMN.

private void testWbFromDMN(final ConstraintType constraintType) {
    when(additionalAttributes.getOrDefault(key, "")).thenReturn(constraintType.value());
    final InputClauseUnaryTests inputClause = InputClauseUnaryTestsPropertyConverter.wbFromDMN(dmnUnary);
    assertEquals(inputClause.getConstraintType(), constraintType);
    assertEquals(inputClause.getId().getValue(), ID);
    assertEquals(inputClause.getText().getValue(), TEXT);
}
Also used : InputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests)

Example 3 with InputClauseUnaryTests

use of org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests in project kie-wb-common by kiegroup.

the class InputClauseUnaryTestsPropertyConverter method wbFromDMN.

public static InputClauseUnaryTests wbFromDMN(final JSITUnaryTests dmn) {
    if (Objects.isNull(dmn)) {
        return null;
    }
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, XMLConstants.DEFAULT_NS_PREFIX);
    final Map<QName, String> otherAttributes = JSITUnaryTests.getOtherAttributesMap(dmn);
    final String constraintString = otherAttributes.getOrDefault(key, "");
    final ConstraintType constraint = ConstraintType.fromString(constraintString);
    final InputClauseUnaryTests result = new InputClauseUnaryTests(id, new Text(dmn.getText()), constraint);
    return result;
}
Also used : 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) InputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests)

Example 4 with InputClauseUnaryTests

use of org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests in project kie-wb-common by kiegroup.

the class InputClausePropertyConverter method wbFromDMN.

public static InputClause wbFromDMN(final JSITInputClause dmn) {
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final InputClauseLiteralExpression inputExpression = InputClauseLiteralExpressionPropertyConverter.wbFromDMN(dmn.getInputExpression());
    final InputClauseUnaryTests inputValues = Optional.ofNullable(InputClauseUnaryTestsPropertyConverter.wbFromDMN(dmn.getInputValues())).orElse(new InputClauseUnaryTests());
    final InputClause result = new InputClause(id, description, inputExpression, inputValues);
    if (Objects.nonNull(inputExpression)) {
        inputExpression.setParent(result);
    }
    inputValues.setParent(result);
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) InputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) InputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests) JSITInputClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause)

Example 5 with InputClauseUnaryTests

use of org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests in project kie-wb-common by kiegroup.

the class InputClausePropertyConverter method wbFromDMN.

public static InputClause wbFromDMN(final org.kie.dmn.model.api.InputClause dmn) {
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final InputClauseLiteralExpression inputExpression = InputClauseLiteralExpressionPropertyConverter.wbFromDMN(dmn.getInputExpression());
    final InputClauseUnaryTests inputValues = InputClauseUnaryTestsPropertyConverter.wbFromDMN(dmn.getInputValues());
    final InputClause result = new InputClause(id, description, inputExpression, inputValues);
    if (inputExpression != null) {
        inputExpression.setParent(result);
    }
    if (inputValues != null) {
        inputValues.setParent(result);
    }
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) InputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) InputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause)

Aggregations

InputClauseUnaryTests (org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests)5 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 QName (javax.xml.namespace.QName)2 ConstraintType (org.kie.workbench.common.dmn.api.definition.model.ConstraintType)2 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)2 InputClauseLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)2 JSITInputClause (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause)1