com.flexive.shared.tree
Class FxTreeNode

java.lang.Object
  extended by com.flexive.shared.tree.FxTreeNode
All Implemented Interfaces:
ObjectWithLabel, SelectableObject, SelectableObjectWithLabel, SelectableObjectWithName, java.io.Serializable, java.lang.Iterable<FxTreeNode>
Direct Known Subclasses:
FxTreeNodeEdit

public class FxTreeNode
extends java.lang.Object
implements java.io.Serializable, SelectableObjectWithLabel, SelectableObjectWithName, java.lang.Iterable<FxTreeNode>

FxNode implementation for flexive

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Field Summary
protected  boolean activate
           
protected  java.util.List<FxTreeNode> children
           
protected  java.lang.String data
           
protected  long id
           
protected  FxString label
           
protected  FxTreeMode mode
           
protected  java.lang.String name
           
protected  long parentNodeId
           
static int PARTIAL_LOADED_POS
           
static java.lang.String PATH_NOT_LOADED
           
protected  int position
           
protected  FxPK reference
           
static long ROOT_NODE
          Constant id of the root node
 
Constructor Summary
protected FxTreeNode()
          Protected constructor to avoid construction
  FxTreeNode(FxTreeMode mode, long id, long parentNodeId, FxPK reference, long ACLId, java.lang.String name, java.lang.String path, FxString label, int position, java.util.List<FxTreeNode> children, java.util.List<java.lang.Long> childIds, int depth, int totalChildCount, int directChildCount, boolean leaf, boolean dirty, long modifiedAt, java.lang.String data, boolean mayEdit, boolean mayCreate, boolean mayDelete, boolean mayRelate, boolean mayExport)
          Ctor
 
Method Summary
 void _addChild(FxTreeNode node)
          Internal method only used during loading phase of a tree
 void _applyPath(java.lang.String path)
          Internal method to recursively apply a path from the root to all children
 void _applyPosition(int position)
          Internal method to recursively apply positions
 FxTreeNodeEdit asEditable()
          Make this node editable
static FxTreeNode createErrorNode(long nodeId, java.lang.String message)
          Create a temporary error node to be used in UI
static FxTreeNode createNewTemporaryChildNode(FxTreeNode parentNode)
          Create a temporary node below the given parent node
 boolean equals(java.lang.Object obj)
          
 long getACLId()
          Get the id of the ACL assigned to the referenced content
 java.util.List<java.lang.Long> getChildIds()
          Returns the child Id's of this node, but only if they are a part of the resultset.
 java.util.List<FxTreeNode> getChildren()
          Returns the children of this node, but only if they are a part of the resultset - use isLeaf(), getDirectChildCount() and getTotalChildCount() to find out if the node has children.
 java.lang.String getData()
          Get the template assigned to this node, can be null
 int getDepth()
          Returns the depth of the node within the complete tree The root node has depth 1
 int getDirectChildCount()
          Get the number of child nodes directly attached to this node
 long getId()
          The object's unique identifier
 FxString getLabel()
          Return the localized label of the object.
 FxTreeMode getMode()
          Get the tree mode (live or edit)
 long getModifiedAt()
          Get the timestamp of the last modification
 java.lang.String getName()
          Get the name of this node
 long getParentNodeId()
          Get the id of the parent node
 java.lang.String getPath()
          Get the path of this node
 int getPosition()
          Get the position of this node
 FxPK getReference()
          Get the referenced content
 int getTotalChildCount()
          Get the number of child nodes attached to this node and all subchildren
 boolean hasData()
          Is data assigned to this node?
 int hashCode()
          
 boolean hasReference()
          Is a reference set for this node (Description)
 boolean isActivate()
          Is the node marked as active? (only used in GUI, not persisted!)
 boolean isDirty()
          Is this node flagged as dirty?
 boolean isLeaf()
          Is this a leaf node?
 boolean isLive()
          Is this node "live"?
 boolean isMarkForDelete()
          Is this node marked to be deleted? (only used in GUI, not persisted!)
 boolean isMayCreate()
          ACL: Create permission for the calling user
 boolean isMayDelete()
          ACL: Delete permission for the calling user
 boolean isMayEdit()
          ACL: Edit permission for the calling user
 boolean isMayExport()
          ACL: Export permission for the calling user
 boolean isMayRelate()
          ACL: Relate permission for the calling user
 boolean isPartialLoaded()
          Is this FxTreeNode only partially loaded? Loading a (sub)tree is usually performed with partial loading enabled (only the calling users current language filled in the label)
 boolean isTemporary()
          Is this node temporary only? (only used in GUI, not persisted!)
 java.util.Iterator<FxTreeNode> iterator()
          Returns an iterator over this node and its children.
 void setActivate(boolean activate)
          Set the active flag of this tree node (only used in GUI, not persisted!)
 FxTreeNode setMarkForDelete(boolean markForDelete)
          Mark to be deleted for UI (only used in GUI, not persisted!)
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

