Search in sources :

Example 6 with JSITDecisionTable

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

the class DecisionTablePropertyConverter method dmnFromWB.

public static JSITDecisionTable dmnFromWB(final DecisionTable wb) {
    final JSITDecisionTable result = new JSITDecisionTable();
    result.setId(wb.getId().getValue());
    final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    description.ifPresent(result::setDescription);
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (final RuleAnnotationClause annotation : wb.getAnnotations()) {
        final JSITRuleAnnotationClause converted = RuleAnnotationClausePropertyConverter.dmnFromWB(annotation);
        result.addAnnotation(converted);
    }
    for (InputClause input : wb.getInput()) {
        final JSITInputClause c = InputClausePropertyConverter.dmnFromWB(input);
        result.addInput(c);
    }
    for (OutputClause input : wb.getOutput()) {
        final JSITOutputClause c = OutputClausePropertyConverter.dmnFromWB(input);
        result.addOutput(c);
    }
    if (result.getOutput().size() == 1) {
        final JSITOutputClause at = Js.uncheckedCast(result.getOutput().get(0));
        // DROOLS-3281
        at.setName(null);
        // DROOLS-5178
        at.setTypeRef(null);
    }
    for (DecisionRule dr : wb.getRule()) {
        final JSITDecisionRule c = DecisionRulePropertyConverter.dmnFromWB(dr);
        result.addRule(c);
    }
    if (Objects.nonNull(wb.getHitPolicy())) {
        switch(wb.getHitPolicy()) {
            case ANY:
                result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.ANY.value()));
                break;
            case COLLECT:
                result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.COLLECT.value()));
                break;
            case FIRST:
                result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.FIRST.value()));
                break;
            case UNIQUE:
                result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.UNIQUE.value()));
                break;
            case PRIORITY:
                result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.PRIORITY.value()));
                break;
            case RULE_ORDER:
                result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.RULE_ORDER.value()));
                break;
            case OUTPUT_ORDER:
                result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.OUTPUT_ORDER.value()));
                break;
        }
    }
    if (Objects.nonNull(wb.getAggregation())) {
        final String wbBuiltinAggregator = wb.getAggregation().value();
        result.setAggregation(Js.uncheckedCast(wbBuiltinAggregator));
    }
    if (Objects.nonNull(wb.getPreferredOrientation())) {
        final String wbPreferredOrientation = wb.getPreferredOrientation().value();
        result.setPreferredOrientation(Js.uncheckedCast(wbPreferredOrientation));
    }
    result.setOutputLabel(wb.getOutputLabel());
    return result;
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) JSITOutputClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause) JSITInputClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause) JSITRuleAnnotationClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRuleAnnotationClause) RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) JSITDecisionRule(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionRule) JSITDecisionTable(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable) JSITOutputClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause) JSITRuleAnnotationClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRuleAnnotationClause) JSITInputClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) JSITDecisionRule(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionRule) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule)

Aggregations

JSITDecisionTable (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable)6 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)4 Context (org.kie.workbench.common.dmn.api.definition.model.Context)2 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)2 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)2 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)2 Invocation (org.kie.workbench.common.dmn.api.definition.model.Invocation)2 IsLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression)2 List (org.kie.workbench.common.dmn.api.definition.model.List)2 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)2 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)2 RuleAnnotationClause (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause)2 WrapperUtils.getWrappedJSITContext (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITContext)2 WrapperUtils.getWrappedJSITDecisionTable (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITDecisionTable)2 WrapperUtils.getWrappedJSITFunctionDefinition (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITFunctionDefinition)2 WrapperUtils.getWrappedJSITInvocation (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITInvocation)2 WrapperUtils.getWrappedJSITList (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITList)2 WrapperUtils.getWrappedJSITLiteralExpression (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITLiteralExpression)2 WrapperUtils.getWrappedJSITRelation (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITRelation)2 JSITContext (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITContext)2