Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.connector.map
Class AbstractMapWorkspace

    java.lang.Object
      org.modeshape.graph.connector.map.AbstractMapWorkspace

All Implemented Interfaces:
  MapWorkspace

Direct Known Subclasses:
  SimpleJpaRepository.Workspace

    public abstract class AbstractMapWorkspace

extends Object
implements MapWorkspace

A default implementation of `MapWorkspace` that only requires the user to implement some simple, map-like operations.

Constructor Summary
`protected` | `AbstractMapWorkspace(MapRepository repository, String name)`

Method Summary
`protected abstract void` | `addNodeToMap(MapNode node)` Adds the given node to the backing map, replacing any node already in the backing map with the same UUID.
`MapNode` | `cloneNode(ExecutionContext context, MapNode original, MapWorkspace newWorkspace, MapNode newParent, Name desiredName, Path.Segment desiredSegment, boolean removeExisting, Set<Location> removedExistingNodes)` This should clone the subgraph given by the original node and place the cloned copy under the supplied new parent.
`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 MapNode` | `copyNode(ExecutionContext context, MapNode original, MapWorkspace newWorkspace, MapNode newParent, Name desiredName, boolean recursive, Map<UUID,UUID> oldToNewUuids)` 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.
`MapNode` | `createNode(ExecutionContext context, MapNode parentNode, Name name, UUID uuid, Iterable<Property> properties)` Create a new node with the supplied name, as a child of the supplied parent.
`MapNode` | `createNode(ExecutionContext context, String pathToNewNode, Iterable<Property> properties)` Create a node at the supplied path.
`boolean` | `equals(Object obj)`
`Path` | `getLowestExistingPath(Path path)` Find the lowest existing node along the path.
`String` | `getName()` Returns the name of the workspace.
`MapNode` | `getNode(ExecutionContext context, String path)` Find a node with the given path.
`MapNode` | `getNode(Path path)` Find a node with the given path.
`abstract MapNode` | `getNode(UUID nodeUuid)` Gets the node with the given UUID from the backing map, if one exists
`protected MapRepository` | `getRepository()` Get the repository that owns this workspace.
`MapNode` | `getRoot()` Returns the root node in the workspace.
`Set<UUID>` | `getUuidsUnderNode(MapNode node)` Returns all of the UUIDs in the branch rooted at `node`.
`int` | `hashCode()`
`protected void` | `initialize()`
`void` | `moveNode(ExecutionContext context, MapNode node, Name desiredNewName, MapWorkspace newWorkspace, MapNode newParent, MapNode beforeNode)` Move the supplied node to the new parent.
`protected void` | `moveNodeToWorkspace(MapNode node, AbstractMapWorkspace newWorkspace)` Moves the branch rooted at the given node to the new workspace, removing it from this workspace.
`Path` | `pathFor(PathFactory pathFactory, MapNode node)` Returns the absolute path to the given node
`QueryResults` | `query(ExecutionContext context, AccessQueryRequest accessQuery)` Perform a query of this workspace.
`protected abstract void` | `removeAllNodesFromMap()` Removes all of the nodes from the backing map
`boolean` | `removeNode(ExecutionContext context, MapNode node)` Removes the given node and its children, correcting the SNS and child indices for its parent.
`protected abstract 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)` Recursively removes the given node and its children from the backing map
`QueryResults` | `search(ExecutionContext context, String fullTextSearchExpression)` Perform a full-text search of this workspace.
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.modeshape.graph.connector.map.MapWorkspace
`lockNode, unlockNode`

Constructor Detail

### AbstractMapWorkspace

    protected AbstractMapWorkspace(MapRepository repository,
                                   String name)

Method Detail

### initialize

    protected void initialize()

### getRepository

    protected MapRepository getRepository()

  Get the repository that owns this workspace.

  Returns:
    the repository; never null

### addNodeToMap

    protected abstract void addNodeToMap(MapNode node)

  Adds the given node to the backing map, replacing any node already in the backing map with the same UUID.

  Parameters:
    `node` - the node to add to the map; may not be null

### removeNodeFromMap

    protected abstract MapNode removeNodeFromMap(UUID nodeUuid)

  Removes the node with the given UUID from the backing map, returning the node if it exists

  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

### removeAllNodesFromMap

    protected abstract void removeAllNodesFromMap()

  Removes all of the nodes from the backing map

### getNode

    public abstract MapNode getNode(UUID nodeUuid)

  Gets the node with the given UUID from the backing map, if one exists

  Specified by:
    `getNode` in interface `MapWorkspace`
  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

