org.modeshape.connector.store.jpa.model.simple
Class SimpleJpaRepository.Workspace

java.lang.Object
  extended by org.modeshape.graph.connector.map.AbstractMapWorkspace
      extended by org.modeshape.connector.store.jpa.model.simple.SimpleJpaRepository.Workspace
All Implemented Interfaces:
MapWorkspace
Enclosing class:
SimpleJpaRepository

protected class SimpleJpaRepository.Workspace
extends AbstractMapWorkspace

This class provides a logical mapping of UUIDs to nodes within a named workspace.

Like its enclosing class, this class only survives for the lifetime of a single request (which may be a CompositeRequest).


Constructor Summary
SimpleJpaRepository.Workspace(MapRepository repository, String name, long workspaceId)
           
 
Method Summary
protected  void addNodeToMap(MapNode node)
          Adds the given node to the persistent store, replacing any node already in the persistent store with the same UUID.
 MapNode copyNode(ExecutionContext context, MapNode original, MapWorkspace newWorkspace, MapNode newParent, Name desiredName, boolean recursive)
          This should copy the subgraph given by the original node and place the new copy under the supplied new parent.
protected  void correctSameNameSiblingIndexes(ExecutionContext context, MapNode parentNode, Name name)
          Corrects the SNS indices for all children of the node with the given name
protected  MapNode createMapNode(UUID uuid)
          Creates an empty node with the given UUID.
 List<MapNode> getBranch(Location rootLocation, int maximumDepth)
          Retrieves the branch of nodes rooted at the given location using the subgraph bulk accessor method.
 MapNode getNode(Path path)
          Find a node with the given path.
 SimpleJpaRepository.JpaNode getNode(UUID nodeUuid)
          Gets the node with the given UUID from the backing map, if one exists
 void lockNode(MapNode node, LockBranchRequest.LockScope lockScope, long lockTimeoutInMillis)
          This connector does not support connector-level, persistent locking of nodes.
protected  void removeAllNodesFromMap()
          Removes all of the nodes in this workspace from the persistent store with a single query.
protected  MapNode removeNodeFromMap(UUID nodeUuid)
          Removes the node with the given UUID from the backing map, returning the node if it exists
protected  void removeUuidReference(MapNode node)
          Removes the given node and its children from the persistent store using the subgraph bulk delete method.
 void unlockNode(MapNode node)
          This connector does not support connector-level, persistent locking of nodes.
 
Methods inherited from class org.modeshape.graph.connector.map.AbstractMapWorkspace
cloneNode, copyNode, createNode, createNode, equals, getLowestExistingPath, getName, getNode, getRepository, getRoot, getUuidsUnderNode, hashCode, initialize, moveNode, moveNodeToWorkspace, pathFor, query, removeNode, search, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleJpaRepository.Workspace

public SimpleJpaRepository.Workspace(MapRepository repository,
                                     String name,
                                     long workspaceId)
Method Detail

copyNode

public MapNode copyNode(ExecutionContext context,
                        MapNode original,
                        MapWorkspace newWorkspace,
                        MapNode newParent,
                        Name desiredName,
                        boolean recursive)
This should copy the subgraph given by the original node and place the new copy under the supplied new parent. Note that internal references between nodes within the original subgraph must be reflected as internal nodes within the new subgraph.

Specified by:
copyNode in interface MapWorkspace
Overrides:
copyNode in class AbstractMapWorkspace
Parameters:
context - the context; may not be null
original - the node to be copied; may not be null
newWorkspace - the workspace containing the new parent node; may not be null
newParent - the parent where the copy is to be placed; may not be null
desiredName - the desired name for the node; if null, the name will be obtained from the original node
recursive - true if the copy should be recursive
Returns:
the new node, which is the top of the new subgraph

correctSameNameSiblingIndexes

protected void correctSameNameSiblingIndexes(ExecutionContext context,
                                             MapNode parentNode,
                                             Name name)
Description copied from class: AbstractMapWorkspace
Corrects the SNS indices for all children of the node with the given name

Overrides:
correctSameNameSiblingIndexes in class AbstractMapWorkspace
Parameters:
context - the execution context
parentNode - the parent node
name - the name of the child nodes for which the SNS indices should be recalculated

addNodeToMap

protected void addNodeToMap(MapNode node)
Adds the given node to the persistent store, replacing any node already in the persistent store with the same UUID.

Invoking this method causes a database INSERT statement to execute immediately.

Specified by:
addNodeToMap in class AbstractMapWorkspace
Parameters:
node - the node to add to the persistent store; may not be null

removeNodeFromMap

protected MapNode removeNodeFromMap(UUID nodeUuid)
Description copied from class: AbstractMapWorkspace
Removes the node with the given UUID from the backing map, returning the node if it exists

Specified by:
removeNodeFromMap in class AbstractMapWorkspace
Parameters:
nodeUuid - the UUID of the node to replace; may not be null
Returns:
if a node with that UUID exists in the backing map (prior to removal), that node is returned; otherwise null

removeUuidReference

protected void removeUuidReference(MapNode node)
Removes the given node and its children from the persistent store using the subgraph bulk delete method.

Overrides:
removeUuidReference in class AbstractMapWorkspace
Parameters:
node - the root of the branch to be removed

createMapNode

protected MapNode createMapNode(UUID uuid)
Description copied from class: AbstractMapWorkspace
Creates an empty node with the given UUID.

This method does not add the new map node to the map. That must be done with a separate call to AbstractMapWorkspace.addNodeToMap(MapNode).

Overrides:
createMapNode in class AbstractMapWorkspace
Parameters:
uuid - the UUID that identifies the new node; may not be null
Returns:
the new node with the given UUID

removeAllNodesFromMap

protected void removeAllNodesFromMap()
Removes all of the nodes in this workspace from the persistent store with a single query.

Specified by:
removeAllNodesFromMap in class AbstractMapWorkspace

getNode

public SimpleJpaRepository.JpaNode getNode(UUID nodeUuid)
Description copied from class: AbstractMapWorkspace
Gets the node with the given UUID from the backing map, if one exists

Specified by:
getNode in interface MapWorkspace
Specified by:
getNode in class AbstractMapWorkspace
Parameters:
nodeUuid - the UUID of the node to be retrieved; may not be null
Returns:
the node that exists in the backing map with the given UUID

getNode

public MapNode getNode(Path path)
Description copied from class: AbstractMapWorkspace
Find a node with the given path.

Specified by:
getNode in interface MapWorkspace
Overrides:
getNode in class AbstractMapWorkspace
Parameters:
path - the path to the node; may not be null
Returns:
the node with the path, or null if the node does not exist

getBranch

public List<MapNode> getBranch(Location rootLocation,
                               int maximumDepth)
Retrieves the branch of nodes rooted at the given location using the subgraph bulk accessor method.

Parameters:
rootLocation - the root of the branch of nodes to retrieve
maximumDepth - the maximum depth to retrieve; a negative number indicates that the entire branch should be retrieved
Returns:
the list of nodes in the branch rooted at rootLocation

lockNode

public void lockNode(MapNode node,
                     LockBranchRequest.LockScope lockScope,
                     long lockTimeoutInMillis)
              throws LockFailedException
This connector does not support connector-level, persistent locking of nodes.

Parameters:
node -
lockScope -
lockTimeoutInMillis -
Throws:
LockFailedException

unlockNode

public void unlockNode(MapNode node)
This connector does not support connector-level, persistent locking of nodes.

Parameters:
node - the node to be unlocked


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.