org.gcube.data.tr.neo.nodes
Class PersistentNode

java.lang.Object
  extended by org.gcube.data.trees.data.Node
      extended by org.gcube.data.trees.data.InnerNode
          extended by org.gcube.data.tr.neo.nodes.PersistentNode

public class PersistentNode
extends org.gcube.data.trees.data.InnerNode

An InnerNode with persistent state.

Persistent nodes load their state on demand, i.e. when access is required. This optimises partial tree traversals, such as those performed to prune the results of read operations or to update trees in place.

Persistent nodes that are created in READ mode, do not persist state changes. Those that are created in UPDATE mode do. This side-effect is visible to clients to the extent that new nodes acquire identifiers. The following example captures the implications:

 PersistentNode node =..
 Edge e = ....
 node.add(e);
 assertFalse(node.remove(e));
 

Author:
Fabio Simeoni

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gcube.data.trees.data.Node
org.gcube.data.trees.data.Node.State
 
Constructor Summary
PersistentNode(org.neo4j.graphdb.GraphDatabaseService db, org.gcube.data.trees.data.InnerNode node)
          Creates an instance in BindingMode.ADD that persists an InnerNode, assigning an identifier to it and its descendants.
PersistentNode(org.neo4j.graphdb.GraphDatabaseService db, org.neo4j.graphdb.Node dbnode, BindingMode mode)
          Creates an instance over a database node, in a given binding mode.
 
Method Summary
 boolean add(org.gcube.data.trees.data.Edge e)
          
 Map<QName,String> attributes()
          
 org.neo4j.graphdb.Node dbnode()
          Returns the database node that acts as the entry point to the persistent state of this node
 void delete()
          
 List<org.gcube.data.trees.data.Edge> edges()
          
 boolean equals(Object obj)
          
 int hashCode()
          
 boolean remove(org.gcube.data.trees.data.Edge e)
          
 String removeAttribute(QName name)
          
 String setAttribute(QName name, String value)
          
 
Methods inherited from class org.gcube.data.trees.data.InnerNode
add, add, child, child, child, child, child, child, children, children, children, children, children, children, children, children, clearState, delta, descendant, descendant, descendants, descendants, descendants, descendants, edge, edge, edge, edges, edges, edges, find, find, hasEdge, hasEdge, hasEdge, labels, labels, markAsNew, remove, remove, remove, remove, size, toString, update
 
Methods inherited from class org.gcube.data.trees.data.Node
ancestors, ancestorsAndSelf, attribute, attribute, hasAttribute, hasAttribute, id, parent, removeAttribute, setAttribute, setParent, state, state
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PersistentNode

public PersistentNode(org.neo4j.graphdb.GraphDatabaseService db,
                      org.gcube.data.trees.data.InnerNode node)
               throws IllegalArgumentException
Creates an instance in BindingMode.ADD that persists an InnerNode, assigning an identifier to it and its descendants.

This works as a copy constructor with side-effects in the database. As it clones the node in memory, it also serialises its state in the database.

Parameters:
the - database
node - the node
Throws:
IllegalArgumentException - if the input has already an identifier.

PersistentNode

public PersistentNode(org.neo4j.graphdb.GraphDatabaseService db,
                      org.neo4j.graphdb.Node dbnode,
                      BindingMode mode)
Creates an instance over a database node, in a given binding mode.

Parameters:
db - the database
dbnode - the database node
mode - the binding mode
Method Detail

dbnode

public org.neo4j.graphdb.Node dbnode()
Returns the database node that acts as the entry point to the persistent state of this node

Returns:
the database node

attributes

public Map<QName,String> attributes()

Overrides:
attributes in class org.gcube.data.trees.data.Node

setAttribute

public String setAttribute(QName name,
                           String value)

Overrides:
setAttribute in class org.gcube.data.trees.data.Node

removeAttribute

public String removeAttribute(QName name)

Overrides:
removeAttribute in class org.gcube.data.trees.data.Node

edges

public List<org.gcube.data.trees.data.Edge> edges()

Overrides:
edges in class org.gcube.data.trees.data.InnerNode

add

public boolean add(org.gcube.data.trees.data.Edge e)

Overrides:
add in class org.gcube.data.trees.data.InnerNode

remove

public boolean remove(org.gcube.data.trees.data.Edge e)

Overrides:
remove in class org.gcube.data.trees.data.InnerNode

delete

public void delete()

Overrides:
delete in class org.gcube.data.trees.data.InnerNode

equals

public boolean equals(Object obj)

Overrides:
equals in class org.gcube.data.trees.data.InnerNode

hashCode

public int hashCode()

Overrides:
hashCode in class org.gcube.data.trees.data.InnerNode


Copyright © 2012. All Rights Reserved.