com.flexive.shared.interfaces
Interface TreeEngine

All Known Subinterfaces:
TreeEngineLocal

public interface TreeEngine

Tree Interface

Author:
Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Method Summary
 void activate(FxTreeMode mode, long nodeId, boolean includeChildren)
          Activates a node - copying it from the "Edit" to the "Live" tree
 void clear(FxTreeMode mode)
          Clears the requested tree and creates a new root node
 long copy(FxTreeMode mode, long source, long destination, int destinationPosition)
          Copies a node to the specified parent and the specified position.
 long[] createNodes(FxTreeMode mode, long parentNodeId, int position, java.lang.String path)
          Create a tree folders of the given path relative to the parent node, creating all folders stored in path if they dont exist (similar to File.mkdirs()).
 boolean exist(FxTreeMode mode, long id)
          Returns true if a node with the specified id exists.
 FxTreeNode findChild(FxTreeMode mode, long nodeId, FxPK pk)
          Find a (direct) child with the given PK under the node nodeId.
 FxTreeNode findChild(FxTreeMode mode, long nodeId, FxReference reference)
          Find a (direct) child with the given reference under the node nodeId.
 FxTreeNode findChild(FxTreeMode mode, long nodeId, long referenceId)
          Find a (direct) child with the given reference ID under the node nodeId.
 FxTreeNode findChild(FxTreeMode mode, long nodeId, java.lang.String name)
          Find a (direct) child with the given name under the node nodeId.
 java.lang.String[] getDatas(FxTreeMode mode, long id)
          Returns all the data to use for this node ordered by relevance.
 long getIdByFQNPath(FxTreeMode mode, long startNode, java.lang.String path)
          Returns the node id specified by a FQN path thats starts from the given node.
 long getIdByLabelPath(FxTreeMode mode, long startNode, java.lang.String path)
          Returns the node id specified by a label path thats starts from the given node.
 long getIdByPath(FxTreeMode mode, java.lang.String path)
          Returns the node id specified by a path.
 long[] getIdChain(FxTreeMode mode, long nodeId)
          Returns all ids from the given node up to the root.
 java.util.List<java.lang.String> getLabels(FxTreeMode mode, FxLanguage lang, long... ids)
          Returns a list of paths made up of Caption's for the given id's.
 java.util.List<java.lang.String> getLabels(FxTreeMode mode, long... ids)
          Returns a list of paths made up of Caption's for the given id's.
 FxTreeNode getNode(FxTreeMode mode, long id)
          Returns the informations for a single node
 java.util.List<FxTreeNode> getNodesWithReference(FxTreeMode mode, long reference)
          Returns all nodes that match the given reference.
 java.lang.String getPathById(FxTreeMode mode, long nodeId)
          Returns the path for a specified id.
 java.util.List<java.lang.String> getPaths(FxTreeMode mode, long... ids)
          Returns a list of paths made up of FQN's for the given id's The root node will be excluded.
 long[] getReverseIdChain(FxTreeMode mode, long id)
          Returns all ids from the root up to the given node.
 FxTreeNode getTree(FxTreeMode mode, long nodeId, int depth)
          Retrieves a (sub)tree, starting from the given node.
 void move(FxTreeMode mode, long nodeId, long destinationId, int newPosition)
          Moves a node to the specified parent and the specified position.
 void populate(FxTreeMode mode)
          Populate the tree with test data
 void remove(FxTreeMode mode, long nodeId, boolean removeReferencedContent, boolean removeChildren)
          Remove a node and optionally its children.
 void remove(FxTreeNode node, boolean removeReferencedContent, boolean removeChildren)
          Remove a node and optionally its children.
 long save(FxTreeNodeEdit node)
          Create a new or save an existing node
 void setData(FxTreeMode mode, long nodeId, java.lang.String data)
          Sets the data of the node.
 

Method Detail

save

long save(FxTreeNodeEdit node)
          throws FxApplicationException
Create a new or save an existing node

Parameters:
node - the node to save
Returns:
id of the saved node
Throws:
FxApplicationException - on errors

remove

void remove(FxTreeNode node,
            boolean removeReferencedContent,
            boolean removeChildren)
            throws FxApplicationException
Remove a node and optionally its children. Referenced content content will only be removed if removedReferencedContent is set to true and the referenced content is not referenced elsewhere. The only exception is if the referenced content is of type FOLDER, then the folder is removed if it is not referenced from anywhere else.

Parameters:
node - the node to removed
removeReferencedContent - remove referenced content
removeChildren - remove children as well?
Throws:
FxApplicationException - on errors

remove

void remove(FxTreeMode mode,
            long nodeId,
            boolean removeReferencedContent,
            boolean removeChildren)
            throws FxApplicationException
Remove a node and optionally its children. Referenced content content will only be removed if removedReferencedContent is set to true and the referenced content is not referenced elsewhere. The only exception is if the referenced content is of type FOLDER, then the folder is removed if it is not referenced from anywhere else.

