Class MCRCategoryDAOImpl
java.lang.Object
org.mycore.datamodel.classifications2.impl.MCRCategoryDAOImpl
- All Implemented Interfaces:
MCRCategoryDAO
- Direct Known Subclasses:
MCREventedCategoryDAOImpl
,MCRSolrCategoryDAO
- Since:
- 2.0
- Version:
- $Revision$ $Date: 2008-02-06 17:27:24 +0000 (Mi, 06 Feb 2008) $
- Author:
- Thomas Scheffler (yagee)
-
Constructor Summary
-
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.static MCRCategoryImpl
getByNaturalID
(EntityManager entityManager, MCRCategoryID id) returns database backed MCRCategoryImpl every change to the returned MCRCategory is reflected in the database.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.getChildren
(MCRCategoryID cid) 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 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
hasChildren
(MCRCategoryID cid) 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.void
repairLeftRightValue
(String classID) 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.protected void
updateLastModified
(String root) Method updates the last modified timestamp, for the given root id.
-
Constructor Details
-
MCRCategoryDAOImpl
public MCRCategoryDAOImpl()
-
-
Method Details
-
addCategory
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 interfaceMCRCategoryDAO
- Parameters:
parentID
- ID of the parent categorycategory
- Category (with children) to be added- Returns:
- the parent category
-
addCategory
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 interfaceMCRCategoryDAO
- Parameters:
parentID
- ID of the parent categorycategory
- Category (with children) to be addedposition
- insert position- Returns:
- the parent category
-
deleteCategory
Description copied from interface:MCRCategoryDAO
Deletes a category with all child categories.- Specified by:
deleteCategory
in interfaceMCRCategoryDAO
- Parameters:
id
- ID of Category to be removed
-
exist
Description copied from interface:MCRCategoryDAO
Tells if a given category exists.- Specified by:
exist
in interfaceMCRCategoryDAO
- Parameters:
id
- ID of Category- Returns:
- true if category is present
-
getCategoriesByLabel
Description copied from interface:MCRCategoryDAO
Retrieve all Categories tagged by a specific label in a specific lang.- Specified by:
getCategoriesByLabel
in interfaceMCRCategoryDAO
- Parameters:
lang
- language attribute of the labeltext
- text of the label- Returns:
- a collection of MCRCategories with matching labels
-
getCategoriesByLabel
Description copied from interface:MCRCategoryDAO
Retrieve all Categories tagged by a specific label in a specific lang.- Specified by:
getCategoriesByLabel
in interfaceMCRCategoryDAO
- 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
-
getCategory
Description copied from interface:MCRCategoryDAO
Returns MCRCategory with this id and childLevel levels of subcategories.- Specified by:
getCategory
in interfaceMCRCategoryDAO
- 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
Description copied from interface:MCRCategoryDAO
Returns the list of child categories for the specified category.- Specified by:
getChildren
in interfaceMCRCategoryDAO
- Parameters:
cid
- ID of category- Returns:
- list of child category
-
getParents
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 interfaceMCRCategoryDAO
- Parameters:
id
- ID of Category- Returns:
- list of parents
-
getRootCategoryIDs
Description copied from interface:MCRCategoryDAO
Returns all category IDs that do not have a parent category.- Specified by:
getRootCategoryIDs
in interfaceMCRCategoryDAO
- Returns:
- list of category IDs
-
getRootCategories
Description copied from interface:MCRCategoryDAO
Returns all categories that do not have a parent category.- Specified by:
getRootCategories
in interfaceMCRCategoryDAO
- Returns:
- list of category IDs
-
getRootCategory
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 interfaceMCRCategoryDAO
- 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
Description copied from interface:MCRCategoryDAO
Tells if a given category contains subcategories.- Specified by:
hasChildren
in interfaceMCRCategoryDAO
- Parameters:
cid
- ID of Category- Returns:
- true if subcategories are present
-
moveCategory
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 interfaceMCRCategoryDAO
- Parameters:
id
- ID of the Category which should be movednewParentID
- ID of the new parent
-
moveCategory
Description copied from interface:MCRCategoryDAO
Moves a Category from one subtree in a classification to a new parent as theindex
th child.- Specified by:
moveCategory
in interfaceMCRCategoryDAO
- 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
Description copied from interface:MCRCategoryDAO
Removes a label from a Category.- Specified by:
removeLabel
in interfaceMCRCategoryDAO
- Parameters:
id
- ID of the categorylang
- 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 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.- Specified by:
replaceCategory
in interfaceMCRCategoryDAO
- Parameters:
newCategory
- new version of MCRCategory- Returns:
- collection of replaced categories
- Throws:
IllegalArgumentException
- if old version of MCRCategory does not exist
-
setLabel
Description copied from interface:MCRCategoryDAO
Sets or updates a label from a Category.- Specified by:
setLabel
in interfaceMCRCategoryDAO
- Parameters:
id
- ID of the categorylabel
- to be set or updated- Returns:
- category where the label was set
-
setLabels
Description copied from interface:MCRCategoryDAO
Sets a new set of labels from a Category.- Specified by:
setLabels
in interfaceMCRCategoryDAO
- Parameters:
id
- ID of the categorylabels
- to be set- Returns:
- category where the labels was set
-
setURI
Description copied from interface:MCRCategoryDAO
Sets or updates the URI from a Category.- Specified by:
setURI
in interfaceMCRCategoryDAO
- Parameters:
id
- ID of the categoryuri
- to be set or updated- Returns:
- category where the uri was set
-
repairLeftRightValue
-
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 interfaceMCRCategoryDAO
- Returns:
- either the last change time or the init time of the DAO class
-
getByNaturalID
returns database backed MCRCategoryImpl every change to the returned MCRCategory is reflected in the database. -
updateLastModified
Method updates the last modified timestamp, for the given root id. -
getLastModified
Gets the timestamp for the given root id. If there is not timestamp at the moment -1 is returned.- Specified by:
getLastModified
in interfaceMCRCategoryDAO
- Parameters:
root
- ID of root category- Returns:
- the last modified timestamp (if any) or -1
-