### createMapNode

    protected MapNode createMapNode(UUID uuid)

  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 `addNodeToMap(MapNode)`.

  Parameters:
    `uuid` - the UUID that identifies the new node; may not be null
  Returns:
    the new node with the given UUID

### getName

    public String getName()

  Description copied from interface: `MapWorkspace`
  Returns the name of the workspace. There can only be one workspace with a given name per repository.

  Specified by:
    `getName` in interface `MapWorkspace`
  Returns:
    name

### getRoot

    public MapNode getRoot()

  Returns the root node in the workspace. This returns a `map node` where `node.getParent() == null` and `node.getUuid() == repository.getRootNodeUuid()`.

  Specified by:
    `getRoot` in interface `MapWorkspace`
  Returns:
    the root node in the workspace
  See Also:
    `MapWorkspace.getRoot()`

### getNode

    public MapNode getNode(ExecutionContext context,
                           String path)

  Find a node with the given path.

  Parameters:
    `context` - the execution context to use to convert `path` to a `Path`; may not be null
    `path` - the path to the node; may not be null
  Returns:
    the node with the path, or null if the node does not exist

### getNode

    public MapNode getNode(Path path)

  Find a node with the given path.

  Specified by:
    `getNode` in interface `MapWorkspace`
  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

### pathFor

    public Path pathFor(PathFactory pathFactory,
                        MapNode node)

  Returns the absolute path to the given node

  Specified by:
    `pathFor` in interface `MapWorkspace`
  Parameters:
    `pathFactory` - the path factory to use to create the path from the list of names of all of the nodes on the path from the root node to the given node
    `node` - the node for which the path should be returned
  Returns:
    the absolute path to the given node

### getLowestExistingPath

    public Path getLowestExistingPath(Path path)

  Find the lowest existing node along the path.

  Specified by:
    `getLowestExistingPath` in interface `MapWorkspace`
  Parameters:
    `path` - the path to the node; may not be null
  Returns:
    the lowest existing node along the path, or the root node if no node exists on the path

### removeNode

    public boolean removeNode(ExecutionContext context,
                              MapNode node)

  Removes the given node and its children, correcting the SNS and child indices for its parent. This method will return false if the given node does not exist in this workspace.

  Specified by:
    `removeNode` in interface `MapWorkspace`
  Parameters:
    `context` - the current execution context; may not be null
    `node` - the node to be removed; may not be null
  Returns:
    whether a node was removed as a result of this operation

### removeUuidReference

    protected void removeUuidReference(MapNode node)

  Recursively removes the given node and its children from the backing map

  Parameters:
    `node` - the root of the branch to be removed

### createNode

    public MapNode createNode(ExecutionContext context,
                              String pathToNewNode,
                              Iterable<Property> properties)

  Create a node at the supplied path. The parent of the new node must already exist.

  Specified by:
    `createNode` in interface `MapWorkspace`
  Parameters:
    `context` - the environment; may not be null
    `pathToNewNode` - the path to the new node; may not be null
    `properties` - the properties for the new node
  Returns:
    the new node (or root if the path specified the root)

### createNode

    public MapNode createNode(ExecutionContext context,
                              MapNode parentNode,
                              Name name,
                              UUID uuid,
                              Iterable<Property> properties)

  Create a new node with the supplied name, as a child of the supplied parent.

  Specified by:
    `createNode` in interface `MapWorkspace`
  Parameters:
    `context` - the execution context
    `parentNode` - the parent node; may not be null
    `name` - the name; may not be null
    `uuid` - the UUID of the node, or null if the UUID is to be generated
    `properties` - the properties for the new node
  Returns:
    the new node

### moveNode

    public void moveNode(ExecutionContext context,
                         MapNode node,
                         Name desiredNewName,
                         MapWorkspace newWorkspace,
                         MapNode newParent,
                         MapNode beforeNode)

  Move the supplied node to the new parent. This method automatically removes the node from its existing parent, and also correctly adjusts the `index` to be correct in the new parent.

  Specified by:
    `moveNode` in interface `MapWorkspace`
  Parameters:
    `context` -
    `node` - the node to be moved; may not be the `root`
    `desiredNewName` - the new name for the node, if it is to be changed; may be null
    `newWorkspace` - the workspace containing the new parent node
    `newParent` - the new parent; may not be the `root`
    `beforeNode` - the node before which this new node should be placed

