summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManisha Aggarwal <ma9181@att.com>2017-09-11 13:17:30 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-11 13:17:30 +0000
commite08ff66979e68caf67f9fff081742b609f84b9b4 (patch)
tree42f410e8cd86074a26d63ce25ffe295ecfd14d4f
parent12b7cd08164d0e79faa5833b445407ad6afd98eb (diff)
parent58a22a95581d560ba37c5d40c3439b9dc5eac1bf (diff)
Merge "Adding named-query for APPC"
-rw-r--r--aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/vnf-to-esr-system-info-1.0.json71
-rw-r--r--aai-traversal/bundleconfig-local/etc/scriptdata/widget-model-json/esr-system-info-1.0.json11
-rw-r--r--aai-traversal/src/main/java/org/openecomp/aai/util/MakeNamedQuery.java64
3 files changed, 124 insertions, 22 deletions
diff --git a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/vnf-to-esr-system-info-1.0.json b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/vnf-to-esr-system-info-1.0.json
new file mode 100644
index 0000000..c371796
--- /dev/null
+++ b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/vnf-to-esr-system-info-1.0.json
@@ -0,0 +1,71 @@
+{
+ "named-query-uuid" : "037eb932-edac-48f5-9782-c19c0aa5a031",
+ "named-query-name" : "vnf-to-esr-system-info",
+ "named-query-version" : "1.0",
+ "description" : "Named Query - VNF to ESR System Info",
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "0562518b-e5b3-49f4-8ad8-19b43766c79d"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "425b2158-e51d-4509-9945-dad4556474a3"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "97c26c99-6870-44c1-8a07-1d900d3f4ce6"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "ff69d4e0-a8e8-4108-bdb0-dd63217e63c7"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "acc6edd8-a8d4-4b93-afaa-0994068be14c"
+ } ]
+ } ]
+ }
+ } ]
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/bundleconfig-local/etc/scriptdata/widget-model-json/esr-system-info-1.0.json b/aai-traversal/bundleconfig-local/etc/scriptdata/widget-model-json/esr-system-info-1.0.json
new file mode 100644
index 0000000..54a3bc8
--- /dev/null
+++ b/aai-traversal/bundleconfig-local/etc/scriptdata/widget-model-json/esr-system-info-1.0.json
@@ -0,0 +1,11 @@
+{
+ "model-invariant-id" : "0562518b-e5b3-49f4-8ad8-19b43766c79d",
+ "model-type" : "widget",
+ "model-vers" : {
+ "model-ver" : [ {
+ "model-version-id" : "5ded840b-42aa-4692-a7ac-9a6ed5f3146b",
+ "model-version" : "1.0",
+ "model-name" : "esr-system-info"
+ } ]
+ }
+}
diff --git a/aai-traversal/src/main/java/org/openecomp/aai/util/MakeNamedQuery.java b/aai-traversal/src/main/java/org/openecomp/aai/util/MakeNamedQuery.java
index 3f984a3..c6ca599 100644
--- a/aai-traversal/src/main/java/org/openecomp/aai/util/MakeNamedQuery.java
+++ b/aai-traversal/src/main/java/org/openecomp/aai/util/MakeNamedQuery.java
@@ -77,7 +77,7 @@ public class MakeNamedQuery {
ArrayList<String> processedWidgets = new ArrayList<String>();
- HashMap<String, Introspector> widgetToRelationship = new HashMap<String, Introspector>();
+ HashMap<String, List<Introspector>> widgetToRelationship = new HashMap<String, List<Introspector>>();
for (Entry<String, Introspector> aaiResEnt : loader.getAllObjects().entrySet()) {
Introspector meObject = loader.introspectorFromName("model");
// no need for a ModelVers DynamicEntity
@@ -105,46 +105,66 @@ public class MakeNamedQuery {
Introspector modelVers = meObject.getWrappedValue("model-vers");
List<Introspector> modelVerList = (List<Introspector>) modelVers.getWrappedListValue("model-ver");
for (Introspector modelVer : modelVerList) {
- widgetToRelationship.put(widgetName, makeWidgetRelationship(loader, modelInvariantId,
- modelVer.getValue("model-version-id").toString()));
+
+ List<Introspector> relList = new ArrayList<Introspector>();
+ Introspector widgetRelationship = makeWidgetRelationship(loader, modelInvariantId,
+ modelVer.getValue("model-version-id").toString());
+ relList.add(widgetRelationship);
+
+ widgetToRelationship.put(widgetName, relList);
}
}
}
}
}
+
+// esr-system-info-from-vnf=builder.store('x').union(\
+// builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(\
+// builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x')\
+// .createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x')\
+// .createEdgeTraversal(EdgeType.TREE, 'cloud-region', 'esr-system-info').store('x')\
+// )).cap('x').unfold.dedup()
+
//source vnf-id, related service-instance-id, all related vnfs in this service-instance-id
- Introspector genericVnfRelationship = widgetToRelationship.get("generic-vnf");
- Introspector serviceInstanceRelationship = widgetToRelationship.get("service-instance");
- Introspector vceRelationship = widgetToRelationship.get("vce");
+
+ //this should be abstracted and moved to a file
+
+ HashMap<String, List<Introspector>> relationshipMap = new HashMap<String, List<Introspector>>();
+
+ List<Introspector> genericVnfRelationship = widgetToRelationship.get("generic-vnf");
+ List<Introspector> vserverRelationship = widgetToRelationship.get("vserver");
+ List<Introspector> tenantRelationship = widgetToRelationship.get("tenant");
+ List<Introspector> cloudRegionRelationship = widgetToRelationship.get("cloud-region");
+ List<Introspector> esrSystemInfoRelationship = widgetToRelationship.get("esr-system-info");
Introspector namedQueryObj = loader.introspectorFromName("named-query");
namedQueryObj.setValue("named-query-uuid", namedQueryUuid);
- namedQueryObj.setValue("named-query-name", "vnf-to-service-instance");
+ namedQueryObj.setValue("named-query-name", "vnf-to-esr-system-info");
namedQueryObj.setValue("named-query-version", "1.0");
- namedQueryObj.setValue("description", "Named Query - VNF to Service Instance");
-
- List<Introspector> genericVnfRels = new ArrayList<Introspector>();
- genericVnfRels.add(genericVnfRelationship);
- List<Introspector> serviceInstanceRels = new ArrayList<Introspector>();
- serviceInstanceRels.add(serviceInstanceRelationship);
- List<Introspector> vceRels = new ArrayList<Introspector>();
- vceRels.add(vceRelationship);
-
-
- Introspector genericVnfNQE = setupNQElements(namedQueryObj, genericVnfRels);
+ namedQueryObj.setValue("description", "Named Query - VNF to ESR System Info");
+
+ Introspector genericVnfNQE = setupNQElements(namedQueryObj, genericVnfRelationship);
- //Introspector vceNQE2 = setupNQElements(namedQueryObj, vceRels);
+ Introspector vserverNQE = setupNQElements(genericVnfNQE, vserverRelationship);
- Introspector serviceInstanceNQE = setupNQElements(genericVnfNQE, serviceInstanceRels);
+ Introspector tenantNQE = setupNQElements(vserverNQE, tenantRelationship);
- Introspector newGenericVnfNQE = setupNQElements(serviceInstanceNQE, genericVnfRels);
+ Introspector cloudRegionNQE = setupNQElements(tenantNQE, cloudRegionRelationship);
+
+ Introspector esrSystemInfoNQE = setupNQElements(cloudRegionNQE, esrSystemInfoRelationship);
System.out.println(namedQueryObj.marshal(true));
System.exit(0);
}
-
+ private static List<Introspector> getRels(String widgetName, HashMap<String, Introspector> widgetToRelationship) {
+ List<Introspector> relList = new ArrayList<Introspector>();
+ Introspector genericVnfRelationship = widgetToRelationship.get(widgetName);
+ relList.add(genericVnfRelationship);
+ return relList;
+ }
+
private static Introspector setupNQElements (Introspector nqeObj, List<Introspector> listOfRelationships) {
Introspector newNQElement = null;
try {