Search in sources :

Example 1 with JSITUnaryTests

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

the class OutputClausePropertyConverter method dmnFromWB.

public static JSITOutputClause dmnFromWB(final OutputClause wb) {
    final JSITOutputClause result = new JSITOutputClause();
    result.setId(wb.getId().getValue());
    result.setName(wb.getName());
    final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    description.ifPresent(result::setDescription);
    final JSITUnaryTests outputValues = OutputClauseUnaryTestsPropertyConverter.dmnFromWB(wb.getOutputValues());
    if (Objects.nonNull(outputValues) && StringUtils.nonEmpty(outputValues.getText())) {
        result.setOutputValues(outputValues);
    }
    final JSITLiteralExpression defaultOutputEntry = OutputClauseLiteralExpressionPropertyConverter.dmnFromWB(wb.getDefaultOutputEntry());
    if (Objects.nonNull(defaultOutputEntry) && StringUtils.nonEmpty(defaultOutputEntry.getText())) {
        result.setDefaultOutputEntry(defaultOutputEntry);
    }
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    return result;
}
Also used : 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) JSITOutputClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause)

Example 2 with JSITUnaryTests

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

the class UnaryTestsPropertyConverter method dmnFromWB.

public static JSITUnaryTests dmnFromWB(final IsUnaryTests wb) {
    if (Objects.isNull(wb)) {
        return null;
    }
    final JSITUnaryTests result = UNARY_TESTS_FACTORY.make();
    final Map<QName, String> otherAttributes = new HashMap<>();
    result.setId(wb.getId().getValue());
    result.setText(wb.getText().getValue());
    result.setOtherAttributes(ATTRIBUTES_UTILS.cast(otherAttributes));
    final ConstraintType constraint = wb.getConstraintType();
    if (isNotNone(constraint)) {
        final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
        otherAttributes.put(key, constraint.value());
        result.setOtherAttributes(ATTRIBUTES_UTILS.cast(otherAttributes));
    }
    return result;
}
Also used : JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType)

Example 3 with JSITUnaryTests

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

Example 4 with JSITUnaryTests

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

the class DecisionRulePropertyConverter method dmnFromWB.

public static JSITDecisionRule dmnFromWB(final DecisionRule wb) {
    final JSITDecisionRule result = new JSITDecisionRule();
    result.setId(wb.getId().getValue());
    final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    description.ifPresent(result::setDescription);
    for (final RuleAnnotationClauseText ruleAnnotationClauseText : wb.getAnnotationEntry()) {
        final JSITRuleAnnotation ruleAnnotation = RuleAnnotationClauseTextPropertyConverter.dmnFromWB(ruleAnnotationClauseText);
        result.addAnnotationEntry(ruleAnnotation);
    }
    for (UnaryTests ie : wb.getInputEntry()) {
        final JSITUnaryTests inputEntryConverted = UnaryTestsPropertyConverter.dmnFromWB(ie);
        result.addInputEntry(inputEntryConverted);
    }
    for (LiteralExpression oe : wb.getOutputEntry()) {
        final JSITLiteralExpression outputEntryConverted = LiteralExpressionPropertyConverter.dmnFromWB(oe);
        result.addOutputEntry(outputEntryConverted);
    }
    return result;
}
Also used : 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) 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) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests) JSITRuleAnnotation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRuleAnnotation)

Example 5 with JSITUnaryTests

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

Aggregations

JSITUnaryTests (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests)12 Test (org.junit.Test)4 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)4 JSITLiteralExpression (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression)4 OutputClauseUnaryTests (org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests)3 QName (javax.xml.namespace.QName)2 ConstraintType (org.kie.workbench.common.dmn.api.definition.model.ConstraintType)2 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)2 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2 JSITDecisionRule (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionRule)2 JSITRuleAnnotation (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRuleAnnotation)2 HashMap (java.util.HashMap)1 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)1 IsUnaryTests (org.kie.workbench.common.dmn.api.definition.model.IsUnaryTests)1 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)1 ExpressionLanguage (org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage)1 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)1 JSITInputClause (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause)1