com.arsdigita.categorization
Class Category

java.lang.Object
  extended bycom.arsdigita.domain.DomainObject
      extended bycom.arsdigita.domain.ObservableDomainObject
          extended bycom.arsdigita.kernel.ACSObject
              extended bycom.arsdigita.categorization.Category

public class Category
extends ACSObject

Implements persistent storage of categories. See com.arsdigita.categorization for a more detailed description of what categories are and what they can be used for.

This is a persistent class backed by the data object type whose name is specified by BASE_DATA_OBJECT_TYPE. The attribute names of of this data object type are exposed via the public string fields such as CHILD, DEFAULT_ANCESTORS. See below.

This version of the class deprecates the notion of category purposes and replaces it with the notion of use contexts. The following methods should no longer be used:

The following methods should be used instead:

Version:
$Revision: #74 $ $DateTime: 2004/04/07 16:07:11 $
Author:
Randy Graebner

Field Summary
static String BASE_DATA_OBJECT_TYPE
           
static String CATEGORIES
           
static String CATEGORY_ID
           
static String CATEGORY_OWNER
           
static String CHILD
          An attribute name for the underlying data object.
static String CHILD_OBJECTS
           
static String DEFAULT_ANCESTORS
          An attribute name for the underlying data object.
static String DESCRIPTION
          An attribute name for the underlying data object.
static String IS_ABSTRACT
          An attribute name for the underlying data object.
static String IS_DEFAULT
           
static String IS_ENABLED
          An attribute name for the underlying data object.
static String IS_INDEX
           
static PrivilegeDescriptor MAP_DESCRIPTOR
          The PrivilegeDescriptor corresponding to the privilege to map subcategories and objects to this category
static String NAME
          An attribute name for the underlying data object.
static String OWNER_USE_CONTEXT
           
static String PARENT_CATEGORY
           
static String PARENTS
          An attribute name for the underlying data object.
static String REL_TYPE
          An attribute name for the underlying data object.
static String RELATED
          An attribute name for the underlying data object.
static String RELATED_CATEGORIES
           
static String ROOT_CATEGORY
           
static String ROOT_USE_CONTEXT
           
static String SORT_KEY
          An attribute name for the underlying data object.
static String URL
          An attribute name for the underlying data object.
static String USE_CONTEXT
           
 
Fields inherited from class com.arsdigita.kernel.ACSObject
CONTAINER, DEFAULT_DOMAIN_CLASS, DISPLAY_NAME, ID, OBJECT_TYPE, versionId
 
Constructor Summary
Category()
          Serves as a shortcut to Category(Category.BSE_DATA_OBJECT_TYPE).
Category(BigDecimal id)
          Retrieves the data object with the specified ID from the persistence storage mechanism.
Category(DataObject categoryObjectData)
          Initializes the category with the specified data object.
Category(ObjectType type)
          Initializes the contained data object with a new data object whose object type is the specified type.
Category(OID oid)
          Retrieves the data object with the specified OID from the persistent storage mechanism.
Category(OID categoryID, String name, String description)
          Retrieves the category with the given category ID, and sets the name and description.
Category(OID categoryID, String name, String description, String url)
          Retrieves the category with the given category ID, and sets the name and description.
Category(String typeName)
          Initializes the contained data object with a new data object whose object type is specified by the passed in type name.
Category(String name, String description)
          Creates a new category with the given name and description.
Category(String name, String description, String url)
          Creates a new category with the given name, description and URL component.
 
Method Summary
 void addChild(ACSObject object)
          This makes the ACS object a child of the category if: The to-be child will not cause a loop in the category hierarchy The to-be child is not already a child.
 void addPurpose(CategoryPurpose purpose)
          Deprecated. use the "use context" APIs instead
 void addRelatedCategory(Category category)
          Adds a new "related" category mapping to a category object.
 void alphabetizeChildCategories()
          Alphabetizes the child categories so that they will always be displayed in alphabetical order.
protected  void beforeSave()
           
 boolean canAdmin()
          This returns a boolean indicating if the current user has the permission to change the permissions on this category.
 boolean canDelete()
          Returns a boolean indicating if the current user can delete this category.
 boolean canEdit()
          Returns a boolean indicating if the current user can edit the properties of the category.
 boolean canMap()
          Returns a boolean indicating if the current user can map a child object to this category.
 boolean canRead()
          Returns a boolean indicating if the current user has the permission to read properties of this category.