### moveNodeToWorkspace

    protected void moveNodeToWorkspace(MapNode node,
                                       AbstractMapWorkspace newWorkspace)

  Moves the branch rooted at the given node to the new workspace, removing it from this workspace. If a node with any of the UUIDs in the branch already exists in the new workspace, it will be replaced by the node from the branch.

  Parameters:
    `node` - the root node of the branch to be moved
    `newWorkspace` - the workspace to which the branch should be moved

### 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`
  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

### copyNode

    protected MapNode copyNode(ExecutionContext context,
                               MapNode original,
                               MapWorkspace newWorkspace,
                               MapNode newParent,
                               Name desiredName,
                               boolean recursive,
                               Map<UUID,UUID> oldToNewUuids)

  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.

  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
    `oldToNewUuids` - the map of UUIDs of nodes in the new subgraph keyed by the UUIDs of nodes in the original; may be null if the UUIDs are to be maintained
  Returns:
    the new node, which is the top of the new subgraph

### cloneNode

    public MapNode cloneNode(ExecutionContext context,
                             MapNode original,
                             MapWorkspace newWorkspace,
                             MapNode newParent,
                             Name desiredName,
                             Path.Segment desiredSegment,
                             boolean removeExisting,
                             Set<Location> removedExistingNodes)
                      throws UuidAlreadyExistsException

  This should clone the subgraph given by the original node and place the cloned 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:
    `cloneNode` in interface `MapWorkspace`
  Parameters:
    `context` - the context; may not be null
    `original` - the node to be cloned; may not be null
    `newWorkspace` - the workspace containing the new parent node; may not be null
    `newParent` - the parent where the clone is to be placed; may not be null
    `desiredName` - the desired name for the node; if null, the name will be calculated from `desiredSegment`; Exactly one of `desiredSegment` and `desiredName` must be non-null
    `desiredSegment` - the exact segment at which the clone should be rooted; if null, the name will be inferred from `desiredName`; Exactly one of `desiredSegment` and `desiredName` must be non-null
    `removeExisting` - true if existing nodes in the new workspace with the same UUIDs as nodes in the branch rooted at `original` should be removed; if false, a UuidAlreadyExistsException will be thrown if a UUID conflict is detected
    `removedExistingNodes` - the set into which should be placed all of the existing nodes that were removed as a result of this clone operation, or null if these nodes need not be collected
  Returns:
    the new node, which is the top of the new subgraph
  Throws:
    `UuidAlreadyExistsException` - if `removeExisting` is true and and a UUID in the source tree already exists in the new workspace
  See Also:
    `MapWorkspace#cloneNode(ExecutionContext, MapNode, MapWorkspace, MapNode, Name, Segment, boolean, Set)`

### query

    public QueryResults query(ExecutionContext context,
                              AccessQueryRequest accessQuery)

  Perform a query of this workspace.

  Specified by:
    `query` in interface `MapWorkspace`
  Parameters:
    `context` - the context in which the query is to be executed; may not be null
    `accessQuery` - the access query; may not be null
  Returns:
    the query results, or null if the query is not supported
  See Also:
    `MapWorkspace.query(org.modeshape.graph.ExecutionContext, org.modeshape.graph.request.AccessQueryRequest)`

### search

    public QueryResults search(ExecutionContext context,
                               String fullTextSearchExpression)

  Perform a full-text search of this workspace.

  Specified by:
    `search` in interface `MapWorkspace`
  Parameters:
    `context` - the context in which the query is to be executed; may not be null
    `fullTextSearchExpression` - the full-text search expression; may not be null
  Returns:
    the query results, or null if the query is not supported
  See Also:
    `MapWorkspace.search(org.modeshape.graph.ExecutionContext, java.lang.String)`

### getUuidsUnderNode

    public Set<UUID> getUuidsUnderNode(MapNode node)

  Returns all of the UUIDs in the branch rooted at `node`. The UUID of `node` will be included in the set of returned UUIDs.

  Parameters:
    `node` - the root of the branch
  Returns:
    all of the UUIDs in the branch rooted at `node`

### correctSameNameSiblingIndexes

    protected void correctSameNameSiblingIndexes(ExecutionContext context,
                                                 MapNode parentNode,
                                                 Name name)

  Corrects the SNS indices for all children of the node with the given name

  Parameters:
    `context` - the execution context
    `parentNode` - the parent node
    `name` - the name of the child nodes for which the SNS indices should be recalculated

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`
  See Also:
    `Object.equals(java.lang.Object)`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  See Also:
    `Object.toString()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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