org.mycore.datamodel.classifications2
Interface MCRCategoryDAO

All Known Implementing Classes:
MCRCategoryDAOImpl

public interface MCRCategoryDAO

Interface of the Data Access Object for Classifications.

Since:
2.0
Version:
$Revision: 14450 $ $Date: 2008-11-21 11:54:03 +0100 (Fr, 21 Nov 2008) $
Author:
Thomas Scheffler (yagee)

Method Summary
 void addCategory(MCRCategoryID parentID, MCRCategory category)
          Adds a category as child of another category.
 void deleteCategory(MCRCategoryID id)
          Deletes a category with all child categories.
 boolean exist(MCRCategoryID id)
          Tells if a given category exists.
 List<MCRCategory> getCategoriesByLabel(MCRCategoryID baseID, String lang, String text)
          Retrieve all Categories tagged by a specific label in a specific lang.
 MCRCategory getCategory(MCRCategoryID id, int childLevel)
          Returns MCRCategory with this id and childLevel levels of subcategories.
 List<MCRCategory> getChildren(MCRCategoryID id)
          Returns the list of child categories for the specified category.
 long getLastModified()
          allows to determine when the last change was made to the categories.
 List<MCRCategory> getParents(MCRCategoryID id)
          Returns the parent of the given category and its parent and so on.
 List<MCRCategory> getRootCategories()
          Returns all categories that do not have a parent category.
 MCRCategory getRootCategory(MCRCategoryID baseID, int childLevel)
          Returns the root Category with ancestor axis of the specified category and childLevel levels of subcategories.
 List<MCRCategoryID> getRootCategoryIDs()
          Returns all category IDs that do not have a parent category.
 boolean hasChildren(MCRCategoryID id)
          Tells if a given category contains subcategories.
 void moveCategory(MCRCategoryID id, MCRCategoryID newParentID)
          Moves a Category from one subtree in a classification to a new parent.
 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.
 void removeLabel(MCRCategoryID id, String lang)
          Removes a label from a Category.
 void replaceCategory(MCRCategory newCategory)
          Replaces a MCRCategory by a new version of the same category.
 void setLabel(MCRCategoryID id, MCRLabel label)
          Sets or updates a label from a Category.
 

Method Detail

addCategory

void addCategory(MCRCategoryID parentID,
                 MCRCategory category)
Adds a category as child of another category.

Parameters:
parentID - ID of the parent category
category - Category (with children) to be added

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

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 invinitive)
Returns:
MCRCategory with id

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:
getParents(MCRCategoryID), getCategory(MCRCategoryID, int)

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

void removeLabel(MCRCategoryID id,
                 String lang)
Removes a label from a Category.

Parameters:
id - ID of the category
lang - which language should be removed?

replaceCategory

void 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
Throws:
IllegalArgumentException - if old version of MCRCategory does not exist

setLabel

void 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

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