label

protected FxString label

reference

protected FxPK reference

mode

protected FxTreeMode mode

position

protected int position

children

protected java.util.List<FxTreeNode> children

id

protected long id

parentNodeId

protected long parentNodeId

name

protected java.lang.String name

data

protected java.lang.String data

activate

protected boolean activate

PARTIAL_LOADED_POS

public static final int PARTIAL_LOADED_POS
See Also:
Constant Field Values

PATH_NOT_LOADED

public static final java.lang.String PATH_NOT_LOADED
See Also:
Constant Field Values

ROOT_NODE

public static final long ROOT_NODE
Constant id of the root node

See Also:
Constant Field Values
Constructor Detail

FxTreeNode

protected FxTreeNode()
Protected constructor to avoid construction


FxTreeNode

public FxTreeNode(FxTreeMode mode,
                  long id,
                  long parentNodeId,
                  FxPK reference,
                  long ACLId,
                  java.lang.String name,
                  java.lang.String path,
                  FxString label,
                  int position,
                  java.util.List<FxTreeNode> children,
                  java.util.List<java.lang.Long> childIds,
                  int depth,
                  int totalChildCount,
                  int directChildCount,
                  boolean leaf,
                  boolean dirty,
                  long modifiedAt,
                  java.lang.String data,
                  boolean mayEdit,
                  boolean mayCreate,
                  boolean mayDelete,
                  boolean mayRelate,
                  boolean mayExport)
Ctor

