@Test public void testWBFromDMNSingleOutputClauseTypeRef() { final org.kie.dmn.model.api.DecisionTable dmn = new TDecisionTable(); final org.kie.dmn.model.api.OutputClause dmnOutputClause1 = new TOutputClause(); dmn.setId(UUID); dmn.setDescription(DESCRIPTION); dmn.setTypeRef(new QName(QNAME_LOCALPART)); dmnOutputClause1.setName(NAME); dmnOutputClause1.setTypeRef(new QName(QNAME_LOCALPART + "-oc1")); dmn.getOutput().add(dmnOutputClause1); final DecisionTable wb = DecisionTablePropertyConverter.wbFromDMN(dmn); assertThat(wb).isNotNull(); assertThat(wb.getId()).isNotNull(); assertThat(wb.getId().getValue()).isEqualTo(UUID); assertThat(wb.getDescription()).isNotNull(); assertThat(wb.getDescription().getValue()).isEqualTo(DESCRIPTION); assertThat(wb.getTypeRef()).isNotNull(); assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART); assertThat(wb.getOutput()).hasSize(1); final OutputClause wbOutputClause1 = wb.getOutput().get(0); assertThat(wbOutputClause1.getName()).isNull(); assertThat(wbOutputClause1.getTypeRef()).isNull(); }
public static DecisionTable wbFromDMN(final org.kie.dmn.model.api.DecisionTable dmn) { final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); if (!(dmn instanceof org.kie.dmn.model.v1_1.TDecisionTable)) { if (dmn.getAnnotation().isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause : dmn.getAnnotation()) { final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(ruleAnnotationClause); if (converted != null) { converted.setParent(result); } result.getAnnotations().add(converted); } } } for (org.kie.dmn.model.api.InputClause input : dmn.getInput()) { final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (inputClauseConverted != null) { inputClauseConverted.setParent(result); } result.getInput().add(inputClauseConverted); } for (org.kie.dmn.model.api.OutputClause output : dmn.getOutput()) { final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (outputClauseConverted != null) { outputClauseConverted.setParent(result); } result.getOutput().add(outputClauseConverted); } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(null); } for (org.kie.dmn.model.api.DecisionRule dr : dmn.getRule()) { final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (decisionRuleConverted != null) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } if (dmn.getHitPolicy() != null) { result.setHitPolicy(HitPolicy.fromValue(dmn.getHitPolicy().value())); } if (dmn.getAggregation() != null) { result.setAggregation(BuiltinAggregator.fromValue(dmn.getAggregation().value())); } if (dmn.getPreferredOrientation() != null) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(dmn.getPreferredOrientation().value())); } result.setOutputLabel(dmn.getOutputLabel()); return result; }
DecisionTablePropertyConverter { public static DecisionTable wbFromDMN(final org.kie.dmn.model.api.DecisionTable dmn) { final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); if (!(dmn instanceof org.kie.dmn.model.v1_1.TDecisionTable)) { if (dmn.getAnnotation().isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause : dmn.getAnnotation()) { final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(ruleAnnotationClause); if (converted != null) { converted.setParent(result); } result.getAnnotations().add(converted); } } } for (org.kie.dmn.model.api.InputClause input : dmn.getInput()) { final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (inputClauseConverted != null) { inputClauseConverted.setParent(result); } result.getInput().add(inputClauseConverted); } for (org.kie.dmn.model.api.OutputClause output : dmn.getOutput()) { final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (outputClauseConverted != null) { outputClauseConverted.setParent(result); } result.getOutput().add(outputClauseConverted); } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(null); } for (org.kie.dmn.model.api.DecisionRule dr : dmn.getRule()) { final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (decisionRuleConverted != null) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } if (dmn.getHitPolicy() != null) { result.setHitPolicy(HitPolicy.fromValue(dmn.getHitPolicy().value())); } if (dmn.getAggregation() != null) { result.setAggregation(BuiltinAggregator.fromValue(dmn.getAggregation().value())); } if (dmn.getPreferredOrientation() != null) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(dmn.getPreferredOrientation().value())); } result.setOutputLabel(dmn.getOutputLabel()); return result; } }
DecisionTablePropertyConverter { public static DecisionTable wbFromDMN(final org.kie.dmn.model.api.DecisionTable dmn) { final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); if (!(dmn instanceof org.kie.dmn.model.v1_1.TDecisionTable)) { if (dmn.getAnnotation().isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause : dmn.getAnnotation()) { final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(ruleAnnotationClause); if (converted != null) { converted.setParent(result); } result.getAnnotations().add(converted); } } } for (org.kie.dmn.model.api.InputClause input : dmn.getInput()) { final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (inputClauseConverted != null) { inputClauseConverted.setParent(result); } result.getInput().add(inputClauseConverted); } for (org.kie.dmn.model.api.OutputClause output : dmn.getOutput()) { final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (outputClauseConverted != null) { outputClauseConverted.setParent(result); } result.getOutput().add(outputClauseConverted); } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(null); } for (org.kie.dmn.model.api.DecisionRule dr : dmn.getRule()) { final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (decisionRuleConverted != null) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } if (dmn.getHitPolicy() != null) { result.setHitPolicy(HitPolicy.fromValue(dmn.getHitPolicy().value())); } if (dmn.getAggregation() != null) { result.setAggregation(BuiltinAggregator.fromValue(dmn.getAggregation().value())); } if (dmn.getPreferredOrientation() != null) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(dmn.getPreferredOrientation().value())); } result.setOutputLabel(dmn.getOutputLabel()); return result; }  }
DecisionTablePropertyConverter { public static DecisionTable wbFromDMN(final org.kie.dmn.model.api.DecisionTable dmn) { final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); if (!(dmn instanceof org.kie.dmn.model.v1_1.TDecisionTable)) { if (dmn.getAnnotation().isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause : dmn.getAnnotation()) { final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(ruleAnnotationClause); if (converted != null) { converted.setParent(result); } result.getAnnotations().add(converted); } } } for (org.kie.dmn.model.api.InputClause input : dmn.getInput()) { final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (inputClauseConverted != null) { inputClauseConverted.setParent(result); } result.getInput().add(inputClauseConverted); } for (org.kie.dmn.model.api.OutputClause output : dmn.getOutput()) { final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (outputClauseConverted != null) { outputClauseConverted.setParent(result); } result.getOutput().add(outputClauseConverted); } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(null); } for (org.kie.dmn.model.api.DecisionRule dr : dmn.getRule()) { final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (decisionRuleConverted != null) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } if (dmn.getHitPolicy() != null) { result.setHitPolicy(HitPolicy.fromValue(dmn.getHitPolicy().value())); } if (dmn.getAggregation() != null) { result.setAggregation(BuiltinAggregator.fromValue(dmn.getAggregation().value())); } if (dmn.getPreferredOrientation() != null) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(dmn.getPreferredOrientation().value())); } result.setOutputLabel(dmn.getOutputLabel()); return result; }  static DecisionTable wbFromDMN(final org.kie.dmn.model.api.DecisionTable dmn); static org.kie.dmn.model.api.DecisionTable dmnFromWB(final DecisionTable wb); }
DecisionTablePropertyConverter { public static DecisionTable wbFromDMN(final org.kie.dmn.model.api.DecisionTable dmn) { final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); if (!(dmn instanceof org.kie.dmn.model.v1_1.TDecisionTable)) { if (dmn.getAnnotation().isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause : dmn.getAnnotation()) { final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(ruleAnnotationClause); if (converted != null) { converted.setParent(result); } result.getAnnotations().add(converted); } } } for (org.kie.dmn.model.api.InputClause input : dmn.getInput()) { final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (inputClauseConverted != null) { inputClauseConverted.setParent(result); } result.getInput().add(inputClauseConverted); } for (org.kie.dmn.model.api.OutputClause output : dmn.getOutput()) { final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (outputClauseConverted != null) { outputClauseConverted.setParent(result); } result.getOutput().add(outputClauseConverted); } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(null); } for (org.kie.dmn.model.api.DecisionRule dr : dmn.getRule()) { final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (decisionRuleConverted != null) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } if (dmn.getHitPolicy() != null) { result.setHitPolicy(HitPolicy.fromValue(dmn.getHitPolicy().value())); } if (dmn.getAggregation() != null) { result.setAggregation(BuiltinAggregator.fromValue(dmn.getAggregation().value())); } if (dmn.getPreferredOrientation() != null) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(dmn.getPreferredOrientation().value())); } result.setOutputLabel(dmn.getOutputLabel()); return result; }  static DecisionTable wbFromDMN(final org.kie.dmn.model.api.DecisionTable dmn); static org.kie.dmn.model.api.DecisionTable dmnFromWB(final DecisionTable wb);  }