|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.arsdigita.kernel.ui.DataQueryTreeModel
A generic tree model for representing data base backed trees in an efficient manner. The number of queries is proportional to the number of branches in the tree, rather than the total number of nodes. All that is required to use this class are two custom data queries, the names of which will be passed into the constructor. The first one is used to pull out the name, id and number of children for the root node. The following example shows an example implementation for category tree, which should be customized to suit your data model.
query getRootCategory {
do {
select g.name,
g.category_id,
count(sd.category_id) as sub_count
from cat_categories g,
cat_category_category_map sd
where g.category_id = :objectID
and sd.category_id(+) = g.category_id
group by g.name, g.category_id
} map {
id = g.category_id;
name = g.name;
nchild = sub_count;
}
}
The second data query does a similar task, but for
*all* children of a particular node. Again the following
example for categories can be customized by changing the
table names:
query getSubCategories {
do {
select g.name,
g.category_id,
count(sd2.category_id) as sub_count
from cat_categories g,
cat_category_category_map sd1,
cat_category_category_map sd2
where sd1.category_id = :objectID
and g.category_id = sd1.related_category_id
and sd2.category_id(+) = sd1.related_category_id
group by g.name, g.category_id
} map {
id = g.category_id;
name = g.name;
nchild = sub_count;
}
}
| Field Summary | |
static String |
versionId
|
| Constructor Summary | |
DataQueryTreeModel(BigDecimal root,
String getRootCategory,
String getSubCategories)
Constructor, which takes in the root Category. |
|
DataQueryTreeModel(String getRootCategory,
String getSubCategories)
|
|
| Method Summary | |
Iterator |
getChildren(TreeNode node,
PageState data)
Obtains all the children of the node as an iterator, returning CategoryTreeNodeLites. |
protected DataQueryTreeIterator |
getDataQueryTreeIterator(DataQueryTreeNode node,
String getSubCategories)
|
TreeNode |
getRoot(PageState state)
Obtain the root node of the tree, passing in PageState for permissioning purposes |
boolean |
hasChildren(TreeNode node,
PageState state)
Indicates whether the specified tree node has children. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String versionId
| Constructor Detail |
public DataQueryTreeModel(String getRootCategory,
String getSubCategories)
public DataQueryTreeModel(BigDecimal root,
String getRootCategory,
String getSubCategories)
root - the object id of the root categorygetRootCategory - the data query name for root categorygetSubCategories - the data query name for sub categories| Method Detail |
public Iterator getChildren(TreeNode node,
PageState data)
getChildren in interface TreeModeldata - the PageState to use for permissioning purposes
public boolean hasChildren(TreeNode node,
PageState state)
hasChildren in interface TreeModelpublic TreeNode getRoot(PageState state)
TreeModel
getRoot in interface TreeModel
protected DataQueryTreeIterator getDataQueryTreeIterator(DataQueryTreeNode node,
String getSubCategories)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||