@Test public void testDMNFromWB() { final DecisionService wb = new DecisionService(); final InformationItemPrimary informationItem = new InformationItemPrimary(); wb.getId().setValue(DECISION_SERVICE_UUID); wb.getName().setValue(DECISION_SERVICE_NAME); wb.getDescription().setValue(DECISION_SERVICE_DESCRIPTION); wb.setVariable(informationItem); final Node<View<DecisionService>, ?> node = new NodeImpl<>(UUID.uuid()); final View<DecisionService> view = new ViewImpl<>(wb, Bounds.create()); node.setContent(view); final org.kie.dmn.model.api.DecisionService dmn = converter.dmnFromNode(node, componentWidthsConsumer); assertThat(dmn).isNotNull(); assertThat(dmn.getId()).isNotNull(); assertThat(dmn.getId()).isEqualTo(DECISION_SERVICE_UUID); assertThat(dmn.getName()).isNotNull(); assertThat(dmn.getName()).isEqualTo(DECISION_SERVICE_NAME); assertThat(dmn.getDescription()).isNotNull(); assertThat(dmn.getDescription()).isEqualTo(DECISION_SERVICE_DESCRIPTION); assertThat(dmn.getVariable()).isNotNull(); assertThat(dmn.getVariable().getName()).isEqualTo(DECISION_SERVICE_NAME); verifyNoMoreInteractions(componentWidthsConsumer); }
@Override @SuppressWarnings("unchecked") public org.kie.dmn.model.api.DecisionService dmnFromNode(final Node<View<DecisionService>, ?> node, final Consumer<ComponentWidths> componentWidthsConsumer) { final DecisionService source = (DecisionService) DefinitionUtils.getElementDefinition(node); final org.kie.dmn.model.api.DecisionService ds = new org.kie.dmn.model.v1_2.TDecisionService(); ds.setId(source.getId().getValue()); ds.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription())); ds.setName(source.getName().getValue()); final org.kie.dmn.model.api.InformationItem variable = InformationItemPrimaryPropertyConverter.dmnFromWB(source.getVariable(), source); if (variable != null) { variable.setParent(ds); } ds.setVariable(variable); final List<org.kie.dmn.model.api.DMNElementReference> existing_outputDecision = source.getOutputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_encapsulatedDecision = source.getEncapsulatedDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputDecision = source.getInputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputData = source.getInputData().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> candidate_outputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_encapsulatedDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputData = new ArrayList<>(); final List<InputData> reqInputs = new ArrayList<>(); final List<Decision> reqDecisions = new ArrayList<>(); final List<Edge<?, ?>> outEdges = (List<Edge<?, ?>>) node.getOutEdges(); for (Edge<?, ?> e : outEdges) { if (e.getContent() instanceof Child) { @SuppressWarnings("unchecked") final Node<View<?>, ?> targetNode = e.getTargetNode(); final View<?> targetNodeView = targetNode.getContent(); if (targetNodeView.getDefinition() instanceof DRGElement) { final DRGElement drgElement = (DRGElement) targetNodeView.getDefinition(); if (drgElement instanceof Decision) { final Decision decision = (Decision) drgElement; final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(decision.getId().getValue()).toString()); if (isOutputDecision(targetNode.getContent(), node.getContent())) { candidate_outputDecision.add(ri); } else { candidate_encapsulatedDecision.add(ri); } inspectDecisionForDSReqs(targetNode, reqInputs, reqDecisions); } else { throw new UnsupportedOperationException("wrong model definition: a DecisionService is expected to encapsulate only Decision"); } } } else if (e.getContent() instanceof View && ((View) e.getContent()).getDefinition() instanceof KnowledgeRequirement) { } else { throw new UnsupportedOperationException("wrong model definition."); } } reqInputs.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputData::add); reqDecisions.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputDecision::add); for (org.kie.dmn.model.api.DMNElementReference er : candidate_outputDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } for (org.kie.dmn.model.api.DMNElementReference er : candidate_encapsulatedDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } reconcileExistingAndCandidate(ds.getInputData(), existing_inputData, candidate_inputData); reconcileExistingAndCandidate(ds.getInputDecision(), existing_inputDecision, candidate_inputDecision); reconcileExistingAndCandidate(ds.getEncapsulatedDecision(), existing_encapsulatedDecision, candidate_encapsulatedDecision); reconcileExistingAndCandidate(ds.getOutputDecision(), existing_outputDecision, candidate_outputDecision); DMNExternalLinksToExtensionElements.loadExternalLinksIntoExtensionElements(source, ds); return ds; }
DecisionServiceConverter implements NodeConverter<org.kie.dmn.model.api.DecisionService, org.kie.workbench.common.dmn.api.definition.model.DecisionService> { @Override @SuppressWarnings("unchecked") public org.kie.dmn.model.api.DecisionService dmnFromNode(final Node<View<DecisionService>, ?> node, final Consumer<ComponentWidths> componentWidthsConsumer) { final DecisionService source = (DecisionService) DefinitionUtils.getElementDefinition(node); final org.kie.dmn.model.api.DecisionService ds = new org.kie.dmn.model.v1_2.TDecisionService(); ds.setId(source.getId().getValue()); ds.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription())); ds.setName(source.getName().getValue()); final org.kie.dmn.model.api.InformationItem variable = InformationItemPrimaryPropertyConverter.dmnFromWB(source.getVariable(), source); if (variable != null) { variable.setParent(ds); } ds.setVariable(variable); final List<org.kie.dmn.model.api.DMNElementReference> existing_outputDecision = source.getOutputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_encapsulatedDecision = source.getEncapsulatedDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputDecision = source.getInputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputData = source.getInputData().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> candidate_outputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_encapsulatedDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputData = new ArrayList<>(); final List<InputData> reqInputs = new ArrayList<>(); final List<Decision> reqDecisions = new ArrayList<>(); final List<Edge<?, ?>> outEdges = (List<Edge<?, ?>>) node.getOutEdges(); for (Edge<?, ?> e : outEdges) { if (e.getContent() instanceof Child) { @SuppressWarnings("unchecked") final Node<View<?>, ?> targetNode = e.getTargetNode(); final View<?> targetNodeView = targetNode.getContent(); if (targetNodeView.getDefinition() instanceof DRGElement) { final DRGElement drgElement = (DRGElement) targetNodeView.getDefinition(); if (drgElement instanceof Decision) { final Decision decision = (Decision) drgElement; final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(decision.getId().getValue()).toString()); if (isOutputDecision(targetNode.getContent(), node.getContent())) { candidate_outputDecision.add(ri); } else { candidate_encapsulatedDecision.add(ri); } inspectDecisionForDSReqs(targetNode, reqInputs, reqDecisions); } else { throw new UnsupportedOperationException("wrong model definition: a DecisionService is expected to encapsulate only Decision"); } } } else if (e.getContent() instanceof View && ((View) e.getContent()).getDefinition() instanceof KnowledgeRequirement) { } else { throw new UnsupportedOperationException("wrong model definition."); } } reqInputs.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputData::add); reqDecisions.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputDecision::add); for (org.kie.dmn.model.api.DMNElementReference er : candidate_outputDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } for (org.kie.dmn.model.api.DMNElementReference er : candidate_encapsulatedDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } reconcileExistingAndCandidate(ds.getInputData(), existing_inputData, candidate_inputData); reconcileExistingAndCandidate(ds.getInputDecision(), existing_inputDecision, candidate_inputDecision); reconcileExistingAndCandidate(ds.getEncapsulatedDecision(), existing_encapsulatedDecision, candidate_encapsulatedDecision); reconcileExistingAndCandidate(ds.getOutputDecision(), existing_outputDecision, candidate_outputDecision); DMNExternalLinksToExtensionElements.loadExternalLinksIntoExtensionElements(source, ds); return ds; } }
DecisionServiceConverter implements NodeConverter<org.kie.dmn.model.api.DecisionService, org.kie.workbench.common.dmn.api.definition.model.DecisionService> { @Override @SuppressWarnings("unchecked") public org.kie.dmn.model.api.DecisionService dmnFromNode(final Node<View<DecisionService>, ?> node, final Consumer<ComponentWidths> componentWidthsConsumer) { final DecisionService source = (DecisionService) DefinitionUtils.getElementDefinition(node); final org.kie.dmn.model.api.DecisionService ds = new org.kie.dmn.model.v1_2.TDecisionService(); ds.setId(source.getId().getValue()); ds.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription())); ds.setName(source.getName().getValue()); final org.kie.dmn.model.api.InformationItem variable = InformationItemPrimaryPropertyConverter.dmnFromWB(source.getVariable(), source); if (variable != null) { variable.setParent(ds); } ds.setVariable(variable); final List<org.kie.dmn.model.api.DMNElementReference> existing_outputDecision = source.getOutputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_encapsulatedDecision = source.getEncapsulatedDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputDecision = source.getInputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputData = source.getInputData().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> candidate_outputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_encapsulatedDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputData = new ArrayList<>(); final List<InputData> reqInputs = new ArrayList<>(); final List<Decision> reqDecisions = new ArrayList<>(); final List<Edge<?, ?>> outEdges = (List<Edge<?, ?>>) node.getOutEdges(); for (Edge<?, ?> e : outEdges) { if (e.getContent() instanceof Child) { @SuppressWarnings("unchecked") final Node<View<?>, ?> targetNode = e.getTargetNode(); final View<?> targetNodeView = targetNode.getContent(); if (targetNodeView.getDefinition() instanceof DRGElement) { final DRGElement drgElement = (DRGElement) targetNodeView.getDefinition(); if (drgElement instanceof Decision) { final Decision decision = (Decision) drgElement; final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(decision.getId().getValue()).toString()); if (isOutputDecision(targetNode.getContent(), node.getContent())) { candidate_outputDecision.add(ri); } else { candidate_encapsulatedDecision.add(ri); } inspectDecisionForDSReqs(targetNode, reqInputs, reqDecisions); } else { throw new UnsupportedOperationException("wrong model definition: a DecisionService is expected to encapsulate only Decision"); } } } else if (e.getContent() instanceof View && ((View) e.getContent()).getDefinition() instanceof KnowledgeRequirement) { } else { throw new UnsupportedOperationException("wrong model definition."); } } reqInputs.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputData::add); reqDecisions.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputDecision::add); for (org.kie.dmn.model.api.DMNElementReference er : candidate_outputDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } for (org.kie.dmn.model.api.DMNElementReference er : candidate_encapsulatedDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } reconcileExistingAndCandidate(ds.getInputData(), existing_inputData, candidate_inputData); reconcileExistingAndCandidate(ds.getInputDecision(), existing_inputDecision, candidate_inputDecision); reconcileExistingAndCandidate(ds.getEncapsulatedDecision(), existing_encapsulatedDecision, candidate_encapsulatedDecision); reconcileExistingAndCandidate(ds.getOutputDecision(), existing_outputDecision, candidate_outputDecision); DMNExternalLinksToExtensionElements.loadExternalLinksIntoExtensionElements(source, ds); return ds; } DecisionServiceConverter(final FactoryManager factoryManager); }
DecisionServiceConverter implements NodeConverter<org.kie.dmn.model.api.DecisionService, org.kie.workbench.common.dmn.api.definition.model.DecisionService> { @Override @SuppressWarnings("unchecked") public org.kie.dmn.model.api.DecisionService dmnFromNode(final Node<View<DecisionService>, ?> node, final Consumer<ComponentWidths> componentWidthsConsumer) { final DecisionService source = (DecisionService) DefinitionUtils.getElementDefinition(node); final org.kie.dmn.model.api.DecisionService ds = new org.kie.dmn.model.v1_2.TDecisionService(); ds.setId(source.getId().getValue()); ds.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription())); ds.setName(source.getName().getValue()); final org.kie.dmn.model.api.InformationItem variable = InformationItemPrimaryPropertyConverter.dmnFromWB(source.getVariable(), source); if (variable != null) { variable.setParent(ds); } ds.setVariable(variable); final List<org.kie.dmn.model.api.DMNElementReference> existing_outputDecision = source.getOutputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_encapsulatedDecision = source.getEncapsulatedDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputDecision = source.getInputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputData = source.getInputData().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> candidate_outputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_encapsulatedDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputData = new ArrayList<>(); final List<InputData> reqInputs = new ArrayList<>(); final List<Decision> reqDecisions = new ArrayList<>(); final List<Edge<?, ?>> outEdges = (List<Edge<?, ?>>) node.getOutEdges(); for (Edge<?, ?> e : outEdges) { if (e.getContent() instanceof Child) { @SuppressWarnings("unchecked") final Node<View<?>, ?> targetNode = e.getTargetNode(); final View<?> targetNodeView = targetNode.getContent(); if (targetNodeView.getDefinition() instanceof DRGElement) { final DRGElement drgElement = (DRGElement) targetNodeView.getDefinition(); if (drgElement instanceof Decision) { final Decision decision = (Decision) drgElement; final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(decision.getId().getValue()).toString()); if (isOutputDecision(targetNode.getContent(), node.getContent())) { candidate_outputDecision.add(ri); } else { candidate_encapsulatedDecision.add(ri); } inspectDecisionForDSReqs(targetNode, reqInputs, reqDecisions); } else { throw new UnsupportedOperationException("wrong model definition: a DecisionService is expected to encapsulate only Decision"); } } } else if (e.getContent() instanceof View && ((View) e.getContent()).getDefinition() instanceof KnowledgeRequirement) { } else { throw new UnsupportedOperationException("wrong model definition."); } } reqInputs.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputData::add); reqDecisions.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputDecision::add); for (org.kie.dmn.model.api.DMNElementReference er : candidate_outputDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } for (org.kie.dmn.model.api.DMNElementReference er : candidate_encapsulatedDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } reconcileExistingAndCandidate(ds.getInputData(), existing_inputData, candidate_inputData); reconcileExistingAndCandidate(ds.getInputDecision(), existing_inputDecision, candidate_inputDecision); reconcileExistingAndCandidate(ds.getEncapsulatedDecision(), existing_encapsulatedDecision, candidate_encapsulatedDecision); reconcileExistingAndCandidate(ds.getOutputDecision(), existing_outputDecision, candidate_outputDecision); DMNExternalLinksToExtensionElements.loadExternalLinksIntoExtensionElements(source, ds); return ds; } DecisionServiceConverter(final FactoryManager factoryManager); @Override Node<View<DecisionService>, ?> nodeFromDMN(final org.kie.dmn.model.api.DecisionService dmn,
                                                      final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); @Override @SuppressWarnings("unchecked") org.kie.dmn.model.api.DecisionService dmnFromNode(final Node<View<DecisionService>, ?> node,
                                                             final Consumer<ComponentWidths> componentWidthsConsumer); }
