Package org.mycore.solr.classification
Class MCRSolrCategoryDAO
java.lang.Object
org.mycore.datamodel.classifications2.impl.MCRCategoryDAOImpl
org.mycore.solr.classification.MCRSolrCategoryDAO
- All Implemented Interfaces:
MCRCategoryDAO
Extends the default category dao with solr support. Every create/write/delete operation
on a classification/category results in a solr reindex additionally.
- Author:
- Matthias Eichner
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddCategory
(MCRCategoryID parentID, MCRCategory category, int position) Adds a category as child of another category.void
Deletes a category with all child categories.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.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
solrDelete
(MCRCategoryID id, MCRCategory parent) protected void
solrMove
(MCRCategoryID id, MCRCategoryID newParentID, int index) Methods inherited from class org.mycore.datamodel.classifications2.impl.MCRCategoryDAOImpl
addCategory, exist, getByNaturalID, getCategoriesByLabel, getCategoriesByLabel, getCategory, getChildren, getLastModified, getLastModified, getParents, getRootCategories, getRootCategory, getRootCategoryIDs, hasChildren, moveCategory, repairLeftRightValue, updateLastModified
-
Constructor Details
-
MCRSolrCategoryDAO
public MCRSolrCategoryDAO()
-
-
Method Details
-
setURI
Description copied from interface:MCRCategoryDAO
Sets or updates the URI from a Category.- Specified by:
setURI
in interfaceMCRCategoryDAO
- Overrides:
setURI
in classMCRCategoryDAOImpl
- Parameters:
id
- ID of the categoryuri
- to be set or updated- Returns:
- category where the uri was set
-
setLabel
Description copied from interface:MCRCategoryDAO
Sets or updates a label from a Category.- Specified by:
setLabel
in interfaceMCRCategoryDAO
- Overrides:
setLabel
in classMCRCategoryDAOImpl
- 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
- Overrides:
setLabels
in classMCRCategoryDAOImpl
- Parameters:
id
- ID of the categorylabels
- to be set- Returns:
- category where the labels was set
-
removeLabel
Description copied from interface:MCRCategoryDAO
Removes a label from a Category.- Specified by:
removeLabel
in interfaceMCRCategoryDAO
- Overrides:
removeLabel
in classMCRCategoryDAOImpl
- Parameters:
id
- ID of the categorylang
- which language should be removed?- Returns:
- category where the label was removed
-
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
- Overrides:
addCategory
in classMCRCategoryDAOImpl
- 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
- Overrides:
deleteCategory
in classMCRCategoryDAOImpl
- Parameters:
id
- ID of Category to be removed
-
solrDelete
-
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
- Overrides:
moveCategory
in classMCRCategoryDAOImpl
- Parameters:
id
- ID of the Category which should be movednewParentID
- ID of the new parentindex
- insert category at index in the list of children
-
solrMove
-
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
- Overrides:
replaceCategory
in classMCRCategoryDAOImpl
- Parameters:
newCategory
- new version of MCRCategory- Returns:
- collection of replaced categories
- Throws:
IllegalArgumentException
- if old version of MCRCategory does not exist
-