-
- All Implemented Interfaces:
public final class NodeSetProperty<T extends Node> extends BaseProperty<T>
Property for the many side of a relation Is mapped to a Connection in GraphQL
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
NodeSetProperty.NodeSet
Stub which handles set functionality Lazy loads both on read, but also on any write (add, remove) The iterator supports remove
-
Field Summary
Fields Modifier and Type Field Description private NodeSetProperty.NodeSet<T>
nodeSet
private final HashSet<T>
addedNodes
private final HashSet<T>
removedNodes
private Set<T>
currentNodes
private final Boolean
isLoaded
private final IdentityHashMap<NodeQueryOptions, NodeQueryResult<T>>
cache
private final Node
parent
private final KProperty1<?, ?>
property
-
Constructor Summary
Constructors Constructor Description NodeSetProperty(Node parent, KProperty1<?, ?> property)
-
Method Summary
Modifier and Type Method Description final NodeSetProperty.NodeSet<T>
getNodeSet()
The Set stub returned to the user final Unit
setNodeSet(NodeSetProperty.NodeSet<T> nodeSet)
The Set stub returned to the user final HashSet<T>
getAddedNodes()
Newly added nodes, relations must be added to the database final HashSet<T>
getRemovedNodes()
Newly removed nodes, relations must be removed from the database final Set<T>
getCurrentNodes()
Current set of nodes final Unit
setCurrentNodes(Set<T> currentNodes)
Current set of nodes final Boolean
getIsLoaded()
final IdentityHashMap<NodeQueryOptions, NodeQueryResult<T>>
getCache()
Cache for database results for specific query parts final Node
getParent()
final KProperty1<?, ?>
getProperty()
final NodeSetProperty.NodeSet<T>
getValue(Node thisRef, KProperty<?> property)
Gets the value of the property Unit
registerQueryResult(NodeQueryResult<T> nodeQueryResult)
Called to register a database query result Adds the result to the cache Can be overridden to add custom behavior (super should be called in this case) DataFetcherResult<?>
constructGraphQLResult(NodeQueryResult<T> result, NodeQuery localContext, NodeQueryParser nodeQueryParser)
Constructs the field result for a graphql query RelationshipDiff
getRelationshipDiff(Map<Node, String> nodeIdLookup)
Gets the diff of added and removed relationships to persist in the database Collection<Node>
getRelatedNodesToSave()
Gets Nodes which should be persisted when this Node is persisted final Set<T>
getCurrentNodes()
Gets the current set of nodes Lazy loads if from the database if necessary -
-
Constructor Detail
-
NodeSetProperty
NodeSetProperty(Node parent, KProperty1<?, ?> property)
- Parameters:
parent
- see BaseProperty.parentproperty
- see BaseProperty.property
-
-
Method Detail
-
getNodeSet
final NodeSetProperty.NodeSet<T> getNodeSet()
The Set stub returned to the user
-
setNodeSet
final Unit setNodeSet(NodeSetProperty.NodeSet<T> nodeSet)
The Set stub returned to the user
-
getAddedNodes
final HashSet<T> getAddedNodes()
Newly added nodes, relations must be added to the database
-
getRemovedNodes
final HashSet<T> getRemovedNodes()
Newly removed nodes, relations must be removed from the database
-
getCurrentNodes
final Set<T> getCurrentNodes()
Current set of nodes
-
setCurrentNodes
final Unit setCurrentNodes(Set<T> currentNodes)
Current set of nodes
-
getIsLoaded
final Boolean getIsLoaded()
-
getCache
final IdentityHashMap<NodeQueryOptions, NodeQueryResult<T>> getCache()
Cache for database results for specific query parts
-
getProperty
final KProperty1<?, ?> getProperty()
-
getValue
final NodeSetProperty.NodeSet<T> getValue(Node thisRef, KProperty<?> property)
Gets the value of the property
- Parameters:
thisRef
- the node which has this propertyproperty
- the represented property
-
registerQueryResult
Unit registerQueryResult(NodeQueryResult<T> nodeQueryResult)
Called to register a database query result Adds the result to the cache Can be overridden to add custom behavior (super should be called in this case)
- Parameters:
nodeQueryResult
- the result of the database query
-
constructGraphQLResult
DataFetcherResult<?> constructGraphQLResult(NodeQueryResult<T> result, NodeQuery localContext, NodeQueryParser nodeQueryParser)
Constructs the field result for a graphql query
- Parameters:
result
- the result of the database query, might be cached or newly queriedlocalContext
- the existing local context, might be transformednodeQueryParser
- parser for node queries, e.g.
-
getRelationshipDiff
RelationshipDiff getRelationshipDiff(Map<Node, String> nodeIdLookup)
Gets the diff of added and removed relationships to persist in the database
- Parameters:
nodeIdLookup
- lookup from Node to its id to add relation to non-persisted nodes (these nodes are already persisted, but not newly fetched from the database)
-
getRelatedNodesToSave
Collection<Node> getRelatedNodesToSave()
-
getCurrentNodes
final Set<T> getCurrentNodes()
Gets the current set of nodes Lazy loads if from the database if necessary
-
-
-
-