Parameters:
mode - the tree mode (edit or live)
nodeId - the node to removed
removeReferencedContent - remove referenced content
removeChildren - remove children as well?
Throws:
FxApplicationException - on errors

createNodes

long[] createNodes(FxTreeMode mode,
                   long parentNodeId,
                   int position,
                   java.lang.String path)
                   throws FxApplicationException
Create a tree folders of the given path relative to the parent node, creating all folders stored in path if they dont exist (similar to File.mkdirs()).

Parameters:
mode - operate on live or edit tree?
parentNodeId - the parent node to create the path from
position - desired position (will be applied to all "folders" hence in most cases only min or max values make sense)
path - the path to be created, e.g. "/my/virtual/folder"
Returns:
the node id's of the created path
Throws:
FxApplicationException - on errors

clear

void clear(FxTreeMode mode)
           throws FxApplicationException
Clears the requested tree and creates a new root node

Parameters:
mode - the tree to clear
Throws:
FxApplicationException - on errors

move

void move(FxTreeMode mode,
          long nodeId,
          long destinationId,
          int newPosition)
          throws FxApplicationException
Moves a node to the specified parent and the specified position.

Parameters:
mode - tree mode to use (Live or Edit tree)
nodeId - the node to move
destinationId - the new parent
newPosition - the new position in the new parents children
Throws:
FxApplicationException - on errors

copy

long copy(FxTreeMode mode,
          long source,
          long destination,
          int destinationPosition)
          throws FxApplicationException
Copies a node to the specified parent and the specified position.

Parameters:
mode - tree mode to use (Live or Edit tree)
source - the parent id of the structure to copy
destination - the destination node
destinationPosition - the position in the destination node's children @return the (root-)id the copy
Returns:
the id of the new node (the "copy")
Throws:
FxApplicationException - on errors

setData

void setData(FxTreeMode mode,
             long nodeId,
             java.lang.String data)
Sets the data of the node.

Parameters:
mode - tree mode to use (Live or Edit tree)
nodeId - the node id
data - the data, or null for no data

activate

void activate(FxTreeMode mode,
              long nodeId,
              boolean includeChildren)
              throws FxApplicationException
Activates a node - copying it from the "Edit" to the "Live" tree

Parameters:
mode - tree mode (currently only Edit supported)
nodeId - the node to activate
includeChildren - if true all children of the node are activated as well
Throws:
FxApplicationException - on errors

exist

boolean exist(FxTreeMode mode,
              long id)
              throws FxApplicationException
Returns true if a node with the specified id exists.

Parameters:
mode - tree mode to use (Live or Edit tree)
id - the id to check for
Returns:
true if the node exists
Throws:
FxApplicationException - on errors

getNode

FxTreeNode getNode(FxTreeMode mode,
                   long id)
                   throws FxApplicationException
Returns the informations for a single node

Parameters:
mode - tree mode to use (Live or Edit tree)
id - the id of the node to get
Returns:
the node information, or null if the node does not exist
Throws:
FxApplicationException - on errors

getTree

FxTreeNode getTree(FxTreeMode mode,
                   long nodeId,
                   int depth)
                   throws FxApplicationException
Retrieves a (sub)tree, starting from the given node. Loading a tree with all data takes a lot of time hence the position of the nodes is not initialized and the labels are only loaded in the language set as default for the calling user. Incase the position or (detailed) label is needed the node can be reloaded using getNode()

Parameters:
mode - tree mode to use (Live or Edit tree)
nodeId - the nod to start from
depth - the maximum depth to read
Returns:
the (sub)tree
Throws:
FxApplicationException - on errors

getDatas

java.lang.String[] getDatas(FxTreeMode mode,
                            long id)
Returns all the data to use for this node ordered by relevance.

Parameters:
mode - tree mode to use (Live or Edit tree)
id - the id to get the datas for
Returns:
the data, or null if the node does not exist

findChild

FxTreeNode findChild(FxTreeMode mode,
                     long nodeId,
                     java.lang.String name)
                     throws FxApplicationException
Find a (direct) child with the given name under the node nodeId.

Parameters:
mode - tree mode to use (Live or Edit tree)
nodeId - the parent node ID
name - name of the requested node @return the tree node
Returns:
the selected node. If no node was found, a runtime exception is thrown.
Throws:
FxApplicationException - on errors

findChild

FxTreeNode findChild(FxTreeMode mode,
                     long nodeId,
                     long referenceId)
                     throws FxApplicationException
Find a (direct) child with the given reference ID under the node nodeId.

Parameters:
mode - tree mode to use (Live or Edit tree)
nodeId - the parent node ID
referenceId - the reference ID
Returns:
the selected node. If no node was found, a runtime exception is thrown.
Throws:
FxApplicationException - on errors

findChild

FxTreeNode findChild(FxTreeMode mode,
                     long nodeId,
                     FxPK pk)
                     throws FxApplicationException
Find a (direct) child with the given PK under the node nodeId.

