public interface ImprovedTransactionData extends TransactionDataWrapper
TransactionData,
i.e. before or after a transaction commit, this API improves the TransactionData API
in a number of ways.
It categorizes Entitys, i.e. Nodes and Relationships into:
Entity has been created, deleted, or changed in
this transaction and obtain all the created, deleted, and changed Entitys.
Properties that have been created, deleted, and changed in the transaction are grouped by the changed
Entity they belong to. Users can find out, which properties have been created,
deleted, and changed for a given changed Entity and check, whether
a given property for a given changed Entity has been created, deleted,
or changed.
Properties of created Entitys are available through the actual created
Entity. Properties of deleted Entitys
(as they were before the transaction started) are available through the snapshot of the deleted Entity,
obtained by calling getDeleted(org.neo4j.graphdb.Node) or getDeleted(org.neo4j.graphdb.Relationship).
Properties of created and deleted entities will not be returned by changedProperties(org.neo4j.graphdb.Node) and changedProperties(org.neo4j.graphdb.Relationship)
as these only return changed properties of changed Entitys.
Changed Entitys and properties are wrapped in a Change object which holds
the previous state of the object before the transaction started, and the current state of the object (when the transaction
commits).
All created Entitys + properties and current versions of changed Entitys
+ properties can be accessed by native Neo4j API and the traversal API as one would expect. For example, one can
traverse the graph starting from a newly created node, using a mixture of newly created and already existing
relationships. In other words, one can traverse the graph as if the transaction has already been committed. This is
similar to using TransactionData.
A major difference between this API and TransactionData, however, is what one can do
with the returned information about deleted Entitys + properties and the previous
versions thereof. With this API, one can traverse a snapshot of the graph as it was before the transaction started.
As opposed to the TransactionData API, this will not result in exceptions being thrown.
For example, one can start traversing the graph from a deleted Node, or the previous version of a changed
Node. Such traversal will only traverse Relationships that existed before the transaction started and
will return properties and their values as they were before the transaction started. This is achieved using NodeSnapshot
and RelationshipSnapshot decorators.
One can even perform additional mutating operations on the previous version (snapshot) of the graph, provided that the
mutated objects have been changed in the transaction (as opposed to deleted). Mutating deleted Entitys
and properties does not make any sense and will cause exceptions.
To summarize, this API gives access to two versions of the same graph. Through created Entitys
and/or their current versions, one can traverse the current version of the graph as it will be after the transaction
commits. Through deleted and/or previous versions of Entitys, one can traverse
the previous snapshot of the graph, as it was before the transaction started.| Modifier and Type | Method and Description |
|---|---|
Set<org.neo4j.graphdb.Label> |
assignedLabels(org.neo4j.graphdb.Node node)
Get labels assigned in the transaction.
|
Map<String,Change<Object>> |
changedProperties(org.neo4j.graphdb.Node node)
Get properties changed in the transaction.
|
Map<String,Change<Object>> |
changedProperties(org.neo4j.graphdb.Relationship relationship)
Get properties changed in the transaction.
|
Map<String,Object> |
createdProperties(org.neo4j.graphdb.Node node)
Get properties created in the transaction.
|
Map<String,Object> |
createdProperties(org.neo4j.graphdb.Relationship relationship)
Get properties created in the transaction.
|
Map<String,Object> |
deletedProperties(org.neo4j.graphdb.Node node)
Get properties deleted in the transaction.
|
Map<String,Object> |
deletedProperties(org.neo4j.graphdb.Relationship relationship)
Get properties deleted in the transaction.
|
Collection<Change<org.neo4j.graphdb.Node>> |
getAllChangedNodes()
Get all nodes changed in the transaction.
|
Collection<Change<org.neo4j.graphdb.Relationship>> |
getAllChangedRelationships()
Get all relationships changed in the transaction.
|
Collection<org.neo4j.graphdb.Node> |
getAllCreatedNodes()
Get all nodes created in the transaction.
|
Collection<org.neo4j.graphdb.Relationship> |
getAllCreatedRelationships()
Get all relationships created in the transaction.
|
Collection<org.neo4j.graphdb.Node> |
getAllDeletedNodes()
Get all nodes deleted in the transaction as they were before the transaction started.
|
Collection<org.neo4j.graphdb.Relationship> |
getAllDeletedRelationships()
Get all relationships deleted in the transaction as they were before the transaction started.
|
Change<org.neo4j.graphdb.Node> |
getChanged(org.neo4j.graphdb.Node node)
Get a node that has been changed in this transaction as it was before the transaction started and as it is now.
|
Change<org.neo4j.graphdb.Relationship> |
getChanged(org.neo4j.graphdb.Relationship relationship)
Get a relationship that has been changed in this transaction as it was before the transaction started and as it is now.
|
org.neo4j.graphdb.Node |
getDeleted(org.neo4j.graphdb.Node node)
Get a node that has been deleted in this transaction as it was before the transaction started.
|
org.neo4j.graphdb.Relationship |
getDeleted(org.neo4j.graphdb.Relationship relationship)
Get a relationship that has been deleted in this transaction as it was before the transaction started.
|
Collection<org.neo4j.graphdb.Relationship> |
getDeletedRelationships(org.neo4j.graphdb.Node node,
org.neo4j.graphdb.Direction direction,
org.neo4j.graphdb.RelationshipType... types)
Get all relationships for the given node and of the given directions and types, which have been deleted in the
transaction.
|
Collection<org.neo4j.graphdb.Relationship> |
getDeletedRelationships(org.neo4j.graphdb.Node node,
org.neo4j.graphdb.RelationshipType... types)
Get all relationships for the given node and of the given types, which have been deleted in the transaction.
|
boolean |
hasBeenChanged(org.neo4j.graphdb.Node node)
Check whether a node has been changed in the transaction, i.e.
|
boolean |
hasBeenChanged(org.neo4j.graphdb.Relationship relationship)
Check whether a relationship has been changed in the transaction, i.e.
|
boolean |
hasBeenCreated(org.neo4j.graphdb.Node node)
Check whether the given node has been created in the transaction.
|
boolean |
hasBeenCreated(org.neo4j.graphdb.Relationship relationship)
Check whether the given relationship has been created in the transaction.
|
boolean |
hasBeenDeleted(org.neo4j.graphdb.Node node)
Check whether the given node has been deleted in the transaction.
|
boolean |
hasBeenDeleted(org.neo4j.graphdb.Relationship relationship)
Check whether the given relationship has been deleted in the transaction.
|
boolean |
hasLabelBeenAssigned(org.neo4j.graphdb.Node node,
org.neo4j.graphdb.Label label)
Check whether a label has been assigned in the transaction.
|
boolean |
hasLabelBeenRemoved(org.neo4j.graphdb.Node node,
org.neo4j.graphdb.Label label)
Check whether a label has been removed in the transaction.
|
boolean |
hasPropertyBeenChanged(org.neo4j.graphdb.Node node,
String key)
Check whether a property has been changed in the transaction.
|
boolean |
hasPropertyBeenChanged(org.neo4j.graphdb.Relationship relationship,
String key)
Check whether a property has been changed in the transaction.
|
boolean |
hasPropertyBeenCreated(org.neo4j.graphdb.Node node,
String key)
Check whether a property has been created in the transaction.
|
boolean |
hasPropertyBeenCreated(org.neo4j.graphdb.Relationship relationship,
String key)
Check whether a property has been created in the transaction.
|
boolean |
hasPropertyBeenDeleted(org.neo4j.graphdb.Node node,
String key)
Check whether a property has been deleted in the transaction.
|
boolean |
hasPropertyBeenDeleted(org.neo4j.graphdb.Relationship relationship,
String key)
Check whether a property has been deleted in the transaction.
|
boolean |
mutationsOccurred()
Have any mutations actually occurred?
|
Set<String> |
mutationsToStrings()
Convert all mutations in the transaction to human-readable Strings.
|
Set<org.neo4j.graphdb.Label> |
removedLabels(org.neo4j.graphdb.Node node)
Get labels removed in the transaction.
|
getWrappedboolean hasBeenCreated(org.neo4j.graphdb.Node node)
node - to check.Collection<org.neo4j.graphdb.Node> getAllCreatedNodes()
boolean hasBeenDeleted(org.neo4j.graphdb.Node node)
node - to check.org.neo4j.graphdb.Node getDeleted(org.neo4j.graphdb.Node node)
node - to get.IllegalArgumentException - in case the given node has not been deleted in the transaction.Collection<org.neo4j.graphdb.Node> getAllDeletedNodes()
boolean hasBeenChanged(org.neo4j.graphdb.Node node)
node - to check.Change<org.neo4j.graphdb.Node> getChanged(org.neo4j.graphdb.Node node)
node - to get.IllegalArgumentException - in case the given node has not been changed in the transaction.Collection<Change<org.neo4j.graphdb.Node>> getAllChangedNodes()
boolean hasPropertyBeenCreated(org.neo4j.graphdb.Node node,
String key)
node - to check. Must be a changed Node, not a created one.key - of the property to check.Node.Map<String,Object> createdProperties(org.neo4j.graphdb.Node node)
node - for which to get created properties. Must be a changed Node, not a created one.Node.boolean hasPropertyBeenDeleted(org.neo4j.graphdb.Node node,
String key)
node - to check. Must be a changed Node, not a deleted one.key - of the property to check.Node.Map<String,Object> deletedProperties(org.neo4j.graphdb.Node node)
node - for which to get deleted properties. Must be a changed Node, not a deleted one.Node, where the value is the property value before
the transaction started.boolean hasPropertyBeenChanged(org.neo4j.graphdb.Node node,
String key)
node - to check.key - of the property to check.Map<String,Change<Object>> changedProperties(org.neo4j.graphdb.Node node)
node - for which to get changed properties.boolean hasLabelBeenAssigned(org.neo4j.graphdb.Node node,
org.neo4j.graphdb.Label label)
node - to check.label - to check.Set<org.neo4j.graphdb.Label> assignedLabels(org.neo4j.graphdb.Node node)
node - for which to get assigned labels.boolean hasLabelBeenRemoved(org.neo4j.graphdb.Node node,
org.neo4j.graphdb.Label label)
node - to check.label - to check.Set<org.neo4j.graphdb.Label> removedLabels(org.neo4j.graphdb.Node node)
node - for which to get removed labels.boolean hasBeenCreated(org.neo4j.graphdb.Relationship relationship)
relationship - to check.Collection<org.neo4j.graphdb.Relationship> getAllCreatedRelationships()
boolean hasBeenDeleted(org.neo4j.graphdb.Relationship relationship)
relationship - to check.org.neo4j.graphdb.Relationship getDeleted(org.neo4j.graphdb.Relationship relationship)
relationship - to get.IllegalArgumentException - in case the given relationship has not been deleted in the transaction.Collection<org.neo4j.graphdb.Relationship> getAllDeletedRelationships()
Collection<org.neo4j.graphdb.Relationship> getDeletedRelationships(org.neo4j.graphdb.Node node, org.neo4j.graphdb.RelationshipType... types)
node - for which to get deleted relationships.types - of the deleted relationships. If no types are provided, all types are returned.Collection<org.neo4j.graphdb.Relationship> getDeletedRelationships(org.neo4j.graphdb.Node node, org.neo4j.graphdb.Direction direction, org.neo4j.graphdb.RelationshipType... types)
node - for which to get deleted relationships.direction - of the deleted relationshipstypes - of the deleted relationships.boolean hasBeenChanged(org.neo4j.graphdb.Relationship relationship)
relationship - to check.Change<org.neo4j.graphdb.Relationship> getChanged(org.neo4j.graphdb.Relationship relationship)
relationship - to get.IllegalArgumentException - in case the given relationship has not been changed in the transaction.Collection<Change<org.neo4j.graphdb.Relationship>> getAllChangedRelationships()
boolean hasPropertyBeenCreated(org.neo4j.graphdb.Relationship relationship,
String key)
relationship - to check. Must be a changed Relationship, not a created one.key - of the property to check.Relationship.Map<String,Object> createdProperties(org.neo4j.graphdb.Relationship relationship)
relationship - for which to get created properties. Must be a changed Node, not a created one.Relationship.boolean hasPropertyBeenDeleted(org.neo4j.graphdb.Relationship relationship,
String key)
relationship - to check. Must be a changed Relationship, not a deleted one.key - of the property to check.Relationship.Map<String,Object> deletedProperties(org.neo4j.graphdb.Relationship relationship)
relationship - for which to get deleted properties. Must be a changed Relationship, not a deleted one.boolean hasPropertyBeenChanged(org.neo4j.graphdb.Relationship relationship,
String key)
relationship - to check.key - of the property to check.Map<String,Change<Object>> changedProperties(org.neo4j.graphdb.Relationship relationship)
relationship - for which to get changed properties.boolean mutationsOccurred()
getAllCreatedNodes(), getAllCreatedRelationships(), getAllDeletedNodes(),
getAllDeletedRelationships(), getAllChangedNodes(), getAllChangedRelationships().Copyright © 2013-2016–2020 Graph Aware Limited. All rights reserved.