Search in sources :

Example 6 with JSITLiteralExpression

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression in project kie-wb-common by kiegroup.

the class DecisionRulePropertyConverter method wbFromDMN.

public static DecisionRule wbFromDMN(final JSITDecisionRule dmn) {
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final DecisionRule result = new DecisionRule();
    result.setId(id);
    result.setDescription(description);
    final List<JSITRuleAnnotation> jsiAnnotationEntries = dmn.getAnnotationEntry();
    for (int i = 0; i < jsiAnnotationEntries.size(); i++) {
        final JSITRuleAnnotation jsiRuleAnnotation = Js.uncheckedCast(jsiAnnotationEntries.get(i));
        final RuleAnnotationClauseText ruleAnnotationClauseText = RuleAnnotationClauseTextPropertyConverter.wbFromDMN(jsiRuleAnnotation);
        if (Objects.nonNull(ruleAnnotationClauseText)) {
            ruleAnnotationClauseText.setParent(result);
            result.getAnnotationEntry().add(ruleAnnotationClauseText);
        }
    }
    if (result.getAnnotationEntry().isEmpty()) {
        final RuleAnnotationClauseText annotationEntryText = new RuleAnnotationClauseText();
        annotationEntryText.getText().setValue(description.getValue());
        annotationEntryText.setParent(result);
        result.getAnnotationEntry().add(annotationEntryText);
    }
    final List<JSITUnaryTests> jsiInputEntries = dmn.getInputEntry();
    for (int i = 0; i < jsiInputEntries.size(); i++) {
        final JSITUnaryTests jsiInputEntry = Js.uncheckedCast(jsiInputEntries.get(i));
        final UnaryTests inputEntryConverted = UnaryTestsPropertyConverter.wbFromDMN(jsiInputEntry);
        if (Objects.nonNull(inputEntryConverted)) {
            inputEntryConverted.setParent(result);
            result.getInputEntry().add(inputEntryConverted);
        }
    }
    final List<JSITLiteralExpression> jsiOutputEntries = dmn.getOutputEntry();
    for (int i = 0; i < jsiOutputEntries.size(); i++) {
        final JSITLiteralExpression jsiOutputEntry = Js.uncheckedCast(jsiOutputEntries.get(i));
        final LiteralExpression outputEntryConverted = LiteralExpressionPropertyConverter.wbFromDMN(jsiOutputEntry);
        if (Objects.nonNull(outputEntryConverted)) {
            outputEntryConverted.setParent(result);
            result.getOutputEntry().add(outputEntryConverted);
        }
    }
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) JSITDecisionRule(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionRule) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) JSITRuleAnnotation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRuleAnnotation) JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests) JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests)

Example 7 with JSITLiteralExpression

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression in project kie-wb-common by kiegroup.

the class OutputClauseLiteralExpressionPropertyConverterTest method testDMNFromWBWhenNull.

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

Example 8 with JSITLiteralExpression

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression 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 9 with JSITLiteralExpression

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression 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 10 with JSITLiteralExpression

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression 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

JSITLiteralExpression (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression)15 Test (org.junit.Test)5 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)5 IsLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression)4 JSITUnaryTests (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests)4 OutputClauseLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.OutputClauseLiteralExpression)3 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)3 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)3 WrapperUtils.getWrappedJSITLiteralExpression (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITLiteralExpression)3 Context (org.kie.workbench.common.dmn.api.definition.model.Context)2 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)2 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)2 Invocation (org.kie.workbench.common.dmn.api.definition.model.Invocation)2 List (org.kie.workbench.common.dmn.api.definition.model.List)2 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)2 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)2 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)2 ExpressionLanguage (org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage)2 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)2 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)2