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 Summary
Modifier and TypeMethodDescriptionaddCategory
(MCRCategoryID parentID, MCRCategory category) Adds a category as child of another category.addCategory
(MCRCategoryID parentID, MCRCategory category, int position) Adds a category as child of another category.void
Deletes a category with all child categories.boolean
exist
(MCRCategoryID id) Tells if a given category exists.getCategoriesByLabel
(String lang, String text) Retrieve all Categories tagged by a specific label in a specific lang.getCategoriesByLabel
(MCRCategoryID baseID, String lang, String text) Retrieve all Categories tagged by a specific label in a specific lang.getCategory
(MCRCategoryID id, int childLevel) Returns MCRCategory with this id and childLevel levels of subcategories.Returns the list of child categories for the specified category.long
allows to determine when the last change was made to the categories.long
getLastModified
(String root) Gets the last modified timestamp for the given root id.Returns the parent of the given category and its parent and so on.Returns all categories that do not have a parent category.getRootCategory
(MCRCategoryID baseID, int childLevel) Returns the root Category with ancestor axis of the specified category and childLevel levels of subcategories.Returns all category IDs that do not have a parent category.boolean
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 theindex
th child.removeLabel
(MCRCategoryID id, String lang) Removes a label from a Category.Collection<? extends MCRCategory>
replaceCategory
(MCRCategory newCategory) Replaces aMCRCategory
by a new version of the same category.setLabel
(MCRCategoryID id, MCRLabel label) Sets or updates a label from a Category.setLabels
(MCRCategoryID id, SortedSet<MCRLabel> labels) Sets a new set of labels from a Category.setURI
(MCRCategoryID id, URI uri) Sets or updates the URI from a Category.
-
Method Details
-
addCategory
Adds a category as child of another category. When parentID is null a root category will be created.- Parameters:
parentID
- ID of the parent categorycategory
- Category (with children) to be added- Returns:
- the parent category
-
addCategory
Adds a category as child of another category. When parentID is null a root category will be created.- Parameters:
parentID
- ID of the parent categorycategory
- Category (with children) to be addedposition
- insert position- Returns:
- the parent category
-
deleteCategory
Deletes a category with all child categories.- Parameters:
id
- ID of Category to be removed
-
exist
Tells if a given category exists.- Parameters:
id
- ID of Category- Returns:
- true if category is present
-
getCategoriesByLabel
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 labeltext
- text of the label- Returns:
- a collection of MCRCategories with matching labels
-
getCategoriesByLabel
Retrieve all Categories tagged by a specific label in a specific lang.- Parameters:
lang
- language attribute of the labeltext
- text of the label- Returns:
- a collection of MCRCategories with matching labels
-
getCategory
Returns MCRCategory with this id and childLevel levels of subcategories.- Parameters:
id
- ID of categorychildLevel
- how many levels of subcategories should be retrieved (-1 for infinitive)- Returns:
- MCRCategory with
id
or null if the category cannot be found
-
getChildren
Returns the list of child categories for the specified category.- Parameters:
id
- ID of category- Returns:
- list of child category
-
getParents
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
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
Tells if a given category contains subcategories.- Parameters:
id
- ID of Category- Returns:
- true if subcategories are present
-
moveCategory
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 movednewParentID
- ID of the new parent
-
moveCategory
Moves a Category from one subtree in a classification to a new parent as theindex
th child.- Parameters:
id
- ID of the Category which should be movednewParentID
- ID of the new parentindex
- insert category at index in the list of children
-
removeLabel
Removes a label from a Category.- Parameters:
id
- ID of the categorylang
- which language should be removed?- Returns:
- category where the label was removed
-
replaceCategory
Collection<? extends MCRCategory> replaceCategory(MCRCategory newCategory) throws IllegalArgumentException Replaces aMCRCategory
by a new version of the same category. This replacment includes all subcategories and labels. So former subcategories and labels not present innewCategory
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
Sets or updates a label from a Category.- Parameters:
id
- ID of the categorylabel
- to be set or updated- Returns:
- category where the label was set
-
setLabels
Sets a new set of labels from a Category.- Parameters:
id
- ID of the categorylabels
- to be set- Returns:
- category where the labels was set
-
setURI
Sets or updates the URI from a Category.- Parameters:
id
- ID of the categoryuri
- 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
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
-