summaryrefslogtreecommitdiffstats
path: root/common/src
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-10 17:32:29 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-10 17:32:29 -0400
commit4cd8072f009e5a9820f281ce31a1444a52246e78 (patch)
treed48004d9b4419193297a311e9d5f9dd2794ac112 /common/src
parent6f6ff2d81cde79a129e40846f1e3bd33848595d8 (diff)
added edge label support to A&AI client
you can now specify an edge label when connecting two objects Issue-ID: SO-849 Change-Id: I851d523c271823911cdc344ac8c28beec993cb09 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'common/src')
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java26
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java21
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryEdgeLabel.java8
3 files changed, 55 insertions, 0 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
index 04757c6fc2..96cc397e13 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
@@ -32,6 +32,7 @@ import javax.ws.rs.core.Response.Status;
import org.onap.aai.domain.yang.Relationship;
import org.onap.so.client.RestClient;
import org.onap.so.client.RestProperties;
+import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUri;
@@ -100,6 +101,21 @@ public class AAIResourcesClient extends AAIClient {
}
/**
+ * Adds a relationship between two objects in A&AI
+ * with a given edge label
+ * @param uriA
+ * @param uriB
+ * @param edge label
+ * @return
+ */
+ public void connect(AAIResourceUri uriA, AAIResourceUri uriB, AAIEdgeLabel label) {
+ AAIResourceUri uriAClone = uriA.clone();
+ RestClient aaiRC = this.createClient(uriAClone.relationshipAPI());
+ aaiRC.put(this.buildRelationship(uriB, label));
+ return;
+ }
+
+ /**
* Removes relationship from two objects in A&AI
*
* @param uriA
@@ -203,8 +219,18 @@ public class AAIResourcesClient extends AAIClient {
}
private Relationship buildRelationship(AAIResourceUri uri) {
+ return buildRelationship(uri, Optional.empty());
+ }
+
+ private Relationship buildRelationship(AAIResourceUri uri, AAIEdgeLabel label) {
+ return buildRelationship(uri, Optional.of(label));
+ }
+ private Relationship buildRelationship(AAIResourceUri uri, Optional<AAIEdgeLabel> label) {
final Relationship result = new Relationship();
result.setRelatedLink(uri.build().toString());
+ if (label.isPresent()) {
+ result.setRelationshipLabel(label.toString());
+ }
return result;
}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java
new file mode 100644
index 0000000000..0356e86861
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java
@@ -0,0 +1,21 @@
+package org.onap.so.client.aai.entities;
+
+import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel;
+
+public enum AAIEdgeLabel implements GraphInventoryEdgeLabel {
+
+ BELONGS_TO("org.onap.relationships.inventory.BelongsTo"),
+ USES("org.onap.relationships.inventory.Uses");
+
+
+ private final String label;
+ private AAIEdgeLabel(String label) {
+ this.label = label;
+ }
+
+
+ @Override
+ public String toString() {
+ return this.label;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryEdgeLabel.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryEdgeLabel.java
new file mode 100644
index 0000000000..1ede2f9e1b
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryEdgeLabel.java
@@ -0,0 +1,8 @@
+package org.onap.so.client.graphinventory.entities;
+
+public interface GraphInventoryEdgeLabel {
+
+
+ @Override
+ public String toString();
+}