From: Shwetank Dave Date: Mon, 24 Dec 2018 17:32:42 +0000 (-0500) Subject: Fix bug in gixmo interface X-Git-Tag: 1.4.0~11 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fmodel-loader.git;a=commitdiff_plain;h=c919bbafb8163529c56588f06caee60d1d87356f Fix bug in gixmo interface Change-Id: I75a6d3fdde11359aa834113c97f9b35a8744e902 Issue-ID: AAI-1957 Signed-off-by: Shwetank Dave --- diff --git a/src/main/java/org/onap/aai/modelloader/util/GizmoTranslator.java b/src/main/java/org/onap/aai/modelloader/util/GizmoTranslator.java index cb08a25..2f4469f 100644 --- a/src/main/java/org/onap/aai/modelloader/util/GizmoTranslator.java +++ b/src/main/java/org/onap/aai/modelloader/util/GizmoTranslator.java @@ -2,8 +2,8 @@ * ============LICENSE_START========================================== * org.onap.aai * =================================================================== - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +63,8 @@ public class GizmoTranslator { private static Logger logger = LoggerFactory.getInstance().getLogger(GizmoTranslator.class.getName()); public static String translate(String xmlPayload) throws ParserConfigurationException, SAXException, IOException { + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Process XML model artifact: " + xmlPayload); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); DocumentBuilder builder = factory.newDocumentBuilder(); @@ -202,6 +204,28 @@ public class GizmoTranslator { private static String generateModelElementId(Element node) { Set elemSet = new HashSet<>(); + // Get the parent model version / named query version + String parentVersion = null; + Node parentNode = node.getParentNode(); + while ( (parentNode != null) && (parentVersion == null) ) { + if (getNodeType(parentNode).equals(NodeType.VERTEX)) { + NodeList childNodes = ((Element)parentNode).getElementsByTagName("*"); + for (int ix = 0; ix < childNodes.getLength(); ix++) { + if (childNodes.item(ix).getNodeName().equalsIgnoreCase("named-query-uuid") || + childNodes.item(ix).getNodeName().equalsIgnoreCase("model-version-id")) { + parentVersion = childNodes.item(ix).getTextContent().trim(); + break; + } + } + } + + parentNode = parentNode.getParentNode(); + } + + if (parentVersion != null) { + elemSet.add(parentVersion); + } + NodeList childNodes = node.getElementsByTagName("*"); for (int ix = 0; ix < childNodes.getLength(); ix++) { NodeType nt = getNodeType(childNodes.item(ix));