summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-08-15 14:07:00 +0100
committeradheli.tavares <adheli.tavares@est.tech>2024-08-15 14:52:09 +0100
commitcc58683b528a670402e9f8b4a8c579605ce5f6da (patch)
tree8c7fc954a07c4e04f77bd5e062d76f4ae992e35e /models-interactions/model-impl
parentb7804abcf865dc58a01bed3f2be4756e731d9288 (diff)
Fix constant missing in drools-applications
Issue-ID: POLICY-5107 Change-Id: I63d71445de2c188916692d7f4136fdf9e4512948 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'models-interactions/model-impl')
-rw-r--r--models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java69
1 files changed, 28 insertions, 41 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 ed77525be..e06f796ea 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
@@ -24,10 +24,13 @@ package org.onap.policy.aai;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
+import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.aai.domain.yang.CloudRegion;
@@ -41,11 +44,16 @@ import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.Vserver;
public class AaiCqResponse implements Serializable {
+
+ @Serial
private static final long serialVersionUID = 1L;
+ public static final String CONTEXT_KEY = AaiConstants.CONTEXT_PREFIX + "AaiCqResponse"; // NOSONAR used in pdps
public static final String OPERATION = "CustomQuery";
private static final String GENERIC_VNF = "generic-vnf";
private static final String VF_MODULE = "vf-module";
+ @Getter
+ @Setter
@SerializedName("results")
private List<Serializable> inventoryResponseItems = new LinkedList<>();
@@ -166,14 +174,6 @@ public class AaiCqResponse implements Serializable {
}
}
- public List<Serializable> getInventoryResponseItems() {
- return inventoryResponseItems;
- }
-
- public void setInventoryResponseItems(List<Serializable> inventoryResponseItems) {
- this.inventoryResponseItems = inventoryResponseItems;
- }
-
/**
* Get list of A&AI objects in the custom query.
*
@@ -360,14 +360,29 @@ public class AaiCqResponse implements Serializable {
List<Relationship> relations = vserver.getRelationshipList().getRelationship();
// Find the relationship of the genericVNF
+ var genericVnfId = getGenericVnfId(relations, GENERIC_VNF, "generic-vnf.vnf-id");
+
+ // Get the list of generic vnfs
+ List<GenericVnf> genericVnfList = this.getGenericVnfs();
+
+ for (GenericVnf genVnf : genericVnfList) {
+ if (genericVnfId.equals(genVnf.getVnfId())) {
+ genericVnf = genVnf;
+ }
+ }
+
+ return genericVnf;
+ }
+
+ private static String getGenericVnfId(List<Relationship> relations, String genericVnf, String x) {
var genericVnfId = "";
- List<RelationshipData> relationshipData = null;
+ List<RelationshipData> relationshipData = new ArrayList<>();
// 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())) {
+ if (genericVnf.equals(r.getRelatedTo())) {
relationshipData = r.getRelationshipData();
}
}
@@ -375,21 +390,11 @@ public class AaiCqResponse implements Serializable {
// Iterate through relationship data, and get vnf-id
for (RelationshipData rd : relationshipData) {
// Get the id of the generic-vnf
- if ("generic-vnf.vnf-id".equals(rd.getRelationshipKey())) {
+ if (x.equals(rd.getRelationshipKey())) {
genericVnfId = rd.getRelationshipValue();
}
}
-
- // Get the list of generic vnfs
- List<GenericVnf> genericVnfList = this.getGenericVnfs();
-
- for (GenericVnf genVnf : genericVnfList) {
- if (genericVnfId.equals(genVnf.getVnfId())) {
- genericVnf = genVnf;
- }
- }
-
- return genericVnf;
+ return genericVnfId;
}
/**
@@ -408,25 +413,7 @@ public class AaiCqResponse implements Serializable {
List<Relationship> relations = vserver.getRelationshipList().getRelationship();
// Find the relationship of VfModule
- var vfModuleId = "";
- List<RelationshipData> relationshipData = null;
-
- // 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())) {
- relationshipData = r.getRelationshipData();
- }
- }
-
- // Iterate through relationship data, and get vf-module-id
- for (RelationshipData rd : relationshipData) {
- // Get the id of the vf-module
- if ("vf-module.vf-module-id".equals(rd.getRelationshipKey())) {
- vfModuleId = rd.getRelationshipValue();
- }
- }
+ var vfModuleId = getGenericVnfId(relations, VF_MODULE, "vf-module.vf-module-id");
// Get the generic VNF associated with this vserver query
genericVnf = this.getDefaultGenericVnf();