Search in sources :

Example 11 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 LiteralExpressionPropertyConverterTest method testDMNFromWB.

@Test
public void testDMNFromWB() {
    when(wb.getId()).thenReturn(new Id(UUID));
    when(wb.getDescription()).thenReturn(new Description(DESCRIPTION));
    when(wb.getTypeRef()).thenReturn(new QName(KIE.getUri(), TYPE_REF, KIE.getPrefix()));
    when(wb.getText()).thenReturn(new Text(TEXT));
    when(wb.getExpressionLanguage()).thenReturn(new ExpressionLanguage(EXPRESSION_LANGUAGE));
    final JSITLiteralExpression result = LiteralExpressionPropertyConverter.dmnFromWB(wb);
    verify(result).setId(UUID);
    verify(result).setDescription(DESCRIPTION);
    verify(result).setTypeRef("{" + KIE.getUri() + "}" + TYPE_REF);
    verify(result).setText(TEXT);
    verify(result).setExpressionLanguage(EXPRESSION_LANGUAGE);
}
Also used : JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) 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) Test(org.junit.Test)

Example 12 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 WrapperUtils method getWrappedJSITLiteralExpression.

public static JSITLiteralExpression getWrappedJSITLiteralExpression(final JSITLiteralExpression toWrap, final String prefix, final String localPart) {
    final JSITLiteralExpression toReturn = Js.uncheckedCast(JsUtils.getWrappedElement(toWrap));
    final JSIName jsiName = JSITLiteralExpression.getJSIName();
    updateJSIName(jsiName, prefix, localPart);
    JsUtils.setNameOnWrapped(toReturn, jsiName);
    return toReturn;
}
Also used : JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) JSIName(org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JSIName)

Example 13 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 InputClausePropertyConverter method dmnFromWB.

public static JSITInputClause dmnFromWB(final InputClause wb) {
    final JSITInputClause result = new JSITInputClause();
    result.setId(wb.getId().getValue());
    final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    description.ifPresent(result::setDescription);
    final JSITLiteralExpression expression = LiteralExpressionPropertyConverter.dmnFromWB(wb.getInputExpression());
    final JSITUnaryTests inputValues = UnaryTestsPropertyConverter.dmnFromWB(wb.getInputValues());
    result.setInputExpression(expression);
    if (Objects.nonNull(inputValues) && StringUtils.nonEmpty(inputValues.getText())) {
        result.setInputValues(inputValues);
    }
    return result;
}
Also used : JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests) JSITInputClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause)

Example 14 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 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 15 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 LiteralExpressionPropertyConverter method wbFromDMN.

public static LiteralExpression wbFromDMN(final JSITLiteralExpression dmn) {
    if (Objects.isNull(dmn)) {
        return null;
    }
    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(Objects.nonNull(dmn.getText()) ? 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 (Objects.nonNull(importedValues)) {
        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) JSITImportedValues(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImportedValues) 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) JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) 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)

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