com.tenduke.objectmodel
Class Category

java.lang.Object
  extended by com.tenduke.types.AbstractBindableObject
      extended by com.tenduke.objectmodel.TendukeObject
          extended by com.tenduke.objectmodel.Category
All Implemented Interfaces:
RelationObject, SerializableObject, java.lang.Cloneable

public class Category
extends TendukeObject

Hierarchical category object that can be referenced from TendukeObjects

Category model is flexible and can be used in several variations. Usage variations are enabled by the hierarchical nature of the Category model and that Category is used to categorize other objects. The relation is many to one from categorized object point of view (an object can be in one category and one category may hold several objects). It is important to note that known default bind implementation (com.tenduke.binding) uses Category object's parent field (AbstractBindableObject.getParent()) to determine parent based naming. The default bind implementation chooses to persist Category object in a table, which is named using the categorized object (e.g. when writing a Category object who's parent is a VideoEntry the Category object will be stored into a table called VideoCategory). Parent based naming is only activated if the Category object's parent handle is set.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.tenduke.objectmodel.TendukeObject
TendukeObject.CreatedDateComparator<T extends TendukeObject>, TendukeObject.ModifiedDateComparator<T extends TendukeObject>
 
Field Summary
static int FIELD_LENGTH_CATEGORY_DESCRIPTION
          Maximum length for field data that holds category description.
static int FIELD_LENGTH_CATEGORY_NAME
          Maximum length for field data that holds category name.
static int FIELD_LENGTH_CATEGORY_PARENT_ID
          Maximum length for field data that holds parent category id.
static java.lang.String FIELD_NAME_CATEGORY_DESCRIPTION
          Identifier for field that holds category description.
static java.lang.String FIELD_NAME_CATEGORY_NAME
          Identifier for field that holds category name.
static java.lang.String FIELD_NAME_CATEGORY_OWNER
          Identifier for field that holds category "owner" object.
static java.lang.String FIELD_NAME_CHILD_CATEGORIES
          Identifier for field that holds child categories objects.
static java.lang.String FIELD_NAME_PARENT_CATEGORY_ID
          Identifier for field that holds parent category id.
 
Fields inherited from class com.tenduke.objectmodel.TendukeObject
FIELD_NAME_CREATED, FIELD_NAME_CREATED_BY_PROFILE, FIELD_NAME_MODIFIED, FIELD_NAME_MODIFIED_BY_PROFILE, FIELD_NAME_OBJECT_CATEGORY, FIELD_NAME_OBJECT_CATEGORY_ID, FIELD_NAME_OBJECT_CONSUMPTION, FIELD_NAME_OBJECT_FEATURES, FIELD_NAME_OBJECT_PROPERTIES, RELATED_FIELD_COPY_STYLE_DEEP, RELATED_FIELD_COPY_STYLE_NONE, RELATED_FIELD_COPY_STYLE_SHALLOW
 
Fields inherited from class com.tenduke.types.AbstractBindableObject
FIELD_LENGTH_SHORT_ID, FIELD_NAME_OBJECT_STATE_CHANGE, FIELD_NAME_REPLACES_OBJECT, FIELD_NAME_SHORT_ID, PERMISSION_ACTION_CREATE, PERMISSION_ACTION_DELETE, PERMISSION_ACTION_MODIFY, PERMISSION_ACTION_READ
 
Constructor Summary
Category()
          Construct new Category with random UUID.
Category(java.lang.String name, java.lang.String description)
          Construct new Category with caller defined name and description and a random UUID as object's id.
Category(java.util.UUID categoryId)
          Construct new Category with caller defined UUID as object's unique id.
Category(java.util.UUID categoryId, java.lang.String name, java.lang.String description)
          Construct new Category with caller defined name, description and UUID as object's id.
 
Method Summary
 void addChildCategory(Category childCategory)
          Adds a category as child category of this category and sets the child's parent id to id of this.
 java.lang.Object clone()
          Clones the instance.
 void copyThis(Category result)
          Copies this instance into caller defined result object.
 java.util.UUID getCategoryId()
          Gets the object's unique id.
 TendukeObject getCategoryOwner()
          Gets category's owner object (the categorized object).
 java.util.List<Category> getChildCategories()
          Gets this category's child categories.
 java.lang.String getDescription()
          Gets the category description.
 java.util.UUID getId()
          Gets object's unique id.
 java.lang.String getName()
          Gets the category name.
 java.util.UUID getParentCategoryId()
          Gets the parent category's id.
