|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.domain.DomainObject
com.arsdigita.domain.ObservableDomainObject
com.arsdigita.kernel.ACSObject
com.arsdigita.categorization.Category
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:
getRootForObject(ACSObject, String)
setRootForObject(ACSObject, Category,String)
clearRootForObject(ACSObject, String)
getRootCategories(ACSObject)
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 |
public static final String BASE_DATA_OBJECT_TYPE
ObjectType
,
Constant Field Valuespublic static final PrivilegeDescriptor MAP_DESCRIPTOR
PrivilegeDescriptor corresponding
to the privilege to
map subcategories and objects to this category
public static final String ROOT_CATEGORY
public static final String USE_CONTEXT
public static final String CATEGORY_OWNER
public static final String ROOT_USE_CONTEXT
public static final String OWNER_USE_CONTEXT
public static final String CHILD
public static final String PARENTS
public static final String RELATED
public static final String REL_TYPE
public static final String SORT_KEY
public static final String IS_DEFAULT
public static final String IS_INDEX
public static final String PARENT_CATEGORY
public static final String CATEGORY_ID
public static final String NAME
public static final String DESCRIPTION
public static final String URL
public static final String IS_ENABLED
public static final String IS_ABSTRACT
public static final String DEFAULT_ANCESTORS
public static final String CHILD_OBJECTS
public static final String RELATED_CATEGORIES
public static final String CATEGORIES
Constructor Detail |
public Category(DataObject categoryObjectData)
categoryObjectData
- the data objectpublic Category()
Category(Category.BSE_DATA_OBJECT_TYPE)
.
DomainObject.DomainObject(String)
public Category(String typeName)
typeName
- the object type for the contained data objectDomainObject.DomainObject(String)
,
DataObject
,
ObjectType
public Category(ObjectType type)
type
- the object type for the contained data objectDomainObject.DomainObject(ObjectType)
,
DataObject
public Category(OID oid)
oid
- the OID for the data object to retrieve
DataObjectNotFoundException
- if this OID is invalid or has been
deleted.DomainObject.DomainObject(OID)
,
DataObject
public Category(BigDecimal id)
Category(OID)
constructor.
DataObjectNotFoundException
public Category(String name, String description)
name
- the name for the new categorydescription
- the description for the new categorypublic Category(String name, String description, String url)
name
- the name for the new categorydescription
- the description for the new categoryurl
- URL component used when browsing categories.public Category(OID categoryID, String name, String description)
categoryID
- the category IDname
- the category namedescription
- the category description
DataObjectNotFoundException
- if this OID is
invalid or has been deleted.DomainObject.DomainObject(OID)
public Category(OID categoryID, String name, String description, String url)
categoryID
- the category IDname
- the category namedescription
- the category descriptionurl
- URL component used when browsing categories.
DataObjectNotFoundException
- if this OID is
invalid or has been deleted.DomainObject.DomainObject(OID)
Method Detail |
protected String getBaseDataObjectType()
DomainObject
getBaseDataObjectType
in class ACSObject
public static String getBaseDataObjectPackage()
BASE_DATA_OBJECT_TYPE
.
protected void initialize()
ACSObject
initialize
in class ACSObject
DomainObject.initialize()
public String getName()
public String getDisplayName()
getDisplayName
in class ACSObject
public String getQualifiedName(String delimeter, boolean includeRoot)
For example, when called on the Televised Events category in
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.
null
this is the root category, and includeRoot
is false.getDefaultAscendants()
public String getQualifiedURL(String delimeter, boolean includeRoot)
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.getDefaultAscendants()
public void setName(String value)
value
- the new name of the categorypublic String getDescription()
public void setDescription(String value)
value
- the new description of the categorypublic String getURL()
public void setURL(String url)
url
- URL component used when browsing categoriespublic boolean isEnabled()
true
if the category is enabled; false
otherwise.public void setEnabled(boolean isEnabled)
isEnabled
- true
if the category is enabled;
false otherwise.
public boolean isAbstract()
true
if the category is abstract; false
otherwise.public void setAbstract(boolean isAbstract)
isAbstract()
public Collection getPurposes()
public void addPurpose(CategoryPurpose purpose)
purpose
- The purposepublic void removePurpose(CategoryPurpose purpose)
purpose
- the purposeprotected void beforeSave()
beforeSave
in class ACSObject
DomainObject.beforeSave()
public static boolean isCategory(ACSObject object)
object
- the object to test
true
if the passed in object is a category;
false
otherwise.public void delete()
deleteCategoryAndRemap()
, deleteCategoryAndOrphan()
, or
deleteCategorySubtree()
instead.
delete
in class DomainObject
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()
.DataObject.delete()
public void deleteCategorySubtree()
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).
public void deleteCategoryAndRemap()
public void deleteCategoryAndOrphan()
public void addChild(ACSObject 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.
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.
object
- the domain object to categorizepublic void addRelatedCategory(Category category)
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.
category
- The related categorypublic void removeChild(ACSObject acsObj)
acsObj
- the domain object to uncategorize
NullPointerException
- if acsObj
is nullpublic void removeChild(Category category)
NullPointerException
- if category is nullpublic void removeRelatedCategory(Category category)
public void setIndexObject(ACSObject object)
object
- The object to set as Index.public ACSObject getIndexObject()
public ACSObject getDirectIndexObject()
public boolean isLeaf()
true
if the category is a leaf; false
otherwise.public boolean hasChildObjects()
true
if the category does not have any child objects;
false
otherwise.public boolean hasChildCategories()
true
if the category does not have any child
categories; false
otherwise.public boolean isRoot()
true
if the category does not have
any parents; false
otherwise.public long getParentCategoryCount()
public void setDefaultParentCategory(Category parent)
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.
parent
- the category that will become the new
default category. Pass in null to clear the current
default parent.
CategoryNotFoundException
- if the passed in category is
not a parent of this category.public void swapWithNext(ACSObject child)
swapWithPrevious(ACSObject)
public void swapWithPrevious(ACSObject child)
swapWithNext(ACSObject)
public void alphabetizeChildCategories()
public void setSortKey(ACSObject child, int key)
child
- The child object or category to set the sortKey forkey
- The integer to use for the sortKeypublic void swapSortKeys(BigDecimal childID1, BigDecimal childID2)
public DataAssociationCursor getRelatedCategories(String relation)
relation
- The type of relation to retrieve.public long getNumberOfChildCategories()
myCollection.size()
.
long
indicating the number of child categories.public CategoryCollection getChildren()
NullPointerException
- if objectType is nullgetDescendants()
public CategorizedCollection getObjects(String objectType)
getObjects(objectType, null)
.
NullPointerException
- if objectType is nullgetObjects(String, String)
public CategorizedCollection getObjects(String objectType, String path)
objectType
- the return collection will only contain objects of this
typepath
- 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.
NullPointerException
- if either parameter is nullpublic long getNumberOfChildObjects()
myCollection.size()
.
long
indicating the number of child objects.public CategoryCollection getParents()
public Category getDefaultParentCategory()
public boolean isMemberOfSubtree(ACSObject acsObject)
acsObject
- the item to search for
true
if the object appears mapped somewhere in
the subtree; false
otherwise.public CategoryCollection getDefaultAscendants()
public CategoryCollection getDescendants()
getChildren()
public CategorizedCollection getDescendantObjects()
getDescendants()
public CategorizedCollection getDescendantObjects(String objectType, String path)
public Category[] getChildrenByURL(String path)
path
- A string representing the relative path.
null
.public String toString()
DomainObject
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.
toString
in class DomainObject
public static Category getRootForObject(ACSObject object)
getRootForObject(ACSObject, String)
called with
the null context.
getRootForObject(ACSObject, String)
public static RootCategoryCollection getRootCategories(ACSObject acsObj)
public static Category getRootForObject(ACSObject object, String context)
public static void setRootForObject(ACSObject acsObj, Category root)
setRootForObject(ACSObject, Category,
String)
with the null context.
root
- the root category for the objectsetRootForObject(ACSObject, Category, String)
public static void setRootForObject(ACSObject acsObj, Category rootCat, String 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.
setRootForObject(ACSObject, Category, String)
public static void clearRootForObject(ACSObject object)
clearRootForObject(ACSObject, String)
with the null context.
clearRootForObject(ACSObject, String)
public static void clearRootForObject(ACSObject object, String context)
object
- the object to remove the root category frompublic boolean canEdit()
public boolean canDelete()
public boolean canMap()
public boolean canRead()
public boolean canAdmin()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |