Package org.ametys.plugins.thesaurus
Class ThesaurusDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.thesaurus.ThesaurusDAO
-
- All Implemented Interfaces:
LogEnabled
,PluginAware
,Component
,Serviceable
public class ThesaurusDAO extends AbstractLogEnabled implements Serviceable, Component, PluginAware
DAO for manipulating thesaurus
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__PLUGIN_NODE_NAME
private static String
__ROOT_THESAURII_NODETYPE
protected ContentAttributeTypeExtensionPoint
_contentAttributeTypeExtensionPoint
The extension point for available attribute typesprotected ContentDAO
_contentDAO
The contentDAOprotected ContentTypeExtensionPoint
_contentTypeEP
The extension point for content typesprotected ContentTypesHelper
_contentTypesHelper
The content types helperprotected CurrentUserProvider
_currentUserProvider
The current user providerprotected EditContentTypeHelper
_editContentTypeHelper
The EditContentTypeHelperprotected ObservationManager
_observationManager
Ametys observation mangerprivate String
_pluginName
protected AmetysObjectResolver
_resolver
Ametys resolverprotected RightManager
_rightManager
The right managerstatic String
METADATA_APPLICATION_NOTE
Metadata for applicationNotestatic String
METADATA_EXPLANATORY_NOTE
Metadata for explanatoryNotestatic String
METADATA_GENERIC_TERM
Metadata for generic termstatic String
METADATA_RELATED_TERMS
Metadata for related termsstatic String
METADATA_SPECIFIC_TERMS
Metadata for specific termsstatic String
METADATA_SYNONYMS
Metadata for synonymsstatic String
MICROTHESAURUS_ABSTRACT_CONTENT_TYPE
Id of all microthesaurus super content typestatic String
MICROTHESAURUS_CONTENT_TYPE_PREFIX
Metadata for related termsstatic String
ROLE
The Avalon role
-
Constructor Summary
Constructors Constructor Description ThesaurusDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_deleteTerm(Content term)
private ContentTypeDefinition
_getMicrothesaurusContentTypeDefinition(String cTypeId, String label, Thesaurus parentThesaurus)
Get the contentTypeDefinition for a microthesaurusprivate List<ModelItem>
_getModelItems(String microthesaurusCTypeId)
Get the additional metadata for a microthesaurusprotected ModifiableTraversableAmetysObject
_getOrCreateNode(ModifiableTraversableAmetysObject parentNode, String nodeName, String nodeType)
Get or create a nodeMap<String,Object>
checkBeforeMicrothesaurusDeletion(String microthesaurusId)
Do some check before microthesaurus deletionMap<String,Object>
createMicrothesaurus(String label, String thesaurusId, String microthesaurusName)
Creates a microthesaurusMap<String,Object>
createThesaurus(String label)
Creates a thesaurusMap<String,Object>
deleteMicrothesaurus(String microthesaurusId)
Deletes a microthesaurusMap<String,Object>
deleteThesaurus(String thesaurusId)
Deletes a thesaurusThesaurus
findThesaurusByLabel(String label)
Get a thesaurus by its labelAmetysObjectIterable<Content>
getAllTerms(String microthesaurusId)
Get the all terms of a microthesaurusAmetysObjectIterable<Content>
getChildTerms(String microthesaurusId, String parentId)
Get direct child terms of a termList<String>
getMicrothesaurii()
Get the list of ids of all the microthesauriiList<String>
getMicrothesaurii(String thesaurusId)
Get microthesaurii of a thesaurusThesaurus
getParentThesaurus(ContentType microThesaurus)
Get the parent thesaurusModifiableTraversableAmetysObject
getRootNode()
Get the root plugin storage object.AmetysObjectIterable<Content>
getRootTerms(String microthesaurusId)
Get the root terms of a microthesaurusAmetysObjectIterable<Thesaurus>
getThesaurii()
Get the list of thesaurusString
getThesaurusLabel(String thesaurusId)
Get the label of thesaurusboolean
hasReferencingContents(String microthesaurusId, Content term)
Determines if a term which belongs to a microthesaurus is referenced by contents outside the microthesaurusvoid
service(ServiceManager manager)
void
setPluginInfo(String pluginName, String featureName, String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.Map<String,Object>
updateMicrothesaurus(String microthesaurusId, String label)
Edit a microthesaurusMap<String,Object>
updateThesaurus(String thesaurusId, String label)
Updates a thesaurus-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
MICROTHESAURUS_CONTENT_TYPE_PREFIX
public static final String MICROTHESAURUS_CONTENT_TYPE_PREFIX
Metadata for related terms- See Also:
- Constant Field Values
-
MICROTHESAURUS_ABSTRACT_CONTENT_TYPE
public static final String MICROTHESAURUS_ABSTRACT_CONTENT_TYPE
Id of all microthesaurus super content type- See Also:
- Constant Field Values
-
METADATA_RELATED_TERMS
public static final String METADATA_RELATED_TERMS
Metadata for related terms- See Also:
- Constant Field Values
-
METADATA_SPECIFIC_TERMS
public static final String METADATA_SPECIFIC_TERMS
Metadata for specific terms- See Also:
- Constant Field Values
-
METADATA_GENERIC_TERM
public static final String METADATA_GENERIC_TERM
Metadata for generic term- See Also:
- Constant Field Values
-
METADATA_SYNONYMS
public static final String METADATA_SYNONYMS
Metadata for synonyms- See Also:
- Constant Field Values
-
METADATA_APPLICATION_NOTE
public static final String METADATA_APPLICATION_NOTE
Metadata for applicationNote- See Also:
- Constant Field Values
-
METADATA_EXPLANATORY_NOTE
public static final String METADATA_EXPLANATORY_NOTE
Metadata for explanatoryNote- See Also:
- Constant Field Values
-
__PLUGIN_NODE_NAME
private static final String __PLUGIN_NODE_NAME
- See Also:
- Constant Field Values
-
__ROOT_THESAURII_NODETYPE
private static final String __ROOT_THESAURII_NODETYPE
- See Also:
- Constant Field Values
-
_resolver
protected AmetysObjectResolver _resolver
Ametys resolver
-
_rightManager
protected RightManager _rightManager
The right manager
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_contentTypeEP
protected ContentTypeExtensionPoint _contentTypeEP
The extension point for content types
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
The content types helper
-
_contentAttributeTypeExtensionPoint
protected ContentAttributeTypeExtensionPoint _contentAttributeTypeExtensionPoint
The extension point for available attribute types
-
_contentDAO
protected ContentDAO _contentDAO
The contentDAO
-
_editContentTypeHelper
protected EditContentTypeHelper _editContentTypeHelper
The EditContentTypeHelper
-
_observationManager
protected ObservationManager _observationManager
Ametys observation manger
-
_pluginName
private String _pluginName
-
-
Constructor Detail
-
ThesaurusDAO
public ThesaurusDAO()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
getThesaurii
public AmetysObjectIterable<Thesaurus> getThesaurii()
Get the list of thesaurus- Returns:
- the thesaurus
-
getMicrothesaurii
public List<String> getMicrothesaurii(String thesaurusId)
Get microthesaurii of a thesaurus- Parameters:
thesaurusId
- The id of thesaurus- Returns:
- the contentType ids of microthesaurii
-
getMicrothesaurii
public List<String> getMicrothesaurii()
Get the list of ids of all the microthesaurii- Returns:
- the list if microthesaurii ids
-
getParentThesaurus
public Thesaurus getParentThesaurus(ContentType microThesaurus)
Get the parent thesaurus- Parameters:
microThesaurus
- The microthesaurus- Returns:
- the parent thesaurus
-
_getMicrothesaurusContentTypeDefinition
private ContentTypeDefinition _getMicrothesaurusContentTypeDefinition(String cTypeId, String label, Thesaurus parentThesaurus)
Get the contentTypeDefinition for a microthesaurus- Parameters:
cTypeId
- The id of content type for this microthesauruslabel
- The label of the microthesaurusparentThesaurus
- The parent thesaurus- Returns:
- The ContentTypeDefinition of the reference table content type
-
_getModelItems
private List<ModelItem> _getModelItems(String microthesaurusCTypeId)
Get the additional metadata for a microthesaurus- Parameters:
microthesaurusCTypeId
- The id of content type for this microthesaurus- Returns:
- The list of additional metadata definition
-
findThesaurusByLabel
public Thesaurus findThesaurusByLabel(String label)
Get a thesaurus by its label- Parameters:
label
- the label- Returns:
- the thesaurus or null if not found
-
createThesaurus
public Map<String,Object> createThesaurus(String label)
Creates a thesaurus- Parameters:
label
- The label- Returns:
- The id and label of the created microthesaurus
-
updateThesaurus
public Map<String,Object> updateThesaurus(String thesaurusId, String label) throws EditContentTypeException
Updates a thesaurus- Parameters:
thesaurusId
- The id of microthesauruslabel
- The new label- Returns:
- The id and label of the updated microthesaurus
- Throws:
EditContentTypeException
- if failed to update the existing content types for child microthesaurii.
-
deleteThesaurus
public Map<String,Object> deleteThesaurus(String thesaurusId)
Deletes a thesaurus- Parameters:
thesaurusId
- The id of thesaurus- Returns:
- The id of the deleted thesaurus
-
getThesaurusLabel
public String getThesaurusLabel(String thesaurusId)
Get the label of thesaurus- Parameters:
thesaurusId
- The id of thesaurus- Returns:
- The id and label of the thesaurus
-
getAllTerms
public AmetysObjectIterable<Content> getAllTerms(String microthesaurusId)
Get the all terms of a microthesaurus- Parameters:
microthesaurusId
- the id of microthesaurus- Returns:
- all terms
-
getRootTerms
public AmetysObjectIterable<Content> getRootTerms(String microthesaurusId)
Get the root terms of a microthesaurus- Parameters:
microthesaurusId
- the id of microthesaurus- Returns:
- root terms
-
getChildTerms
public AmetysObjectIterable<Content> getChildTerms(String microthesaurusId, String parentId)
Get direct child terms of a term- Parameters:
microthesaurusId
- the id of microthesaurusparentId
- The parent Id- Returns:
- The child terms
-
hasReferencingContents
public boolean hasReferencingContents(String microthesaurusId, Content term)
Determines if a term which belongs to a microthesaurus is referenced by contents outside the microthesaurus- Parameters:
microthesaurusId
- the id of microthesaurusterm
- the content term- Returns:
- true if the term has at least one referencing content outside the microthesaurus
-
createMicrothesaurus
public Map<String,Object> createMicrothesaurus(String label, String thesaurusId, String microthesaurusName) throws EditContentTypeException
Creates a microthesaurus- Parameters:
label
- The labelthesaurusId
- The id of parent thesaurusmicrothesaurusName
- the name of the microthesaurus- Returns:
- The id and label of the created microthesaurus
- Throws:
EditContentTypeException
- if failed to create the microthesaurus content type
-
updateMicrothesaurus
public Map<String,Object> updateMicrothesaurus(String microthesaurusId, String label) throws EditContentTypeException
Edit a microthesaurus- Parameters:
microthesaurusId
- The id of microthesaurus to editlabel
- The new label- Returns:
- The id and label of the updated microthesaurus
- Throws:
EditContentTypeException
- if failed to update the content type for this microthesaurus
-
checkBeforeMicrothesaurusDeletion
public Map<String,Object> checkBeforeMicrothesaurusDeletion(String microthesaurusId)
Do some check before microthesaurus deletion- Parameters:
microthesaurusId
- the id of microthesaurus- Returns:
- the check result
-
deleteMicrothesaurus
public Map<String,Object> deleteMicrothesaurus(String microthesaurusId)
Deletes a microthesaurus- Parameters:
microthesaurusId
- The id of microthesaurus- Returns:
- The id of the deleted microthesaurus
-
_deleteTerm
private void _deleteTerm(Content term)
-
getRootNode
public ModifiableTraversableAmetysObject getRootNode() throws AmetysRepositoryException
Get the root plugin storage object.- Returns:
- the root plugin storage object.
- Throws:
AmetysRepositoryException
- if a repository error occurs.
-
_getOrCreateNode
protected ModifiableTraversableAmetysObject _getOrCreateNode(ModifiableTraversableAmetysObject parentNode, String nodeName, String nodeType) throws AmetysRepositoryException
Get or create a node- Parameters:
parentNode
- the parent nodenodeName
- the name of the nodenodeType
- the type of the node- Returns:
- The retrieved or created node
- Throws:
AmetysRepositoryException
- if an error occurs when manipulating the repository
-
-