Chapter 11. Services Tutorials

These tutorials build upon the discussion in Chapter 5 WAF Component: Services.

11.1. Categorization Tutorial

This section presents an overview of using the categorization layer within WAF. The focus in this section is on describing the main classes and interfaces that a programmer uses to work with the categorization API.

11.1.1. Classes

To use the categorization layer, you should become familiar with the following classes.

  • Category.java

  • CategoryFilter.java

  • CategorizedObject.java

com.arsdigita.categorization.Category

http://rhea.redhat.com/doc/waf/6.0/api/com/arsdigita/categorization/Category.html

A Category encapsulates a persistent category object. This object contains the name and description for the category, as well as information about whether the category is enabled. It also provides an API for placing objects within this category, creating subcategories under the instance category, and retrieving parent and child categories and objects.

This class has several notable methods that you should understand before beginning work with categorization. The URLs have been line broken with a "\" for printing purposes:

com.arsdigita.categorization.CategorizedObject

http://rhea.redhat.com/doc/waf/6.0/api/com/arsdigita/categorization/CategorizedObject.html

This class is the leaf node of a category tree, containing the actual data object and methods to find the parent. That is, when a subcategory is asked for its objects, it returns a collection of CategorizedObjects. Methods within CategorizedObject can then be used to retrieve information about the parents of the given Object as well as the actual ACSObject.

com.arsdigita.categorization.CategoryFilter

http://rhea.redhat.com/doc/waf/6.0/api/com/arsdigita/categorization/CategoryFilter.html

This class allows you to filter the categories that will be returned as parents or children of categories. Currently, it allows you to choose enabled categories only, disabled categories only, or all categories. By subclassing this class, applications can add further filtering criteria.

Other Classes

These classes work together to provide access to a Bebop Tree that can be used to display the category tree:

These classes are not of much importance to you unless you want to change the way the tree appears. Displaying a category hierarchy is a multiple-step process. First, create a TreeModelBuilder that will instantiate a CategoryTreeModel (based either on a query or some other external data source). This TreeModelBuilder is passed to the Tree, which uses your builder to create its TreeModel. This process is necessary since a DataObject cannot be used across connections.