Class CategoryTree
- java.lang.Object
-
- ch.ivyteam.ivy.workflow.category.CategoryTree
-
public class CategoryTree extends Object
This class implements a tree data model to manageCategories
of Tasks or Cases, e.g. to show an overview of involved categories in atask
orcase
query.The
CategoryTree
is created by the methodcreateFor(CaseQuery)
orcreateFor(TaskQuery)
, the method optimize and executes the passed query and returns the corresponding tree model.Example:
Lets imagine that the query
returns the following four tasks which are categorized as below:TaskQuery query = TaskQuery.create().where().currentUserCanWorkOn(); List<ITask> query.executor().results();
- Task 1 in category 'Finance/Invoices' - Task 2 in category 'Finance/Invoices' - Task 3 in category 'Finance/Invoices/Incoming' - Task 4 in category 'Support/FirstLevel'
The same query could be passed to the
createFor(TaskQuery)
method to get the corresponding category tree model.
The above query would create the following tree model:- Root-Entry (task count: 4, children: 2) - Finance (task count: 3, children: 1) - Invoices (task count: 3, children: 1) - Incoming (task count: 3, children: 0) - Support (task count: 1, children: 1) - FirstLevel (task count: 1, children: 0)
The tree model could be accessed by code as follows:
CategoryTree rootNode = CategoryTree.createFor(query); rootNode.getCategory(); // null rootNode.count(); // 4 -> 4 tasks blow this category CategoryTree financeNode = rootNode.getChildren().get(0); // first node 'Finance' financeNode.getCategory().getName(); // 'Finance' financeNode.count(); // 3 -> 3 tasks blow this category CategoryTree invoicesNode = financeNode.getChildren().get(0); invoicesNode.getCategory().getName(); // 'Invoices' invoicesNode.count(); // 3 -> 3 tasks blow this category CategoryTree incomingNode = invoicesNode.getChildren().get(0); incomingNode.getCategory().getName(); // 'Incoming' incomingNode.count(); // 1 -> there is 1 task blow this category CategoryTree supportNode = rootNode.getChildren().get(1); supportNode.getCategory().getName(); // 'Support' supportNode.count(); // 1 -> there is 1 task blow this category CategoryTree firstLevelNode = supportNode.getChildren().get(1); firstLevelNode.getCategory().getName(); // 'FirstLevel' firstLevelNode.count(); // 1 -> there is 1 task blow this category
- API:
- This is a public API.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
count()
Returns to total count of involved tasks or cases of this entry.static CategoryTree
createFor(CaseQuery caseQuery)
Creates a tree model based on the passedCaseQuery
.static CategoryTree
createFor(TaskQuery taskQuery)
Creates a tree model based on the passedTaskQuery
.List<CategoryTree>
getAllChildren()
Returns the children and their children recursively.Category
getCategory()
Returns theCategory
of this entry.List<CategoryTree>
getChildren()
Returns the children of this entry.String
getRawPath()
Returns the raw category path of this entry.
-
-
-
Method Detail
-
createFor
public static CategoryTree createFor(CaseQuery caseQuery)
Creates a tree model based on the passedCaseQuery
.- Parameters:
caseQuery
- the basedCaseQuery
- Returns:
- The root node of the
CategoryTree
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
createFor
public static CategoryTree createFor(TaskQuery taskQuery)
Creates a tree model based on the passedTaskQuery
.- Parameters:
taskQuery
- the basedTaskQuery
- Returns:
- The root node of the
CategoryTree
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
getRawPath
public String getRawPath()
Returns the raw category path of this entry.- Returns:
- the raw category path of this entry
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
getCategory
public Category getCategory()
- Returns:
- the
Category
of this entry - API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
count
public long count()
Returns to total count of involved tasks or cases of this entry.- Returns:
- to total count of involved tasks or cases of this entry
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
getChildren
public List<CategoryTree> getChildren()
Returns the children of this entry.- Returns:
- the children of this entry, maybe a empty list
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
getAllChildren
public List<CategoryTree> getAllChildren()
Returns the children and their children recursively.- Returns:
- all the children of this entry, maybe a empty list
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
-