Add instructions to invoke the linter and code formatter plugins to the README and...
[aai/schema-service.git] / aai-schema-gen / src / main / java / org / onap / aai / schemagen / genxsd / YAMLfromOXM.java
index 849b40c..ff6f7dd 100644 (file)
@@ -22,6 +22,7 @@ package org.onap.aai.schemagen.genxsd;
 
 import com.google.common.base.CharMatcher;
 import com.google.common.collect.Multimap;
+
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -40,7 +41,9 @@ import java.util.StringTokenizer;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.Vector;
+
 import javax.xml.parsers.ParserConfigurationException;
+
 import org.apache.commons.lang3.StringUtils;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.edges.EdgeRule;
@@ -71,7 +74,7 @@ public class YAMLfromOXM extends OxmFileProcessor {
     private String basePath;
 
     public YAMLfromOXM(String basePath, SchemaVersions schemaVersions, NodeIngestor ni,
-                       EdgeIngestor ei) {
+        EdgeIngestor ei) {
         super(schemaVersions, ni, ei);
         this.basePath = basePath;
     }
@@ -94,17 +97,21 @@ public class YAMLfromOXM extends OxmFileProcessor {
         sb.append("swagger: \"2.0\"\ninfo:").append(LINE_SEPARATOR).append("  ");
         sb.append("description: |");
         if (versionSupportsSwaggerDiff(v.toString())) {
-            sb.append("\n\n    [Differences versus the previous schema version]("
-                + "apidocs" + basePath + "/aai_swagger_" + v.toString() + ".diff)");
+            sb.append("\n\n    [Differences versus the previous schema version](" + "apidocs"
+                + basePath + "/aai_swagger_" + v.toString() + ".diff)");
         }
-        sb.append(DOUBLE_LINE_SEPARATOR).append(
-            "    Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.")
-            .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR).append(
-            "    Licensed under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License.")
-            .append(DOUBLE_LINE_SEPARATOR).append(
-            "    You may obtain a copy of the License at\n\n    (https://creativecommons.org/licenses/by/4.0/)")
-            .append(DOUBLE_LINE_SEPARATOR).append(
-            "    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.")
+        sb.append(DOUBLE_LINE_SEPARATOR)
+            .append(
+                "    Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.")
+            .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR)
+            .append(
+                "    Licensed under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License.")
+            .append(DOUBLE_LINE_SEPARATOR)
+            .append(
+                "    You may obtain a copy of the License at\n\n    (https://creativecommons.org/licenses/by/4.0/)")
+            .append(DOUBLE_LINE_SEPARATOR)
+            .append(
+                "    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.")
             .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR)
             .append("    This document is best viewed with Firefox or Chrome. ");
         sb.append(
@@ -112,8 +119,9 @@ public class YAMLfromOXM extends OxmFileProcessor {
         sb.append("Edge definitions can be found with the node definitions.").append(LINE_SEPARATOR)
             .append("  version: \"").append(v.toString()).append("\"").append(LINE_SEPARATOR);
         sb.append("  title: Active and Available Inventory REST API").append(LINE_SEPARATOR);
-        sb.append("  license:").append(LINE_SEPARATOR).append(
-            "    name: Apache 2.0\n    url: http://www.apache.org/licenses/LICENSE-2.0.html")
+        sb.append("  license:").append(LINE_SEPARATOR)
+            .append(
+                "    name: Apache 2.0\n    url: http://www.apache.org/licenses/LICENSE-2.0.html")
             .append(LINE_SEPARATOR);
         sb.append("  contact:").append(LINE_SEPARATOR).append("    name: n/a")
             .append(LINE_SEPARATOR).append("    url: n/a").append(LINE_SEPARATOR)
@@ -238,9 +246,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
         return dictSb.toString();
     }
 
-    private String processJavaTypeElementSwagger(
-        String javaTypeName, Element javaTypeElement, StringBuilder pathSb,
-        StringBuilder definitionsSb, String path, String tag, String opId,
+    private String processJavaTypeElementSwagger(String javaTypeName, Element javaTypeElement,
+        StringBuilder pathSb, StringBuilder definitionsSb, String path, String tag, String opId,
         String getItemName, StringBuilder pathParams, String validEdges) {
 
         String xmlRootElementName = getXMLRootElementName(javaTypeElement);
@@ -302,8 +309,9 @@ public class YAMLfromOXM extends OxmFileProcessor {
         NodeList xmlElementNodes = parentElement.getElementsByTagName("xml-element");
 
         StringBuilder sbParameters = new StringBuilder();
-        StringBuilder sbPathParameters =
-            new StringBuilder(); // separate naming path parameters from name of parameter in the schema
+        StringBuilder sbPathParameters = new StringBuilder(); // separate naming path parameters
+                                                              // from name of parameter in the
+                                                              // schema
         StringBuilder sbRequired = new StringBuilder();
 
         int requiredCnt = 0;
@@ -339,8 +347,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
             // use alternate name for parameter if already in the path string
             modifiedName = "/{" + xmlElementElement.getAttribute("name") + "}";
             if (path.contains(modifiedName)) {
-                modifiedName = path.substring(path.lastIndexOf('/') + 1) + "." +
-                    xmlElementElement.getAttribute("name");
+                modifiedName = path.substring(path.lastIndexOf('/') + 1) + "."
+                    xmlElementElement.getAttribute("name");
             } else {
                 modifiedName = xmlElementElement.getAttribute("name");
             }
@@ -443,9 +451,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
                         .equals(xmlElementElement.getAttribute("container-type"))) {
                         // need properties for getXmlRootElementName(addType)
                         namespaceFilter.add(getXmlRootElementName(addType));
-                        newPathParams =
-                            new StringBuilder((pathParams == null ? "" : pathParams.toString())
-                                + sbParameters);
+                        newPathParams = new StringBuilder(
+                            (pathParams == null ? "" : pathParams.toString()) + sbParameters);
                         processJavaTypeElementSwagger(addType, getJavaTypeElementSwagger(addType),
                             pathSb, definitionsSb, path, tag == null ? useTag : tag, useOpId, null,
                             newPathParams, validEdges);
@@ -644,8 +651,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
         if (patchPropertyCnt > 0) {
             definitionsLocalPatchSb.append("  " + patchDefinePrefix).append(xmlRootElementName)
                 .append(":\n");
-            if (StringUtils.isNotEmpty(pathDescriptionProperty) ||
-                StringUtils.isNotEmpty(validEdges)) {
+            if (StringUtils.isNotEmpty(pathDescriptionProperty)
+                || StringUtils.isNotEmpty(validEdges)) {
                 definitionsLocalPatchSb.append("    description: |\n");
             }
             if (pathDescriptionProperty != null) {
@@ -721,8 +728,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
             parentDir.mkdirs();
         }
         try {
-            if(!outfile.createNewFile()) {
-                logger.error( "File {} already exist", outfileName);
+            if (!outfile.createNewFile()) {
+                logger.error("File {} already exist", outfileName);
             }
         } catch (IOException e) {
             logger.error("Exception creating output file " + outfileName, e);
@@ -747,4 +754,3 @@ public class YAMLfromOXM extends OxmFileProcessor {
     }
 
 }
-