static void clearRootForObject(ACSObject object)
          Calls clearRootForObject(ACSObject, String) with the null context.
static void clearRootForObject(ACSObject object, String context)
          Removes any root category associated with the object in the specified context.
 void delete()
          Cleans up all the mappings where this category is a child, and then deletes the category.
 void deleteCategoryAndOrphan()
          Deletes the passed in category.
 void deleteCategoryAndRemap()
          Deletes the passed in category after remapping all the children.
 void deleteCategorySubtree()
          Deletes the category after deleting all default categories in its subtree
static String getBaseDataObjectPackage()
          Returns the model name of BASE_DATA_OBJECT_TYPE.
protected  String getBaseDataObjectType()
          Returns the base data object type for this domain object class.
 CategoryCollection getChildren()
          Retrieves a collection of domain objects of the specified type that are immediate children of this category.
 Category[] getChildrenByURL(String path)
          Given a relative path, returns the list of constituent categories of the path.
 CategoryCollection getDefaultAscendants()
          Returns a collection of default progenitors of this category, up to and including the root category.
 Category getDefaultParentCategory()
          Returns the default parent category.
 CategorizedCollection getDescendantObjects()
          Returns a collection of objects that are children of this category or its descendant categories.
 CategorizedCollection getDescendantObjects(String objectType, String path)
           
 CategoryCollection getDescendants()
          Returns a collection of all the categories in this category's subtree.
 String getDescription()
          Returns the description of the category.
 ACSObject getDirectIndexObject()
          This returns the index item directly mapped to this category and null if it does not have one.
 String getDisplayName()
          Returns the display name of the category.
 ACSObject getIndexObject()
          Retrieves the index object for this category.
 String getName()
           
 long getNumberOfChildCategories()
          Returns the number of child categories for this category.
 long getNumberOfChildObjects()
          Returns the number of child objects for this category.
 CategorizedCollection getObjects(String objectType)
          A convinience wrapper for getObjects(objectType, null).
 CategorizedCollection getObjects(String objectType, String path)
          Returns a collection of the child objects of this category.
 long getParentCategoryCount()
          Returns the number of parent categories for this category.
 CategoryCollection getParents()
          Returns the parent categories for this category (the categories under which this category is categorized).
 Collection getPurposes()
          Deprecated. use the "use context" APIs instead
 String getQualifiedName(String delimeter, boolean includeRoot)
          Returns the name of the category along with its default ancestors.
 String getQualifiedURL(String delimeter, boolean includeRoot)
          Returns the url of the category along with its default ancestors
 DataAssociationCursor getRelatedCategories(String relation)
          Returns the Cursor for the related categories so that the caller can filter, if desired.
static RootCategoryCollection getRootCategories(ACSObject acsObj)
          Returns a collection of root categories to which this object is mapped.
static Category getRootForObject(ACSObject object)
          A shortcut for getRootForObject(ACSObject, String) called with the null context.
static Category getRootForObject(ACSObject object, String context)
          Retrieves the root category associated with an object in the given use context.
 String getURL()
          Returns the URL component of the category.
 boolean hasChildCategories()
          Determines whether the category has any child categories.
 boolean hasChildObjects()
          Determines whether the category has child objects.
protected  void initialize()
          Called from base class (DomainObject) constructors.
 boolean isAbstract()
          An abstract category cannot have any child objects, but it can have child categories.
static boolean isCategory(ACSObject object)
          Determines whether the passed in object is a category.
 boolean isEnabled()
          Determines the current state of the category.
 boolean isLeaf()
          Determines whether the category is a leaf (does not have any child objects or child categories).
 boolean isMemberOfSubtree(ACSObject acsObject)
          Determines whether the ACS object is in the subtree with the specified category as the root.
 boolean isRoot()
          Determines whether the category is a root.
 void removeChild(ACSObject acsObj)
          Removes a category mapping from the domain object so that an ACS object is no longer a child of a category.
 void removeChild(Category category)
          Removes the specified child category.
 void removePurpose(CategoryPurpose purpose)
          Deprecated. use the "use context" APIs instead
 void removeRelatedCategory(Category category)
          This takes a category and removes its relation to this category.
 void setAbstract(boolean isAbstract)
          Sets whether the category is abstract.
 void setDefaultParentCategory(Category parent)
          Sets this category's default parent category to the one that is passed in.
 void setDescription(String value)
          Sets the description of the category.
 void setEnabled(boolean isEnabled)
          Sets whether the category is enabled.
 void setIndexObject(ACSObject object)
          Sets the index object for this category.
 void setName(String value)
          Sets the name of the category.
