| com.flexive.core.storage.TreeStorage
All known Subclasses: com.flexive.core.storage.genericSQL.GenericTreeStorage,
TreeStorage | public interface TreeStorage (Code) | | Tree storage interface.
The tree used is an enhanced nested set model tree based on the article found at
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html enhanced by using spacing
for performance, and adds the parent and depth columns to even more simplify queries.
Nested Set Models are optimized for read/query operations, but slow on update/move/create operations. This
implementation uses "spacing" between nodes to minimize slow operations - only when a level runs out of "space" a
reorganization on a part of the tree is performed (this can take quite a few seconds, dependong on the amount of
affected nodes), otherwise the update operation will be almost as fast as when using a standard Adjacency List Model
(pure id<->parent based) tree.
Since count(*) can be very slow the total childcount of every node is stored within its row.
author: Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at) author: Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at) |
Field Summary | |
final public static long | ROOT_NODE |
Method Summary | |
void | activateAll(Connection con, FxTreeMode mode) | void | activateNode(Connection con, SequencerEngine seq, ContentEngine ce, FxTreeMode mode, long nodeId) | void | activateSubtree(Connection con, SequencerEngine seq, ContentEngine ce, FxTreeMode mode, long nodeId) | void | checkTreeIfEnabled(Connection con, FxTreeMode mode) | void | clearTree(Connection con, ContentEngine ce, FxTreeMode mode) | void | contentRemoved(Connection con, long contentId, boolean liveVersionRemovedOnly) | long | copy(Connection con, SequencerEngine seq, FxTreeMode mode, long srcNodeId, long dstParentNodeId, int dstPosition, boolean deepReferenceCopy, String copyOfPrefix) | long | createNode(Connection con, SequencerEngine seq, ContentEngine ce, FxTreeMode mode, long nodeId, long parentNodeId, String name, FxString label, int position, FxPK reference, String template) | long[] | createNodes(Connection con, SequencerEngine seq, ContentEngine ce, FxTreeMode mode, long parentNodeId, String path, int position) | boolean | exists(Connection con, FxTreeMode mode, long id) | long | getIdByFQNPath(Connection con, FxTreeMode mode, long startNode, String path) | long | getIdByLabelPath(Connection con, FxTreeMode mode, long startNode, String path) | long[] | getIdChain(Connection con, FxTreeMode mode, long nodeId) Returns all ids from the given node up to the root. | List<String> | getLabels(Connection con, FxTreeMode mode, long labelPropertyId, FxLanguage language, boolean stripNodeInfos, long... nodeIds) Returns a list of paths made up of Caption's for the given id's. | FxTreeNode | getNode(Connection con, FxTreeMode mode, long nodeId) | List<FxTreeNode> | getNodesWithReference(Connection con, FxTreeMode mode, long referenceId) | String | getPathById(Connection con, FxTreeMode mode, long id) Returns the path for a specified id. | FxTreeNode | getTree(Connection con, ContentEngine ce, FxTreeMode mode, long nodeId, int depth, boolean loadPartial, FxLanguage partialLoadLanguage) Load a (sub)tree. | FxTreeNodeInfo | getTreeNodeInfo(Connection con, FxTreeMode mode, long nodeId) | void | move(Connection con, SequencerEngine seq, FxTreeMode mode, long nodeId, long newParentId, int newPosition) Moves a node to the specified parent and the specified position. | void | populate(Connection con, SequencerEngine seq, ContentEngine ce, FxTreeMode mode) Populate the tree with test data. | void | removeNode(Connection con, FxTreeMode mode, ContentEngine ce, long nodeId, boolean removeChildren) | void | setTemplate(Connection con, FxTreeMode mode, long nodeId, String template) Sets the template of the node. | void | syncFQNName(Connection con, long referenceId, boolean maxVersion, boolean liveVersion, String name) | void | updateName(Connection con, FxTreeMode mode, ContentEngine ce, long nodeId, String name) Update the name of a tree node. |
ROOT_NODE | final public static long ROOT_NODE(Code) | | |
contentRemoved | void contentRemoved(Connection con, long contentId, boolean liveVersionRemovedOnly) throws FxApplicationException(Code) | | Callback when a content is removed to replace it with a folder or remove the node(s)
Parameters: con - an open and valid connection Parameters: contentId - referenced content id Parameters: liveVersionRemovedOnly - if just the live version was removed (other versions have no impact) @throws FxApplicationException on errors throws: FxApplicationException - on errors |
copy | long copy(Connection con, SequencerEngine seq, FxTreeMode mode, long srcNodeId, long dstParentNodeId, int dstPosition, boolean deepReferenceCopy, String copyOfPrefix) throws FxApplicationException(Code) | | Copy a node and all its children to a new parent node
Parameters: con - an open and valid connection Parameters: seq - reference to the sequencer Parameters: mode - tree mode Parameters: srcNodeId - source node id Parameters: dstParentNodeId - destination parent node id Parameters: dstPosition - destination position Parameters: deepReferenceCopy - perform a deep reference copy, cloning all references Parameters: copyOfPrefix - prefix to set for FQN if deep reference copy is performed id of the copied (new) tree node throws: com.flexive.shared.exceptions.FxApplicationException - on errors |
createNode | long createNode(Connection con, SequencerEngine seq, ContentEngine ce, FxTreeMode mode, long nodeId, long parentNodeId, String name, FxString label, int position, FxPK reference, String template) throws FxApplicationException(Code) | | Create a new node
Parameters: con - an open and valid Connection Parameters: seq - reference to the sequencer Parameters: ce - reference to the content engine Parameters: mode - tree mode Parameters: nodeId - use this id unless it is < 0 then generate a new one Parameters: parentNodeId - id of the parent node Parameters: name - name (will only be used if no FQN property is available in the reference) Parameters: label - label for Caption property (only used if new reference is created) Parameters: position - position Parameters: reference - referenced content id Parameters: template - optional template to assign @return id of the created node id of the node created throws: FxApplicationException - on errors |
createNodes | long[] createNodes(Connection con, SequencerEngine seq, ContentEngine ce, FxTreeMode mode, long parentNodeId, String path, int position) throws FxApplicationException(Code) | | Create a set of nodes and attach new Folder instances to them
Parameters: con - an open and valid connection Parameters: seq - reference to the sequencer Parameters: ce - reference to the content engine Parameters: mode - tree mode Parameters: parentNodeId - id of the parent node Parameters: path - the path to create (separated by "/") Parameters: position - position within each fqn array of the id's throws: FxApplicationException - on errors |
getIdByFQNPath | long getIdByFQNPath(Connection con, FxTreeMode mode, long startNode, String path) throws FxApplicationException(Code) | | Get the id of rightmost node in a path described by the nodes FQNs
Parameters: con - an open and valid connection Parameters: mode - tree mode Parameters: startNode - the start node id Parameters: path - requested path consisting of FQNs id of the rightmost node in the path throws: FxApplicationException - on errors |
getIdByLabelPath | long getIdByLabelPath(Connection con, FxTreeMode mode, long startNode, String path) throws FxApplicationException(Code) | | Get the id of rightmost node in a path described by the nodes Labels/Captions
Parameters: con - an open and valid connection Parameters: mode - tree mode Parameters: startNode - the start node id Parameters: path - requested path consisting of Labels/Captions id of the rightmost node in the path throws: FxApplicationException - on errors |
getIdChain | long[] getIdChain(Connection con, FxTreeMode mode, long nodeId) throws FxApplicationException(Code) | | Returns all ids from the given node up to the root.
Parameters: con - an open and valid connection Parameters: mode - tree mode Parameters: nodeId - the node id to start with all ids from the given node up to the root or null if the node was not found throws: FxApplicationException - on errors |
getLabels | List<String> getLabels(Connection con, FxTreeMode mode, long labelPropertyId, FxLanguage language, boolean stripNodeInfos, long... nodeIds) throws FxApplicationException(Code) | | Returns a list of paths made up of Caption's for the given id's.
If there is no caption propery found in the instance, the FQN will be used.
The root node will be excluded.
Example: input ids = [12,4]
Result: ["/DescriptionForNode1/DescriptionForNode12","/DescriptionForNode1/DescriptionForNode4"]
Parameters: con - an open and valid connection Parameters: mode - tree mode to use (Live or Edit tree) Parameters: labelPropertyId - propertyId of the label Parameters: language - desired result language Parameters: stripNodeInfos - remove node specific meta information in result Parameters: nodeIds - the id's of the nodes to get the path to the root node for a list with all paths made up of Caption's throws: FxApplicationException - on errors |
getTree | FxTreeNode getTree(Connection con, ContentEngine ce, FxTreeMode mode, long nodeId, int depth, boolean loadPartial, FxLanguage partialLoadLanguage) throws FxApplicationException(Code) | | Load a (sub)tree.
Loading a tree with all data takes a lot of time!
If loadPartial is set to true the position and path of the nodes is not initialized and
the labels are only loaded in the language requested with partialLoadLanguage .
Incase the position, path or (detailed) label is needed the node can be reloaded using getNode()
Parameters: con - an open and valid connection Parameters: ce - reference to ContentEngine Parameters: mode - tree mode Parameters: nodeId - start node id Parameters: depth - depth to load Parameters: loadPartial - load all data? Parameters: partialLoadLanguage - language to load for labels if not loading fully start node with preloaded and chained children throws: FxApplicationException - on errors |
move | void move(Connection con, SequencerEngine seq, FxTreeMode mode, long nodeId, long newParentId, int newPosition) throws FxApplicationException(Code) | | Moves a node to the specified parent and the specified position.
Parameters: con - an open and valid connection Parameters: seq - reference to the sequencer Parameters: mode - tree mode Parameters: nodeId - the node to move Parameters: newParentId - the new parent Parameters: newPosition - the new position in the new parents children, 0 based throws: FxApplicationException - on errors |
removeNode | void removeNode(Connection con, FxTreeMode mode, ContentEngine ce, long nodeId, boolean removeChildren) throws FxApplicationException(Code) | | Remove a node
Parameters: con - an open and valid connection Parameters: mode - tree mode Parameters: ce - reference to the content engine Parameters: nodeId - the node to remove Parameters: removeChildren - if true all nodes that are inside the subtree of the given node aredeleted as well, if false the subtree is moved one level up (to the parent of the specifiednode) throws: FxApplicationException - on errors |
syncFQNName | void syncFQNName(Connection con, long referenceId, boolean maxVersion, boolean liveVersion, String name) throws FxApplicationException(Code) | | Callback from the ContentEngine (actually the HierarchicalStorage implementation) if aFQN
property has changed to reflect changes back into the tree
Parameters: con - an open and valid connection Parameters: referenceId - id of the referenced content Parameters: maxVersion - change affects the max version? Parameters: liveVersion - change affects the live version Parameters: name - the new name throws: FxApplicationException - on errors |
updateName | void updateName(Connection con, FxTreeMode mode, ContentEngine ce, long nodeId, String name) throws FxApplicationException(Code) | | Update the name of a tree node.
Will update the FQN of the referenced content as well if assigned.
Parameters: con - an open and valid connection Parameters: mode - tree mode Parameters: ce - reference to the content engine Parameters: nodeId - node id to update Parameters: name - new name throws: FxApplicationException - on errors |
|
|