diff options
author | Kajur, Harish (vk250x) <vk250x@att.com> | 2018-11-01 15:44:03 -0400 |
---|---|---|
committer | Kajur, Harish (vk250x) <vk250x@att.com> | 2018-11-01 15:44:09 -0400 |
commit | 9bae143d3310eb57bfbb0674f62f278f740db0f4 (patch) | |
tree | cf1e08c39254d408f0a5726439288f8053f89ca3 | |
parent | 653948302e921dbcee24ed6746c73557c0b54c92 (diff) |
Replace platform specific line seperators System
Issue-ID: AAI-1463
Change-Id: Ibdd3803dd825342d54dfa1b008f1a8c2d78d6198
Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
5 files changed, 196 insertions, 189 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/HTMLfromOXM.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/HTMLfromOXM.java index b1a4d919..7d3b37d1 100644 --- a/aai-core/src/main/java/org/onap/aai/util/genxsd/HTMLfromOXM.java +++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/HTMLfromOXM.java @@ -28,7 +28,7 @@ import java.util.List; import javax.xml.parsers.ParserConfigurationException; -import org.apache.commons.lang.StringUtils; + import org.onap.aai.config.SpringContextAware; import org.onap.aai.edges.EdgeIngestor; import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; @@ -42,16 +42,12 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -import com.google.common.base.CaseFormat; - public class HTMLfromOXM extends OxmFileProcessor { private static final Logger logger = LoggerFactory.getLogger("HTMLfromOXM.class"); - public static final String LINE_SEPARATOR = System.getProperty("line.separator"); private String maxOccurs; @@ -77,7 +73,7 @@ public class HTMLfromOXM extends OxmFileProcessor { public String getDocumentHeader() { StringBuffer sb = new StringBuffer(); logger.trace("processing starts"); - sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + LINE_SEPARATOR); String namespace = "org.onap"; if (v.compareTo(getSchemaVersions().getNamespaceChangeVersion()) < 0 ) { namespace = "org.openecomp"; @@ -85,22 +81,22 @@ public class HTMLfromOXM extends OxmFileProcessor { if ( versionUsesAnnotations(v.toString()) ) { sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://" + namespace + ".aai.inventory/" + v.toString() + "\" xmlns:tns=\"http://" + namespace + ".aai.inventory/" + v.toString() + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"" - + "\n" - + "xmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\"\r\n" + - " jaxb:version=\"2.1\"\r\n" + - " xmlns:annox=\"http://annox.dev.java.net\"\r\n" + - " jaxb:extensionBindingPrefixes=\"annox\">\n\n"); + + LINE_SEPARATOR + + "xmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\"" + LINE_SEPARATOR + + " jaxb:version=\"2.1\"" + LINE_SEPARATOR + + " xmlns:annox=\"http://annox.dev.java.net\"" + LINE_SEPARATOR + + " jaxb:extensionBindingPrefixes=\"annox\">" + DOUBLE_LINE_SEPARATOR); } else { sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://" + namespace + ".aai.inventory/" - + v.toString() + "\" xmlns:tns=\"http://" + namespace + ".aai.inventory/" + v.toString() + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n\n"); + + v.toString() + "\" xmlns:tns=\"http://" + namespace + ".aai.inventory/" + v.toString() + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" + DOUBLE_LINE_SEPARATOR); } return sb.toString(); } - @Override public String process() throws ParserConfigurationException, SAXException, IOException, AAIException, FileNotFoundException, EdgeRuleNotFoundException { StringBuilder sb = new StringBuilder(); + try { init(); } catch(Exception e) { @@ -141,11 +137,10 @@ public class HTMLfromOXM extends OxmFileProcessor { sb.append(processJavaTypeElement( javaTypeName, javaTypeElement, sbInventory )); } sb.append(sbInventory); - sb.append(" </xs:sequence>\n"); - sb.append(" </xs:complexType>\n"); - sb.append(" </xs:element>\n"); - sb.append("</xs:schema>\n"); - StringBuilder invalidSb = new StringBuilder(); + sb.append(" </xs:sequence>" + LINE_SEPARATOR); + sb.append(" </xs:complexType>" + LINE_SEPARATOR); + sb.append(" </xs:element>" + LINE_SEPARATOR); + sb.append("</xs:schema>" + LINE_SEPARATOR); return sb.toString(); } @@ -156,6 +151,14 @@ public class HTMLfromOXM extends OxmFileProcessor { String pattern = "^[a-z0-9-]*$"; return name.matches(pattern); } + + protected boolean skipCheck( String javaAttribute ) { + if ( javaAttribute.equals("model") + || javaAttribute.equals("eventHeader") ) { + return true; + } + return false; + } public String processJavaTypeElement( String javaTypeName, Element javaType_Element, StringBuilder sbInventory) { String xmlRootElementName = getXMLRootElementName(javaType_Element); @@ -183,15 +186,15 @@ public class HTMLfromOXM extends OxmFileProcessor { if ( xmlElementNodes.getLength() > 0 ) { if ( !processingInventory || !hasPreviousInventory ) { - sb1.append(" <xs:element name=\"" + xmlRootElementName + "\">\n"); - sb1.append(" <xs:complexType>\n"); + sb1.append(" <xs:element name=\"" + xmlRootElementName + "\">" + LINE_SEPARATOR); + sb1.append(" <xs:complexType>" + LINE_SEPARATOR); XSDElement javaTypeElement = new XSDElement(javaType_Element, maxOccurs); logger.debug("XSDElement name: "+javaTypeElement.name()); if(versionUsesAnnotations(v.toString())) { sb1.append(javaTypeElement.getHTMLAnnotation("class", " ")); } - sb1.append(" <xs:sequence>\n"); + sb1.append(" <xs:sequence>" + LINE_SEPARATOR); } Element javatypeElement; for ( int i = 0; i < xmlElementNodes.getLength(); ++i ) { @@ -205,7 +208,6 @@ public class HTMLfromOXM extends OxmFileProcessor { if ( elementType.contains("." + v.toString() + ".") && !generatedJavaType.containsKey(addType) ) { generatedJavaType.put(addType, elementType); javatypeElement = getJavaTypeElement(addType, processingInventory); - sb.append(processJavaTypeElement( addType, javatypeElement, null )); } if ("Nodes".equals(addType)) { @@ -216,18 +218,18 @@ public class HTMLfromOXM extends OxmFileProcessor { sb1.append(xmlElementElement.getHTMLElement(v, versionUsesAnnotations(v.toString()), this)); } if ( !processingInventory ) { - sb1.append(" </xs:sequence>\n"); - sb1.append(" </xs:complexType>\n"); - sb1.append(" </xs:element>\n"); + sb1.append(" </xs:sequence>" + LINE_SEPARATOR); + sb1.append(" </xs:complexType>" + LINE_SEPARATOR); + sb1.append(" </xs:element>" + LINE_SEPARATOR); } } if ( xmlElementNodes.getLength() < 1 ) { - sb.append(" <xs:element name=\"" + xmlRootElementName + "\">\n"); - sb.append(" <xs:complexType>\n"); - sb.append(" <xs:sequence/>\n"); - sb.append(" </xs:complexType>\n"); - sb.append(" </xs:element>\n"); + sb.append(" <xs:element name=\"" + xmlRootElementName + "\">" + LINE_SEPARATOR); + sb.append(" <xs:complexType>" + LINE_SEPARATOR); + sb.append(" <xs:sequence/>" + LINE_SEPARATOR); + sb.append(" </xs:complexType>" + LINE_SEPARATOR); + sb.append(" </xs:element>" + LINE_SEPARATOR); generatedJavaType.put(javaTypeName, null); return sb.toString(); } @@ -283,4 +285,4 @@ public class HTMLfromOXM extends OxmFileProcessor { } return false; } -}
\ No newline at end of file +} diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/OxmFileProcessor.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/OxmFileProcessor.java index 44e5a9f8..a758be50 100644 --- a/aai-core/src/main/java/org/onap/aai/util/genxsd/OxmFileProcessor.java +++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/OxmFileProcessor.java @@ -62,6 +62,10 @@ import org.xml.sax.SAXException; import org.xml.sax.InputSource; public abstract class OxmFileProcessor { + + public static final String LINE_SEPARATOR = System.getProperty("line.separator"); + public static final String DOUBLE_LINE_SEPARATOR = System.getProperty("line.separator") + System.getProperty("line.separator"); + EdgeIngestor ei; NodeIngestor ni; protected Set<String> namespaceFilter; diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java index 1494b8f6..9de7967e 100644 --- a/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java +++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java @@ -314,11 +314,11 @@ public class XSDElement implements Element { } if(useAnnotation) { String annotation = new XSDElement(xmlElementElement, maxOccurs).getHTMLAnnotation("field", " "); - sbElement.append(StringUtils.isNotEmpty(annotation) ? ">\n" : ""); + sbElement.append(StringUtils.isNotEmpty(annotation) ? ">" + OxmFileProcessor.LINE_SEPARATOR : ""); sbElement.append(annotation); - sbElement.append(StringUtils.isNotEmpty(annotation) ? " </xs:element>\n" : "/>\n" ); + sbElement.append(StringUtils.isNotEmpty(annotation) ? " </xs:element>" + OxmFileProcessor.LINE_SEPARATOR : "/>" + OxmFileProcessor.LINE_SEPARATOR ); } else { - sbElement.append("/>\n"); + sbElement.append("/>" + OxmFileProcessor.LINE_SEPARATOR); } return this.getHTMLElementWrapper(sbElement.toString(), v, useAnnotation); // return sbElement.toString(); @@ -346,18 +346,18 @@ public class XSDElement implements Element { if ( elementIsRequired == null || !elementIsRequired.equals("true")||addType != null) { sbElement.append(" minOccurs=\"0\""); } - sbElement.append(">\n"); - sbElement.append(" <xs:complexType>\n"); + sbElement.append(">" + OxmFileProcessor.LINE_SEPARATOR); + sbElement.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); if(useAnnotation) { XSDElement javaTypeElement = new XSDElement((Element)this.getParentNode(), maxOccurs); sbElement.append(javaTypeElement.getHTMLAnnotation("class", " ")); } - sbElement.append(" <xs:sequence>\n"); + sbElement.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); sbElement.append(" "); sbElement.append(unwrappedElement); - sbElement.append(" </xs:sequence>\n"); - sbElement.append(" </xs:complexType>\n"); - sbElement.append(" </xs:element>\n"); + sbElement.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sbElement.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sbElement.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); return sbElement.toString(); } @@ -394,12 +394,12 @@ public class XSDElement implements Element { if(metadata.size() == 0) { return ""; } - sb.append(indentation +"<xs:annotation>\r\n"); + sb.append(indentation +"<xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); sb.append( - indentation + " <xs:appinfo>\r\n" + - indentation + " <annox:annotate target=\""+target+"\">@org.onap.aai.annotations.Metadata(" + Joiner.on(",").join(metadata) + ")</annox:annotate>\r\n" + - indentation + " </xs:appinfo>\r\n"); - sb.append(indentation +"</xs:annotation>\r\n"); + indentation + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + + indentation + " <annox:annotate target=\""+target+"\">@org.onap.aai.annotations.Metadata(" + Joiner.on(",").join(metadata) + ")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + + indentation + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(indentation +"</xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); return sb.toString(); } @@ -731,5 +731,4 @@ public class XSDElement implements Element { } -} - +}
\ No newline at end of file diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java index 5e019196..57835b50 100644 --- a/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java @@ -33,6 +33,7 @@ import java.nio.file.Paths; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.onap.aai.config.SwaggerGenerationConfiguration; import org.onap.aai.setup.SchemaVersion; @@ -140,7 +141,7 @@ public class HTMLfromOXMTest { logger.debug(fileContent); assertThat(fileContent, is(HTMLresult(0))); } - + @Test public void testProcessWithCombiningJavaTypes() { SchemaVersion v = schemaVersions.getAppRootVersion(); @@ -226,11 +227,11 @@ public class HTMLfromOXMTest { public String HTMLheader() { StringBuilder sb = new StringBuilder(1500); - sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"); - sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://org.onap.aai.inventory/v11\" xmlns:tns=\"http://org.onap.aai.inventory/v11\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\nxmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\"\r\n"); - sb.append(" jaxb:version=\"2.1\"\r\n"); - sb.append(" xmlns:annox=\"http://annox.dev.java.net\"\r\n"); - sb.append(" jaxb:extensionBindingPrefixes=\"annox\">\n\n"); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://org.onap.aai.inventory/v11\" xmlns:tns=\"http://org.onap.aai.inventory/v11\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"" + OxmFileProcessor.LINE_SEPARATOR + "xmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\"" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" jaxb:version=\"2.1\"" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" xmlns:annox=\"http://annox.dev.java.net\"" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" jaxb:extensionBindingPrefixes=\"annox\">" + OxmFileProcessor.DOUBLE_LINE_SEPARATOR); return sb.toString(); } @@ -239,144 +240,145 @@ public class HTMLfromOXMTest { } public String HTMLdefs(int sbopt) { StringBuilder sb = new StringBuilder(1500); - sb.append(" <xs:element name=\"service-subscription\">\n"); - sb.append(" <xs:complexType>\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" <xs:sequence>\n"); - sb.append(" <xs:element name=\"service-type\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Value defined by orchestration to identify this service.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"temp-ub-sub-account-id\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"This property will be deleted from A&AI in the near future. Only stop gap solution.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); - sb.append(" </xs:sequence>\n"); - sb.append(" </xs:complexType>\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"service-subscriptions\">\n"); - sb.append(" <xs:complexType>\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" <xs:sequence>\n"); - sb.append(" <xs:element ref=\"tns:service-subscription\" minOccurs=\"0\" maxOccurs=\"5000\"/>\n"); - sb.append(" </xs:sequence>\n"); - sb.append(" </xs:complexType>\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"customer\">\n"); - sb.append(" <xs:complexType>\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); + sb.append(" <xs:element name=\"service-subscription\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"service-type\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Value defined by orchestration to identify this service.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"temp-ub-sub-account-id\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"This property will be deleted from A&AI in the near future. Only stop gap solution.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"service-subscriptions\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element ref=\"tns:service-subscription\" minOccurs=\"0\" maxOccurs=\"5000\"/>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"customer\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); if ( sbopt == 0 ) { - sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>\r\n"); + sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); } else { - sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-type,subscriber-name,global-customer-id\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>\r\n"); + sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-type,subscriber-name,global-customer-id\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); } - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" <xs:sequence>\n"); - sb.append(" <xs:element name=\"global-customer-id\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Global customer id used across to uniquely identify customer.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"subscriber-name\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber name, an alternate way to retrieve a customer.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"global-customer-id\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Global customer id used across to uniquely identify customer.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"subscriber-name\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber name, an alternate way to retrieve a customer.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); if ( sbopt == 0 ) { - sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); + sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); } else { - sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); + sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); } - sb.append(" <xs:element ref=\"tns:service-subscriptions\" minOccurs=\"0\"/>\n"); - sb.append(" </xs:sequence>\n"); - sb.append(" </xs:complexType>\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"customers\">\n"); - sb.append(" <xs:complexType>\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" <xs:sequence>\n"); - sb.append(" <xs:element ref=\"tns:customer\" minOccurs=\"0\" maxOccurs=\"5000\"/>\n"); - sb.append(" </xs:sequence>\n"); - sb.append(" </xs:complexType>\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"business\">\n"); - sb.append(" <xs:complexType>\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" <xs:sequence>\n"); - sb.append(" <xs:element ref=\"tns:customers\" minOccurs=\"0\"/>\n"); - sb.append(" </xs:sequence>\n"); - sb.append(" </xs:complexType>\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"inventory\">\n"); - sb.append(" <xs:complexType>\n"); - sb.append(" <xs:sequence>\n"); - sb.append(" <xs:element ref=\"tns:business\" minOccurs=\"0\"/>\n"); - sb.append(" </xs:sequence>\n"); - sb.append(" </xs:complexType>\n"); - sb.append(" </xs:element>\n"); - sb.append("</xs:schema>\n"); + sb.append(" <xs:element ref=\"tns:service-subscriptions\" minOccurs=\"0\"/>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"customers\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element ref=\"tns:customer\" minOccurs=\"0\" maxOccurs=\"5000\"/>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"business\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element ref=\"tns:customers\" minOccurs=\"0\"/>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element name=\"inventory\">" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" <xs:element ref=\"tns:business\" minOccurs=\"0\"/>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR); + sb.append("</xs:schema>" + OxmFileProcessor.LINE_SEPARATOR); return sb.toString(); } } + diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java index 7f0d1ed7..cfab4cc2 100644 --- a/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java @@ -564,11 +564,11 @@ public class XSDElementTest { @Test public void testGetHTMLAnnotation() { ArrayList<String> target = new ArrayList<String>(); - target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"Business\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n"); - target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"Customers\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n"); - target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"Customer\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n"); - target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"ServiceSubscriptions\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n"); - target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"ServiceSubscription\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n"); + target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"Business\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"Customers\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"Customer\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"ServiceSubscriptions\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); + target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"ServiceSubscription\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR); List<String> annotes = new ArrayList<String>(); for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) { XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i)); |