Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.webapps.bean
Class TreeExtension  view TreeExtension download TreeExtension.java

java.lang.Object
  extended bycom.RuntimeCollective.webapps.bean.TreeExtension
All Implemented Interfaces:
EntityBean, java.io.Serializable

public class TreeExtension
extends java.lang.Object
implements EntityBean

This is an extension which places the extended EntityBean into a tree, thus having 0/1 parent and 0/n children. The type of parents and children is unconstrained (EntityBeans, that is).

A given EntityBean can belong to any number of trees, it will have 1/n TreeExtension(s) for each tree it belongs to.

Version:
$Id: TreeExtension.java,v 1.7 2003/09/30 15:13:10 joe Exp $

Field Summary
private static java.lang.String AND_PARENT
           
private static java.lang.String AND_TREE_NAME
           
protected  int beanId
          The id of the EntityBean this TreeExtension is for.
protected  java.util.List childrenIds
          The Children
static java.lang.String DATABASE_TABLE
           
private static java.lang.String DELETE_FROM
           
private static java.lang.String EMPTY_STRING
           
static java.lang.String END_HREF
           
static java.lang.String END_QUOTE_TAG
           
static java.lang.String END_SPAN
           
private static java.lang.String ESC
           
private static java.lang.String FIELD_BEAN_ID
           
private static java.lang.String FIELD_PARENT_ID
           
private static java.lang.String FIELD_POSITION
           
private static java.lang.String FIELD_TREE_NAME
           
protected  int id
          This bean's id
private static java.lang.String NULL_PARENT_WHERE
           
private static java.lang.String ORDER_BY_TREE_NAME
           
private static java.lang.String ORDER_POSITION
           
protected  int parentId
          The Parent
private static java.lang.String SELECT_DATA
           
private static java.lang.String SELECT_ID
           
private static java.lang.String SELECT_TREE_NAME
           
static java.lang.String SEPARATOR
           
private static java.lang.String SET_POSITION
           
private static java.lang.String SPACE
           
static java.lang.String START_HREF
           
static java.lang.String START_SPAN
           
protected  java.lang.String treeName
          The name of the tree we are in.
static java.lang.String UNKNOWN
           
private static java.lang.String UPDATE
           
private static java.lang.String WHERE_BEAN_ID
           
private static java.lang.String WHERE_ID
           
private static java.lang.String WHERE_PARENT
           
 
Fields inherited from interface com.RuntimeCollective.webapps.bean.EntityBean
INTERFACE_BEAN, NULL_ID
 
Constructor Summary
TreeExtension()
          Constructs a new blank bean with a unique id.
TreeExtension(int id)
          Gets a bean from the RuntimeDataSource, given an id.
 
Method Summary
 void addChild(TreeExtension child)
          Add a Child to this TreeExtension.
 boolean canPerformAction(java.lang.String action, User user)
          Recursive Permission test, which will check the PermissibleExtension of the EntityBean of this TreeExtension, and then (if necessary) do the same on the parent(s).
 void delete()
          Delete this bean from the database.
 java.lang.String displayInBreadCrumb(javax.servlet.jsp.PageContext pageContext, java.lang.String displayProperty, java.lang.String displayPath, boolean asLinks, java.lang.String styleClass, boolean isLast)
          Render the TreeExtension as one element in a Breadcrumb.
static java.util.List getAllFor(EntityBean bean)
          Gets all the TreeExtensions for a particular bean, ordered by treeName then by id.
static java.util.List getAllFor(EntityBean bean, java.lang.String treeName)
          Gets all the TreeExtensions for a particular bean and a particular treeName, ordered by id.
 java.lang.String getBreadcrumb(javax.servlet.jsp.PageContext pageContext, java.lang.String displayProperty, java.lang.String displayPath, boolean asLinks, java.lang.String styleClass)
          Construct a breadcrumb for this TreeExtension.
 TreeExtension getChild(int position)
          Get the position-nth child from this TreeExtension.
 int getChildPosition(TreeExtension child)
          Get the position of a child.
 java.util.List getChildren()
          Get the list of children (a List of TreeExtension).
 EntityBean getEntityBean()
          Gets the bean.
