com.elasticpath.domain.catalog.impl
Class CategoryImpl

java.lang.Object
  extended by com.elasticpath.domain.impl.AbstractEpDomainImpl
      extended by com.elasticpath.domain.impl.AbstractPersistenceImpl
          extended by com.elasticpath.domain.impl.AbstractEntityImpl
              extended by com.elasticpath.domain.catalog.impl.CategoryImpl
All Implemented Interfaces:
Category, ObjectWithLocaleDependantFields, BranchNode, Entity, EpDomain, Persistence, java.io.Serializable, java.lang.Comparable

public class CategoryImpl
extends AbstractEntityImpl
implements Category

The default implementation of Category.

See Also:
Serialized Form

Field Summary
static long serialVersionUID
          Serial version id.
 
Constructor Summary
CategoryImpl()
          Default constructor.
 
Method Summary
 void addChild(Category category)
          Add the given category as a child.
 void addOrUpdateLocaleDependantFields(LocaleDependantFields ldf)
          Sets the LocaleDependantFields.
 int compareTo(java.lang.Object object)
          Compares this category with the specified object for order.
 boolean equals(Category cat)
          Returns true if this category equals the given category.
 boolean equals(java.lang.Object obj)
          Returns true if this category equals the given object.
 void executeBeforePersistAction()
          Update the last modified date.
 AttributeValueGroup getAttributeValueGroup()
          Get the attribute value group.
 java.util.Set getAvailableChildren()
          Get the available child categories.
 CategoryType getCategoryType()
          Returns the category type.
 java.util.Set getChildren()
          Get the child categories.
 java.lang.String getCode()
          Returns the category code.
 java.lang.String getDisplayName(java.util.Locale locale)
          Returns the display name of the given locale.
 java.util.Date getEndDate()
          Get the end date.
 java.lang.String getGuid()
          Return the guid.
 boolean getHasSubCategories()
          Return the flag to indicate whether this category has subCategories or not.
 java.util.Date getLastModifiedDate()
          Returns the date when the category was last modified.
 int getLevel()
          Get category level.
 LocaleDependantFields getLocaleDependantFields(java.util.Locale locale)
          Returns the LocaleDependantFields of the given locale.
 java.util.Map getLocaleDependantFieldsMap()
          Gets the all LocaleDependantFields as a map.
 LocaleDependantFields getLocaleDependantFieldsWithoutFallBack(java.util.Locale locale)
          Returns the LocaleDependantFields of the given locale without a fallback.
 int getOrdering()
          Get the ordering number.
 Category getParent()
          Get the parent category of this category.
 java.util.Stack getPath()
          Get the path from the root category to this category on the tree.
 java.util.List getPathAsList()
          Returns the category path as a List.
 java.lang.String getSeoUrl(java.util.Locale locale, int pageNumber)
          Returns the SEO URL, E.g.
 java.lang.String getSeoUrlWithoutSuffix(java.util.Locale locale)
          Returns the SEO URL without the suffix, E.g.
 java.util.Date getStartDate()
          Get the start date that this category will become available to customers.
 java.lang.String getTemplate()
          Gets the display template of this category.
 java.lang.String getTemplateWithFallBack(java.lang.String defaultTemplate)
          Get the display template name of this category.
 java.util.Set getTopSellers()
          Returns the top sellers for this category.
 int hashCode()
          Generate the hash code.
 boolean isAvailable()
          Returns true if the category is available to be displayed.
 boolean isHidden()
          Returns true if the product should not be displayed (e.g.
 void removeChild(Category category)
          Remove the given category from the children list.
 void setAttributeValueGroup(AttributeValueGroup attributeValueGroup)
          Set the attribute value group.
 void setCategoryType(CategoryType categoryType)
          Set the CategoryType.
 void setCode(java.lang.String code)
          Sets the category code.
 void setDefaultValues()
          Set default values for those fields that need default values.
 void setEndDate(java.util.Date endDate)
          Set the end date.
 void setGuid(java.lang.String guid)
          Set the guid.
 void setHidden(boolean hidden)
          Set to true if the product should not be displayed.
 void setLastModifiedDate(java.util.Date lastModifiedDate)
          Set the date when the category was last modified.
 void setLocaleDependantFieldsMap(java.util.Map localeDependantFieldsMap)
          Sets all LocaleDependantFields with the given map.
 void setOrdering(int ordering)
          Set the ordering number.
 void setParent(Category newParent)
          Set the parent cateogry.
 void setParentOneWay(Category newParent)
          Set the parent cateogry.
 void setStartDate(java.util.Date startDate)
          Set the start date that this category will become valid.
 void setTopSellers(java.util.Set topSellers)
          Sets the top sellers for this category.
 
Methods inherited from class com.elasticpath.domain.impl.AbstractEntityImpl
convertAttributeGroupAttributes
 
Methods inherited from class com.elasticpath.domain.impl.AbstractPersistenceImpl
getUidPk, isPersistent, setUidPk
 
Methods inherited from class com.elasticpath.domain.impl.AbstractEpDomainImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.domain.Persistence
getUidPk, isPersistent, setUidPk
 
Methods inherited from interface com.elasticpath.domain.EpDomain
getElasticPath, setElasticPath
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Serial version id.

See Also:
Constant Field Values
Constructor Detail

CategoryImpl

public CategoryImpl()
Default constructor.

Method Detail

addChild

public void addChild(Category category)
Add the given category as a child.

Specified by:
addChild in interface Category
Parameters:
category - the category to be added as a child

addOrUpdateLocaleDependantFields

public void addOrUpdateLocaleDependantFields(LocaleDependantFields ldf)
Sets the LocaleDependantFields.

Specified by:
addOrUpdateLocaleDependantFields in interface ObjectWithLocaleDependantFields
Parameters:
ldf - the LocaleDependantFields instance to set.

compareTo

public int compareTo(java.lang.Object object)
              throws EpDomainException
Compares this category with the specified object for order.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
object - the given object
Returns:
a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.
Throws:
EpDomainException - if the given object is not a Category

equals

public boolean equals(Category cat)
Returns true if this category equals the given category.

Parameters:
cat - the given category
Returns:
true if this category equals the given category

equals

public boolean equals(java.lang.Object obj)
Returns true if this category equals the given object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the given object
Returns:
true if this category equals the given object

executeBeforePersistAction

public void executeBeforePersistAction()
Update the last modified date.

Specified by:
executeBeforePersistAction in interface Persistence
Overrides:
executeBeforePersistAction in class AbstractPersistenceImpl

getAttributeValueGroup

public AttributeValueGroup getAttributeValueGroup()
Get the attribute value group.

Specified by:
getAttributeValueGroup in interface Category
Returns:
the domain model's AttributeValueGroup

getAvailableChildren

public java.util.Set getAvailableChildren()
Get the available child categories.

Specified by:
getAvailableChildren in interface Category
Returns:
the available child categories as a set

getCategoryType

public CategoryType getCategoryType()
Returns the category type.

Specified by:
getCategoryType in interface Category
Returns:
the category type

getChildren

public java.util.Set getChildren()
Get the child categories.

Specified by:
getChildren in interface Category
Returns:
the child categories as a set

getCode

public java.lang.String getCode()
Returns the category code.

Specified by:
getCode in interface Category
Returns:
the category code

getDisplayName

public java.lang.String getDisplayName(java.util.Locale locale)
Returns the display name of the given locale. This method provides a faster way to just get display name. The result is the same with getLocaleDependantFields(Locale).getDisplayName().

Specified by:
getDisplayName in interface ObjectWithLocaleDependantFields
Parameters:
locale - the locale
Returns:
the display name

getEndDate

public java.util.Date getEndDate()
Get the end date. After the end date, the category will become unavailable to customers.

Specified by:
getEndDate in interface Category
Returns:
the end date

getGuid

public java.lang.String getGuid()
Return the guid.

Specified by:
getGuid in interface Entity
Overrides:
getGuid in class AbstractEntityImpl
Returns:
the guid.

getHasSubCategories

public boolean getHasSubCategories()
Return the flag to indicate whether this category has subCategories or not.

Specified by:
getHasSubCategories in interface Category
Returns:
the flag to indicate whether this category has subCategories or not.

getLastModifiedDate

public java.util.Date getLastModifiedDate()
Returns the date when the category was last modified.

Specified by:
getLastModifiedDate in interface Category
Returns:
the date when the category was last modified

getLevel

public int getLevel()
Get category level. The root categories will have level 1.
A category's level = it's parent category's level + 1

Specified by:
getLevel in interface BranchNode
Returns:
the category level

getLocaleDependantFields

public LocaleDependantFields getLocaleDependantFields(java.util.Locale locale)
Returns the LocaleDependantFields of the given locale.

Specified by:
getLocaleDependantFields in interface ObjectWithLocaleDependantFields
Parameters:
locale - the locale
Returns:
the LocaleDependantFields of the given locale if it exists, otherwise an empty LocaleDependantFields.

getLocaleDependantFieldsMap

public java.util.Map getLocaleDependantFieldsMap()
Gets the all LocaleDependantFields as a map.

Specified by:
getLocaleDependantFieldsMap in interface Category
Specified by:
getLocaleDependantFieldsMap in interface ObjectWithLocaleDependantFields
Returns:
the LocaleDependantFields map

getLocaleDependantFieldsWithoutFallBack

public LocaleDependantFields getLocaleDependantFieldsWithoutFallBack(java.util.Locale locale)
Returns the LocaleDependantFields of the given locale without a fallback.

Specified by:
getLocaleDependantFieldsWithoutFallBack in interface ObjectWithLocaleDependantFields
Parameters:
locale - the locale
Returns:
the LocaleDependantFields of the given locale

getOrdering

public int getOrdering()
Get the ordering number.

Specified by:
getOrdering in interface Category
Returns:
the ordering number

getParent

public Category getParent()
Get the parent category of this category. Returns null if this category doesn't have a parent.

Specified by:
getParent in interface Category
Returns:
the parent category(or null no parent)

getPath

public java.util.Stack getPath()
Get the path from the root category to this category on the tree.

Specified by:
getPath in interface BranchNode
Returns:
a stack contains the path, the root category is on the top.

getPathAsList

public java.util.List getPathAsList()
Returns the category path as a List. The root category will be the first.

Specified by:
getPathAsList in interface Category
Returns:
the category path as a List.

getSeoUrl

public java.lang.String getSeoUrl(java.util.Locale locale,
                                  int pageNumber)
Returns the SEO URL, E.g. cars/bwm/convertibles/cat-356-all.html.

Specified by:
getSeoUrl in interface Category
Parameters:
locale - the locale
pageNumber - the page number
Returns:
the SEO URL

getSeoUrlWithoutSuffix

public java.lang.String getSeoUrlWithoutSuffix(java.util.Locale locale)
Returns the SEO URL without the suffix, E.g. cars/bwm/convertibles .

Specified by:
getSeoUrlWithoutSuffix in interface Category
Parameters:
locale - the locale
Returns:
the SEO URL

getStartDate

public java.util.Date getStartDate()
Get the start date that this category will become available to customers.

Specified by:
getStartDate in interface Category
Returns:
the start date

getTemplate

public java.lang.String getTemplate()
Gets the display template of this category.

Specified by:
getTemplate in interface Category
Returns:
the template

getTemplateWithFallBack

public java.lang.String getTemplateWithFallBack(java.lang.String defaultTemplate)
Get the display template name of this category.

Specified by:
getTemplateWithFallBack in interface Category
Parameters:
defaultTemplate - the default template name
Returns:
the template name if it is defined for this category, otherwise the given default template name

getTopSellers

public java.util.Set getTopSellers()
Returns the top sellers for this category.

Specified by:
getTopSellers in interface Category
Returns:
top sellers for this category

hashCode

public int hashCode()
Generate the hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code.

isAvailable

public boolean isAvailable()
Returns true if the category is available to be displayed.

Specified by:
isAvailable in interface Category
Returns:
true if the category is available.

isHidden

public boolean isHidden()
Returns true if the product should not be displayed (e.g. in its category or as a search result).

Specified by:
isHidden in interface Category
Returns:
true if the product should not be displayed

removeChild

public void removeChild(Category category)
Remove the given category from the children list.

Specified by:
removeChild in interface Category
Parameters:
category - the category to be removed

setAttributeValueGroup

public void setAttributeValueGroup(AttributeValueGroup attributeValueGroup)
Set the attribute value group.

Specified by:
setAttributeValueGroup in interface Category
Parameters:
attributeValueGroup - the AttributeValueGroup

setCategoryType

public void setCategoryType(CategoryType categoryType)
Set the CategoryType.

Specified by:
setCategoryType in interface Category
Parameters:
categoryType - the CategoryType

setCode

public void setCode(java.lang.String code)
Sets the category code.

Specified by:
setCode in interface Category
Parameters:
code - the category code

setDefaultValues

public void setDefaultValues()
Set default values for those fields that need default values.

Specified by:
setDefaultValues in interface Persistence
Overrides:
setDefaultValues in class AbstractEntityImpl

setEndDate

public void setEndDate(java.util.Date endDate)
Set the end date.

Specified by:
setEndDate in interface Category
Parameters:
endDate - the end date

setGuid

public void setGuid(java.lang.String guid)
Set the guid.

Specified by:
setGuid in interface Entity
Overrides:
setGuid in class AbstractEntityImpl
Parameters:
guid - the guid to set.

setHidden

public void setHidden(boolean hidden)
Set to true if the product should not be displayed.

Specified by:
setHidden in interface Category
Parameters:
hidden - true if the product should not be displayed

setLastModifiedDate

public void setLastModifiedDate(java.util.Date lastModifiedDate)
Set the date when the category was last modified.

Specified by:
setLastModifiedDate in interface Category
Parameters:
lastModifiedDate - the date when the category was last modified

setLocaleDependantFieldsMap

public void setLocaleDependantFieldsMap(java.util.Map localeDependantFieldsMap)
Sets all LocaleDependantFields with the given map.

Specified by:
setLocaleDependantFieldsMap in interface ObjectWithLocaleDependantFields
Parameters:
localeDependantFieldsMap - the LocaleDependantFields map to set

setOrdering

public void setOrdering(int ordering)
Set the ordering number.

Specified by:
setOrdering in interface Category
Parameters:
ordering - the ordering number

setParent

public void setParent(Category newParent)
Set the parent cateogry.

Specified by:
setParent in interface Category
Parameters:
newParent - the new parent category

setParentOneWay

public void setParentOneWay(Category newParent)
Set the parent cateogry.

Specified by:
setParentOneWay in interface Category
Parameters:
newParent - the new parent category

setStartDate

public void setStartDate(java.util.Date startDate)
Set the start date that this category will become valid.

Specified by:
setStartDate in interface Category
Parameters:
startDate - the start date

setTopSellers

public void setTopSellers(java.util.Set topSellers)
Sets the top sellers for this category.

Specified by:
setTopSellers in interface Category
Parameters:
topSellers - the top sellers for this category