protected  void resolveParentBindableType()
          Resolves and sets #getParentBindType() based on currently set parent object.
 void setCategoryId(java.util.UUID categoryId)
          Sets object's unique id.
 void setCategoryOwner(TendukeObject categoryOwner)
          Sets category's owner object (the categorized object).
 void setChildCategories(java.util.List<Category> childCategories)
          Sets the child list, also sets parent id of each child.
 void setDescription(java.lang.String value)
          Sets category description.
 void setId(java.util.UUID id)
          Sets object's unique id.
 void setName(java.lang.String name)
          Sets the category name.
 void setParentCategoryId(java.util.UUID categoryParentId)
          Sets parent category's id.
 
Methods inherited from class com.tenduke.objectmodel.TendukeObject
addFeature, addObjectConsumption, addObjectProperty, addProperty, addRelatedObjectDefault, addRelatedObjectDefault, addRelatedObjectsDefault, addRelatedObjectsDefault, clone, copyThis, copyThis, equals, fieldValueToString, findProperty, findProperty, getChangedSerializableFieldValues, getCreated, getCreatedBy, getCreatedByRecursive, getCreatingActor, getModified, getModifiedBy, getModifiedByRecursive, getModifyingActor, getObjectCategory, getObjectCategoryId, getObjectConsumption, getObjectContractName, getObjectContractName, getObjectFeature, getObjectFeatures, getObjectProperties, getObjectProperty, getObjectPropertyValue, getRelatedObjectsDefault, getRelatedObjectsDefault, hashCode, idFromString, merge, objectFeaturesToMap, objectPropertiesToMap, orderByCreatedDate, orderByModifiedDate, setCreated, setCreatedBy, setCreatedByRecursive, setCreatedByRecursive, setCreatingActor, setModified, setModifiedBy, setModifiedBy, setModifiedByRecursive, setModifiedByRecursive, setModifiedByRecursive, setModifyingActor, setObjectCategory, setObjectCategoryId, setObjectConsumption, setObjectFeatures, setObjectProperties, setRelatedObjectsDefault, setRelatedObjectsDefault, toString
 
Methods inherited from class com.tenduke.types.AbstractBindableObject
addRelatedObject, addRelatedObject, addRelatedObject, addRelatedObject, addRelatedObjects, addRelatedObjects, addRelatedObjects, copyThis, getFirstObjectById, getGrantedObjectPermissionActions, getParent, getParentBindableType, getParentBindableTypeChain, getParentId, getParentNode, getParentType, getRelatedObjectList, getRelatedObjectList, getRelatedObjectLists, getRelatedObjectLists, getRelatedObjects, getRelatedObjects, getRelatedObjects, getRelatedObjects, getRelatedObjects, getRelatedObjects, getRelationAttributeObject, getRelationField, getRelationHandler, getRelationType, getReplaces, getShortId, getStateChange, hasRelatedObjects, hasRelatedObjects, resolveParentBindableTypeByTreeParent, setGrantedObjectPermissionActions, setParent, setParent, setParentBindableType, setParentNode, setRelatedObjectList, setRelatedObjects, setRelatedObjects, setRelatedObjects, setRelatedObjects, setRelatedObjects, setRelatedObjects, setRelationAttributeObject, setRelationHandler, setReplaces, setShortId, setStateChange
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FIELD_LENGTH_CATEGORY_DESCRIPTION

public static final int FIELD_LENGTH_CATEGORY_DESCRIPTION
Maximum length for field data that holds category description.

See Also:
Constant Field Values

FIELD_LENGTH_CATEGORY_NAME

public static final int FIELD_LENGTH_CATEGORY_NAME
Maximum length for field data that holds category name.

See Also:
Constant Field Values

FIELD_LENGTH_CATEGORY_PARENT_ID

public static final int FIELD_LENGTH_CATEGORY_PARENT_ID
Maximum length for field data that holds parent category id.

See Also:
Constant Field Values

FIELD_NAME_CATEGORY_DESCRIPTION

public static final java.lang.String FIELD_NAME_CATEGORY_DESCRIPTION
Identifier for field that holds category description.

See Also:
Constant Field Values

FIELD_NAME_CATEGORY_NAME

