X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=models-interactions%2Fmodel-impl%2Faai%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Faai%2FAaiCqResponse.java;h=7024231e30972b13b75665e926d02fde9ec30aae;hb=e940ccf7d38373c145b5d5f4a95603edaa089796;hp=dea11d56337187ae56b2294c4134e826756f0f3a;hpb=e936413c9082afed0fef4646b8f12d351c87800c;p=policy%2Fmodels.git diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java index dea11d563..7024231e3 100644 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java @@ -55,7 +55,6 @@ public class AaiCqResponse { private static JAXBContext jaxbContext; private static Unmarshaller unmarshaller; - // JABX initial stuff static { Map properties = new HashMap<>(); @@ -63,8 +62,17 @@ public class AaiCqResponse { properties.put(JAXBContextProperties.JSON_INCLUDE_ROOT, false); // Define JAXB context try { - jaxbContext = JAXBContextFactory.createContext(new Class[] {Vserver.class, GenericVnf.class, VfModule.class, - CloudRegion.class, ServiceInstance.class, Tenant.class, ModelVer.class}, properties); + // @formatter:off + jaxbContext = JAXBContextFactory.createContext(new Class[] { + Vserver.class, + GenericVnf.class, + VfModule.class, + CloudRegion.class, + ServiceInstance.class, + Tenant.class, + ModelVer.class + }, properties); + // @formatter:on unmarshaller = jaxbContext.createUnmarshaller(); } catch (JAXBException e) { LOGGER.error("Could not initialize JAXBContext", e); @@ -75,7 +83,6 @@ public class AaiCqResponse { @SerializedName("results") private List inventoryResponseItems = new LinkedList<>(); - /** * Constructor creates a custom query response from a valid json string. * @@ -184,12 +191,8 @@ public class AaiCqResponse { } - - } - - private T getAaiObject(StreamSource json, final Class classOfResponse) { try { return unmarshaller.unmarshal(json, classOfResponse).getValue(); @@ -289,7 +292,6 @@ public class AaiCqResponse { } - /** * Returns a generic Vnf matching vnf name. * @@ -340,7 +342,6 @@ public class AaiCqResponse { } - /** * Returns a generic Vnf of a given VF Module ID. * @@ -362,8 +363,6 @@ public class AaiCqResponse { return null; } - - /** * Get the generic vnf associated with the vserver in the custom query. * @@ -382,7 +381,8 @@ public class AaiCqResponse { String genericVnfId = ""; List relationshipData = null; - // Iterate through the list of relationships and get generic vnf relationship data + // Iterate through the list of relationships and get generic vnf + // relationship data for (Relationship r : relations) { // Get the name of generic-vnf related to this server if (GENERIC_VNF.equals(r.getRelatedTo())) { @@ -410,7 +410,6 @@ public class AaiCqResponse { return genericVnf; } - /** * Get Vf Module associated with the vserver in the custom query. * @@ -430,7 +429,8 @@ public class AaiCqResponse { String vfModuleId = ""; List relationshipData = null; - // Iterate through the list of relationships and get vf module relationship data + // Iterate through the list of relationships and get vf module + // relationship data for (Relationship r : relations) { // Get relationship data of vfmodule related to this server if (VF_MODULE.equals(r.getRelatedTo())) { @@ -461,7 +461,6 @@ public class AaiCqResponse { return vfModule; } - /** * Get vf modules in the custom query. * @@ -494,7 +493,6 @@ public class AaiCqResponse { return vfModule; } - /** * Get Vf Module matching a specific VF model invariant ID. * @@ -543,8 +541,6 @@ public class AaiCqResponse { return modelVerList; } - - /** * Get ModelVer matching a specific version id. * @@ -562,5 +558,29 @@ public class AaiCqResponse { return modelVer; } -} + /** + * Get the count of vfModules matching customizationId, InvariantId and VersionId. + * + * @param custId ModelCustomizationId + * @param invId ModelInvariantId + * @param verId ModelVersionId + * @return Returns the count of vf modules + */ + public int getVfModuleCount(String custId, String invId, String verId) { + List vfModuleList = this.getAllVfModules(); + int count = 0; + for (VfModule vfModule : vfModuleList) { + if (vfModule.getModelCustomizationId() == null || vfModule.getModelInvariantId() == null + || vfModule.getModelVersionId() == null) { + continue; + } + + if (vfModule.getModelCustomizationId().equals(custId) && vfModule.getModelInvariantId().equals(invId) + && vfModule.getModelVersionId().equals(verId)) { + count = count + 1; + } + } + return count; + } +}