summaryrefslogtreecommitdiffstats
path: root/aai-service
diff options
context:
space:
mode:
authorRich Tabedzki <richard.tabedzki@att.com>2017-11-07 14:05:51 +0000
committerRich Tabedzki <richard.tabedzki@att.com>2017-11-07 14:06:33 +0000
commit62c68af9f6dca99bf3a867e1bbcc008aa5603aef (patch)
treed0bb4eea6bf3c4e5d271a8bb0d18b040e1fd6084 /aai-service
parent825e3e0df023078fd926218f4ba74fb26d766e6b (diff)
Update aai-service request processing
Changes made: * update processing of AAI add relationship request to include processing of related-to-property data Change-Id: I4e694b9476a7f6c187b085ce00e6768e1a2eff22 Issue-ID: SDNC-161 Signed-off-by: Rich Tabedzki <richard.tabedzki@att.com>
Diffstat (limited to 'aai-service')
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java121
1 files changed, 84 insertions, 37 deletions
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
index 53906c878..c5a4c22ee 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
@@ -58,6 +58,7 @@ import org.openecomp.aai.inventory.v11.LogicalLink;
import org.openecomp.aai.inventory.v11.Metadata;
import org.openecomp.aai.inventory.v11.Metadatum;
import org.openecomp.aai.inventory.v11.Pnf;
+import org.openecomp.aai.inventory.v11.RelatedToProperty;
import org.openecomp.aai.inventory.v11.Relationship;
import org.openecomp.aai.inventory.v11.RelationshipData;
import org.openecomp.aai.inventory.v11.RelationshipList;
@@ -1305,18 +1306,17 @@ public abstract class AAIDeclarations implements AAIClient {
if(relatedLink != null) {
relationship.setRelatedLink(relatedLink);
} else {
-// List<RelationshipData> relData = relationship.getRelationshipData();
Map<String, String> relParams = new HashMap<>();
- while(true) {
- String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-key";
- String searchRelationshipValue = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-value";
- if(!params.containsKey(searchRelationshipKey))
- break;
+ while(true) {
+ String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-key";
+ String searchRelationshipValue = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-value";
+ if(!params.containsKey(searchRelationshipKey))
+ break;
- relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
- j++;
- }
+ relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
+ j++;
+ }
AAIRequest rlRequest = AAIRequest.createRequest(relatedTo, relParams);
for(Map.Entry<String,String> entry : relParams.entrySet()) {
rlRequest.addRequestProperty(entry.getKey(), entry.getValue());
@@ -1324,6 +1324,26 @@ public abstract class AAIDeclarations implements AAIClient {
String path = rlRequest.updatePathDataValues(null);
relationship.setRelatedLink(path);
}
+ {
+ int k = 0;
+ // process related to properties
+ Map<String, String> relParams = new HashMap<String, String>();
+
+ while(true) {
+ String searchRelatedToKey = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-key";
+ String searchRelatedToValue = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-value";
+ if(!params.containsKey(searchRelatedToKey))
+ break;
+
+ RelatedToProperty relDatum = new RelatedToProperty();
+ relDatum.setPropertyKey(params.get(searchRelatedToKey));
+ relDatum.setPropertyValue(params.get(searchRelatedToValue));
+ relationship.getRelatedToProperty().add(relDatum);
+
+ relParams.put(params.get(searchRelatedToKey), params.get(searchRelatedToValue));
+ k++;
+ }
+ }
i++;
}
}
@@ -1564,7 +1584,6 @@ public abstract class AAIDeclarations implements AAIClient {
if(!params.containsKey(searchKey))
break;
- int j = 0;
String relatedTo = params.get(searchKey);
String relatedLinkKey = "relationship-list.relationship[" + i + "].related-link";
String relatedLink = null;
@@ -1572,33 +1591,61 @@ public abstract class AAIDeclarations implements AAIClient {
relatedLink = params.get(relatedLinkKey);
}
- Relationship relationship = new Relationship();
- relationships.add(relationship);
- relationship.setRelatedTo(relatedTo);
- if(relatedLink != null) {
- relationship.setRelatedLink(relatedLink);
- } else {
- Map<String, String> relParams = new HashMap<>();
-
- while(true) {
- String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-key";
- String searchRelationshipValue = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-value";
- if(!params.containsKey(searchRelationshipKey))
- break;
-
- relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
- j++;
- }
- AAIRequest rlRequest = AAIRequest.createRequest(relatedTo, relParams);
- for(Map.Entry<String,String> entry : relParams.entrySet()) {
- rlRequest.addRequestProperty(entry.getKey(), entry.getValue());
- }
- String path = rlRequest.updatePathDataValues(null);
- relationship.setRelatedLink(path);
- }
-
- i++;
- }
+ Relationship relationship = new Relationship();
+ relationships.add(relationship);
+ relationship.setRelatedTo(relatedTo);
+ if (relatedLink != null) {
+ relationship.setRelatedLink(relatedLink);
+ } else {
+ Map<String, String> relParams = new HashMap<>();
+ int j = 0;
+
+ while (true) {
+ String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data["
+ + j + "].relationship-key";
+ String searchRelationshipValue = "relationship-list.relationship[" + i + "].relationship-data["
+ + j + "].relationship-value";
+ if (!params.containsKey(searchRelationshipKey))
+ break;
+
+ RelationshipData relDatum = new RelationshipData();
+ relDatum.setRelationshipKey(params.get(searchRelationshipKey));
+ relDatum.setRelationshipValue(params.get(searchRelationshipValue));
+ relationship.getRelationshipData().add(relDatum);
+
+ relParams.put(params.get(searchRelationshipKey), params.get(searchRelationshipValue));
+ j++;
+ }
+ AAIRequest rlRequest = AAIRequest.createRequest(relatedTo, relParams);
+ for (Map.Entry<String, String> entry : relParams.entrySet()) {
+ rlRequest.addRequestProperty(entry.getKey(), entry.getValue());
+ }
+ String path = rlRequest.updatePathDataValues(null);
+ relationship.setRelatedLink(path);
+ }
+ {
+ int k = 0;
+ // process related to properties
+ Map<String, String> relParams = new HashMap<String, String>();
+
+ while(true) {
+ String searchRelatedToKey = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-key";
+ String searchRelatedToValue = "relationship-list.relationship[" + i + "].related-to-property[" + k + "].property-value";
+ if(!params.containsKey(searchRelatedToKey))
+ break;
+
+ RelatedToProperty relDatum = new RelatedToProperty();
+ relDatum.setPropertyKey(params.get(searchRelatedToKey));
+ relDatum.setPropertyValue(params.get(searchRelatedToValue));
+ relationship.getRelatedToProperty().add(relDatum);
+
+ relParams.put(params.get(searchRelatedToKey), params.get(searchRelatedToValue));
+ k++;
+ }
+ }
+
+ i++;
+ }
}
return QueryStatus.SUCCESS;