static TreeExtension getFor(EntityBean bean, java.lang.String treeName)
          Gets the TreeExtension for a particular bean and a particular treeName, if one exists.
 int getId()
          Get the unique id of this bean instance.
 TreeExtension getParent()
          Get the Parent
 int getPosition()
          Get the position, by calling the Parent's getChildPosition.
 TreeExtension getTopParent()
          Get the Parent at the top of the tree, recursively.
 java.lang.String getTreeName()
          Gets the tree name.
static java.util.List getTreeNamesFor(EntityBean bean)
          Get a list of TreeNames to which an EntityBean belongs, order alphabetically.
static boolean onlyBelongsTo(EntityBean bean, java.lang.String treeName)
          Check if the EntityBean belongs, and *only* belongs, to the TreeName provided.
 void removeChild(int position)
          Remove a Child at a given position.
 void removeChild(TreeExtension child)
          Remove a Child from this TreeExtension (all its positions, if more than one).
 void save()
          Save this bean in the database.
 void setEntityBean(EntityBean bean)
          Sets the bean.
 void setId(int id)
          Set the unique id of this bean instance.
 void setParent(TreeExtension parent)
          Set the Parent - don't use this unless you really mean to; use parent.addChild() instead.
 void setTreeName(java.lang.String approve)
          Sets the tree name.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SELECT_ID

private static final java.lang.String SELECT_ID
See Also:
Constant Field Values

SELECT_TREE_NAME

private static final java.lang.String SELECT_TREE_NAME
See Also:
Constant Field Values

WHERE_BEAN_ID

private static final java.lang.String WHERE_BEAN_ID
See Also:
Constant Field Values

AND_TREE_NAME

private static final java.lang.String AND_TREE_NAME
See Also:
Constant Field Values

DELETE_FROM

private static final java.lang.String DELETE_FROM
See Also:
Constant Field Values

WHERE_ID

private static final java.lang.String WHERE_ID
See Also:
Constant Field Values

SELECT_DATA

private static final java.lang.String SELECT_DATA
See Also:
Constant Field Values

UPDATE

private static final java.lang.String UPDATE
See Also:
Constant Field Values

SET_POSITION

private static final java.lang.String SET_POSITION
See Also:
Constant Field Values

AND_PARENT

private static final java.lang.String AND_PARENT
See Also:
Constant Field Values

NULL_PARENT_WHERE

private static final java.lang.String NULL_PARENT_WHERE
See Also:
Constant Field Values

WHERE_PARENT

private static final java.lang.String WHERE_PARENT
See Also:
Constant Field Values

ORDER_POSITION

private static final java.lang.String ORDER_POSITION
See Also:
Constant Field Values

ORDER_BY_TREE_NAME

private static final java.lang.String ORDER_BY_TREE_NAME
See Also:
Constant Field Values

ESC

private static final java.lang.String ESC
See Also:
Constant Field Values

EMPTY_STRING

private static final java.lang.String EMPTY_STRING
See Also:
Constant Field Values

SPACE

private static final java.lang.String SPACE
See Also:
Constant Field Values

DATABASE_TABLE

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

FIELD_TREE_NAME

private static final java.lang.String FIELD_TREE_NAME
See Also:
Constant Field Values

FIELD_BEAN_ID

private static final java.lang.String FIELD_BEAN_ID
See Also:
Constant Field Values

FIELD_PARENT_ID

private static final java.lang.String FIELD_PARENT_ID
See Also:
Constant Field Values

FIELD_POSITION

private static final java.lang.String FIELD_POSITION
See Also:
Constant Field Values

START_HREF

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

START_SPAN

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

END_QUOTE_TAG

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

END_HREF

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

END_SPAN

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

UNKNOWN

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

SEPARATOR

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

id

protected int id
This bean's id


beanId

protected int beanId
The id of the EntityBean this TreeExtension is for.