Parameters:
mode - FxTreeMode
id - node id
parentNodeId - id of the parent node
reference - pk of the referenced content
ACLId - acl of the referenced content
name - name (part of the path)
path - complete path from the root node
label - label
position - position
children - child nodes (only available if loaded with #getTree)
childIds - ids of the child nodes (only available if loaded with #getTree)
depth - depth of this node relative to the root node
totalChildCount - total number of children
directChildCount - number of children attached to this node directly
leaf - is this node a leaf?
dirty - dirty flag
modifiedAt - timestamp of last modification
data - optional data
mayEdit - edit permission for the calling user
mayCreate - create permission for the calling user
mayDelete - delete permission for the calling user
mayRelate - relate permission for the calling user
mayExport - export permission for the calling user
Method Detail

getPosition

public int getPosition()
Get the position of this node

Returns:
position of this node

isPartialLoaded

public boolean isPartialLoaded()
Is this FxTreeNode only partially loaded? Loading a (sub)tree is usually performed with partial loading enabled (only the calling users current language filled in the label)

Returns:
if this FxTreeNode is only partially loaded

isLive

public boolean isLive()
Is this node "live"?

Returns:
if the node is "live"

isDirty

public boolean isDirty()
Is this node flagged as dirty?

Returns:
node flagged as dirty?

getId

public long getId()
The object's unique identifier

Specified by:
getId in interface SelectableObject
Returns:
the object's unique identiefier

getACLId

public long getACLId()
Get the id of the ACL assigned to the referenced content

Returns:
id of the ACL assigned to the referenced content

getParentNodeId

public long getParentNodeId()
Get the id of the parent node

Returns:
id of the parent node

getName

public java.lang.String getName()
Get the name of this node

Specified by:
getName in interface SelectableObjectWithName
Returns:
name of this node

hasReference

public boolean hasReference()
Is a reference set for this node (Description)

Returns:
if a reference is set

getReference

public FxPK getReference()
Get the referenced content

Returns:
referenced content

getModifiedAt

public long getModifiedAt()
Get the timestamp of the last modification

Returns:
timestamp of the last modification

hasData

public boolean hasData()
Is data assigned to this node?

Returns:
if data is assigned to this node

getData

public java.lang.String getData()
Get the template assigned to this node, can be null

Returns:
template assigned to this node, can be null

getDepth

public int getDepth()
Returns the depth of the node within the complete tree The root node has depth 1

Returns:
the depth of the node

getTotalChildCount

public int getTotalChildCount()
Get the number of child nodes attached to this node and all subchildren

Returns:
the number of child nodes attached to this node and all subchildren

getDirectChildCount

public int getDirectChildCount()
Get the number of child nodes directly attached to this node

Returns:
the number of child nodes directly attached to this node

isLeaf

public boolean isLeaf()
Is this a leaf node?

Returns:
if this node is a leaf node

getLabel

public FxString getLabel()
Return the localized label of the object.

Specified by:
getLabel in interface ObjectWithLabel
Returns:
the localized label for the object.

getPath

public java.lang.String getPath()
Get the path of this node

Returns:
path

getChildren

public java.util.List<FxTreeNode> getChildren()
Returns the children of this node, but only if they are a part of the resultset - use isLeaf(), getDirectChildCount() and getTotalChildCount() to find out if the node has children. This function never returns null, but a empty List when no children are available

Returns:
the children of this node, but only if they are a part of the resultset

getChildIds

public java.util.List<java.lang.Long> getChildIds()
Returns the child Id's of this node, but only if they are a part of the resultset.

Returns:
the child Id's of this node, but only if they are a part of the resultset

isMayEdit

public boolean isMayEdit()
ACL: Edit permission for the calling user

Returns:
ACL: Edit permission for the calling user

isMayDelete

public boolean isMayDelete()
ACL: Delete permission for the calling user

Returns:
ACL: Delete permission for the calling user

isMayRelate

public boolean isMayRelate()
ACL: Relate permission for the calling user

Returns:
ACL: Relate permission for the calling user

isMayExport

public boolean isMayExport()
ACL: Export permission for the calling user

Returns:
ACL: Export permission for the calling user

isMayCreate

public boolean isMayCreate()
ACL: Create permission for the calling user

Returns:
ACL: Create permission for the calling user

isMarkForDelete

public boolean isMarkForDelete()
Is this node marked to be deleted? (only used in GUI, not persisted!)

Returns:
marked for delete

setMarkForDelete

public FxTreeNode setMarkForDelete(boolean markForDelete)
Mark to be deleted for UI (only used in GUI, not persisted!)

Parameters:
markForDelete - delete?
Returns:
this

setActivate

public void setActivate(boolean activate)
Set the active flag of this tree node (only used in GUI, not persisted!)

Parameters:
activate - activate flag

isActivate

public boolean isActivate()
Is the node marked as active? (only used in GUI, not persisted!)

Returns:
active status

isTemporary

public boolean isTemporary()
Is this node temporary only? (only used in GUI, not persisted!)

Returns:
if this node is temporary only

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

createErrorNode

public static FxTreeNode createErrorNode(long nodeId,
                                         java.lang.String message)
Create a temporary error node to be used in UI

Parameters:
nodeId - desired node id
message - error message
Returns:
FxTreeNode

getMode

public FxTreeMode getMode()
Get the tree mode (live or edit)

Returns:
tree mode

asEditable

public FxTreeNodeEdit asEditable()
Make this node editable

Returns:
FxTreeNodeEdit

createNewTemporaryChildNode

public static FxTreeNode createNewTemporaryChildNode(FxTreeNode parentNode)
Create a temporary node below the given parent node

Parameters:
parentNode - the parent node
Returns:
temporary node

_addChild

public void _addChild(FxTreeNode node)
Internal method only used during loading phase of a tree

Parameters:
node - child node to add

_applyPath

public void _applyPath(java.lang.String path)
Internal method to recursively apply a path from the root to all children

Parameters:
path - path to apply (includes name already!)

_applyPosition

public void _applyPosition(int position)
Internal method to recursively apply positions

Parameters:
position - position to apply to this node

iterator

public java.util.Iterator<FxTreeNode> iterator()
Returns an iterator over this node and its children.

Specified by:
iterator in interface java.lang.Iterable<FxTreeNode>
Returns:
an iterator over this node and its children.