Parameters:
mode - tree mode to use (Live or Edit tree)
nodeId - the parent node ID
pk - the reference
Returns:
the selected node. If no node was found, a runtime exception is thrown.
Throws:
FxApplicationException - on errors

findChild

FxTreeNode findChild(FxTreeMode mode,
                     long nodeId,
                     FxReference reference)
                     throws FxApplicationException
Find a (direct) child with the given reference under the node nodeId.

Parameters:
mode - tree mode to use (Live or Edit tree)
nodeId - the parent node ID
reference - the reference
Returns:
the selected node. If no node was found, a runtime exception is thrown.
Throws:
FxApplicationException - on errors

getNodesWithReference

java.util.List<FxTreeNode> getNodesWithReference(FxTreeMode mode,
                                                 long reference)
                                                 throws FxApplicationException
Returns all nodes that match the given reference.

Parameters:
mode - tree mode to use (Live or Edit tree)
reference - the reference
Returns:
the matching nodes
Throws:
FxApplicationException - on errors

getIdByPath

long getIdByPath(FxTreeMode mode,
                 java.lang.String path)
                 throws FxApplicationException
Returns the node id specified by a path.

Parameters:
mode - tree mode to use (Live or Edit tree)
path - the path - eg '/nodeA/nodeB', the virtual root '/Root' node must not be included, and the path has to start with a '/'.
Returns:
the node id, or -1 if the path does not exist
Throws:
FxApplicationException - on errors

getIdByFQNPath

long getIdByFQNPath(FxTreeMode mode,
                    long startNode,
                    java.lang.String path)
                    throws FxApplicationException
Returns the node id specified by a FQN path thats starts from the given node.

Parameters:
mode - tree mode to use (Live or Edit tree)
startNode - the root node.
path - the path - eg '/nodeA/nodeB', the virtual root '/Root' node must not be included, and the path has to start with a '/'.
Returns:
the node id, or -1 if the path does not exist
Throws:
FxApplicationException - on errors

getIdByLabelPath

long getIdByLabelPath(FxTreeMode mode,
                      long startNode,
                      java.lang.String path)
                      throws FxApplicationException
Returns the node id specified by a label path thats starts from the given node.

Parameters:
mode - tree mode to use (Live or Edit tree)
startNode - the root node.
path - the path - eg '/nodeA/nodeB', the virtual root '/Root' node must not be included, and the path has to start with a '/'.
Returns:
the node id, or -1 if the path does not exist
Throws:
FxApplicationException - on errors

getPathById

java.lang.String getPathById(FxTreeMode mode,
                             long nodeId)
                             throws FxApplicationException
Returns the path for a specified id.

Parameters:
mode - tree mode to use (Live or Edit tree)
nodeId - the node id to get the path for
Returns:
the node id, or -1 if the path does not exist
Throws:
FxApplicationException - on errors

getIdChain

long[] getIdChain(FxTreeMode mode,
                  long nodeId)
                  throws FxApplicationException
Returns all ids from the given node up to the root.

Parameters:
mode - tree mode to use (Live or Edit tree)
nodeId - the id to start with
Returns:
the id chain, or null if the node does not exist
Throws:
FxApplicationException - on errors

getReverseIdChain

long[] getReverseIdChain(FxTreeMode mode,
                         long id)
Returns all ids from the root up to the given node.

Parameters:
mode - tree mode to use (Live or Edit tree)
id - the id to start with
Returns:
the id chain, or null if the node does not exist

getPaths

java.util.List<java.lang.String> getPaths(FxTreeMode mode,
                                          long... ids)
                                          throws FxApplicationException
Returns a list of paths made up of FQN's for the given id's The root node will be excluded.

Example: input id's = [12,4]
Result: ["/Node1/Node12","/Node1/Node4"]

Parameters:
mode - tree mode to use (Live or Edit tree)
ids - the id's of the nodes to get the path to the root node for
Returns:
a list with all paths made up of FQN's
Throws:
FxApplicationException - on errors

getLabels

java.util.List<java.lang.String> getLabels(FxTreeMode mode,
                                           long... ids)
                                           throws FxApplicationException
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. The language is the calling users preferred language.

Example: input ids = [12,4]
Result: ["/DescriptionForNode1/DescriptionForNode12","/DescriptionForNode1/DescriptionForNode4"]

Parameters:
mode - tree mode to use (Live or Edit tree)
ids - the id's of the nodes to get the path to the root node for
Returns:
a list with all paths made up of Caption's
Throws:
FxApplicationException - on errors

getLabels

java.util.List<java.lang.String> getLabels(FxTreeMode mode,
                                           FxLanguage lang,
                                           long... ids)
                                           throws FxApplicationException
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:
mode - tree mode to use (Live or Edit tree)
lang - desired result language
ids - the id's of the nodes to get the path to the root node for
Returns:
a list with all paths made up of Caption's
Throws:
FxApplicationException - on errors

populate

void populate(FxTreeMode mode)
              throws FxApplicationException
Populate the tree with test data

Parameters:
mode - tree mode
Throws:
FxApplicationException - on errors