diff options
author | Manisha Aggarwal <ma9181@att.com> | 2017-09-11 13:17:30 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-11 13:17:30 +0000 |
commit | e08ff66979e68caf67f9fff081742b609f84b9b4 (patch) | |
tree | 42f410e8cd86074a26d63ce25ffe295ecfd14d4f /aai-traversal/src/main/java | |
parent | 12b7cd08164d0e79faa5833b445407ad6afd98eb (diff) | |
parent | 58a22a95581d560ba37c5d40c3439b9dc5eac1bf (diff) |
Merge "Adding named-query for APPC"
Diffstat (limited to 'aai-traversal/src/main/java')
-rw-r--r-- | aai-traversal/src/main/java/org/openecomp/aai/util/MakeNamedQuery.java | 64 |
1 files changed, 42 insertions, 22 deletions
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 { |