diff options
author | 2020-04-30 10:41:46 -0400 | |
---|---|---|
committer | 2020-04-30 11:08:10 -0400 | |
commit | e7f7527a7ad0397f9f98c739f6f4dfba357bcf3a (patch) | |
tree | 96db50b73b0a7d096683ecb0672c79cf6897ee90 /graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory | |
parent | 0fdf096ae4ff4ee4b7a644549bd67d75e4aa82b1 (diff) |
add fluent type builder support to A&AI client
add fluent type builder support to A&AI client
Issue-ID: SO-2856
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I2957aedb84a1c6b23979ff2e1c4dfb16b3a646c7
Diffstat (limited to 'graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory')
8 files changed, 52 insertions, 7 deletions
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTopLevelType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTopLevelType.java new file mode 100644 index 0000000000..9740016d17 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTopLevelType.java @@ -0,0 +1,5 @@ +package org.onap.aaiclient.client.graphinventory; + +public interface GraphInventoryFluentTopLevelType extends GraphInventoryFluentTypeBase { + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java new file mode 100644 index 0000000000..94fa240244 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java @@ -0,0 +1,10 @@ +package org.onap.aaiclient.client.graphinventory; + +public interface GraphInventoryFluentType<T> extends GraphInventoryFluentTypeBase { + + public interface Info extends GraphInventoryFluentTypeBase.Info { + String getName(); + } + + T build(); +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTypeBase.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTypeBase.java new file mode 100644 index 0000000000..1a258fcd88 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentTypeBase.java @@ -0,0 +1,16 @@ +package org.onap.aaiclient.client.graphinventory; + +import java.util.List; + +public interface GraphInventoryFluentTypeBase { + + public interface Info { + String getPartialUri(); + + List<String> getPaths(); + } + + Object[] values(); + + String uriTemplate(); +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectPlurals.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectPlurals.java index 3eb71b21c2..a2d31f80b5 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectPlurals.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectPlurals.java @@ -22,6 +22,4 @@ package org.onap.aaiclient.client.graphinventory; public interface GraphInventoryObjectPlurals extends GraphInventoryObjectBase { - public GraphInventoryObjectType getType(); - } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java index 8aa03e2920..c749561e5f 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java @@ -95,8 +95,8 @@ public abstract class GraphInventoryQueryClient<S, I, Wrapper extends GraphInven if (!entrySet.getKey().equals("url")) { String url = (String) m.get("url"); String stringJson = mapper.writeValueAsString(entrySet.getValue()); - result.add( - new ResourceAndUrl<Wrapper>(url, createType(entrySet.getKey()), createWrapper(stringJson))); + result.add(new ResourceAndUrl<Wrapper>(url, createType(entrySet.getKey(), url), + createWrapper(stringJson))); } } } @@ -106,7 +106,7 @@ public abstract class GraphInventoryQueryClient<S, I, Wrapper extends GraphInven public abstract Wrapper createWrapper(String json); - public abstract Type createType(String name); + public abstract Type createType(String name, String uri); public S depth(String depth) { this.depth = Optional.of(depth); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java index 7d960877b0..48feba25df 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java @@ -86,8 +86,8 @@ public abstract class GraphInventoryRelationships<Wrapper extends GraphInventory final String relatedTo = (String) relationship.get("related-to"); if (p.test(relatedTo)) { Type type; - type = fromTypeName(relatedTo); final String relatedLink = (String) relationship.get("related-link"); + type = fromTypeName(relatedTo, relatedLink); result.add(createUri(type, relatedLink)); } @@ -116,7 +116,7 @@ public abstract class GraphInventoryRelationships<Wrapper extends GraphInventory protected abstract Uri createUri(Type type, String relatedLink); - protected abstract Type fromTypeName(String name); + protected abstract Type fromTypeName(String name, String uri); protected List<String> getRelatedLinks(Optional<GraphInventoryObjectName> type) { String matcher = ""; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParser.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParser.java index 24a20240e0..c6a2f96550 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParser.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParser.java @@ -27,4 +27,8 @@ public interface UriParser { public Set<String> getVariables(); public Map<String, String> parse(final String uri); + + public boolean isMatch(final String uri); + + public String getTemplate(); } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java index db13ef742a..291e395373 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java @@ -32,9 +32,16 @@ import org.springframework.web.util.UriUtils; public class UriParserSpringImpl implements UriParser { private final UriTemplate uriTemplate; + private final String template; public UriParserSpringImpl(final String template) { this.uriTemplate = new UriTemplate(template); + this.template = template; + } + + @Override + public boolean isMatch(final String uri) { + return this.uriTemplate.matches(uri); } @Override @@ -51,6 +58,11 @@ public class UriParserSpringImpl implements UriParser { return Collections.unmodifiableSet(new LinkedHashSet<String>(this.uriTemplate.getVariableNames())); } + @Override + public String getTemplate() { + return this.template; + } + protected Map<String, String> decodeParams(Map<String, String> map) { final Map<String, String> result = new LinkedHashMap<>(); |