treeName

protected java.lang.String treeName
The name of the tree we are in.


parentId

protected int parentId
The Parent


childrenIds

protected java.util.List childrenIds
The Children

Constructor Detail

TreeExtension

public TreeExtension()
              throws java.sql.SQLException
Constructs a new blank bean with a unique id.


TreeExtension

public TreeExtension(int id)
              throws java.sql.SQLException
Gets a bean from the RuntimeDataSource, given an id.

Method Detail

setId

public void setId(int id)
Set the unique id of this bean instance.

Specified by:
setId in interface EntityBean

getId

public int getId()
Get the unique id of this bean instance.

Specified by:
getId in interface EntityBean

save

public void save()
Save this bean in the database.

Specified by:
save in interface EntityBean

delete

public void delete()
Delete this bean from the database.

Specified by:
delete in interface EntityBean

getEntityBean

public EntityBean getEntityBean()
Gets the bean.


setEntityBean

public void setEntityBean(EntityBean bean)
Sets the bean.


getTreeName

public java.lang.String getTreeName()
Gets the tree name.


setTreeName

public void setTreeName(java.lang.String approve)
Sets the tree name.


setParent

public void setParent(TreeExtension parent)
Set the Parent - don't use this unless you really mean to; use parent.addChild() instead.


getParent

public TreeExtension getParent()
Get the Parent


getTopParent

public TreeExtension getTopParent()
Get the Parent at the top of the tree, recursively.


removeChild

public void removeChild(int position)
Remove a Child at a given position.


removeChild

public void removeChild(TreeExtension child)
Remove a Child from this TreeExtension (all its positions, if more than one).


addChild

public void addChild(TreeExtension child)
Add a Child to this TreeExtension.


getChild

public TreeExtension getChild(int position)
Get the position-nth child from this TreeExtension.


getChildren

public java.util.List getChildren()
Get the list of children (a List of TreeExtension).


getPosition

public int getPosition()
Get the position, by calling the Parent's getChildPosition. Returns -1 by default (ie no parent).


getChildPosition

public int getChildPosition(TreeExtension child)
Get the position of a child. Returns -1 by default (ie not there).


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


getBreadcrumb

public java.lang.String getBreadcrumb(javax.servlet.jsp.PageContext pageContext,
                                      java.lang.String displayProperty,
                                      java.lang.String displayPath,
                                      boolean asLinks,
                                      java.lang.String styleClass)
Construct a breadcrumb for this TreeExtension.


displayInBreadCrumb

public java.lang.String displayInBreadCrumb(javax.servlet.jsp.PageContext pageContext,
                                            java.lang.String displayProperty,
                                            java.lang.String displayPath,
                                            boolean asLinks,
                                            java.lang.String styleClass,
                                            boolean isLast)
Render the TreeExtension as one element in a Breadcrumb.


canPerformAction

public boolean canPerformAction(java.lang.String action,
                                User user)
Recursive Permission test, which will check the PermissibleExtension of the EntityBean of this TreeExtension, and then (if necessary) do the same on the parent(s).


getFor

public static TreeExtension getFor(EntityBean bean,
                                   java.lang.String treeName)
Gets the TreeExtension for a particular bean and a particular treeName, if one exists. If more than one exists, the firstly created on (ie smallest id) will be returned.


getAllFor

public static java.util.List getAllFor(EntityBean bean,
                                       java.lang.String treeName)
Gets all the TreeExtensions for a particular bean and a particular treeName, ordered by id.


getAllFor

public static java.util.List getAllFor(EntityBean bean)
Gets all the TreeExtensions for a particular bean, ordered by treeName then by id.


getTreeNamesFor

public static java.util.List getTreeNamesFor(EntityBean bean)
Get a list of TreeNames to which an EntityBean belongs, order alphabetically.


onlyBelongsTo

public static boolean onlyBelongsTo(EntityBean bean,
                                    java.lang.String treeName)
Check if the EntityBean belongs, and *only* belongs, to the TreeName provided.