Search in sources :

Example 1 with OutputClauseLiteralExpression

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

the class OutputClausePropertyConverter method wbFromDMN.

public static OutputClause wbFromDMN(final JSITOutputClause dmn) {
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final OutputClauseUnaryTests outputValues = OutputClauseUnaryTestsPropertyConverter.wbFromDMN(dmn.getOutputValues());
    final OutputClauseLiteralExpression defaultOutputEntry = OutputClauseLiteralExpressionPropertyConverter.wbFromDMN(dmn.getDefaultOutputEntry());
    final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    final OutputClause result = new OutputClause();
    result.setId(id);
    result.setName(dmn.getName());
    result.setDescription(description);
    result.setOutputValues(outputValues);
    result.setDefaultOutputEntry(defaultOutputEntry);
    result.setTypeRef(typeRef);
    if (Objects.nonNull(outputValues)) {
        outputValues.setParent(result);
    }
    if (Objects.nonNull(defaultOutputEntry)) {
        defaultOutputEntry.setParent(result);
    }
    return result;
}
Also used : JSITOutputClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause) OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) OutputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.OutputClauseLiteralExpression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests)

Example 2 with OutputClauseLiteralExpression

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

the class OutputClauseLiteralExpressionPropertyConverter method wbFromDMN.

/**
 * Returns a non-null instance of OutputClauseLiteralExpression. The Properties Panel needs
 * non-null objects to bind therefore a concrete object must always be returned.
 * @param dmn
 * @return
 */
public static OutputClauseLiteralExpression wbFromDMN(final JSITLiteralExpression dmn) {
    if (Objects.isNull(dmn)) {
        return new OutputClauseLiteralExpression();
    }
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    final Text text = new Text(dmn.getText());
    final ImportedValues importedValues = ImportedValuesConverter.wbFromDMN(dmn.getImportedValues());
    final OutputClauseLiteralExpression result = new OutputClauseLiteralExpression(id, description, typeRef, text, importedValues);
    if (Objects.nonNull(importedValues)) {
        importedValues.setParent(result);
    }
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) OutputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.OutputClauseLiteralExpression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ImportedValues(org.kie.workbench.common.dmn.api.definition.model.ImportedValues) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 3 with OutputClauseLiteralExpression

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

the class OutputClauseLiteralExpressionPropertyConverterTest method testDMNFromWBWhenTextIsNull.

@Test
public void testDMNFromWBWhenTextIsNull() {
    final OutputClauseLiteralExpression wb = new OutputClauseLiteralExpression();
    wb.setText(null);
    final JSITLiteralExpression dmn = OutputClauseLiteralExpressionPropertyConverter.dmnFromWB(wb);
    assertThat(dmn).isNull();
}
Also used : JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) OutputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.OutputClauseLiteralExpression) Test(org.junit.Test)

Example 4 with OutputClauseLiteralExpression

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

the class OutputClauseLiteralExpressionPropertyConverterTest method testDMNFromWBWhenNonNullWithEmptyString.

@Test
public void testDMNFromWBWhenNonNullWithEmptyString() {
    final OutputClauseLiteralExpression wb = new OutputClauseLiteralExpression();
    wb.getText().setValue("");
    final JSITLiteralExpression dmn = OutputClauseLiteralExpressionPropertyConverter.dmnFromWB(wb);
    assertThat(dmn).isNull();
}
Also used : JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) OutputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.OutputClauseLiteralExpression) Test(org.junit.Test)

Example 5 with OutputClauseLiteralExpression

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

the class OutputClauseLiteralExpressionPropertyConverterTest method testDMNFromWBWhenNonNullWithNonEmptyString.

@Test
public void testDMNFromWBWhenNonNullWithNonEmptyString() {
    final OutputClauseLiteralExpression wb = new OutputClauseLiteralExpression();
    wb.getText().setValue(TEXT);
    final JSITLiteralExpression dmn = OutputClauseLiteralExpressionPropertyConverter.dmnFromWB(wb);
    assertThat(dmn).isNotNull();
    verify(jsitLiteralExpression).setText(TEXT);
}
Also used : JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) OutputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.OutputClauseLiteralExpression) Test(org.junit.Test)

Aggregations

OutputClauseLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.OutputClauseLiteralExpression)9 Test (org.junit.Test)5 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)4 JSITLiteralExpression (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression)3 ImportedValues (org.kie.workbench.common.dmn.api.definition.model.ImportedValues)2 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)2 OutputClauseUnaryTests (org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests)2 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)2 JSITOutputClause (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause)1