diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-09-08 23:25:31 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-09-10 09:42:44 -0400 |
commit | df20b8670136d4c26c0ba28dde131ca8e0702546 (patch) | |
tree | 41f42b1a5c5ff4ac7ff59017f090bbafe47edd98 /common/src/main/java/org/onap | |
parent | dfdb5a1d8cff4327a88220dfcc7f8df31814bf65 (diff) |
add ability to start from parent uri
AAIResourceUris can now be created from parent uris
fixed unit test after change to task impl
removed last use of nodes query in code
Change-Id: I797cb12674e3421972e35957bd4d431c3cf3285b
Issue-ID: SO-1000
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'common/src/main/java/org/onap')
5 files changed, 41 insertions, 5 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java index 8731ae719a..9b5acc5bee 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java @@ -27,7 +27,9 @@ import javax.ws.rs.core.UriBuilder; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.graphinventory.Format; +import org.onap.so.client.graphinventory.GraphInventoryObjectType; import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri; import org.onap.so.client.graphinventory.entities.uri.SimpleUri; public class AAISimpleUri extends SimpleUri implements AAIResourceUri { @@ -51,6 +53,9 @@ public class AAISimpleUri extends SimpleUri implements AAIResourceUri { protected AAISimpleUri(AAIObjectPlurals type, Object... values) { super(type, values); } + protected AAISimpleUri(AAIResourceUri parentUri, AAIObjectType childType, Object... childValues) { + super(parentUri, childType, childValues); + } @Override public AAISimpleUri relationshipAPI() { diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java index 192b593603..1f819ca5de 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java @@ -24,7 +24,6 @@ import java.net.URI; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.graphinventory.entities.uri.SimpleUri; public class AAIUriFactory { @@ -56,6 +55,11 @@ public class AAIUriFactory { } + public static AAIResourceUri createNodesUri(AAIObjectPlurals type) { + return new NodesUri(type); + + } + /** * This method should only be used to wrap a URI retrieved from A&AI contained within an object response * @@ -67,6 +71,20 @@ public class AAIUriFactory { return new AAISimpleUri(type, uri); } + + /** + * creates an AAIResourceUri from a parentUri + * + * @param parentUri + * @param childType + * @param childValues + * @return + */ + public static AAIResourceUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectType childType, Object... childValues) { + + return new AAISimpleUri(parentUri, childType, childValues); + } + /** * Creates a uri for a plural type e.g. /cloud-infrastructure/pservers * diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUri.java index e063bf8935..091d0c9e97 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUri.java @@ -38,8 +38,8 @@ public class AllottedResourceLookupUri extends HttpLookupUri { } @Override - public ServiceInstanceUri clone() { - return new ServiceInstanceUri(this.internalURI.clone(), this.getCachedValue(), values); + public AllottedResourceLookupUri clone() { + return new AllottedResourceLookupUri(this.internalURI.clone(), this.getCachedValue(), values); } public AAIResourcesClient getResourcesClient() { diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java index ccae0b44b7..3c9ca0ed7f 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java @@ -20,6 +20,9 @@ package org.onap.so.client.aai.entities.uri; +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; import org.onap.so.client.graphinventory.GraphInventoryObjectType; @@ -30,14 +33,18 @@ public class NodesUri extends AAISimpleUri { super(type, values); } + protected NodesUri(AAIObjectPlurals type) { + super(type); + } + @Override protected String getTemplate(GraphInventoryObjectType type) { - return "/nodes" + type.partialUri(); + return UriBuilder.fromUri("/nodes").path(type.partialUri()).toTemplate(); } @Override protected String getTemplate(GraphInventoryObjectPlurals type) { - return "/nodes" + type.partialUri(); + return UriBuilder.fromUri("/nodes").path(type.partialUri()).toTemplate(); } } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java index 975fa318e8..026f1c3929 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java @@ -82,6 +82,12 @@ public class SimpleUri implements GraphInventoryResourceUri { this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); this.values = values; } + protected SimpleUri(GraphInventoryResourceUri parentUri, GraphInventoryObjectType childType, Object... childValues) { + this.type = childType; + this.pluralType = null; + this.internalURI = UriBuilder.fromUri(parentUri.build()).path(childType.partialUri()); + this.values = childValues; + } @Override public SimpleUri relationshipAPI() { |