private static JAXBContext jaxbContext;
private static Unmarshaller unmarshaller;
-
// JABX initial stuff
static {
Map<String, Object> properties = new HashMap<>();
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);
@SerializedName("results")
private List<Object> inventoryResponseItems = new LinkedList<>();
-
/**
* Constructor creates a custom query response from a valid json string.
*
}
-
-
}
-
-
private <T> T getAaiObject(StreamSource json, final Class<T> classOfResponse) {
try {
return unmarshaller.unmarshal(json, classOfResponse).getValue();
}
-
/**
* Returns a generic Vnf matching vnf name.
*
}
-
/**
* Returns a generic Vnf of a given VF Module ID.
*
return null;
}
-
-
/**
* Get the generic vnf associated with the vserver in the custom query.
*
String genericVnfId = "";
List<RelationshipData> 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())) {
return genericVnf;
}
-
/**
* Get Vf Module associated with the vserver in the custom query.
*
String vfModuleId = "";
List<RelationshipData> 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())) {
return vfModule;
}
-
/**
* Get vf modules in the custom query.
*
return vfModule;
}
-
/**
* Get Vf Module matching a specific VF model invariant ID.
*
return modelVerList;
}
-
-
/**
* Get ModelVer matching a specific version id.
*
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<VfModule> 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;
+ }
+}