protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { super.handleNode(node, element, uri, localName, parser); String decisionRef = element.getAttribute("decisionRef"); if (decisionRef == null) { throw new IllegalArgumentException("Decision information is mandatory"); } RuleSetNode ruleSetNode = (RuleSetNode) node; ruleSetNode.setRuleFlowGroup(decisionRef); ruleSetNode.setLanguage(RuleSetNode.DRL_LANG); ruleSetNode.setNamespace((String) ruleSetNode.removeParameter(NAMESPACE_PROP)); ruleSetNode.setModel((String) ruleSetNode.removeParameter(MODEL_PROP)); ruleSetNode.setDecision((String) ruleSetNode.removeParameter(DECISION_PROP)); Map<String, String> inputs = new HashMap<>(); Map<String, String> outputs = new HashMap<>(); Map<String, String> inputTypes = new HashMap<>(); Map<String, String> outputTypes = new HashMap<>(); loadDataInputsAndOutputs(element, inputs, outputs, inputTypes, outputTypes, parser); ruleSetNode.setMetaData("DataInputs", inputTypes); ruleSetNode.setMetaData("DataOutputs", outputTypes); for (Entry<String, String> entry : inputs.entrySet()) { ruleSetNode.addInAssociation(new DataAssociation(entry.getValue(), entry.getKey(), Collections.emptyList(), null)); } for (Entry<String, String> entry : outputs.entrySet()) { ruleSetNode.addOutAssociation(new DataAssociation(entry.getKey(), entry.getValue(), Collections.emptyList(), null)); } }
ruleSetNode.setDecision((String) ruleSetNode.removeParameter(DECISION_PROP));
private void postProcessNodes(RuleFlowProcess process, NodeContainer container, ProcessBuildData buildData, ExtensibleXmlParser parser) { for (Node node : container.getNodes()) { if (node instanceof SubProcessNode) { Map<String, String> processes = (Map<String, String>) buildData.getMetaData("ProcessElements"); if (processes != null) { SubProcessNode subprocessNode = (SubProcessNode) node; subprocessNode.setProcessId(processes.getOrDefault(subprocessNode.getProcessId(), subprocessNode.getProcessId())); } } else if (node instanceof RuleSetNode) { Map<String, Decision> decisions = (Map<String, Decision>) buildData.getMetaData("DecisionElements"); RuleSetNode ruleSetNode = (RuleSetNode) node; if (decisions != null && decisions.containsKey(ruleSetNode.getRuleFlowGroup())) { Decision decision = decisions.get(ruleSetNode.getRuleFlowGroup()); ruleSetNode.setRuleFlowGroup(null); ruleSetNode.setLanguage(RuleSetNode.DMN_LANG); ruleSetNode.setNamespace((String) parser.getNamespaceURI(decision.getNamespace())); ruleSetNode.setModel(decision.getModel()); ruleSetNode.setDecision(decision.getDecision()); } } if (node instanceof NodeContainer) { postProcessNodes(process, (NodeContainer) node, buildData, parser); } } }
protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { super.handleNode(node, element, uri, localName, parser); String decisionRef = element.getAttribute("decisionRef"); if (decisionRef == null) { throw new IllegalArgumentException("Decision information is mandatory"); } RuleSetNode ruleSetNode = (RuleSetNode) node; ruleSetNode.setRuleFlowGroup(decisionRef); ruleSetNode.setLanguage(RuleSetNode.DRL_LANG); ruleSetNode.setNamespace((String) ruleSetNode.removeParameter(NAMESPACE_PROP)); ruleSetNode.setModel((String) ruleSetNode.removeParameter(MODEL_PROP)); ruleSetNode.setDecision((String) ruleSetNode.removeParameter(DECISION_PROP)); Map<String, String> inputs = new HashMap<>(); Map<String, String> outputs = new HashMap<>(); Map<String, String> inputTypes = new HashMap<>(); Map<String, String> outputTypes = new HashMap<>(); loadDataInputsAndOutputs(element, inputs, outputs, inputTypes, outputTypes, parser); ruleSetNode.setMetaData("DataInputs", inputTypes); ruleSetNode.setMetaData("DataOutputs", outputTypes); for (Entry<String, String> entry : inputs.entrySet()) { ruleSetNode.addInAssociation(new DataAssociation(entry.getValue(), entry.getKey(), Collections.emptyList(), null)); } for (Entry<String, String> entry : outputs.entrySet()) { ruleSetNode.addOutAssociation(new DataAssociation(entry.getKey(), entry.getValue(), Collections.emptyList(), null)); } }
ruleSetNode.setDecision((String) ruleSetNode.removeParameter(DECISION_PROP));
private void postProcessNodes(RuleFlowProcess process, NodeContainer container, ProcessBuildData buildData, ExtensibleXmlParser parser) { for (Node node : container.getNodes()) { if (node instanceof SubProcessNode) { Map<String, String> processes = (Map<String, String>) buildData.getMetaData("ProcessElements"); if (processes != null) { SubProcessNode subprocessNode = (SubProcessNode) node; subprocessNode.setProcessId(processes.getOrDefault(subprocessNode.getProcessId(), subprocessNode.getProcessId())); } } else if (node instanceof RuleSetNode) { Map<String, Decision> decisions = (Map<String, Decision>) buildData.getMetaData("DecisionElements"); RuleSetNode ruleSetNode = (RuleSetNode) node; if (decisions != null && decisions.containsKey(ruleSetNode.getRuleFlowGroup())) { Decision decision = decisions.get(ruleSetNode.getRuleFlowGroup()); ruleSetNode.setRuleFlowGroup(null); ruleSetNode.setLanguage(RuleSetNode.DMN_LANG); ruleSetNode.setNamespace((String) parser.getNamespaceURI(decision.getNamespace())); ruleSetNode.setModel(decision.getModel()); ruleSetNode.setDecision(decision.getDecision()); } } if (node instanceof NodeContainer) { postProcessNodes(process, (NodeContainer) node, buildData, parser); } } }