summaryrefslogtreecommitdiffstats
path: root/aai-schema-gen/src/main/java/org/onap
diff options
context:
space:
mode:
authorLaMont, William(wl2432) <wl2432@att.com>2020-04-14 14:00:00 -0400
committerLaMont, William(wl2432) <wl2432@att.com>2020-04-15 15:36:42 -0400
commit86e7411b128bd7db440eceff7265533844e577bb (patch)
tree82d33b012b11c44e6edcfce8df0b45724ff6ec3e /aai-schema-gen/src/main/java/org/onap
parent8e131584d755d07bb12a99fa0d5981d84ed5592a (diff)
schema-service processing for v19
Issue-ID: AAI-2864 Change-Id: I41a430ec9c9fd69be75bd9d01693249895e0928b Signed-off-by: LaMont, William(wl2432) <wl2432@att.com>
Diffstat (limited to 'aai-schema-gen/src/main/java/org/onap')
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java12
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java9
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java2
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java50
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java16
5 files changed, 64 insertions, 25 deletions
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java
index 9ff0fa3..e75be8f 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java
@@ -87,8 +87,12 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
+ "apidocs/aai_swagger_" + v.toString() + ".diff)");
}
sb.append(
- DOUBLE_LINE_SEPARATOR + " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved.\n\n Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License." + DOUBLE_LINE_SEPARATOR + " You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)" + DOUBLE_LINE_SEPARATOR + " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; 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.\n\n This document is best viewed with Firefox or Chrome. Nodes can be found by appending /#/definitions/node-type-to-find to the path to this document. Edge definitions can be found with the node definitions." + LINE_SEPARATOR + " version: \""
- + v.toString() + "\"" + LINE_SEPARATOR );
+ DOUBLE_LINE_SEPARATOR + " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR + " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License." + DOUBLE_LINE_SEPARATOR + " You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)" + DOUBLE_LINE_SEPARATOR + " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; 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." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR + " This document is best viewed with Firefox or Chrome. ");
+ sb.append(
+ "Nodes can be found by opening the models link below and finding the node-type. ");
+ sb.append(
+ "Edge definitions can be found with the node definitions." + LINE_SEPARATOR + " version: \""
+ + v.toString() + "\"" + LINE_SEPARATOR );
sb.append(" title: Active and Available Inventory REST API" + LINE_SEPARATOR);
sb.append(
" license:" + LINE_SEPARATOR + " name: Apache 2.0" + LINE_SEPARATOR + " url: http://www.apache.org/licenses/LICENSE-2.0.html" + LINE_SEPARATOR);
@@ -257,6 +261,7 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
String pathDescriptionProperty = javaType.getPathDescriptionProperty();
String container = javaType.getContainerProperty();
Vector<String> indexedProps = javaType.getIndexedProps();
+ Vector<String> dslStartNodeProps = javaType.getDslStartNodeProps();
Vector<String> containerProps = new Vector<String>();
if (container != null) {
logger.debug("javaTypeName " + javaTypeName + " container:" + container
@@ -324,7 +329,8 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
NodeGetOperation.addContainerProps(container, containerProps);
}
if (xmlElementElement.isStandardType()) {
- sbProperties.append(xmlElementElement.getTypePropertyYAML());
+ boolean isDslStartNode = dslStartNodeProps.contains(xmlElementElement.getAttribute("name"));
+ sbProperties.append(xmlElementElement.getTypePropertyYAML(isDslStartNode));
++propertyCnt;
}
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java
index 5ab3678..496f3df 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java
@@ -20,6 +20,7 @@
package org.onap.aai.schemagen.genxsd;
import org.apache.commons.lang3.StringUtils;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.schemagen.GenerateXsd;
import java.util.StringTokenizer;
@@ -31,8 +32,9 @@ public class PatchOperation {
private String path;
private String pathParams;
private String prefixForPatch;
+ private SchemaVersion version;
- public PatchOperation(String useOpId, String xmlRootElementName, String tag, String path, String pathParams) {
+ public PatchOperation(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, SchemaVersion v) {
super();
this.useOpId = useOpId;
this.xmlRootElementName = xmlRootElementName;
@@ -40,6 +42,7 @@ public class PatchOperation {
this.path = path;
this.pathParams = pathParams;
this.prefixForPatch = "";
+ this.version = v;
}
public void setPrefixForPatchRef(String prefixForPatchRef) {
this.prefixForPatch = prefixForPatchRef;
@@ -81,8 +84,8 @@ public class PatchOperation {
if ( path.endsWith("/relationship") ) {
pathSb.append(" summary: see node definition for valid relationships\n");
- relationshipExamplesSb.append("[See Examples](apidocs/relations/"+GenerateXsd.getAPIVersion()+"/"+useOpId+".json)");
} else {
+ relationshipExamplesSb.append("[See Examples](apidocs/relations/"+version.toString()+"/"+useOpId+".json)");
pathSb.append(" summary: update an existing " + xmlRootElementName + "\n");
pathSb.append(" description: |\n");
pathSb.append(" Update an existing " + xmlRootElementName + "\n");
@@ -109,7 +112,7 @@ public class PatchOperation {
pathSb.append(pathParams); // for nesting
pathSb.append(" - name: body\n");
pathSb.append(" in: body\n");
- pathSb.append(" description: " + xmlRootElementName + " object that needs to be updated."+relationshipExamplesSb.toString()+"\n");
+ pathSb.append(" description: " + xmlRootElementName + " object that needs to be updated."+relationshipExamplesSb.toString()+"\n");
pathSb.append(" required: true\n");
pathSb.append(" schema:\n");
pathSb.append(" $ref: \"#/definitions/" + prefixForPatch + xmlRootElementName + "\"\n");
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java
index c666d9f..2b3fcf2 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java
@@ -76,7 +76,7 @@ public class PutRelationPathSet {
relations.add("{\"comment\": \"Valid TO Relations that can be added\"}\n");
SortedSet<String> ss=new TreeSet<String>(results.keySet());
for(String key : ss) {
- results.get(key).stream().filter((i) -> (! i.isPrivateEdge())).forEach((i) ->{ String rel = selectedRelation(i); relations.add(rel); logger.debug("Relation added: "+rel); } );
+ results.get(key).stream().filter((i) -> ("NONE".equals(i.getContains()) &&! i.isPrivateEdge())).forEach((i) ->{ String rel = selectedRelation(i); relations.add(rel); logger.debug("Relation added: "+rel); } );
}
} catch(Exception e) {
logger.debug("objectName: "+objectName+"\n"+e);
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java
index 38117e5..785ea68 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java
@@ -37,6 +37,7 @@ public class XSDElement implements Element {
private static final int VALUE_INDEXED_PROPS = 2;
private static final int VALUE_CONTAINER = 3;
private static final int VALUE_REQUIRES = 4;
+ private static final int VALUE_DSLSTARTNODE = 5;
public XSDElement(Element xmlElementElement, String maxOccurs) {
super();
@@ -153,8 +154,9 @@ public class XSDElement implements Element {
}
return pathDescriptionProperty;
}
- public Vector<String> getIndexedProps() {
- Vector<String> indexedProps = new Vector<String>();
+
+ public Vector<String> getProps(int needValue) {
+ Vector<String> props = new Vector<String>();
NodeList xmlPropNodes = this.getElementsByTagName("xml-properties");
for ( int i = 0; i < xmlPropNodes.getLength(); ++i ) {
@@ -173,19 +175,21 @@ public class XSDElement implements Element {
String attrValue = attr.getNodeValue();
if ( attrName == null || attrValue == null )
continue;
- if ( attrValue.equals("indexedProps")) {
+ if ( needValue == VALUE_INDEXED_PROPS && attrValue.equals("indexedProps")) {
useValue = VALUE_INDEXED_PROPS;
+ } else if ( needValue == VALUE_DSLSTARTNODE && attrValue.equals("dslStartNodeProps")) {
+ useValue = VALUE_DSLSTARTNODE;
}
- if ( useValue == VALUE_INDEXED_PROPS && attrName.equals("value")) {
- indexedProps = getIndexedProps( attrValue );
+ if ( useValue != VALUE_NONE && attrName.equals("value")) {
+ props = getProps( attrValue );
}
}
}
}
- return indexedProps;
+ return props;
}
-
- private static Vector<String> getIndexedProps( String attrValue )
+
+ private static Vector<String> getProps( String attrValue )
{
if ( attrValue == null )
return null;
@@ -198,6 +202,14 @@ public class XSDElement implements Element {
}
return result;
}
+
+ public Vector<String> getIndexedProps() {
+ return getProps(VALUE_INDEXED_PROPS);
+ }
+
+ public Vector<String> getDslStartNodeProps() {
+ return getProps(VALUE_DSLSTARTNODE);
+ }
public String getContainerProperty() {
NodeList xmlPropNodes = this.getElementsByTagName("xml-properties");
@@ -407,7 +419,7 @@ public class XSDElement implements Element {
return sb.toString();
}
- public String getTypePropertyYAML() {
+ public String getTypePropertyYAML(boolean isDslStartNode) {
StringBuffer sbProperties = new StringBuffer();
sbProperties.append(" " + this.getAttribute("name") + ":\n");
sbProperties.append(" type: ");
@@ -425,8 +437,21 @@ public class XSDElement implements Element {
else if ( ("java.lang.Boolean").equals(this.getAttribute("type")))
sbProperties.append("boolean\n");
String attrDescription = this.getPathDescriptionProperty();
- if ( attrDescription != null && attrDescription.length() > 0 )
- sbProperties.append(" description: " + attrDescription + "\n");
+ if ( attrDescription != null && attrDescription.length() > 0 ) {
+ if ( !isDslStartNode ) {
+ sbProperties.append(" description: " + attrDescription + "\n");
+ } else {
+ sbProperties.append(" description: |\n");
+ sbProperties.append(" " + attrDescription + "\n");
+ sbProperties.append(" *This property can be used as a filter to find the start node for a dsl query\n");
+ }
+ } else {
+ if ( isDslStartNode ) {
+ sbProperties.append(" description: |\n");
+ sbProperties.append(" \n");
+ sbProperties.append(" *This property can be used as a filter to find the start node for a dsl query\n");
+ }
+ }
String elementAlsoRequiresProperty=this.getRequiresProperty();
if ( StringUtils.isNotEmpty(elementAlsoRequiresProperty) )
sbProperties.append(" also requires: " + elementAlsoRequiresProperty + "\n");
@@ -735,5 +760,4 @@ public class XSDElement implements Element {
}
-}
-
+} \ No newline at end of file
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java
index b75a1dc..40d5c0e 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java
@@ -88,8 +88,12 @@ public class YAMLfromOXM extends OxmFileProcessor {
+ "apidocs/aai_swagger_" + v.toString() + ".diff)");
}
sb.append(
- DOUBLE_LINE_SEPARATOR + " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved." + DOUBLE_LINE_SEPARATOR + " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License.\n\n You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)\n\n Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; 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." + DOUBLE_LINE_SEPARATOR + " This document is best viewed with Firefox or Chrome. Nodes can be found by appending /#/definitions/node-type-to-find to the path to this document. Edge definitions can be found with the node definitions." + LINE_SEPARATOR + " version: \""
- + v.toString() + "\"" + LINE_SEPARATOR );
+ DOUBLE_LINE_SEPARATOR + " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR + " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License." + DOUBLE_LINE_SEPARATOR + " You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)" + DOUBLE_LINE_SEPARATOR + " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; 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." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR + " This document is best viewed with Firefox or Chrome. ");
+ sb.append(
+ "Nodes can be found by opening the models link below and finding the node-type. ");
+ sb.append(
+ "Edge definitions can be found with the node definitions." + LINE_SEPARATOR + " version: \""
+ + v.toString() + "\"" + LINE_SEPARATOR );
sb.append(" title: Active and Available Inventory REST API" + LINE_SEPARATOR);
sb.append(
" license:" + LINE_SEPARATOR + " name: Apache 2.0\n url: http://www.apache.org/licenses/LICENSE-2.0.html" + LINE_SEPARATOR);
@@ -264,6 +268,7 @@ public class YAMLfromOXM extends OxmFileProcessor {
String pathDescriptionProperty = javaType.getPathDescriptionProperty();
String container = javaType.getContainerProperty();
Vector<String> indexedProps = javaType.getIndexedProps();
+ Vector<String> dslStartNodeProps = javaType.getDslStartNodeProps();
Vector<String> containerProps = new Vector<String>();
if (container != null) {
logger.debug("javaTypeName " + javaTypeName + " container:" + container
@@ -345,9 +350,10 @@ public class YAMLfromOXM extends OxmFileProcessor {
GetOperation.addContainerProps(container, containerProps);
}
if (xmlElementElement.isStandardType()) {
- sbProperties.append(xmlElementElement.getTypePropertyYAML());
+ boolean isDslStartNode = dslStartNodeProps.contains(xmlElementElement.getAttribute("name"));
+ sbProperties.append(xmlElementElement.getTypePropertyYAML(isDslStartNode));
if ( !"resource-version".equals(xmlElementElement.getAttribute("name"))) {
- sbPropertiesPatch.append(xmlElementElement.getTypePropertyYAML());
+ sbPropertiesPatch.append(xmlElementElement.getTypePropertyYAML(isDslStartNode));
++patchPropertyCnt;
}
++propertyCnt;
@@ -464,7 +470,7 @@ public class YAMLfromOXM extends OxmFileProcessor {
pathSb.append(put.toString());
// add PATCH
PatchOperation patch = new PatchOperation(useOpId, xmlRootElementName, tag, path,
- pathParams == null ? "" : pathParams.toString());
+ pathParams == null ? "" : pathParams.toString(), this.v);
patch.setPrefixForPatchRef(patchDefinePrefix);
pathSb.append(patch.toString());
// add DELETE