public class RelationResource
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected OrchestrateClient |
client
The Orchestrate client to make requests with.
|
protected JacksonMapper |
jacksonMapper |
protected com.fasterxml.jackson.databind.ObjectMapper |
mapper
The object mapper used to deserialize JSON responses.
|
| Modifier and Type | Method and Description |
|---|---|
<T> OrchestrateRequest<RelationList<T>> |
get(java.lang.Class<T> clazz,
java.lang.String... kinds)
Fetch objects related to a key in the Orchestrate service.
|
OrchestrateRequest<Relation> |
get(java.lang.String kind,
java.lang.String destCollection,
java.lang.String destKey)
Retrieve a Relation object.
|
RelationResource |
ifAbsent()
Equivalent to
this.ifAbsent(Boolean.TRUE). |
RelationResource |
ifAbsent(boolean ifAbsent)
Whether to store the object if no such relation already exists.
|
RelationResource |
ifMatch(java.lang.String objectRef)
The last known version of the stored object to match for the request to
succeed.
|
RelationResource |
invert()
Swap the "source" and "destination" in the request, equivalent to:
|
RelationResource |
invert(boolean invert)
If
invert is true the "source" and "destination" objects
will be swapped in the request. |
RelationResource |
limit(int limit)
The number of relation results to get in this query, this value cannot
exceed 100.
|
RelationResource |
offset(int offset)
The position in the results list to start retrieving results from,
this is useful for paginating results.
|
protected <T> OrchestrateRequest<T> |
parseLink(java.lang.String name,
com.fasterxml.jackson.databind.JsonNode jsonNode,
io.orchestrate.client.ResponseConverter<T> clazz) |
OrchestrateRequest<java.lang.Boolean> |
purge(java.lang.String kind)
Remove a relationship between two objects in the Orchestrate service.
|
OrchestrateRequest<java.lang.Boolean> |
put(java.lang.String kind)
Store a relationship between two objects in the Orchestrate service.
|
OrchestrateRequest<RelationMetadata> |
put(java.lang.String kind,
com.fasterxml.jackson.databind.JsonNode properties)
Store a relationship, with an associated JSON property object,
between two objects in the Orchestrate service.
|
RelationResource |
to(java.lang.String collection,
java.lang.String key)
The "destination" object to point the relationship to.
|
protected byte[] |
toJsonBytes(java.lang.Object value) |
protected com.fasterxml.jackson.databind.JsonNode |
toJsonNode(org.glassfish.grizzly.http.HttpContent response) |
protected com.fasterxml.jackson.databind.JsonNode |
toJsonNodeOrNull(org.glassfish.grizzly.http.HttpContent response) |
protected <T> KvObject<T> |
toKvObject(org.glassfish.grizzly.http.HttpContent response,
java.lang.String collection,
java.lang.String key,
java.lang.Class<T> clazz) |
protected <T> KvObject<T> |
toKvObject(com.fasterxml.jackson.databind.JsonNode result,
java.lang.Class<T> clazz) |
protected final OrchestrateClient client
protected final com.fasterxml.jackson.databind.ObjectMapper mapper
protected final JacksonMapper jacksonMapper
public RelationResource ifAbsent()
this.ifAbsent(Boolean.TRUE).ifAbsent(boolean)public RelationResource ifAbsent(boolean ifAbsent)
ifAbsent - If truepublic RelationResource ifMatch(@NonNull java.lang.String objectRef)
objectRef - The last known version of the stored object.public OrchestrateRequest<Relation> get(java.lang.String kind, java.lang.String destCollection, java.lang.String destKey)
Usage:
Relation relation =
client.relation("someCollection", "someKey")
.get("someKind", "otherCollection", "otherKey")
.get();
kind - String The name of the relationship.destCollection - String The name of destination collection.destKey - String The name of destination key.public <T> OrchestrateRequest<RelationList<T>> get(java.lang.Class<T> clazz, java.lang.String... kinds)
Usage:
RelationList<String> relatedObjects =
client.relation("someCollection", "someKey")
.get(String.class, "someKind")
.get();
T - The type to deserialize the response from the request to.clazz - Type information for deserializing to type T at
runtime.kinds - The name of the relationships to traverse to the related
objects.public OrchestrateRequest<java.lang.Boolean> put(java.lang.String kind)
Usage:
boolean result =
client.relation("someCollection", "someKey")
.to("anotherCollection", "anotherKey")
.put(kind)
.get();
kind - The name of the relationship to create.public OrchestrateRequest<RelationMetadata> put(java.lang.String kind, com.fasterxml.jackson.databind.JsonNode properties)
Usage:
JsonNode properties = new ObjectMapper().readTree("{ \"foo\" : \"bar\" }");
RelationMetadata result =
client.relation("someCollection", "someKey")
.to("anotherCollection", "anotherKey")
.put(kind, properties)
.get();
kind - The name of the relationship to create.properties - A json object representing the properties of this relationship.public OrchestrateRequest<java.lang.Boolean> purge(java.lang.String kind)
boolean result =
client.relation("someCollection", "someKey")
.to("anotherCollection", "anotherKey")
.purge(kind)
.get();
kind - The name of the relationship to delete.public RelationResource to(java.lang.String collection, java.lang.String key)
collection - The collection containing the destination key.key - The destination key to add the relation to.public RelationResource invert()
this.invert(Boolean.TRUE);
invert(boolean)public RelationResource invert(boolean invert)
invert is true the "source" and "destination" objects
will be swapped in the request. This is useful for designing a
bi-directional relationship.invert - Whether to invert the request.public RelationResource limit(int limit)
#put(...) and #purge(...) requests.limit - The number of search results in this query.public RelationResource offset(int offset)
#put(...) and #purge(...) requests.offset - The position to start retrieving results from.protected byte[] toJsonBytes(java.lang.Object value)
protected com.fasterxml.jackson.databind.JsonNode toJsonNodeOrNull(org.glassfish.grizzly.http.HttpContent response)
throws java.io.IOException
java.io.IOExceptionprotected com.fasterxml.jackson.databind.JsonNode toJsonNode(org.glassfish.grizzly.http.HttpContent response)
throws java.io.IOException
java.io.IOExceptionprotected <T> KvObject<T> toKvObject(com.fasterxml.jackson.databind.JsonNode result, java.lang.Class<T> clazz) throws java.io.IOException
java.io.IOExceptionprotected <T> KvObject<T> toKvObject(org.glassfish.grizzly.http.HttpContent response, java.lang.String collection, java.lang.String key, java.lang.Class<T> clazz) throws java.io.IOException
java.io.IOExceptionprotected <T> OrchestrateRequest<T> parseLink(java.lang.String name, com.fasterxml.jackson.databind.JsonNode jsonNode, io.orchestrate.client.ResponseConverter<T> clazz)