static void setRootForObject(ACSObject acsObj, Category root)
          A shortcut for calling setRootForObject(ACSObject, Category, String) with the null context.
static void setRootForObject(ACSObject acsObj, Category rootCat, String context)
          Sets the root category for the supplied object in the given context.
 void setSortKey(ACSObject child, int key)
          Explicitly sets the sort key for this child object (category or otherwise).
 void setURL(String url)
          Sets the URL component of the category.
 void swapSortKeys(BigDecimal childID1, BigDecimal childID2)
          Explicitly swaps the sort keys for two child objects
 void swapWithNext(ACSObject child)
          This takes the child and swaps it with the next child in the sort order.
 void swapWithPrevious(ACSObject child)
          Swaps the order of the child object with the next child object categorized in the category.
 String toString()
          Return the OID plus the flags N,M,D,U depending on whether the object is new, modified, deleted, or unknown.
 
Methods inherited from class com.arsdigita.kernel.ACSObject
assertPrivilege, checkPrivilege, doCreateCheck, doWriteCheck, getContainer, getDefaultDomainClass, getID, getSpecificObjectType, getSpecificOID, gimmeContainer, isContainerModified, setID, setID
 
Methods inherited from class com.arsdigita.domain.ObservableDomainObject
addObserver, getObservers
 
Methods inherited from class com.arsdigita.domain.DomainObject
add, add, addToAssociation, afterDelete, afterSave, beforeDelete, clear, disconnect, equals, get, getObjectType, getOID, getSession, hashCode, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, set, setAssociation, setAssociation, specializeDataObject, specializeDataObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BASE_DATA_OBJECT_TYPE

public static final String BASE_DATA_OBJECT_TYPE
See Also:
ObjectType, Constant Field Values

MAP_DESCRIPTOR

public static final PrivilegeDescriptor MAP_DESCRIPTOR
The PrivilegeDescriptor corresponding to the privilege to map subcategories and objects to this category


ROOT_CATEGORY

public static final String ROOT_CATEGORY
See Also:
Constant Field Values

USE_CONTEXT

public static final String USE_CONTEXT
See Also:
Constant Field Values

CATEGORY_OWNER

public static final String CATEGORY_OWNER
See Also:
Constant Field Values

ROOT_USE_CONTEXT

public static final String ROOT_USE_CONTEXT
See Also:
Constant Field Values

OWNER_USE_CONTEXT

public static final String OWNER_USE_CONTEXT
See Also:
Constant Field Values

CHILD

public static final String CHILD
An attribute name for the underlying data object.

See Also:
Constant Field Values

PARENTS

public static final String PARENTS
An attribute name for the underlying data object.

See Also:
Constant Field Values

RELATED

public static final String RELATED
An attribute name for the underlying data object.

See Also:
Constant Field Values

REL_TYPE

public static final String REL_TYPE
An attribute name for the underlying data object.

See Also:
Constant Field Values

SORT_KEY

public static final String SORT_KEY
An attribute name for the underlying data object.

See Also:
Constant Field Values

IS_DEFAULT

public static final String IS_DEFAULT
See Also:
Constant Field Values

IS_INDEX

public static final String IS_INDEX
See Also:
Constant Field Values

PARENT_CATEGORY

public static final String PARENT_CATEGORY
See Also:
Constant Field Values

CATEGORY_ID

public static final String CATEGORY_ID
See Also:
Constant Field Values

NAME

public static final String NAME
An attribute name for the underlying data object.

See Also:
Constant Field Values

DESCRIPTION

public static final String DESCRIPTION
An attribute name for the underlying data object.

See Also:
Constant Field Values

URL

public static final String URL
An attribute name for the underlying data object.

See Also:
Constant Field Values

IS_ENABLED

public static final String IS_ENABLED
An attribute name for the underlying data object.

See Also:
Constant Field Values

IS_ABSTRACT

public static final String IS_ABSTRACT
An attribute name for the underlying data object.

See Also:
Constant Field Values

DEFAULT_ANCESTORS

public static final String DEFAULT_ANCESTORS
An attribute name for the underlying data object.

See Also:
Constant Field Values

CHILD_OBJECTS

public static final String CHILD_OBJECTS
See Also:
Constant Field Values

RELATED_CATEGORIES

