org.jboss.dna.graph.connector.map
Interface MapWorkspace

All Known Implementing Classes:
AbstractMapWorkspace

public interface MapWorkspace

The MapWorkspace defines the required methods for workspaces in a map repository. By default, a map repository supports multiple workspaces, each equating logically to a map of UUIDs to map nodes.

As each map node (except the root-node for the workspace) has a non-null parent and a set of children, the map nodes naturally construct a tree within the workspace.


Method Summary
 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.
 MapNode createNode(ExecutionContext context, MapNode parentNode, Name name, UUID uuid)
          Create a new node with the supplied name, as a child of the supplied parent.
 MapNode createNode(ExecutionContext context, String pathToNewNode)
          Create a node at the supplied path.
 Path getLowestExistingPath(Path path)
          Find the lowest existing node along the path.
 String getName()
          Returns the name of the workspace.
 MapNode getNode(Path path)
          Returns the node at the given path, if one exists of null if no exists at the given path.
 MapNode getNode(UUID uuid)
          Returns the node with the given UUID, if one exists or null if no with the given UUID exists in the workspace.
 MapNode getRoot()
          Returns the root node in the workspace.
 void moveNode(ExecutionContext context, MapNode node, Name desiredNewName, MapWorkspace newWorkspace, MapNode newParent, MapNode beforeNode)
          Move the supplied node to the new parent.
 Path pathFor(PathFactory pathFactory, MapNode node)
          Returns the path for the given node with this workspace if one exists, or a null if no node exists at the given path.
 void removeNode(ExecutionContext context, MapNode node)
          Removes the given node.
 

Method Detail

getName

String getName()
Returns the name of the workspace. There can only be one workspace with a given name per repository.

Returns:
the name of the workspace

getRoot

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

Returns:
the root node in the workspace

getNode

MapNode getNode(UUID uuid)
Returns the node with the given UUID, if one exists or null if no with the given UUID exists in the workspace.

That is, node == null || node.getUuid().equals(uuid) for the returned node.

Parameters:
uuid - the UUID of the node to be retrieved; may not be null
Returns:
the node with the given UUID, if one exists or null if no with the given UUID exists in the workspace.

getNode

MapNode getNode(Path path)
Returns the node at the given path, if one exists of null if no exists at the given path.

Parameters:
path - the path of the node to retrieve; may not be null
Returns:
the node at the given path, if one exists of null if no exists at the given path.

removeNode

void removeNode(ExecutionContext context,
                MapNode node)
Removes the given node. This method will return silently if the given node does not exist in this workspace.

Parameters:
context - the current execution context; may not be null
node - the node to be removed; may not be null

createNode

MapNode createNode(ExecutionContext context,
                   String pathToNewNode)
Create a node at the supplied path. The parent of the new node must already exist.

Parameters:
context - the environment; may not be null
pathToNewNode - the path to the new node; may not be null
Returns:
the new node (or root if the path specified the root)

createNode

MapNode createNode(ExecutionContext context,
                   MapNode parentNode,
                   Name name,
                   UUID uuid)
Create a new node with the supplied name, as a child of the supplied parent.

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
Returns:
the new node

moveNode

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.

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

copyNode

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.

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

cloneNode

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.

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

getLowestExistingPath

Path getLowestExistingPath(Path path)
Find the lowest existing node along the path.

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

pathFor

Path pathFor(PathFactory pathFactory,
             MapNode node)
Returns the path for the given node with this workspace if one exists, or a null if no node exists at the given path.

Parameters:
pathFactory - the path factory to use to construct the path; may not be null
node - the node for which the path should be retrieved; may not be null
Returns:
the path for the given node with this workspace if one exists or null if the node does not exist in this workspace


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