Interface MCRCategoryDAO

All Known Implementing Classes:
MCRCategoryDAOImpl, MCREventedCategoryDAOImpl, MCRSolrCategoryDAO

public interface MCRCategoryDAO
Interface of the Data Access Object for Classifications.
Since:
2.0
Version:
$Revision$ $Date$
Author:
Thomas Scheffler (yagee)
  • Method Details

    • addCategory

      MCRCategory addCategory(MCRCategoryID parentID, MCRCategory category)
      Adds a category as child of another category. When parentID is null a root category will be created.
      Parameters:
      parentID - ID of the parent category
      category - Category (with children) to be added
      Returns:
      the parent category
    • addCategory

      MCRCategory addCategory(MCRCategoryID parentID, MCRCategory category, int position)
      Adds a category as child of another category. When parentID is null a root category will be created.
      Parameters:
      parentID - ID of the parent category
      category - Category (with children) to be added
      position - insert position
      Returns:
      the parent category
    • deleteCategory

      void deleteCategory(MCRCategoryID id)
      Deletes a category with all child categories.
      Parameters:
      id - ID of Category to be removed
    • exist

      boolean exist(MCRCategoryID id)
      Tells if a given category exists.
      Parameters:
      id - ID of Category
      Returns:
      true if category is present
    • getCategoriesByLabel

      List<MCRCategory> getCategoriesByLabel(MCRCategoryID baseID, String lang, String text)
      Retrieve all Categories tagged by a specific label in a specific lang.
      Parameters:
      baseID - base Category which subtree is searched for the label.
      lang - language attribute of the label
      text - text of the label
      Returns:
      a collection of MCRCategories with matching labels
    • getCategoriesByLabel

      List<MCRCategory> getCategoriesByLabel(String lang, String text)
      Retrieve all Categories tagged by a specific label in a specific lang.
      Parameters:
      lang - language attribute of the label
      text - text of the label
      Returns:
      a collection of MCRCategories with matching labels
    • getCategory

      MCRCategory getCategory(MCRCategoryID id, int childLevel)
      Returns MCRCategory with this id and childLevel levels of subcategories.
      Parameters:
      id - ID of category
      childLevel - how many levels of subcategories should be retrieved (-1 for infinitive)
      Returns:
      MCRCategory with id or null if the category cannot be found
    • getChildren

      List<MCRCategory> getChildren(MCRCategoryID id)
      Returns the list of child categories for the specified category.
      Parameters:
      id - ID of category
      Returns:
      list of child category
    • getParents

      List<MCRCategory> getParents(MCRCategoryID id)
      Returns the parent of the given category and its parent and so on. The last element in the list is the root category (the classification)
      Parameters:
      id - ID of Category
      Returns:
      list of parents
    • getRootCategoryIDs

      List<MCRCategoryID> getRootCategoryIDs()
      Returns all category IDs that do not have a parent category.
      Returns:
      list of category IDs
    • getRootCategories

      List<MCRCategory> getRootCategories()
      Returns all categories that do not have a parent category.
      Returns:
      list of category IDs
    • getRootCategory

      MCRCategory getRootCategory(MCRCategoryID baseID, int childLevel)
      Returns the root Category with ancestor axis of the specified category and childLevel levels of subcategories. You can say it is the combination of getParents(MCRCategoryID) and getCategory(MCRCategoryID, int).
      Parameters:
      baseID - Category with relative level set to "0".
      childLevel - amount of subcategory levels rooted at baseID category
      Returns:
      the root Category (Classification)
      See Also:
    • hasChildren

      boolean hasChildren(MCRCategoryID id)
      Tells if a given category contains subcategories.
      Parameters:
      id - ID of Category
      Returns:
      true if subcategories are present
    • moveCategory

      void moveCategory(MCRCategoryID id, MCRCategoryID newParentID)
      Moves a Category from one subtree in a classification to a new parent. All subcategories remain children of the moved category.
      Parameters:
      id - ID of the Category which should be moved
      newParentID - ID of the new parent
    • moveCategory

      void moveCategory(MCRCategoryID id, MCRCategoryID newParentID, int index)
      Moves a Category from one subtree in a classification to a new parent as the indexth child.
      Parameters:
      id - ID of the Category which should be moved
      newParentID - ID of the new parent
      index - insert category at index in the list of children
    • removeLabel

      MCRCategory removeLabel(MCRCategoryID id, String lang)
      Removes a label from a Category.
      Parameters:
      id - ID of the category
      lang - which language should be removed?
      Returns:
      category where the label was removed
    • replaceCategory

      Collection<? extends MCRCategory> replaceCategory(MCRCategory newCategory) throws IllegalArgumentException
      Replaces a MCRCategory by a new version of the same category. This replacment includes all subcategories and labels. So former subcategories and labels not present in newCategory will be removed while new ones will be inserted. If you can use the other methods defined by this interface as they ought to be more optimized.
      Parameters:
      newCategory - new version of MCRCategory
      Returns:
      collection of replaced categories
      Throws:
      IllegalArgumentException - if old version of MCRCategory does not exist
    • setLabel

      MCRCategory setLabel(MCRCategoryID id, MCRLabel label)
      Sets or updates a label from a Category.
      Parameters:
      id - ID of the category
      label - to be set or updated
      Returns:
      category where the label was set
    • setLabels

      MCRCategory setLabels(MCRCategoryID id, SortedSet<MCRLabel> labels)
      Sets a new set of labels from a Category.
      Parameters:
      id - ID of the category
      labels - to be set
      Returns:
      category where the labels was set
    • setURI

      MCRCategory setURI(MCRCategoryID id, URI uri)
      Sets or updates the URI from a Category.
      Parameters:
      id - ID of the category
      uri - to be set or updated
      Returns:
      category where the uri was set
    • getLastModified

      long getLastModified()
      allows to determine when the last change was made to the categories.
      Returns:
      either the last change time or the init time of the DAO class
    • getLastModified

      long getLastModified(String root)
      Gets the last modified timestamp for the given root id. If there is no timestamp at the moment -1 is returned.
      Parameters:
      root - ID of root category
      Returns:
      the last modified timestamp (if any) or -1