diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2018-08-11 11:20:02 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-11 11:20:02 +0000 |
commit | 5bd7a5cb8a769ce7b6fa89d8df1b1863d977666f (patch) | |
tree | 646b8c3ffc17148d1445d7afcd4902cf017ecdfd /common | |
parent | ea59a688ce8d31426a830500a164b891bc180b54 (diff) | |
parent | 4cd8072f009e5a9820f281ce31a1444a52246e78 (diff) |
Merge "added edge label support to A&AI client"
Diffstat (limited to 'common')
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 c8801eb00f..072534d6f6 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; @@ -104,6 +105,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 @@ -250,8 +266,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(); +} |