public static final String RELATED_CATEGORIES
See Also:
Constant Field Values

CATEGORIES

public static final String CATEGORIES
See Also:
Constant Field Values
Constructor Detail

Category

public Category(DataObject categoryObjectData)
Initializes the category with the specified data object.

Parameters:
categoryObjectData - the data object

Category

public Category()
Serves as a shortcut to Category(Category.BSE_DATA_OBJECT_TYPE).

See Also:
DomainObject.DomainObject(String)

Category

public Category(String typeName)
Initializes the contained data object with a new data object whose object type is specified by the passed in type name.

Parameters:
typeName - the object type for the contained data object
See Also:
DomainObject.DomainObject(String), DataObject, ObjectType

Category

public Category(ObjectType type)
Initializes the contained data object with a new data object whose object type is the specified type.

Parameters:
type - the object type for the contained data object
See Also:
DomainObject.DomainObject(ObjectType), DataObject

Category

public Category(OID oid)
Retrieves the data object with the specified OID from the persistent storage mechanism.

Parameters:
oid - the OID for the data object to retrieve
Throws:
DataObjectNotFoundException - if this OID is invalid or has been deleted.
See Also:
DomainObject.DomainObject(OID), DataObject

Category

public Category(BigDecimal id)
Retrieves the data object with the specified ID from the persistence storage mechanism. This method is just a wrapper for the Category(OID) constructor.

Throws:
DataObjectNotFoundException

Category

public Category(String name,
                String description)
Creates a new category with the given name and description.

Parameters:
name - the name for the new category
description - the description for the new category

Category

public Category(String name,
                String description,
                String url)
Creates a new category with the given name, description and URL component.

Parameters:
name - the name for the new category
description - the description for the new category
url - URL component used when browsing categories.

Category

public Category(OID categoryID,
                String name,
                String description)
Retrieves the category with the given category ID, and sets the name and description. For the new name and descrption to be permanent, the caller must call the save() method.

Parameters:
categoryID - the category ID
name - the category name
description - the category description
Throws:
DataObjectNotFoundException - if this OID is invalid or has been deleted.
See Also:
DomainObject.DomainObject(OID)

Category

public Category(OID categoryID,
                String name,
                String description,
                String url)
Retrieves the category with the given category ID, and sets the name and description. For the new name and descrption to be permanent, the caller must call the save() method.

Parameters:
categoryID - the category ID
name - the category name
description - the category description
url - URL component used when browsing categories.
Throws:
DataObjectNotFoundException - if this OID is invalid or has been deleted.
See Also:
DomainObject.DomainObject(OID)
Method Detail

getBaseDataObjectType

protected String getBaseDataObjectType()
Description copied from class: DomainObject
Returns the base data object type for this domain object class. Intended to be overrided by subclasses whenever the subclass will only work if their primary data object is of a certain base type.

Overrides:
getBaseDataObjectType in class ACSObject

getBaseDataObjectPackage

public static String getBaseDataObjectPackage()
Returns the model name of BASE_DATA_OBJECT_TYPE.


initialize

protected void initialize()
Description copied from class: ACSObject
Called from base class (DomainObject) constructors.

Overrides:
initialize in class ACSObject
See Also:
DomainObject.initialize()

getName

public String getName()
Returns:
the category name.

getDisplayName

public String getDisplayName()
Returns the display name of the category. This overrides the parent implementation.

Overrides:
getDisplayName in class ACSObject
Returns:
the category name.

getQualifiedName

public String getQualifiedName(String delimeter,
                               boolean includeRoot)
Returns the name of the category along with its default ancestors.

For example, when called on the Televised Events category in this example, the return value would be something like "Entertainment >> Movies >> Televised Events".

Parameters:
delimeter - The string to use to seperate the parents from the children. For example, to obtain the above-mentioned result, you need to pass in " >> " as the delimiter.
includeRoot - This indicates whether or not the root category should be included in the name.
Returns:
the qualified name as explained above. May return null this is the root category, and includeRoot is false.
See Also:
getDefaultAscendants()

getQualifiedURL

public String getQualifiedURL(String delimeter,
                              boolean includeRoot)
Returns the url of the category along with its default ancestors

Parameters:
delimeter - The string to use to seperate the parents from the children.
includeRoot - This indicates whether or not the root category should be included in the URL.
See Also:
getDefaultAscendants()

setName

public void setName(String value)
Sets the name of the category.

