From 58a22a95581d560ba37c5d40c3439b9dc5eac1bf Mon Sep 17 00:00:00 2001 From: jimmy Date: Fri, 8 Sep 2017 14:15:33 -0400 Subject: Adding named-query for APPC Issue-ID: AAI-272 Change-Id: Ibe5222dcc876647354f8147090ea276a8685bddf Signed-off-by: jimmy --- .../org/openecomp/aai/util/MakeNamedQuery.java | 64 ++++++++++++++-------- 1 file changed, 42 insertions(+), 22 deletions(-) (limited to 'aai-traversal/src') 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 processedWidgets = new ArrayList(); - HashMap widgetToRelationship = new HashMap(); + HashMap> widgetToRelationship = new HashMap>(); for (Entry 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 modelVerList = (List) modelVers.getWrappedListValue("model-ver"); for (Introspector modelVer : modelVerList) { - widgetToRelationship.put(widgetName, makeWidgetRelationship(loader, modelInvariantId, - modelVer.getValue("model-version-id").toString())); + + List relList = new ArrayList(); + 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> relationshipMap = new HashMap>(); + + List genericVnfRelationship = widgetToRelationship.get("generic-vnf"); + List vserverRelationship = widgetToRelationship.get("vserver"); + List tenantRelationship = widgetToRelationship.get("tenant"); + List cloudRegionRelationship = widgetToRelationship.get("cloud-region"); + List 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 genericVnfRels = new ArrayList(); - genericVnfRels.add(genericVnfRelationship); - List serviceInstanceRels = new ArrayList(); - serviceInstanceRels.add(serviceInstanceRelationship); - List vceRels = new ArrayList(); - 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 getRels(String widgetName, HashMap widgetToRelationship) { + List relList = new ArrayList(); + Introspector genericVnfRelationship = widgetToRelationship.get(widgetName); + relList.add(genericVnfRelationship); + return relList; + } + private static Introspector setupNQElements (Introspector nqeObj, List listOfRelationships) { Introspector newNQElement = null; try { -- cgit 1.2.3-korg