aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/aai/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-impl/aai/src/main')
-rw-r--r--models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java157
1 files changed, 86 insertions, 71 deletions
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 92af217de..1e14e0704 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
@@ -100,100 +100,115 @@ public class AaiCqResponse implements Serializable {
resultsArray = (JSONArray) responseObj.get("results");
}
for (int i = 0; i < resultsArray.length(); i++) {
- // Object is a vserver
- if (resultsArray.getJSONObject(i).has("vserver")) {
+ final JSONObject resultObject = resultsArray.getJSONObject(i);
+
+ extractVserver(resultObject);
+ extractGenericVnf(resultObject);
+ extractServiceInstance(resultObject);
+ extractVfModule(resultObject);
+ extractCloudRegion(resultObject);
+ extractTenant(resultObject);
+ extractModelVer(resultObject);
+ }
+ }
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("vserver").toString()));
+ private void extractVserver(final JSONObject resultObject) {
+ if (resultObject.has("vserver")) {
- // Getting the vserver pojo again from the json
- Vserver vserver = this.getAaiObject(json, Vserver.class);
- this.inventoryResponseItems.add(vserver);
- }
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("vserver").toString()));
- // Object is a Generic VNF
- if (resultsArray.getJSONObject(i).has(GENERIC_VNF)) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject(GENERIC_VNF).toString()));
+ // Getting the vserver pojo again from the json
+ Vserver vserver = this.getAaiObject(json, Vserver.class);
+ this.inventoryResponseItems.add(vserver);
+ }
+ }
- // Getting the generic vnf pojo again from the json
- GenericVnf genericVnf = this.getAaiObject(json, GenericVnf.class);
+ private void extractGenericVnf(final JSONObject resultObject) {
+ if (resultObject.has(GENERIC_VNF)) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject(GENERIC_VNF).toString()));
- this.inventoryResponseItems.add(genericVnf);
- }
+ // Getting the generic vnf pojo again from the json
+ GenericVnf genericVnf = this.getAaiObject(json, GenericVnf.class);
- // Object is a Service Instance
- if (resultsArray.getJSONObject(i).has("service-instance")) {
+ this.inventoryResponseItems.add(genericVnf);
+ }
+ }
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("service-instance").toString()));
+ private void extractServiceInstance(final JSONObject resultObject) {
+ if (resultObject.has("service-instance")) {
- // Getting the employee pojo again from the json
- ServiceInstance serviceInstance = this.getAaiObject(json, ServiceInstance.class);
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("service-instance").toString()));
- this.inventoryResponseItems.add(serviceInstance);
- }
+ // Getting the employee pojo again from the json
+ ServiceInstance serviceInstance = this.getAaiObject(json, ServiceInstance.class);
- // Object is a VF Module
- if (resultsArray.getJSONObject(i).has(VF_MODULE)) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject(VF_MODULE).toString()));
+ this.inventoryResponseItems.add(serviceInstance);
+ }
+ }
- // Getting the vf module pojo again from the json
- VfModule vfModule = this.getAaiObject(json, VfModule.class);
+ private void extractVfModule(final JSONObject resultObject) {
+ if (resultObject.has(VF_MODULE)) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject(VF_MODULE).toString()));
- this.inventoryResponseItems.add(vfModule);
- }
+ // Getting the vf module pojo again from the json
+ VfModule vfModule = this.getAaiObject(json, VfModule.class);
- // Object is a CloudRegion
- if (resultsArray.getJSONObject(i).has("cloud-region")) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("cloud-region").toString()));
+ this.inventoryResponseItems.add(vfModule);
+ }
+ }
- // Getting the cloud region pojo again from the json
- CloudRegion cloudRegion = this.getAaiObject(json, CloudRegion.class);
+ private void extractCloudRegion(final JSONObject resultObject) {
+ if (resultObject.has("cloud-region")) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("cloud-region").toString()));
- this.inventoryResponseItems.add(cloudRegion);
- }
+ // Getting the cloud region pojo again from the json
+ CloudRegion cloudRegion = this.getAaiObject(json, CloudRegion.class);
- // Object is a Tenant
- if (resultsArray.getJSONObject(i).has("tenant")) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("tenant").toString()));
+ this.inventoryResponseItems.add(cloudRegion);
+ }
+ }
- // Getting the tenant pojo again from the json
- Tenant tenant = this.getAaiObject(json, Tenant.class);
+ private void extractTenant(final JSONObject resultObject) {
+ if (resultObject.has("tenant")) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("tenant").toString()));
- this.inventoryResponseItems.add(tenant);
- }
+ // Getting the tenant pojo again from the json
+ Tenant tenant = this.getAaiObject(json, Tenant.class);
- // Object is a ModelVer
- if (resultsArray.getJSONObject(i).has("model-ver")) {
- // Create the StreamSource by creating StringReader using the
- // JSON input
- StreamSource json = new StreamSource(
- new StringReader(resultsArray.getJSONObject(i).getJSONObject("model-ver").toString()));
+ this.inventoryResponseItems.add(tenant);
+ }
+ }
- // Getting the ModelVer pojo again from the json
- ModelVer modelVer = this.getAaiObject(json, ModelVer.class);
+ private void extractModelVer(final JSONObject resultObject) {
+ if (resultObject.has("model-ver")) {
+ // Create the StreamSource by creating StringReader using the
+ // JSON input
+ StreamSource json = new StreamSource(
+ new StringReader(resultObject.getJSONObject("model-ver").toString()));
- this.inventoryResponseItems.add(modelVer);
- }
+ // Getting the ModelVer pojo again from the json
+ ModelVer modelVer = this.getAaiObject(json, ModelVer.class);
+ this.inventoryResponseItems.add(modelVer);
}
-
}
private <T> T getAaiObject(StreamSource json, final Class<T> classOfResponse) {