Parameters:
value - the new name of the category

getDescription

public String getDescription()
Returns the description of the category.

Returns:
the category name.

setDescription

public void setDescription(String value)
Sets the description of the category.

Parameters:
value - the new description of the category

getURL

public String getURL()
Returns the URL component of the category.

Returns:
URL component used when browsing categories

setURL

public void setURL(String url)
Sets the URL component of the category.

Parameters:
url - URL component used when browsing categories

isEnabled

public boolean isEnabled()
Determines the current state of the category.

Returns:
true if the category is enabled; false otherwise.

setEnabled

public void setEnabled(boolean isEnabled)
Sets whether the category is enabled.

Parameters:
isEnabled - true if the category is enabled; false otherwise.

isAbstract

public boolean isAbstract()
An abstract category cannot have any child objects, but it can have child categories.

Returns:
true if the category is abstract; false otherwise.

setAbstract

public void setAbstract(boolean isAbstract)
Sets whether the category is abstract.

See Also:
isAbstract()

getPurposes

public Collection getPurposes()
Deprecated. use the "use context" APIs instead


addPurpose

public void addPurpose(CategoryPurpose purpose)
Deprecated. use the "use context" APIs instead

Adds the specified purpose to this category.

Parameters:
purpose - The purpose

removePurpose

public void removePurpose(CategoryPurpose purpose)
Deprecated. use the "use context" APIs instead

Removes the specified purpose from this category.

Parameters:
purpose - the purpose

beforeSave

protected void beforeSave()
Overrides:
beforeSave in class ACSObject
See Also:
DomainObject.beforeSave()

isCategory

public static boolean isCategory(ACSObject object)
Determines whether the passed in object is a category.

Parameters:
object - the object to test
Returns:
true if the passed in object is a category; false otherwise.

delete

public void delete()
Cleans up all the mappings where this category is a child, and then deletes the category. This method should generally not be used. Use deleteCategoryAndRemap(), deleteCategoryAndOrphan(), or deleteCategorySubtree() instead.

Overrides:
delete in class DomainObject
Throws:
CategorizationException - if the category has child objects or subcategories mapped to it. If the object has children, the programmer must call deleteCategoryAndOrphan(), deleteCategorySubtree(), or deleteCategoryAndRemap().
See Also:
DataObject.delete()

deleteCategorySubtree

public void deleteCategorySubtree()
Deletes the category after deleting all default categories in its subtree

If the category to be deleted is not the default parent of the child category, this method deletes the mapping but it does not delete that section of the subtree (similar to the way a UNIX rm -r works on symbolic links).


deleteCategoryAndRemap

public void deleteCategoryAndRemap()
Deletes the passed in category after remapping all the children. Adds a mapping from the children to the default parent of the passed in category if the mapping does not already exist. If the category that is the parent of the to-be-deleted category is abstract then any objects that are children of that object are not remapped to anywhere


deleteCategoryAndOrphan

public void deleteCategoryAndOrphan()
Deletes the passed in category. Does not remap any of the children categories or objects. Instead, it just deletes all records of the mappings.


addChild

public void addChild(ACSObject object)
This makes the ACS object a child of the category if:
  • The to-be child will not cause a loop in the category hierarchy
  • The to-be child is not already a child.

This method cannot guarantee against loops because it cannot check unsaved mappings. Therefore, it is possible for users to create a loop within the structure if they have not called a save method on all added mappings.

This method should be used both for adding objects to a category and for creating subcategories with this category instance as the parent.

It is important to note that a category cannot be a CHILD and a RELATED category at the same time. If the category is RELATED and you call addChild, the category is removed from the group of RELATED categories and becomes a CHILD category.

Parameters:
object - the domain object to categorize

addRelatedCategory

public void addRelatedCategory(Category category)
Adds a new "related" category mapping to a category object.

This method cannot guarantee against loops because it cannot check unsaved mappings. Therefore, it is possible for users to create a loop within the structure if they have not called a save method on all added mappings.

It is important to note that a category cannot be a CHILD and a RELATED category at the same time. If the category is RELATED and you call addChild, the category is removed from the group of RELATED categories and becomes a CHILD category.

Parameters:
category - The related category

removeChild

public void removeChild(ACSObject acsObj)
Removes a category mapping from the domain object so that an ACS object is no longer a child of a category. This actually deletes the mapping.

Parameters:
acsObj - the domain object to uncategorize
Throws:
NullPointerException - if acsObj is null