DecisionServiceConverter implements NodeConverter<org.kie.dmn.model.api.DecisionService, org.kie.workbench.common.dmn.api.definition.model.DecisionService> { @Override @SuppressWarnings("unchecked") public org.kie.dmn.model.api.DecisionService dmnFromNode(final Node<View<DecisionService>, ?> node, final Consumer<ComponentWidths> componentWidthsConsumer) { final DecisionService source = (DecisionService) DefinitionUtils.getElementDefinition(node); final org.kie.dmn.model.api.DecisionService ds = new org.kie.dmn.model.v1_2.TDecisionService(); ds.setId(source.getId().getValue()); ds.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription())); ds.setName(source.getName().getValue()); final org.kie.dmn.model.api.InformationItem variable = InformationItemPrimaryPropertyConverter.dmnFromWB(source.getVariable(), source); if (variable != null) { variable.setParent(ds); } ds.setVariable(variable); final List<org.kie.dmn.model.api.DMNElementReference> existing_outputDecision = source.getOutputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_encapsulatedDecision = source.getEncapsulatedDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputDecision = source.getInputDecision().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> existing_inputData = source.getInputData().stream().map(DMNElementReferenceConverter::dmnFromWB).collect(Collectors.toList()); final List<org.kie.dmn.model.api.DMNElementReference> candidate_outputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_encapsulatedDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputDecision = new ArrayList<>(); final List<org.kie.dmn.model.api.DMNElementReference> candidate_inputData = new ArrayList<>(); final List<InputData> reqInputs = new ArrayList<>(); final List<Decision> reqDecisions = new ArrayList<>(); final List<Edge<?, ?>> outEdges = (List<Edge<?, ?>>) node.getOutEdges(); for (Edge<?, ?> e : outEdges) { if (e.getContent() instanceof Child) { @SuppressWarnings("unchecked") final Node<View<?>, ?> targetNode = e.getTargetNode(); final View<?> targetNodeView = targetNode.getContent(); if (targetNodeView.getDefinition() instanceof DRGElement) { final DRGElement drgElement = (DRGElement) targetNodeView.getDefinition(); if (drgElement instanceof Decision) { final Decision decision = (Decision) drgElement; final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(decision.getId().getValue()).toString()); if (isOutputDecision(targetNode.getContent(), node.getContent())) { candidate_outputDecision.add(ri); } else { candidate_encapsulatedDecision.add(ri); } inspectDecisionForDSReqs(targetNode, reqInputs, reqDecisions); } else { throw new UnsupportedOperationException("wrong model definition: a DecisionService is expected to encapsulate only Decision"); } } } else if (e.getContent() instanceof View && ((View) e.getContent()).getDefinition() instanceof KnowledgeRequirement) { } else { throw new UnsupportedOperationException("wrong model definition."); } } reqInputs.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputData::add); reqDecisions.stream() .sorted(Comparator.comparing(x -> x.getName().getValue())) .map(x -> { final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference(); ri.setHref(new StringBuilder("#").append(x.getId().getValue()).toString()); return ri; }) .forEach(candidate_inputDecision::add); for (org.kie.dmn.model.api.DMNElementReference er : candidate_outputDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } for (org.kie.dmn.model.api.DMNElementReference er : candidate_encapsulatedDecision) { candidate_inputDecision.removeIf(x -> x.getHref().equals(er.getHref())); } reconcileExistingAndCandidate(ds.getInputData(), existing_inputData, candidate_inputData); reconcileExistingAndCandidate(ds.getInputDecision(), existing_inputDecision, candidate_inputDecision); reconcileExistingAndCandidate(ds.getEncapsulatedDecision(), existing_encapsulatedDecision, candidate_encapsulatedDecision); reconcileExistingAndCandidate(ds.getOutputDecision(), existing_outputDecision, candidate_outputDecision); DMNExternalLinksToExtensionElements.loadExternalLinksIntoExtensionElements(source, ds); return ds; } DecisionServiceConverter(final FactoryManager factoryManager); @Override Node<View<DecisionService>, ?> nodeFromDMN(final org.kie.dmn.model.api.DecisionService dmn,
                                                      final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); @Override @SuppressWarnings("unchecked") org.kie.dmn.model.api.DecisionService dmnFromNode(final Node<View<DecisionService>, ?> node,
                                                             final Consumer<ComponentWidths> componentWidthsConsumer);  }