Class MCRCategoryDAOImpl

java.lang.Object
org.mycore.datamodel.classifications2.impl.MCRCategoryDAOImpl
All Implemented Interfaces:
MCRCategoryDAO
Direct Known Subclasses:
MCREventedCategoryDAOImpl, MCRSolrCategoryDAO

public class MCRCategoryDAOImpl extends Object implements MCRCategoryDAO
Since:
2.0
Version:
$Revision$ $Date: 2008-02-06 17:27:24 +0000 (Mi, 06 Feb 2008) $
Author:
Thomas Scheffler (yagee)
  • Constructor Details

    • MCRCategoryDAOImpl

      public MCRCategoryDAOImpl()
  • Method Details

    • addCategory

      public MCRCategory addCategory(MCRCategoryID parentID, MCRCategory category)
      Description copied from interface: MCRCategoryDAO
      Adds a category as child of another category. When parentID is null a root category will be created.
      Specified by:
      addCategory in interface MCRCategoryDAO
      Parameters:
      parentID - ID of the parent category
      category - Category (with children) to be added
      Returns:
      the parent category
    • addCategory

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

      public void deleteCategory(MCRCategoryID id)
      Description copied from interface: MCRCategoryDAO
      Deletes a category with all child categories.
      Specified by:
      deleteCategory in interface MCRCategoryDAO
      Parameters:
      id - ID of Category to be removed
    • exist

      public boolean exist(MCRCategoryID id)
      Description copied from interface: MCRCategoryDAO
      Tells if a given category exists.
      Specified by:
      exist in interface MCRCategoryDAO
      Parameters:
      id - ID of Category
      Returns:
      true if category is present
    • getCategoriesByLabel

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

      public List<MCRCategory> getCategoriesByLabel(MCRCategoryID baseID, String lang, String text)
      Description copied from interface: MCRCategoryDAO
      Retrieve all Categories tagged by a specific label in a specific lang.
      Specified by:
      getCategoriesByLabel in interface MCRCategoryDAO
      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
    • getCategory

      public MCRCategory getCategory(MCRCategoryID id, int childLevel)
      Description copied from interface: MCRCategoryDAO
      Returns MCRCategory with this id and childLevel levels of subcategories.
      Specified by:
      getCategory in interface MCRCategoryDAO
      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

      public List<MCRCategory> getChildren(MCRCategoryID cid)
      Description copied from interface: MCRCategoryDAO
      Returns the list of child categories for the specified category.
      Specified by:
      getChildren in interface MCRCategoryDAO
      Parameters:
      cid - ID of category
      Returns:
      list of child category
    • getParents

      public List<MCRCategory> getParents(MCRCategoryID id)
      Description copied from interface: MCRCategoryDAO
      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)
      Specified by:
      getParents in interface MCRCategoryDAO
      Parameters:
      id - ID of Category
      Returns:
      list of parents
    • getRootCategoryIDs

      public List<MCRCategoryID> getRootCategoryIDs()
      Description copied from interface: MCRCategoryDAO
      Returns all category IDs that do not have a parent category.
      Specified by:
      getRootCategoryIDs in interface MCRCategoryDAO
      Returns:
      list of category IDs
    • getRootCategories

      public List<MCRCategory> getRootCategories()
      Description copied from interface: MCRCategoryDAO
      Returns all categories that do not have a parent category.
      Specified by:
      getRootCategories in interface MCRCategoryDAO
      Returns:
      list of category IDs
    • getRootCategory

      public MCRCategory getRootCategory(MCRCategoryID baseID, int childLevel)
      Description copied from interface: MCRCategoryDAO
      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).
      Specified by:
      getRootCategory in interface MCRCategoryDAO
      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

      public boolean hasChildren(MCRCategoryID cid)
      Description copied from interface: MCRCategoryDAO
      Tells if a given category contains subcategories.
      Specified by:
      hasChildren in interface MCRCategoryDAO
      Parameters:
      cid - ID of Category
      Returns:
      true if subcategories are present
    • moveCategory

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

      public void moveCategory(MCRCategoryID id, MCRCategoryID newParentID, int index)
      Description copied from interface: MCRCategoryDAO
      Moves a Category from one subtree in a classification to a new parent as the indexth child.
      Specified by:
      moveCategory in interface MCRCategoryDAO
      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

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

      public Collection<MCRCategoryImpl> replaceCategory(MCRCategory newCategory) throws IllegalArgumentException
      Description copied from interface: MCRCategoryDAO
      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.
      Specified by:
      replaceCategory in interface MCRCategoryDAO
      Parameters:
      newCategory - new version of MCRCategory
      Returns:
      collection of replaced categories
      Throws:
      IllegalArgumentException - if old version of MCRCategory does not exist
    • setLabel

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

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

      public MCRCategory setURI(MCRCategoryID id, URI uri)
      Description copied from interface: MCRCategoryDAO
      Sets or updates the URI from a Category.
      Specified by:
      setURI in interface MCRCategoryDAO
      Parameters:
      id - ID of the category
      uri - to be set or updated
      Returns:
      category where the uri was set
    • repairLeftRightValue

      public void repairLeftRightValue(String classID)
    • getLastModified

      public long getLastModified()
      Description copied from interface: MCRCategoryDAO
      allows to determine when the last change was made to the categories.
      Specified by:
      getLastModified in interface MCRCategoryDAO
      Returns:
      either the last change time or the init time of the DAO class
    • getByNaturalID

      public static MCRCategoryImpl getByNaturalID(EntityManager entityManager, MCRCategoryID id)
      returns database backed MCRCategoryImpl every change to the returned MCRCategory is reflected in the database.
    • updateLastModified

      protected void updateLastModified(String root)
      Method updates the last modified timestamp, for the given root id.
    • getLastModified

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