removeChild

public void removeChild(Category category)
Removes the specified child category.

Throws:
NullPointerException - if category is null

removeRelatedCategory

public void removeRelatedCategory(Category category)
This takes a category and removes its relation to this category. If the passed in category is also a child then it is still a child after this call.


setIndexObject

public void setIndexObject(ACSObject object)
Sets the index object for this category.

Parameters:
object - The object to set as Index.

getIndexObject

public ACSObject getIndexObject()
Retrieves the index object for this category. Retrieves the index object for the parent category if there is no explicit index object for this category or null if this is the root category.

Returns:
The Index Object

getDirectIndexObject

public ACSObject getDirectIndexObject()
This returns the index item directly mapped to this category and null if it does not have one.

Returns:
The Index Object

isLeaf

public boolean isLeaf()
Determines whether the category is a leaf (does not have any child objects or child categories).

Returns:
true if the category is a leaf; false otherwise.

hasChildObjects

public boolean hasChildObjects()
Determines whether the category has child objects.

Returns:
true if the category does not have any child objects; false otherwise.

hasChildCategories

public boolean hasChildCategories()
Determines whether the category has any child categories.

Returns:
true if the category does not have any child categories; false otherwise.

isRoot

public boolean isRoot()
Determines whether the category is a root.

Returns:
true if the category does not have any parents; false otherwise.

getParentCategoryCount

public long getParentCategoryCount()
Returns the number of parent categories for this category.

Returns:
the number of times has this category has been mapped to a new category.

setDefaultParentCategory

public void setDefaultParentCategory(Category parent)
Sets this category's default parent category to the one that is passed in.

This clears the previous default mapping. The results will be saved for the user when the transaction is committed.

If the passed in parent is not already a parent then this makes the object a parent.

Parameters:
parent - the category that will become the new default category. Pass in null to clear the current default parent.
Throws:
CategoryNotFoundException - if the passed in category is not a parent of this category.

swapWithNext

public void swapWithNext(ACSObject child)
This takes the child and swaps it with the next child in the sort order. For instance, if the pass in child is 5th in the list then after the call, it will be 6th and the 6th item will become the 5th item.

See Also:
swapWithPrevious(ACSObject)

swapWithPrevious

public void swapWithPrevious(ACSObject child)
Swaps the order of the child object with the next child object categorized in the category. So, if the original order is "A, B, C" and you called B.swapWithPrevious(), the new order would be "B, A, B". If this is called on the first item of the list (e.g. "A") then nothing happens. If no sort key has been assigned yet then this does not alter anything.

See Also:
swapWithNext(ACSObject)

alphabetizeChildCategories

public void alphabetizeChildCategories()
Alphabetizes the child categories so that they will always be displayed in alphabetical order.


setSortKey

public void setSortKey(ACSObject child,
                       int key)
Explicitly sets the sort key for this child object (category or otherwise).

Parameters:
child - The child object or category to set the sortKey for
key - The integer to use for the sortKey

swapSortKeys

public void swapSortKeys(BigDecimal childID1,
                         BigDecimal childID2)
Explicitly swaps the sort keys for two child objects


getRelatedCategories

public DataAssociationCursor getRelatedCategories(String relation)
Returns the Cursor for the related categories so that the caller can filter, if desired.

Parameters:
relation - The type of relation to retrieve.

getNumberOfChildCategories

public long getNumberOfChildCategories()
Returns the number of child categories for this category. This is more efficient than retreiving the collection of categories and calling myCollection.size().

Returns:
a long indicating the number of child categories.

getChildren

public CategoryCollection getChildren()
Retrieves a collection of domain objects of the specified type that are immediate children of this category.

Throws:
NullPointerException - if objectType is null
See Also:
getDescendants()

getObjects

public CategorizedCollection getObjects(String objectType)
A convinience wrapper for getObjects(objectType, null).

Throws:
NullPointerException - if objectType is null
See Also:
getObjects(String, String)

getObjects

public CategorizedCollection getObjects(String objectType,
                                        String path)
Returns a collection of the child objects of this category.

Parameters:
objectType - the return collection will only contain objects of this type
path - the fragment of the PDL join path leading from the specified object type to the Category object type. The common case for CMS is to pass "parent" as the value of path. The common scenario for many other applications is to pass null, in which case getObjects(String) can be used.
Throws:
NullPointerException - if either parameter is null

getNumberOfChildObjects

