Class Category

All Implemented Interfaces:
DBConstants, EditableData, JcmsConstants, ImportConstants, MashupConstants, Searchable, Storable, JaliosConstants, LangPropertyArgument, TreeNode, Cloneable, Comparable<BasicStorable>

public class Category extends Data implements EditableData, TreeNode, Searchable, DBConstants
A Category object is a node of the category tree. It references a set of Publications.
Author:
Olivier Dedieu
  • Field Details

  • Constructor Details

    • Category

      public Category()
      Create a new empty Category (no parent, no name, no description, no children, no synonyms, etc).
    • Category

      public Category(Category other)
      Category constructor by copy.

      Use this constructor to create a new Category or copy an existing one.
      The newly created Category will have the same value for most of (but not all!) fields of the specified Category.

      Important : DO NOT use this constructor to UPDATE Category !, instead use the getUpdateInstance() method. (This constructor by copy does not copy all fields, for example the friendly URLs of the specified category will not be copied into the new Category).

      Parameters:
      other - the category to copy
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Data
    • toFullString

      public String toFullString()
      Overrides:
      toFullString in class Data
    • toCSV

      public String toCSV(String lang)
      Returns a CSV view of this object
      Overrides:
      toCSV in class Data
      Parameters:
      lang - the output language
      Returns:
      a CSV view of this object
      Since:
      jcms-5.0.0
    • getCSVHeader

      public static String getCSVHeader(String lang)
      Returns the CSV header of this object
      Parameters:
      lang - the output language
      Returns:
      the CSV header of this object
      Since:
      jcms-5.0.0
    • getExportXmlDataValue

      public String getExportXmlDataValue()
      Description copied from class: Data
      Returns a string representation of this data used by exportXml().
      Overrides:
      getExportXmlDataValue in class Data
      Returns:
      a string representation of this data used by exportXml().
    • exportXmlField

      public void exportXmlField(StringBuffer sb, int indentLevel)
      Description copied from class: Data
      Fills the given StringBuffer with Xml export of fields of this data.
      Overrides:
      exportXmlField in class Data
      Parameters:
      sb - the StringBuffer
      indentLevel - the indent level
    • getFirstRelatives

      public static Category[] getFirstRelatives(Set<Category> rootSet)
      Check if one category of the set is relatives to an other category.
      Parameters:
      rootSet - a set of root category
      Returns:
      a Category[2] with the 2 first relatives.
    • getFirstNotRelatives

      public static Category getFirstNotRelatives(Set<Category> children, Set<Category> roots)
      Check if one category of the set not relatives to an other category.
      Parameters:
      children - a set of category
      roots - a set of root category
      Returns:
      a Category[2] with the 2 first relatives.
    • getHighestLevelCategorySet

      public static TreeSet<Category> getHighestLevelCategorySet(TreeSet<Category> categorySet)
      Keeps only the categories of highest level
      Parameters:
      categorySet - a set of category
      Returns:
      a set of category
      Since:
      jcms-4.1
    • containsDescendant

      public boolean containsDescendant(Category category)
      Test if a category is a descendant of this category (this method is equivalent to invoke category.hasAncestor(this))
      Parameters:
      category - the category to test
      Returns:
      true if the category is a descendant of this category
    • hasAncestor

      public boolean hasAncestor(Category ancestor)
      Test if a category is an ancestor of this category (it returns false if the received category is this category).
      Parameters:
      ancestor - the category to test
      Returns:
      true if the category is an ancestor of this category
    • getAncestorList

      public List<Category> getAncestorList()
      Returns the list of all the ancestors of this category, from the immediate parent to the root (root excluded).
      Returns:
      the list of ancestors
    • getAncestorList

      public List<Category> getAncestorList(Category ancestor, boolean includeAncestor)
      Returns the list of all the ancestors of this category, from the immediate parent to the given ancestor.
      Parameters:
      ancestor - the ancestor (null means root)
      includeAncestor - if true add the ancestor to the list
      Returns:
      the list of ancestors
      Since:
      jcms-5.0.0
    • getAncestorString

      public String getAncestorString(String sep, boolean includeCat, String lang)
      Returns a String representation of the ancestor of this category (eg First Level > Second Level > Category Name). Root is excluded.
      Parameters:
      sep - the separator
      includeCat - if true, the category is included
      lang - the language to use to build the String
      Returns:
      a String containing the ancestors concatenation.
      Since:
      jcms-4.0
    • getAncestorString

      public String getAncestorString(String sep, boolean includeCat)
      Returns a String representation of the ancestor of this category (eg First Level > Second Level > Category Name). Root is excluded.
      Parameters:
      sep - the separator
      includeCat - if true, the category is included
      Returns:
      a String containing the ancestors concatenation.
      Since:
      jcms-3.0
    • getAncestorString

      public String getAncestorString(Category ancestor, String sep, boolean includeCat, String lang)
      Returns a String representation of the ancestor of this category, truncated according the given ancestor (eg if ancestor String is First Level > Second Level > Category Name, and given ancestor is First Level, it returns Second Level > Category Name). Root is excluded.
      Parameters:
      ancestor - the ancestor
      sep - the separator
      includeCat - if true, the category is included
      lang - the language to use to build the String
      Returns:
      a String containing the ancestors concatenation.
      Since:
      jcms-4.0
    • getAncestorString

      public String getAncestorString(Category ancestor, String sep, boolean includeCat)
      Returns a String representation of the ancestor of this category, truncated according the given ancestor (eg if ancestor String is First Level > Second Level > Category Name, and given ancestor is First Level, it returns Second Level > Category Name). Root is excluded.
      Parameters:
      ancestor - the ancestor
      sep - the separator
      includeCat - if true, the category is included
      Returns:
      a String containing the ancestors concatenation.
      Since:
      jcms-3.0
    • isSibling

      public boolean isSibling(Category cat)
      Returns true if the given category is a sibling of this category. Returns true if the given category is this category.
      Parameters:
      cat - the category
      Returns:
      true if the given category is a sibling of this category. Returns true if the given category is this category.
      Since:
      jcms-6.1.0
    • getAvailableColor

      public String getAvailableColor()
      Find the first available color from this category to these ancestors.
      Returns:
      the first available color from this category to these ancestors (in all the case, return a non null value).
      Since:
      jcms-5.0.0
      See Also:
    • getAvailableColor

      public String getAvailableColor(int levelOffset)
      Find the first available color from this category to these ancestors and apply a color offset corresponding to the sub-level of this cateogy.
      Parameters:
      levelOffset - the offset to apply for each level
      Returns:
      the first available color from this category to these ancestors with the offset applied (in all the case, return a non null value).
      Since:
      jcms-5.5.0
    • getFirstCommonAncestor

      public Category getFirstCommonAncestor(Category category)
      Returns the first common ancestor (FCA) with a given category. The FCA of c1 and c2 is the first category which is an ancestor of c1 and c2.
      If (c1 == c2) FCA = c1.parent.
      If (c1 ancestor of c2) FCA = c1
      Parameters:
      category - the category to used when searching the first common ancestor with this category. if null, return value will be null.
      Returns:
      the first common ancestor Category between this and the specified category, may return null if specified category is null
    • getFirstCommonAncestor

      public static Category getFirstCommonAncestor(Collection<Category> collection)
      Returns the common ancestors of the given categories
      Parameters:
      collection - Collection of Category
      Returns:
      Category the first common ancestor
      Since:
      jcms-5.7.3
    • getPublicationSet

      public <T extends Publication> Set<T> getPublicationSet(Class<T> clazz, Member mbr)
      Returns a NEW Set of Publication of the given class which use this category. Behavior of clazz and mbr relies to underlaying behavior of Channel.getPublicationSet(Class, Member) Check rights.
      Type Parameters:
      T - a type of Publication
      Parameters:
      clazz - the Publication's class to retrieve
      mbr - the Member requesting publications
      Returns:
      Set of Publication
    • getPublicationSet

      public <T extends Publication> Set<T> getPublicationSet(Class<T> clazz)
      Returns a NEW Set of Publication of the given class which use this category. Behavior of clazz relies to underlaying behavior of Channel.getDataSet(Class). DO NOT check rights.
      Type Parameters:
      T - a type of Publication
      Parameters:
      clazz - the Publication's class to retrieve
      Returns:
      Set of Publication
    • getPublicationSet

      public Set<Publication> getPublicationSet()
      Returns the publications which use this category
      Returns:
      a TreeSet of Publication
    • getPublicationSet

      public Set<Publication> getPublicationSet(boolean searchInDB)
      Returns the publications which use this category
      Parameters:
      searchInDB - if true the search is extended to the DB
      Returns:
      a TreeSet of Publication
      Since:
      jcms-6.2
    • getAllPublicationSet

      public Set<Publication> getAllPublicationSet()
      Return a set containing all the publications referenced by this category and all the descendants of this category.

      Warning : Returns an empty collection during store load (since JCMS-5833).

      Returns:
      the publication set
    • getAllPublicationSet

      public Set<Publication> getAllPublicationSet(boolean searchInDB)
      Return a set containing all the publications referenced by this category and all the descendants of this category

      Warning : Returns an empty collection during store load (since JCMS-5833).

      Parameters:
      searchInDB - if true the search is extended to the DB
      Returns:
      the publication set
      Since:
      jcms-6.2
    • getContentSet

      public Set<Content> getContentSet()
      Returns the contents which use this category
      Returns:
      a TreeSet of Content
      Since:
      jcms-4.0
    • getContentSet

      public Set<Content> getContentSet(boolean searchInDB)
      Returns the contents which use this category
      Parameters:
      searchInDB - if true the search is extended to the DB
      Returns:
      a TreeSet of Content
      Since:
      jcms-6.2
    • getAllContentSet

      public Set<Content> getAllContentSet()
      Return a set containing all the contents referenced by this category and all the descendant of this category.

      Warning : Returns an empty collection during store load (since JCMS-5833).

      Returns:
      the content set
      Since:
      jcms-4.0
    • getAllContentSet

      public Set<Content> getAllContentSet(boolean searchInDB)
      Return a set containing all the contents referenced by this category and all the descendant of this category.

      Warning : Returns an empty collection during store load (since JCMS-5833).

      Parameters:
      searchInDB - if true the search is extended to the DB
      Returns:
      the content set
      Since:
      jcms-6.2
    • getDBPublicationCount

      public <T extends Publication> int getDBPublicationCount()
      Count the number of DB publications which belongs to this category (exact mode).

      Warning : as of current implementation, this method will query the database and may not be optimized for frequent use and large volumetry, use wisely.

      Type Parameters:
      T - a type of Publication
      Returns:
      the count of DB Publications which belongs to this Category (exactMode)
      Since:
      7.0.2
    • getDBPublicationCount

      public <T extends Publication> int getDBPublicationCount(Class<T> clazz, boolean exactCat)
      Count the number of DB publication which belongs to this category.

      Warning : as of current implementation, this method will query the database and may not be optimized for frequent use and large volumetry, use wisely.

      Type Parameters:
      T - a type of Publication
      Parameters:
      clazz - the class to search for
      exactCat - true to search for publication only in this publication, false, to search in descendants categories
      Returns:
      the count of DB Publications which belongs to this Category
      Since:
      7.0.2
    • getDBPublicationCount

      public <T extends Publication> int getDBPublicationCount(Class<T> clazz, boolean exactCat, boolean searchInTrash)
      Count the number of DB publication which belongs to this category.

      Warning : as of current implementation, this method will query the database and may not be optimized for frequent use and large volumetry, use wisely.

      Type Parameters:
      T - a type of Publication
      Parameters:
      clazz - the class to search for
      exactCat - true to search for publication only in this publication, false, to search in descendants categories
      searchInTrash - true to searched trashed publication, false to exclude them
      Returns:
      the count of DB Publications which belongs to this Category
      Since:
      jcms-10.0.6 / JCMS-8934
    • updateDBPublicationIndexes

      protected void updateDBPublicationIndexes()
      Update publication allCatIdSet in this Category and its childrens when the Category parent is changed Warning : as of current implementation, this method will query the database and may not be optimized for frequent use and large volumetry, use wisely.
      Since:
      jcms-7.0.2
    • mergeWith

      public ControllerStatus mergeWith(Category tgtCat, Member loggedMember)
      Merges this category with the given the category. All the children of this category are moved to the given category. All the publications assigned tho this category are moved to the given category. The loggedMember must have the right to manage the 2 categories.
      Parameters:
      tgtCat - the category to merge with
      loggedMember - the member.
      Returns:
      true if the merge has been done.
      Since:
      jcms-7.1
    • moveTo

      public ControllerStatus moveTo(Category parent, Member loggedMember)
      Move Category under given parent
      Parameters:
      parent - the Category parent
      loggedMember - the worker
      Returns:
      ControllerStatus for this action
    • addSubs

      public ControllerStatus addSubs(String names, Member loggedMember, String userLang)
      Create a Category under the given category
      Parameters:
      names - Category names to create (comma separated)
      loggedMember - the logged Member
      userLang - the user language
      Returns:
      a ControllerStatus depending on wether the categories can be created or not
      Since:
      jcms-9.0.0
    • addSiblings

      public ControllerStatus addSiblings(String names, Member loggedMember, String userLang)
      Creates categories based on given names as sibling of current Category
      Parameters:
      names - Category names to create (comma separated)
      loggedMember - the logged Member
      userLang - the user language
      Returns:
      a ControllerStatus depending on wether the categories can be created or not
      Since:
      jcms-9.0.1
    • rename

      public ControllerStatus rename(String name, String userLang, Member loggedMember)
      Rename the given category
      Parameters:
      name - the new category name
      userLang - the current language
      loggedMember - the worker
      Returns:
      ControllerStatus for this action
    • delete

      public ControllerStatus delete(Member loggedMember)
      Delete the given category
      Parameters:
      loggedMember - the worker
      Returns:
      ControllerStatus for this action
    • isRoot

      public boolean isRoot()
      Returns true if this category is the root category.
      Returns:
      true if the category has no child
      Since:
      jcms-5.0.0
    • isLeaf

      public boolean isLeaf()
      Returns true if this category is a leaf, that is if it has no child.
      Returns:
      true if the category has no child
    • isNode

      public boolean isNode()
      Returns true if this category is a node, that is if it has at least one child.
      Returns:
      true if the category has at least a child.
    • isLeaf

      public boolean isLeaf(Member mbr)
      Returns true if this category is a leaf according the given member and the category read right, that is if this category has no child readable for the given member.
      Parameters:
      mbr - the member to check the read right
      Returns:
      true if the category has no child
      Since:
      jcms-4.1
    • isNode

      public boolean isNode(Member mbr)
      Returns true if this category is a node according the given member and the category read right, that is if this category has at least one child readable for the given member.
      Parameters:
      mbr - the member to check the read right
      Returns:
      true if the category has at least a child.
      Since:
      jcms-4.1
    • isTerminalNode

      public boolean isTerminalNode()
      Returns true if this category is a terminal node, that is if it has only leaf children
      Returns:
      true if the category has only lead children
      Since:
      jcms-3.0
    • isAlphabeticalOrder

      public boolean isAlphabeticalOrder()
      Returns:
      true if children of this category are alphabically ordered
      Since:
      jcms-3.0
    • isCustomOrder

      public boolean isCustomOrder()
      Returns:
      true if children of this category are custom ordered
      Since:
      jcms-3.0
    • getChildrenSet

      public Set<Category> getChildrenSet()
      Returns the children categories (ie categories having this category as parent)
      Returns:
      a TreeSet of category
    • getChildrenSortedSet

      public SortedSet<Category> getChildrenSortedSet()
      Returns the children categories ordered according the order of this parent category.
      Returns:
      the sorted set of the children categories
    • getDescendantSet

      public Set<Category> getDescendantSet()
      Returns all the descendant categories of this one (ie categories having this category as ancestor)
      Returns:
      a Set of category
      Since:
      jcms-3.0
    • childExist

      public boolean childExist(String name)
      Check if this category contains a child with the given name
      Parameters:
      name - the category name to search
      Returns:
      true if there exists at least one child with the given name
      Since:
      jcms-4.0
    • getChild

      public Category getChild(String name)
      Return the child of this category with the given name
      Parameters:
      name - the category name to search
      Returns:
      the child or null if not found
      Since:
      jcms-4.0
    • containsUnreadPub

      public boolean containsUnreadPub(Member member)
      Check if this category (and all its sub-categories) contains at least one tracked publication which has not been read by the given member
      Parameters:
      member - the reader
      Returns:
      true if there exists at least one unread publication
      Since:
      jcms-4.1
    • getSearchStrings

      public String[] getSearchStrings()
      Description copied from interface: Searchable
      This method gets called to get all the String to search in (typically the String attribute of the Storable). If one of those String match the query, this Storable is added in the result set.
      Specified by:
      getSearchStrings in interface Searchable
      Returns:
      an array of String corresponding to this object.
    • getDataName

      public String getDataName(String language)
      Description copied from class: Data
      Return the name of this Data, every sub class Data which will be displayed to user should implements this method already.
      • The Title (multi-language) for a Publication.
      • The Name (multi-language) for a Category.
      • The Name for a Group, a Member.
      • The Title (multi-language) for a Workspace.
      Can be seen as a smart multi-language toString(), but never returning null.
      Default behaviour is to return toFullString() of Data or empty string if toFullString is null.
      Overrides:
      getDataName in class Data
      Parameters:
      language - the language in which to return the name if multilang available for the data.
      Returns:
      name of Category in given language or empty String if not specified.
      Since:
      jcms-5.1
      See Also:
    • getDataImage

      public String getDataImage()
      Description copied from class: Data
      Retrieves the image path of this data in the channel's main language.

      This method can (should) be implemented by subclasses to provide an image/illustration of this Data.
      Default behaviour is to return empty string.

      Overrides:
      getDataImage in class Data
      Returns:
      a path relative to the webapp root.
    • getDataImage

      public String getDataImage(String lang, boolean useDefault)
      Description copied from class: Data
      Retrieves the image path of this data.

      This method can (should) be implemented by subclasses to provide an image/illustration of this Data.
      Default behaviour is to return empty string.

      Overrides:
      getDataImage in class Data
      Parameters:
      lang - the user language (ISO-639 language code)
      useDefault - should the default language be used if no value is found for the specified language
      Returns:
      a path relative to the webapp root.
    • getName

      public String getName(String lang)
      Get the value of name bound to the given language.
      Parameters:
      lang - the language to get the name
      Returns:
      name in the given language.
      Since:
      jcms-4.0
    • getName

      public String getName(String lang, boolean useDefault)
      Get the value of name bound to the given language.
      Parameters:
      lang - the language to get the name
      useDefault - should main language used as default language if name does not exist in the given language
      Returns:
      name in the given language.
      Since:
      jcms-4.0
    • getName

      public String getName()
      Get the value of name.
      Returns:
      Value of name.
    • setName

      public void setName(String v)
      Set the value of name.
      Parameters:
      v - Value to assign to v.
    • getNameML

      public HashMap<String,String> getNameML()
      Get the value of nameML.
      Returns:
      Value of nameML.
      Since:
      jcms-4.0
    • setNameML

      public void setNameML(HashMap<String,String> v)
      Set the value of nameML.
      Parameters:
      v - Value to assign to nameML.
      Since:
      jcms-4.0
    • setName

      public void setName(String lang, String value)
      Convenient method to set the value of the Name field in any language (default site language or any other).
      This method will set the proper field value (setName(String) or setNameML(HashMap)) depending on the specified language.
      Parameters:
      lang - the language (ISO 639 code) in which to set the value
      value - the value to set.
      Since:
      jcms-5.7
      See Also:
    • getParent

      public Category getParent()
      Get the value of parent.
      Returns:
      Value of parent.
    • setParent

      public void setParent(Category v)
      Set the value of parent.
      Parameters:
      v - Value to assign to parent.
    • getDescription

      public String getDescription(String lang)
      Get the value of description bound to the given language.
      Parameters:
      lang - the language to get the description
      Returns:
      description in the given language.
      Since:
      jcms-4.0
    • getDescription

      public String getDescription(String lang, boolean useDefault)
      Get the value of description bound to the given language.
      Parameters:
      lang - the language to get the description
      useDefault - should main language used as default language if description does not exist in the given language
      Returns:
      description in the given language.
      Since:
      jcms-4.0
    • getDescription

      public String getDescription()
      Get the value of description.
      Returns:
      Value of description.
    • setDescription

      public void setDescription(String v)
      Set the value of description.
      Parameters:
      v - Value to assign to description.
    • getDescriptionML

      public HashMap<String,String> getDescriptionML()
      Get the value of descriptionML.
      Returns:
      Value of descriptionML.
      Since:
      jcms-4.0
    • setDescriptionML

      public void setDescriptionML(HashMap<String,String> v)
      Set the value of descriptionML.
      Parameters:
      v - Value to assign to descriptionML.
      Since:
      jcms-4.0
    • setDescription

      public void setDescription(String lang, String value)
      Convenient method to set the value of the Description field in any language (default site language or any other).
      This method will set the proper field value (setDescription(String) or setDescriptionML(HashMap)) depending on the specified language.
      Parameters:
      lang - the language (ISO 639 code) in which to set the value
      value - the value to set.
      Since:
      jcms-5.7
      See Also:
    • getSynonyms

      public String[] getSynonyms()
      Get the value of synonyms.
      Returns:
      Value of synonyms.
      Since:
      jcms-4.0
    • setSynonyms

      public void setSynonyms(String[] v)
      Set the value of synonyms.
      Parameters:
      v - Value to assign to synonyms.
      Since:
      jcms-4.0
    • setSelectable

      public void setSelectable(boolean isSelectable)
    • isSelectable

      public boolean isSelectable()
    • setOrder

      public void setOrder(int order)
    • getOrder

      public int getOrder()
    • setChildrenOrder

      public void setChildrenOrder(int childrenOrder)
      Define the children ordering to be used in this category
      Parameters:
      childrenOrder - an integer indicating the ordering type to be used. For alphabetical ordering, use constant Category.ALPHABETICAL_ORDER, for custom ordering (using "order" member), use constant Category.CUSTOM_ORDER
      Since:
      jcms-3.0
    • getChildrenOrder

      public int getChildrenOrder()
      Retrieves the current ordering type in use for children of this Category.
      Returns:
      the ordering type in use, Category.ALPHABETICAL_ORDER (0) for alphabetical ordering and Category.CUSTOM_ORDER (1) for custom ordering using order member
      Since:
      jcms-3.0
    • getDataIcon

      public String getDataIcon()
      Description copied from class: Data
      Returns source information for the icon associated to this Data, either a relative path or sprite classes name.

      If this method behavior has not been overriden by subclass, the default icon can be declared using property types.{Type}.icon, where {Type} is the short class name of the type concerned.

      • Either by specifying a relative image path :
        types.Article.icon: images/jalios/icon/abstract.gif 
      • or else by using a sprite icon :
        types.Article.icon: ss_sprite ss_date
      Overrides:
      getDataIcon in class Data
      Returns:
      a relative path (eg images/jalios/icon/abstract.gif) or sprite classes name (eg ss_sprite ss_date).
      See Also:
    • getIcon

      public String getIcon(String lang)
      Get the value of icon bound to the given language.
      Parameters:
      lang - the language to get the icon
      Returns:
      icon in the given language.
      Since:
      jcms-4.0
    • getIcon

      public String getIcon(String lang, boolean useDefault)
      Get the value of icon bound to the given language.
      Parameters:
      lang - the language to get the icon
      useDefault - should main language used as default language if icon does not exist in the given language
      Returns:
      icon in the given language.
      Since:
      jcms-4.0
    • getIcon

      public String getIcon()
      Get the value of icon.
      Returns:
      Value of icon.
    • setIcon

      public void setIcon(String v)
      Set the value of icon.
      Parameters:
      v - Value to assign to icon.
    • getIconML

      public HashMap<String,String> getIconML()
      Get the value of iconML.
      Returns:
      Value of iconML.
      Since:
      jcms-4.0
    • setIconML

      public void setIconML(HashMap<String,String> v)
      Set the value of iconML.
      Parameters:
      v - Value to assign to iconML.
      Since:
      jcms-4.0
    • setIcon

      public void setIcon(String lang, String value)
      Convenient method to set the value of the Icon field in any language (default site language or any other).
      This method will set the proper field value (setIcon(String) or setIconML(HashMap)) depending on the specified language.
      Parameters:
      lang - the language (ISO 639 code) in which to set the value
      value - the value to set.
      Since:
      jcms-5.7
      See Also:
    • getImage

      public String getImage(String lang)
      Get the value of image bound to the given language.
      Parameters:
      lang - the language to get the image
      Returns:
      image in the given language.
      Since:
      jcms-4.0
    • getImage

      public String getImage(String lang, boolean useDefault)
      Get the value of image bound to the given language.
      Parameters:
      lang - the language to get the image
      useDefault - should main language used as default language if image does not exist in the given language
      Returns:
      image in the given language.
      Since:
      jcms-4.0
    • getImage

      public String getImage()
      Get the value of image.
      Returns:
      Value of image.
    • setImage

      public void setImage(String v)
      Set the value of image.
      Parameters:
      v - Value to assign to image.
    • getImageML

      public HashMap<String,String> getImageML()
      Get the value of imageML.
      Returns:
      Value of imageML.
      Since:
      jcms-4.0
    • setImageML

      public void setImageML(HashMap<String,String> v)
      Set the value of imageML.
      Parameters:
      v - Value to assign to imageML.
      Since:
      jcms-4.0
    • setImage

      public void setImage(String lang, String value)
      Convenient method to set the value of the Image field in any language (default site language or any other).
      This method will set the proper field value (setImage(String) or setImageML(HashMap)) depending on the specified language.
      Parameters:
      lang - the language (ISO 639 code) in which to set the value
      value - the value to set.
      Since:
      jcms-5.7
      See Also:
    • getColor

      public String getColor()
      Returns:
      the color of this category.
      Since:
      jcms-5.0.0
    • getColor

      public String getColor(boolean defaultOnParent)
      Returns the color of this category. If defaultOnParent is true, returns the parent category (recursively)
      Parameters:
      defaultOnParent - if true and this category has no color, returns the color of the parent category.
      Returns:
      the color of this category.
      Since:
      jcms-10.0.6
    • setColor

      public void setColor(String v)
      Set the value of color.
      Parameters:
      v - Value to assign to color.
      Since:
      jcms-5.0.0
    • getNewTab

      public boolean getNewTab()
      Returns:
      true if this category must be open in a new tab.
      Since:
      jcms-10.0.7
    • setNewTab

      public void setNewTab(boolean v)
      Set the value of newTab.
      Parameters:
      v - Value to assign to newTab.
      Since:
      jcms-10.0.7
    • getIndexingDate

      public Date getIndexingDate()
      Retrieve the Date at which this Category was indexed in its search engine.
      Returns:
      a Date or null if was not indexed.
      Since:
      jcms-6.0.1
    • getFriendlyURLSet

      public TreeSet<String> getFriendlyURLSet()
      Get friendly urls Set.
      Returns:
      a TreeSet of friendly url (String).
    • setFriendlyURLSet

      public void setFriendlyURLSet(TreeSet<String> v)
      Set the value of friendlyURLSet.
      Parameters:
      v - Value to assign to friendlyURLSet.
    • getComparator

      public <T extends Category> Comparator<T> getComparator(String lang)
      Returns the right comparator (Category.NameComparator, or Category.OrderComparator) to use depending on children order.
      Type Parameters:
      T - type of Category to compare
      Parameters:
      lang - the language in which to compare children categories.
      Returns:
      an instance of a comparator
      Since:
      jcms-10.0.4
      See Also:
    • getNameComparator

      public static Comparator getNameComparator(String lang)
      Retrieves a new Categories' NameComparator.
      Parameters:
      lang - the language in which to compare categorie's name
      Returns:
      a new instance of NameComparator in the specified language.
    • getOrderComparator

      public static Comparator getOrderComparator(String lang)
      Retrieves a new Categories' OrderComparator.
      Parameters:
      lang - the language in which the alphabetical ordering will will performed if the category are ordered alphabetically.
      Returns:
      a new instance of OrderComparator using the default site language if using alphabetical ordering.
      Since:
      jcms-5.6.1
    • getDeepOrderComparator

      @Deprecated public static Comparator<Category> getDeepOrderComparator()
      Deprecated.
      Returns:
      a new instance of DeepOrderComparator in the default site language.
    • getDeepOrderComparator

      public static Comparator<Category> getDeepOrderComparator(String lang)
      Parameters:
      lang - the user language
      Returns:
      a new instance of DeepOrderComparator in the specified language.
      Since:
      jcms-6.0.0
    • getOrderChildrenFirstComparator

      public static Comparator<Category> getOrderChildrenFirstComparator()
    • getOrderChildrenLastComparator

      public static Comparator<Category> getOrderChildrenLastComparator()
    • getAuthorizedSelector

      public static Category.AuthorizedSelector getAuthorizedSelector(Member member)
      Parameters:
      member - the member that will used in the authorized selector to perform selection.
      Returns:
      a new instance of Category.AuthorizedSelector using the given Member.
      Since:
      jcms-5.7.3
    • getNodeSelector

      public static Category.NodeSelector getNodeSelector()
    • getLeafSelector

      public static Category.LeafSelector getLeafSelector()
    • internalCanBeReadBy

      protected boolean internalCanBeReadBy(Member member, boolean searchInGroups)
      Check of this category can be read by the given member
      Parameters:
      member - the member to be checked
      searchInGroups - if true check if one of the group this member belongs to is authorized to read this category.
      Returns:
      true this category can be read by the given member
      Since:
      jcms-4.1
    • canBeReadBy

      public final boolean canBeReadBy(Member member, boolean searchInGroups, RightInfo rightInfo)
      Checks if the specified member is authorized to read this Category.

      This method is the implementation of Data read right control for Category.

      Current implementation delegates to canBeReadBy(member, true, true).

      Overrides:
      canBeReadBy in class Data
      Parameters:
      member - the member to check (may be null for anonymous user)
      searchInGroups - set to true to check for read right authorization using Member's group(s).
      rightInfo - a RightInfo instance in which explanation of read right authorization acceptance or refusal will be indicated. Value is required and cannot be null.
      Returns:
      true if the member can read this Category, false otherwise
      Since:
      jcms-10.0.0
      See Also:
    • canBeReadBy

      public boolean canBeReadBy(Member member, boolean searchInGroups, boolean checkAncestors)
      Check if a member can read this category.
      Parameters:
      member - the member to check
      searchInGroups - if true check if one of the group this member belongs to is authorized to read this category.
      checkAncestors - if true checks the read rights of the ancestors of this category.
      Returns:
      true if the member can read this category
      Since:
      jcms-4.1
    • canBeUsedBy

      public boolean canBeUsedBy(Member member)
      Parameters:
      member - the member to check
      Returns:
      true if the member is not null and can use this category
      Since:
      jcms-6.0
      See Also:
    • hasAnyReadRights

      public boolean hasAnyReadRights()
      Tests if this category has member or group read rights.
      Warning: You cannot use !hasSomeReadRights() to test if this category has no read rights, in this case, use the method hasNoReadRights().
      Returns:
      true if there are member or group read rights.
      Since:
      jcms-5.0.4
    • hasNoReadRights

      public boolean hasNoReadRights()
      Tests if this category has NO member read rights AND NO group read rights.
      Warning: you cannot use !hasNoReadRights() to test if this category has some read rights, in this case, use the method hasAnyReadRights().
      Returns:
      true if there are NO member read rights AND NO group read rights.
      Since:
      jcms-5.0.4
    • getAuthorizedMemberSet

      public Set<Member> getAuthorizedMemberSet()
      Get the value of authorizedMemberSet.
      Returns:
      Value of authorizedMemberSet.
      Since:
      jcms-4.1
    • setAuthorizedMemberSet

      public void setAuthorizedMemberSet(TreeSet<Member> set)
      Set the value of authorizedMemberSet.
      Parameters:
      set - Value to assign to authorizedMemberSet.
      Since:
      jcms-4.1
    • addAuthorizedMember

      public void addAuthorizedMember(Member mbr)
      Add an authorized member.
      Parameters:
      mbr - the member to be added.
      Since:
      jcms-5.5.0
    • removeAuthorizedMember

      public boolean removeAuthorizedMember(Member mbr)
      Remove an authorized member.
      Parameters:
      mbr - the member to be removed.
      Returns:
      true if the set contained the specified member.
      Since:
      jcms-5.5.0
    • getAuthorizedGroupSet

      public Set<Group> getAuthorizedGroupSet()
      Get the value of authorizedGroupSet.
      Returns:
      Value of authorizedGroupSet.
      Since:
      jcms-4.1
    • setAuthorizedGroupSet

      public void setAuthorizedGroupSet(TreeSet<Group> set)
      Set the value of authorizedGroupSet.
      Parameters:
      set - Value to assign to authorizedGroupSet.
      Since:
      jcms-4.1
    • addAuthorizedGroup

      public void addAuthorizedGroup(Group grp)
      Add an authorized group
      Parameters:
      grp - the group to be added.
      Since:
      jcms-5.5.0
    • removeAuthorizedGroup

      public boolean removeAuthorizedGroup(Group grp)
      Remove an authorized group.
      Parameters:
      grp - the group to be removed.
      Returns:
      true if the set contained the specified group.
      Since:
      jcms-5.5.0
    • setUseGroupSet

      public void setUseGroupSet(HashSet<Group> useGroupSet)
      Set the groups who are authorized to use this category (and sub categories).
      Parameters:
      useGroupSet - a Set of Group
      Since:
      jcms-10.0.6 / JCMS-8769
    • getUseGroupSet

      public HashSet<Group> getUseGroupSet()
      Returns:
      the groups declared as authorized to use this category (and sub categories).
      Since:
      jcms-10.0.6 / JCMS-8769
      See Also:
    • getUseGroupSet

      public HashSet<Group> getUseGroupSet(boolean excludeGroupsWithoutReadAuthorization)
      Parameters:
      excludeGroupsWithoutReadAuthorization - true to filter groups which do not have read right on this category, false to return declared groups without any filter
      Returns:
      the groups declared as authorized to use this category (and sub categories), never return null
      Since:
      jcms-10.0.6 / JCMS-9281
    • setUseMemberSet

      public void setUseMemberSet(HashSet<Member> useMemberSet)
      Set the members who are authorized to use this category (and sub categories).
      Parameters:
      useMemberSet - a Set of Member
      Since:
      jcms-10.0.6 / JCMS-8769
    • getUseMemberSet

      public HashSet<Member> getUseMemberSet()
      Returns:
      the members declared as authorized to use this category (and sub categories).
      Since:
      jcms-10.0.6 / JCMS-8769
      See Also:
    • getUseMemberSet

      public HashSet<Member> getUseMemberSet(boolean excludeMembersWithoutReadAuthorization)
      Parameters:
      excludeMembersWithoutReadAuthorization - true to filter members which do not have explicit read right on this category (or its parent), false to return declared member without any filter
      Returns:
      the members declared as authorized to use this category (and sub categories).
      Since:
      jcms-10.0.6 / JCMS-9281
    • isDeclaredUser

      public boolean isDeclaredUser(Member mbr)
      Returns true if the given member is a declared user (for Use Right) on this category (or any parent category).
      Parameters:
      mbr - the member
      Returns:
      true if the given member is a declared user (for use Right) on this category (or any parent category).
      Since:
      jcms-10.0.6 / JCMS-8769
    • isDeclaredUser

      public boolean isDeclaredUser(Member mbr, boolean checkAncestor)
      Returns true if the given member is a declared user (for use Right) on this category.
      Parameters:
      mbr - the member
      checkAncestor - if true check with ancestors of this category
      Returns:
      true if the given member is a declared user (for use Right) on this category.
      Since:
      jcms-10.0.6 / JCMS-8769
    • hasDeclaredUsers

      public boolean hasDeclaredUsers()
      Returns true if members or groups are declared as user (for use Right) on this category.
      Returns:
      true if members or groups are declared as user (for use Right) on this category.
      Since:
      jcms-10.0.6 / JCMS-8769
    • hasDeclaredUsers

      public boolean hasDeclaredUsers(boolean checkAncestor)
      Returns true if members or groups are declared as user (for use Right) on this category.
      Parameters:
      checkAncestor - if true check the parents of this category
      Returns:
      true if members or groups are declared as user (for use Right) on this category.
      Since:
      jcms-10.0.6 / JCMS-8769
    • getManagerMemberSet

      public HashSet<Member> getManagerMemberSet()
      Returns:
      the members declared as manager of this category (and sub categories).
      Since:
      jcms-10.0.5
    • getManagerMemberSet

      public HashSet<Member> getManagerMemberSet(boolean excludeMembersWithoutReadAuthorization)
      Parameters:
      excludeMembersWithoutReadAuthorization - true to filter members which do not have explicit read right on this category (or its parent), false to return declared member without any filter
      Returns:
      the members declared as manager of this category (and sub categories).
      Since:
      jcms-10.0.6 / JCMS-9281
    • setManagerMemberSet

      public void setManagerMemberSet(HashSet<Member> managerMemberSet)
      Set the members declared as manager of this category (and sub categories).
      Parameters:
      managerMemberSet - a set of Member
      Since:
      jcms-10.0.5
    • getManagerGroupSet

      public HashSet<Group> getManagerGroupSet()
      Returns:
      the groups declared as manager of this category (and sub categories).
      Since:
      jcms-10.0.5
      See Also:
    • getManagerGroupSet

      public HashSet<Group> getManagerGroupSet(boolean excludeGroupsWithoutReadAuthorization)
      Parameters:
      excludeGroupsWithoutReadAuthorization - true to filter groups which do not have read right on this category, false to return declared groups without any filter
      Returns:
      the groups declared as authorized to use this category (and sub categories), never return null
      Since:
      jcms-10.0.6 / JCMS-9281
    • setManagerGroupSet

      public void setManagerGroupSet(HashSet<Group> managerGroupSet)
      Set the groups declared as manager of this category (and sub categories).
      Parameters:
      managerGroupSet - a set of Group
      Since:
      jcms-10.0.5
    • isDeclaredManager

      public boolean isDeclaredManager(Member mbr)
      Returns true if the given member is a declared manager on this category (or any parent category).
      Parameters:
      mbr - the member
      Returns:
      true if the given member is a declared manager on this category (or any parent category).
      Since:
      jcms-10.0.5
    • isDeclaredManager

      public boolean isDeclaredManager(Member mbr, boolean checkAncestor)
      Returns true if the given member is a declared manager on this category.
      Parameters:
      mbr - the member
      checkAncestor - if true check with ancestors of this category
      Returns:
      true if the given member is a declared manager on this category.
      Since:
      jcms-10.0.5
    • hasDeclaredManagers

      public boolean hasDeclaredManagers()
      Returns true if members or groups are declared as manager on this category.
      Returns:
      true if members or groups are declared as manager on this category.
      Since:
      jcms-10.0.5
    • hasDeclaredManagers

      public boolean hasDeclaredManagers(boolean checkAncestor)
      Returns true if members or groups are declared as manager on this category.
      Parameters:
      checkAncestor - if true check the parents of this category
      Returns:
      true if members or groups are declared as manager on this category.
      Since:
      jcms-10.0.5
    • getFirstAncestorWithDeclaredManagers

      public Category getFirstAncestorWithDeclaredManagers()
      Returns the first ancestor of this category with declared managers.
      Returns:
      the first ancestor of this category with declared managers.
      Since:
      jcms-10.0.5
    • getReadRightsString

      public String getReadRightsString(int max)
      This convenient method returns a String displaying group/member read rights (eg if this category is restricted to g1, g2, m1, m2 and m3, getReadRightsString(3) will return "g1, g2, m1, ...")
      Parameters:
      max - how many group/member to display
      Returns:
      a String
      Since:
      jcms-4.0
    • getTreeChildren

      public Collection<? extends TreeNode> getTreeChildren()
      Description copied from interface: TreeNode
      Returns a Collection of TreeNode children of the current node
      Specified by:
      getTreeChildren in interface TreeNode
      Returns:
      Collection of TreeNode
    • getTreeParent

      public TreeNode getTreeParent()
      Description copied from interface: TreeNode
      Returns parent of the current node
      Specified by:
      getTreeParent in interface TreeNode
      Returns:
      TreeNode parent Node
    • isTreeLeaf

      public boolean isTreeLeaf()
      Description copied from interface: TreeNode
      Returns boolean true if the TreeNode is a leaf
      Specified by:
      isTreeLeaf in interface TreeNode
      Returns:
      boolean indicating if node is leaf or node
    • isTreeNode

      public boolean isTreeNode()
      Description copied from interface: TreeNode
      Returns boolean true if the TreeNode is a node
      Specified by:
      isTreeNode in interface TreeNode
      Returns:
      boolean indicating if node is leaf or node
    • getTreeRoot

      public TreeNode getTreeRoot()
      Description copied from interface: TreeNode
      Returns the root of the current node
      Specified by:
      getTreeRoot in interface TreeNode
      Returns:
      TreeNode root Node
    • checkIntegrity

      public ControllerStatus checkIntegrity()
      Checks whether or not data integrity constraints are respected.
      Overrides:
      checkIntegrity in class Data
      Returns:
      a ControllerStatus
      Since:
      jcms-5.0.0
    • checkMember

      public ControllerStatus checkMember(int op, Member mbr, Map context)
      Checks if the given member can perform the given operation.
      Overrides:
      checkMember in class Data
      Parameters:
      op - the operation (OP_CREATE, OP_UPDATE, ...)
      mbr - the member which requests the write operation
      context - a map which contains context parameters (may be null)
      Returns:
      a ControllerStatus
      Since:
      jcms-5.0.0
    • nameExists

      public String nameExists(Category parent)
      Check if another category exists with the same name (case insensitive) under a given parent (skip this category). If such a category exists return the language code (en, fr, ...) of the conflicting name. Otherwise returns null.
      Parameters:
      parent - the parent category to be tests
      Returns:
      null if no category use the same name (case insensitive) or the language code of the conflicting name.
      Since:
      jcms-5.6.1
    • checkName

      public boolean checkName(Category parent)
      Return true if another category exists with same name (case insensitive) under the given parent
      Parameters:
      parent - the parent category to test
      Returns:
      true if a category exists
      Since:
      jcms-5.0.0
    • checkUpdate

      public ControllerStatus checkUpdate(Member mbr, Map context)
      Checks if the update can be performed
      Overrides:
      checkUpdate in class Data
      Parameters:
      mbr - the member which requests the write operation
      context - a map which contains context parameters (may be null)
      Returns:
      a ControllerStatus
      Since:
      jcms-5.0.0
    • checkDelete

      public ControllerStatus checkDelete(Member mbr, Map context)
      Checks if the deletion can be performed
      Overrides:
      checkDelete in class Data
      Parameters:
      mbr - the member which requests the write operation
      context - a map which contains context parameters (may be null)
      Returns:
      a ControllerStatus
      Since:
      jcms-5.0.0
    • getTypeReferrerCount

      public int getTypeReferrerCount()
      Returns the number of type referencing this category (through category fields and default categories).
      Returns:
      the number of type referencing this category.
      Since:
      jcms-5.5.0
    • getWSTypeEntryReferrerSet

      public Set<WSTypeEntry> getWSTypeEntryReferrerSet()
      Returns a set of WSTypeEntry referencing this category.
      Returns:
      a set of WSTypeEntry referencing this category.
      Since:
      jcms-5.5.0
    • refreshTypeReferrerCount

      public void refreshTypeReferrerCount()
      Refresh type referrer count.
      Since:
      jcms-5.5.0
    • performDelete

      public void performDelete(Member mbr, Map context)
      Performs data deletion
      Overrides:
      performDelete in class Data
      Parameters:
      mbr - the member which requests the write operation
      context - a map which contains context parameters (may be null)
      Since:
      jcms-5.0.0
    • performBeforeWrite

      protected void performBeforeWrite(int op, Member mbr, Map context)
      Description copied from class: Data
      Called to perform some action before the write.
      Overrides:
      performBeforeWrite in class Data
      Parameters:
      op - the operation (OP_CREATE, OP_UPDATE, ...)
      mbr - the member which requests the write operation
      context - a map which contains context parameters (may be null)
    • performAfterWrite

      protected void performAfterWrite(int op, Member mbr, Map context)
      Description copied from class: Data
      Called to perform some action after the write.
      Overrides:
      performAfterWrite in class Data
      Parameters:
      op - the operation (OP_CREATE, OP_UPDATE, ...)
      mbr - the member which requests the write operation
      context - a map which contains context parameters (may be null)
    • performDeepCopy

      public void performDeepCopy(Member mbr, Map context)
      Performs category deep copy
      Parameters:
      mbr - the member which requests the write operation
      context - a map which contains context parameters (may be null)
      Since:
      jcms-5.0.0
    • getReadableCatSet

      public static Set<Category> getReadableCatSet(Set<Category> catSet, Member mbr)
      Returns a category subset the given member can read
      Parameters:
      catSet - the category set to be filtered
      mbr - the reader
      Returns:
      a clone of catSet without categories the member cannot read
      Since:
      jcms-5.0.1
    • getReadableCatSet

      public static Set<Category> getReadableCatSet(Category[] cats, Member mbr)
      Returns a category subset the given member can read.
      Parameters:
      cats - the category set to be filtered
      mbr - the reader
      Returns:
      a set of categories without categories the member cannot read
      Since:
      jcms-9.0.2
    • performImport

      public ControllerStatus performImport(Member mbr, File file, String languages, String encoding)
      Parse and imports categories from the given file under this category.
      Parameters:
      mbr - the member used for creation and update of categories
      file - the categories file to parse
      languages - is the comma separated list of the languages in which the translation will appear in the specified file.
      For example, {"en", "fr"} if the file contains a line such as "My Category | Ma catégorie".
      Or {"fr", "en"} if the file contains a line such as "Ma catégorie | My Category".
      If null, the current site language will be used (Channel.getLanguageList().
      encoding - the encoding of the file to import, if null, the encoding will be guessed using a CharsetDetector, and if the encoding cannot be guessed, ISO-8859-1 is used as a last resort. Therefore, you should always precise one when possible.
      Returns:
      a ControllerStatus indicating the operation success/failure (never return null)
    • performExport

      public String performExport(Member loggedMember, String languages)
      Returns a String representation of this categories and its descendant in the same format than the import.
      Parameters:
      loggedMember - the member processing export operation, used for read rights
      languages - is the comma separated list of the languages in which the translation will appear in the specified file.
      If null, the current site language will be used (Channel.getLanguageList().
      Returns:
      a String representation of current cat and descendants
      Since:
      jcms-10.0.4 JCMS-7822
    • exportXmlRelated

      protected void exportXmlRelated(StringBuffer sb, String related, int indentLevel)
      Overrides:
      exportXmlRelated in class Data
    • moveChild

      public static boolean moveChild(Category child, int newOrder, Member opAuthor)
      Move the given child at the new order in its parent. The parent must use the custom order.
      Parameters:
      child - a child category
      newOrder - the new order for this child
      opAuthor - the member who perform this operation. This member must have the right to manage the parent category.
      Returns:
      true if the move has succeed.