|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.graph.connector.base.BaseTransaction<NodeType,WorkspaceType>
org.modeshape.graph.connector.base.MapTransaction<NodeType,WorkspaceType>
WorkspaceType
- the type of workspaceNodeType
- the type of node@NotThreadSafe public abstract class MapTransaction<NodeType extends MapNode,WorkspaceType extends MapWorkspace<NodeType>>
An implementation of Transaction
that maintains a cache of nodes by their hash (or UUID
).
Nested Class Summary | |
---|---|
protected class |
MapTransaction.Children
|
protected class |
MapTransaction.WorkspaceChanges
Record of the changes made to a particular workspace. |
Field Summary |
---|
Fields inherited from class org.modeshape.graph.connector.base.BaseTransaction |
---|
context, nameFactory, pathFactory, propertyFactory, rootLocation, rootNodeUuid, valueFactories |
Constructor Summary | |
---|---|
protected |
MapTransaction(ExecutionContext context,
Repository<NodeType,WorkspaceType> repository,
UUID rootNodeUuid)
Create a new transaction. |
Method Summary | |
---|---|
NodeType |
addChild(WorkspaceType workspace,
NodeType parent,
Name name,
int index,
UUID uuid,
Iterable<Property> properties)
Creates a new child node under the supplied parent, where the new child will have the specified name, properties, and (optionally) UUID. |
Location |
addChild(WorkspaceType workspace,
NodeType parent,
NodeType newChild,
NodeType beforeOtherChild,
Name desiredName)
Inserts the specified child at the specified position in the list of children. |
NodeType |
cloneNode(WorkspaceType originalWorkspace,
NodeType original,
WorkspaceType newWorkspace,
NodeType 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. |
void |
commit()
Commit any changes that have been made to the repository. |
protected NodeType |
copyBranch(WorkspaceType originalWorkspace,
NodeType original,
MapTransaction.WorkspaceChanges newWorkspaceChanges,
WorkspaceType newWorkspace,
NodeType newParent,
boolean reuseUuid,
Map<UUID,UUID> oldToNewUuids)
|
NodeType |
copyNode(WorkspaceType originalWorkspace,
NodeType original,
WorkspaceType newWorkspace,
NodeType 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 NodeType |
createNode(UUID uuid,
Path.Segment name,
UUID parentUuid,
Iterable<Property> properties)
Create a new instance of the node, given the supplied UUID. |
protected void |
destroyNode(WorkspaceType workspace,
NodeType node)
Destroy the node. |
protected NodeType |
findLatest(WorkspaceType workspace,
NodeType node)
Find the latest version of the supplied node. |
protected NodeType |
findNode(WorkspaceType workspace,
UUID uuid)
Attempt to find the node with the supplied UUID. |
protected MapTransaction.WorkspaceChanges |
getChangesFor(WorkspaceType workspace,
boolean createIfMissing)
Get the changes for the supplied workspace, optionally creating the necessary object if it does not yet exist. |
NodeType |
getChild(WorkspaceType workspace,
NodeType parent,
Path.Segment childSegment)
Find in the supplied parent node the child with the supplied name and same-name-sibling index. |
List<NodeType> |
getChildren(WorkspaceType workspace,
NodeType node)
Get the children for the supplied node. |
List<Location> |
getChildrenLocations(WorkspaceType workspace,
NodeType node)
Get the locations for all children of the supplied node. |
NodeType |
getNode(WorkspaceType workspace,
Location location)
Find the node with the supplied unique identifier. |
NodeType |
getParent(WorkspaceType workspace,
NodeType node)
Returns the parent of the supplied node. |
protected Set<UUID> |
getUuidsUnderNode(WorkspaceType workspace,
NodeType node)
Returns all of the UUIDs in the branch rooted at node . |
protected void |
print(WorkspaceType workspace,
NodeType node,
int level)
|
QueryResults |
query(WorkspaceType workspace,
AccessQueryRequest accessQuery)
Perform a query of this workspace. |
void |
removeAllChildren(WorkspaceType workspace,
NodeType node)
Removes all of the children for this node in a single operation. |
Location |
removeNode(WorkspaceType workspace,
NodeType node)
Removes the given node from the repository. |
NodeType |
removeProperty(WorkspaceType workspace,
NodeType node,
Name propertyName)
Removes the property with the given name |
void |
rollback()
Rollback any changes that have been made to this repository. |
QueryResults |
search(WorkspaceType workspace,
FullTextSearchRequest search)
Perform a full-text search of this workspace. |
NodeType |
setProperties(WorkspaceType workspace,
NodeType node,
Iterable<Property> propertiesToSet,
Iterable<Name> propertiesToRemove,
boolean removeAllExisting)
Sets the given properties in a single operation, overwriting any previous properties for the same name. |
Location |
verifyNodeExists(WorkspaceType workspace,
Location location)
Verify that the supplied node exists. |
Methods inherited from class org.modeshape.graph.connector.base.BaseTransaction |
---|
getContext, getFirstChild, getNode, getRepository, getRootLocation, getRootNode, getRootUuid, getWorkspaceNames, lockNode, pathFor, readable, unlockNode |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.modeshape.graph.connector.base.Transaction |
---|
destroyWorkspace, getWorkspace |
Constructor Detail |
---|
protected MapTransaction(ExecutionContext context, Repository<NodeType,WorkspaceType> repository, UUID rootNodeUuid)
context
- the execution context for this transaction; may not be nullrepository
- the repository against which the transaction will be operating; may not be nullrootNodeUuid
- the UUID of the root node; may not be nullMethod Detail |
---|
protected MapTransaction.WorkspaceChanges getChangesFor(WorkspaceType workspace, boolean createIfMissing)
commit()
or cleared upon rollback()
.
workspace
- the workspacecreateIfMissing
- true if the changes object should be created if it does not yet exist, or false otherwise
createIfMissing
is false
and the changes object does
not yet exist, or never null if createIfMissing
is true
public NodeType getNode(WorkspaceType workspace, Location location)
workspace
- the workspace; may not be nulllocation
- of the node; may not be null
Transaction.getNode(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.Location)
public Location verifyNodeExists(WorkspaceType workspace, Location location)
workspace
- the workspace; may not be nulllocation
- of the node; may not be null
Transaction.verifyNodeExists(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.Location)
protected NodeType findLatest(WorkspaceType workspace, NodeType node)
workspace
- the workspacenode
- the node
protected NodeType findNode(WorkspaceType workspace, UUID uuid)
workspace
- the workspace; may not be nulluuid
- the UUID of the node; may not be null
protected void destroyNode(WorkspaceType workspace, NodeType node)
workspace
- the workspace; never nullnode
- the node to be destroyedpublic NodeType addChild(WorkspaceType workspace, NodeType parent, Name name, int index, UUID uuid, Iterable<Property> properties)
workspace
- the workspace; may not be nullparent
- the parent node; may not be nullname
- the name; may not be nullindex
- index at which the specified child is to be inserted, or -1 if the child is to be appendeduuid
- the UUID of the node, or null if the UUID is to be generatedproperties
- the properties for the new node; may be null if there are no other properties
Transaction.addChild(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node, org.modeshape.graph.property.Name, int, java.util.UUID, java.lang.Iterable)
public Location addChild(WorkspaceType workspace, NodeType parent, NodeType newChild, NodeType beforeOtherChild, Name desiredName)
This method can also be used to rename an existing child by 'moving' the child node to the existing parent and a new desired name. However, if no 'beforeOtherChild' is supplied, then the node being renamed will also be moved to the end of the children.
workspace
- the workspace; may not be nullparent
- the parent node; may not be nullnewChild
- the node that is to be added as a child of the parent; may not be nullbeforeOtherChild
- the existing child before which the child is to be added; may be null if the child is to be added
at the enddesiredName
- the desired name for the node; may be null if the new child node's name is to be kept
Transaction.addChild(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node, org.modeshape.graph.connector.base.Node,
org.modeshape.graph.connector.base.Node, org.modeshape.graph.property.Name)
protected NodeType createNode(UUID uuid, Path.Segment name, UUID parentUuid, Iterable<Property> properties)
uuid
- the desired UUID; never nullname
- the name of the new node; may be null if the name is not knownparentUuid
- the UUID of the parent node; may be null if this is the root nodeproperties
- the properties; may be null if there are no properties
public NodeType getChild(WorkspaceType workspace, NodeType parent, Path.Segment childSegment)
workspace
- the workspace; may not be nullparent
- the parent node; may not be nullchildSegment
- the segment of the child; may not be null
Transaction.getChild(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node, org.modeshape.graph.property.Path.Segment)
public List<NodeType> getChildren(WorkspaceType workspace, NodeType node)
workspace
- the workspace; may not be nullnode
- the node whose children are to be returned; may not be null
Transaction.getChildren(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node)
public List<Location> getChildrenLocations(WorkspaceType workspace, NodeType node)
workspace
- the workspace; may not be nullnode
- the node whose children are to be returned; may not be null
Transaction.getChildrenLocations(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node)
public NodeType getParent(WorkspaceType workspace, NodeType node)
workspace
- the workspace; may not be nullnode
- the child node; may not be null
Transaction.getParent(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node)
public void removeAllChildren(WorkspaceType workspace, NodeType node)
workspace
- the workspace; may not be nullnode
- the node whose children are to be removed; may not be nullTransaction.removeAllChildren(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node)
public Location removeNode(WorkspaceType workspace, NodeType node)
workspace
- the workspace; may not be nullnode
- the node to be removed; may not be null
Transaction.removeNode(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node)
public NodeType removeProperty(WorkspaceType workspace, NodeType node, Name propertyName)
workspace
- the workspace; may not be nullnode
- the node; may not be nullpropertyName
- the name of the property to remove; may not be null
Transaction.removeProperty(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node, org.modeshape.graph.property.Name)
public NodeType setProperties(WorkspaceType workspace, NodeType node, Iterable<Property> propertiesToSet, Iterable<Name> propertiesToRemove, boolean removeAllExisting)
workspace
- the workspace; may not be nullnode
- the node; may not be nullpropertiesToSet
- the properties to set; may be null or empty if there are no properties being added or setpropertiesToRemove
- the names of the properties that are to be removed; may be null or empty if no properties are
being removedremoveAllExisting
- true if all existing, non-identification properties should be removed, or false otherwise
Transaction.setProperties(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node, java.lang.Iterable, java.lang.Iterable, boolean)
public NodeType copyNode(WorkspaceType originalWorkspace, NodeType original, WorkspaceType newWorkspace, NodeType newParent, Name desiredName, boolean recursive)
originalWorkspace
- the workspace containing the original node that is being cloned; may not be nulloriginal
- the node to be copied; may not be nullnewWorkspace
- the workspace containing the new parent node; may not be nullnewParent
- the parent where the copy is to be placed; may not be nulldesiredName
- the desired name for the node; if null, the name will be obtained from the original noderecursive
- true if the copy should be recursive
Transaction.copyNode(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node, org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node, org.modeshape.graph.property.Name, boolean)
protected void print(WorkspaceType workspace, NodeType node, int level)
public NodeType cloneNode(WorkspaceType originalWorkspace, NodeType original, WorkspaceType newWorkspace, NodeType newParent, Name desiredName, Path.Segment desiredSegment, boolean removeExisting, Set<Location> removedExistingNodes) throws UuidAlreadyExistsException
originalWorkspace
- the workspace containing the original node that is being cloned; may not be nulloriginal
- the node to be cloned; may not be nullnewWorkspace
- the workspace containing the new parent node; may not be nullnewParent
- the parent where the clone is to be placed; may not be nulldesiredName
- the desired name for the node; if null, the name will be calculated from desiredSegment
; Exactly
one of desiredSegment
and desiredName
must be non-nulldesiredSegment
- 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-nullremoveExisting
- 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
detectedremovedExistingNodes
- 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
UuidAlreadyExistsException
- if removeExisting
is true and and a UUID in the source tree already exists in
the new workspaceTransaction.cloneNode(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node, org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.connector.base.Node, org.modeshape.graph.property.Name, org.modeshape.graph.property.Path.Segment,
boolean, java.util.Set)
protected Set<UUID> getUuidsUnderNode(WorkspaceType workspace, NodeType node)
node
. The UUID of node
will be included in the set
of returned UUIDs.
workspace
- the workspacenode
- the root of the branch
node
protected NodeType copyBranch(WorkspaceType originalWorkspace, NodeType original, MapTransaction.WorkspaceChanges newWorkspaceChanges, WorkspaceType newWorkspace, NodeType newParent, boolean reuseUuid, Map<UUID,UUID> oldToNewUuids)
public QueryResults query(WorkspaceType workspace, AccessQueryRequest accessQuery)
This implementation does not support querying the repository contents, so this method returns null. Subclasses can override this if they do support querying.
workspace
- the workspace to be searched; may not be nullaccessQuery
- the access query; may not be null
Transaction.query(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.request.AccessQueryRequest)
public QueryResults search(WorkspaceType workspace, FullTextSearchRequest search)
This implementation does not support searching the repository contents, so this method returns null. Subclasses can override this if they do support searching.
workspace
- the workspace to be searched; may not be nullsearch
- the full-text search; may not be null
Transaction.search(org.modeshape.graph.connector.base.Workspace,
org.modeshape.graph.request.FullTextSearchRequest)
public void commit()
commit
in interface Transaction<NodeType extends MapNode,WorkspaceType extends MapWorkspace<NodeType>>
commit
in class BaseTransaction<NodeType extends MapNode,WorkspaceType extends MapWorkspace<NodeType>>
BaseTransaction.commit()
public void rollback()
rollback
in interface Transaction<NodeType extends MapNode,WorkspaceType extends MapWorkspace<NodeType>>
rollback
in class BaseTransaction<NodeType extends MapNode,WorkspaceType extends MapWorkspace<NodeType>>
BaseTransaction.rollback()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |