Class CategoryTree

java.lang.Object
ch.ivyteam.ivy.workflow.category.CategoryTree

public class CategoryTree extends Object
This class implements a tree data model to manage Categories of Tasks or Cases, e.g. to show an overview of involved categories in a task or case query.

The CategoryTree is created by the method createFor(CaseQuery) or createFor(TaskQuery), the method optimize and executes the passed query and returns the corresponding tree model.

Example:
Lets imagine that the query

 TaskQuery query = TaskQuery.create().where().currentUserCanWorkOn();
 List<ITask> query.executor().results();
returns the following four tasks which are categorized as below:
 - 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 Details

    • createFor

      public static CategoryTree createFor(CaseQuery caseQuery)
      Creates a tree model based on the passed CaseQuery.
      Parameters:
      caseQuery - the based CaseQuery
      Returns:
      The root node of the CategoryTree
      API:
      This public API is available in Java.
    • createFor

      public static CategoryTree createFor(TaskQuery taskQuery)
      Creates a tree model based on the passed TaskQuery.
      Parameters:
      taskQuery - the based TaskQuery
      Returns:
      The root node of the CategoryTree
      API:
      This public API is available in Java.
    • 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 Java.
    • getCategory

      public Category getCategory()
      Returns the Category of this entry. On the Category it is possible to get localized messages.
      Returns:
      the Category of this entry
      API:
      This public API is available in Java.
    • 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 Java.
    • 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 Java.
    • 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 Java.