public static final java.lang.String FIELD_NAME_CATEGORY_NAME
Identifier for field that holds category name.

See Also:
Constant Field Values

FIELD_NAME_CATEGORY_OWNER

public static final java.lang.String FIELD_NAME_CATEGORY_OWNER
Identifier for field that holds category "owner" object.

See Also:
Constant Field Values

FIELD_NAME_CHILD_CATEGORIES

public static final java.lang.String FIELD_NAME_CHILD_CATEGORIES
Identifier for field that holds child categories objects.

See Also:
Constant Field Values

FIELD_NAME_PARENT_CATEGORY_ID

public static final java.lang.String FIELD_NAME_PARENT_CATEGORY_ID
Identifier for field that holds parent category id. Used to build a hierarchical Category model.

See Also:
Constant Field Values
Constructor Detail

Category

public Category()
Construct new Category with random UUID.


Category

public Category(java.lang.String name,
                java.lang.String description)
Construct new Category with caller defined name and description and a random UUID as object's id.

Parameters:
name - Category name.
description - Category description.

Category

public Category(java.util.UUID categoryId)
Construct new Category with caller defined UUID as object's unique id.

Parameters:
categoryId - object's unique id to set.

Category

public Category(java.util.UUID categoryId,
                java.lang.String name,
                java.lang.String description)
Construct new Category with caller defined name, description and UUID as object's id.

Parameters:
categoryId - Unique id for object.
name - Category name.
description - Category description.
Method Detail

addChildCategory

public void addChildCategory(Category childCategory)
Adds a category as child category of this category and sets the child's parent id to id of this.

Parameters:
childCategory - The category to add as a child to this.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the instance.

Overrides:
clone in class TendukeObject
Returns:
Cloned instance of the object.
Throws:
java.lang.CloneNotSupportedException - Clone is implemented, exceptions not explicitly thrown.

copyThis

public void copyThis(Category result)
Copies this instance into caller defined result object.

Parameters:
result - caller defined result object.

getCategoryId

public java.util.UUID getCategoryId()
Gets the object's unique id.

Returns:
object's unique id.

getCategoryOwner

public TendukeObject getCategoryOwner()
Gets category's owner object (the categorized object).

Returns:
category's owner object (the categorized object).

getChildCategories

public java.util.List<Category> getChildCategories()
Gets this category's child categories.

Returns:
this category's child categories.

getDescription

public java.lang.String getDescription()
Gets the category description.

Returns:
category description.

getId

public java.util.UUID getId()
Gets object's unique id.

Specified by:
getId in interface SerializableObject
Specified by:
getId in class AbstractBindableObject
Returns:
object's unique id.

getName

public java.lang.String getName()
Gets the category name.

Returns:
category name.

getParentCategoryId

public java.util.UUID getParentCategoryId()
Gets the parent category's id.

Returns:
parent category's id.

resolveParentBindableType

protected void resolveParentBindableType()
Resolves and sets #getParentBindType() based on currently set parent object. Called by AbstractBindableObject.getParent() after setting parent, parent type and parent id. Overridden in this class for using parent object type based on first parent in current hierarchy that is of different type than this object.

Overrides:
resolveParentBindableType in class AbstractBindableObject

setCategoryId

public void setCategoryId(java.util.UUID categoryId)
Sets object's unique id.

Parameters:
categoryId - object's unique id to set.

setCategoryOwner

public void setCategoryOwner(TendukeObject categoryOwner)
Sets category's owner object (the categorized object).

Parameters:
categoryOwner - category's owner object (the categorized object) to set.

setChildCategories

public void setChildCategories(java.util.List<Category> childCategories)
Sets the child list, also sets parent id of each child. Takes ownership of the caller defined List.

Parameters:
childCategories - this category's child categories to set.

setDescription

public void setDescription(java.lang.String value)
Sets category description.

Parameters:
value - category description to set.

setId

public void setId(java.util.UUID id)
Sets object's unique id.

Specified by:
setId in interface SerializableObject
Specified by:
setId in class AbstractBindableObject
Parameters:
id - object's unique id to set.

setName

public void setName(java.lang.String name)
Sets the category name.

Parameters:
name - category name to set.

setParentCategoryId

public void setParentCategoryId(java.util.UUID categoryParentId)
Sets parent category's id.

Parameters:
categoryParentId - parent category's id to set.