public long getNumberOfChildObjects()
Returns the number of child objects for this category. This is more efficient than retreiving the collection of objects and calling myCollection.size().

Returns:
a long indicating the number of child objects.

getParents

public CategoryCollection getParents()
Returns the parent categories for this category (the categories under which this category is categorized).


getDefaultParentCategory

public Category getDefaultParentCategory()
Returns the default parent category. Note that this category may not be enabled.

Returns:
the default parent category.

isMemberOfSubtree

public boolean isMemberOfSubtree(ACSObject acsObject)
Determines whether the ACS object is in the subtree with the specified category as the root. This works for both categories and regular ACS objects. If the object, the category, or some mapping between the object and category has not been saved, this method does not guarantee a correct result.

Parameters:
acsObject - the item to search for
Returns:
true if the object appears mapped somewhere in the subtree; false otherwise.

getDefaultAscendants

public CategoryCollection getDefaultAscendants()
Returns a collection of default progenitors of this category, up to and including the root category.


getDescendants

public CategoryCollection getDescendants()
Returns a collection of all the categories in this category's subtree. This category is a member of the collection.

See Also:
getChildren()

getDescendantObjects

public CategorizedCollection getDescendantObjects()
Returns a collection of objects that are children of this category or its descendant categories.

See Also:
getDescendants()

getDescendantObjects

public CategorizedCollection getDescendantObjects(String objectType,
                                                  String path)

getChildrenByURL

public Category[] getChildrenByURL(String path)
Given a relative path, returns the list of constituent categories of the path. The array returned will have the current category as its first element, and the destination category as its final element.

Parameters:
path - A string representing the relative path.
Returns:
Array of constituent categories. The first element of the array is the current category (hence the array will always have length >= 1). If the path is bad, this returns null.

toString

public String toString()
Description copied from class: DomainObject
Return the OID plus the flags N,M,D,U depending on whether the object is new, modified, deleted, or unknown. Unknown is for objects that have been invalidated.

Overrides:
toString in class DomainObject

getRootForObject

public static Category getRootForObject(ACSObject object)
A shortcut for getRootForObject(ACSObject, String) called with the null context.

Returns:
the root category, or null if no category is associated
See Also:
getRootForObject(ACSObject, String)

getRootCategories

public static RootCategoryCollection getRootCategories(ACSObject acsObj)
Returns a collection of root categories to which this object is mapped.


getRootForObject

public static Category getRootForObject(ACSObject object,
                                        String context)
Retrieves the root category associated with an object in the given use context.


setRootForObject

public static void setRootForObject(ACSObject acsObj,
                                    Category root)
A shortcut for calling setRootForObject(ACSObject, Category, String) with the null context.

Parameters:
root - the root category for the object
See Also:
setRootForObject(ACSObject, Category, String)

setRootForObject

public static void setRootForObject(ACSObject acsObj,
                                    Category rootCat,
                                    String context)
Sets the root category for the supplied object in the given context.

Conceptually, this method provides a means to add/remove elements to/from a set of triples of the form (acsObj, rootCat, useContext). No two triples have the same (acsObj, rootCat) pair.

If acsObj is already mapped to some other category in the specified use context, then the existing triple's category value is updated to rootCat. Otherwise, a new triple is added.

In theory, rootCat should be a root category, i.e. it should have no parents. This method does not check if this is indeed the case.

See Also:
setRootForObject(ACSObject, Category, String)

clearRootForObject

public static void clearRootForObject(ACSObject object)
Calls clearRootForObject(ACSObject, String) with the null context.

See Also:
clearRootForObject(ACSObject, String)

clearRootForObject

public static void clearRootForObject(ACSObject object,
                                      String context)
Removes any root category associated with the object in the specified context.

Parameters:
object - the object to remove the root category from

canEdit

public boolean canEdit()
Returns a boolean indicating if the current user can edit the properties of the category. This does not include mapping child objects. For mapping, use canMap.


canDelete

public boolean canDelete()
Returns a boolean indicating if the current user can delete this category.


canMap

public boolean canMap()
Returns a boolean indicating if the current user can map a child object to this category. This must return true in order to call addChild or removeChild.


canRead

public boolean canRead()
Returns a boolean indicating if the current user has the permission to read properties of this category.


canAdmin

public boolean canAdmin()
This returns a boolean indicating if the current user has the permission to change the permissions on this category. If canAdmin == true then all of the other canXXX also are true



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC