public class ThesaurusDAO extends AbstractLogEnabled implements Serviceable, Component
Modifier and Type | Field and Description |
---|---|
private static Pattern |
__NUMERIC_PATTERN |
private static String |
__PLUGIN_NODE_NAME |
private static String |
__ROOT_THESAURII_NODETYPE |
private static String |
__TERM_WORKFLOW_NAME |
protected ContentWorkflowHelper |
_contentWorkflowHelper
Content workflow helper
|
protected CurrentUserProvider |
_currentUserProvider
The current user provider
|
protected AmetysObjectResolver |
_resolver
Ametys resolver
|
protected RightManager |
_rightManager
The right manager
|
protected SourceResolver |
_srcResolver
Avalon source resolver
|
static String |
METADATA_APPLICATION_NOTE
Metadata for applicationNote
|
static String |
METADATA_EXPLANATORY_NOTE
Metadata for explanatoryNote
|
static String |
METADATA_RELATED_TERMS
Metadata for related terms
|
static String |
METADATA_SPECIFIC_TERMS
Metadata for specific terms
|
static String |
METADATA_SYNONYMS
Metadata for synonyms
|
static String |
ROLE
The Avalon role
|
static String |
ROOT_CANDIDATES_NODENAME
Name of root candidate node
|
Constructor and Description |
---|
ThesaurusDAO() |
Modifier and Type | Method and Description |
---|---|
private boolean |
_checkReferenced(Content term) |
protected String |
_getContentName(String title)
Retrieves the content name given the desired title
|
private void |
_getMatchingTerm(String value,
TraversableAmetysObject ao,
List<Map<String,Object>> matchingPaths)
Get paths of term which match filter regexp
|
protected ModifiableTraversableAmetysObject |
_getOrCreateNode(ModifiableTraversableAmetysObject parentNode,
String nodeName,
String nodeType)
Get or create a node
|
Map<String,Object> |
createCandidate(String label,
String comment,
String lang,
String microthesaurusId)
Creates a new candidate
|
Map<String,Object> |
createCandidate(String label,
String comment,
String lang,
String microthesaurusId,
boolean disableIndexation)
Creates a new candidate
|
Map<String,Object> |
createMicrothesaurus(String label,
String thesaurusId)
Creates a microthesaurus
|
Map<String,Object> |
createTerm(String label,
String lang,
String parentId)
Creates a new term of micro-thesaurus
|
Map<String,Object> |
createTerm(String label,
String lang,
String parentId,
boolean disableIndexation)
Creates a new term of micro-thesaurus
|
Map<String,Object> |
createThesaurus(String label)
Creates a microthesaurus
|
Map<String,Object> |
deleteMicrothesaurus(String microthesaurusId)
Deletes a microthesaurus
|
Map<String,Object> |
deleteThesaurus(String thesaurusId)
Deletes a thesaurus
|
Map<String,Object> |
editCandidate(String id,
String label,
String comment)
Edits a candidate
|
Map<String,Object> |
filterTermsByRegExp(String value,
String parentId)
Get the path of node which match filter regexp
|
AmetysObjectIterable<Content> |
getChildTerms(String parentId)
Get direct child terms of a microthesaurus or a term
|
AmetysObjectIterable<Content> |
getChildTerms(TraversableAmetysObject parent)
Get child terms of a microthesaurus or a term
|
Content |
getGenericTerm(Content term)
Get the generic term or null
|
Set<Content> |
getIndexedContents(String termId)
Get the contents indexed with this term
|
AmetysObjectIterable<MicroThesaurus> |
getMicrothesaurii(String thesaurusId)
Get microthesaurii of a thesaurus
|
MicroThesaurus |
getMicrothesaurusByName(String thesaurusName,
String microthesaurusName)
Get a microthesaurus by its unique name
|
String |
getMicrothesaurusIdByName(String thesaurusName,
String microthesaurusName)
Get the id of a microthesaurus by its unique name
|
int |
getNumberOfIndexedContents(String termId)
Get the number of contents indexed with this term
|
MicroThesaurus |
getParentMicrothesaurus(Content term)
Get the parent microthesaurus
|
Map<String,Object> |
getParentMicrothesaurus(String termId)
Get the id of parent microthesaurus
|
Thesaurus |
getParentThesaurus(MicroThesaurus microThesaurus)
Get the parent thesaurus
|
ModifiableTraversableAmetysObject |
getRootNode()
Get the root plugin storage object.
|
Map<String,Object> |
getTermInformation(String termId)
Get the JSON representation of term
|
String |
getTermPath(Content term)
Returns the path of this term in its hierarchy
|
Map<String,Object> |
getTermsInformation(List<String> termIds)
Get the JSON representation of terms
|
Map<String,Object> |
getTermsPaths(List<String> termIds)
Returns paths of terms ids
|
AmetysObjectIterable<Thesaurus> |
getThesaurii()
Get the list of thesaurus
|
Thesaurus |
getThesaurusByName(String name)
Get a thesaurus by its unique name
|
Map<String,Object> |
getThesaurusLabel(String thesaurusId)
Get the label of thesaurus
|
boolean |
isCandidate(Content content)
Determines if the content is a candidate
|
void |
moveTerm(Content term,
TraversableAmetysObject parent)
Move a term
|
void |
service(ServiceManager manager) |
Map<String,Object> |
termsToJSON(List<String> ids)
Get the JSON representation of terms
|
Map<String,Object> |
updateMicrothesaurus(String microthesaurusId,
String label)
Updates a microthesaurus
|
Map<String,Object> |
updateThesaurus(String thesaurusId,
String label)
Updates a thesaurus
|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
public static final String METADATA_RELATED_TERMS
public static final String METADATA_SPECIFIC_TERMS
public static final String METADATA_SYNONYMS
public static final String METADATA_APPLICATION_NOTE
public static final String METADATA_EXPLANATORY_NOTE
public static final String ROOT_CANDIDATES_NODENAME
private static final String __PLUGIN_NODE_NAME
private static final String __ROOT_THESAURII_NODETYPE
private static final String __TERM_WORKFLOW_NAME
private static final Pattern __NUMERIC_PATTERN
protected AmetysObjectResolver _resolver
protected ContentWorkflowHelper _contentWorkflowHelper
protected SourceResolver _srcResolver
protected RightManager _rightManager
protected CurrentUserProvider _currentUserProvider
public ThesaurusDAO()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public AmetysObjectIterable<Thesaurus> getThesaurii()
public AmetysObjectIterable<MicroThesaurus> getMicrothesaurii(String thesaurusId)
thesaurusId
- The id of thesauruspublic MicroThesaurus getParentMicrothesaurus(Content term)
term
- The termpublic Thesaurus getThesaurusByName(String name)
name
- The thesaurus' namenull
if not foundpublic MicroThesaurus getMicrothesaurusByName(String thesaurusName, String microthesaurusName)
thesaurusName
- The thesaurusName' namemicrothesaurusName
- The microthesaurus' namenull
if not foundpublic String getMicrothesaurusIdByName(String thesaurusName, String microthesaurusName)
thesaurusName
- The thesaurusName' namemicrothesaurusName
- The microthesaurus' namepublic Map<String,Object> getParentMicrothesaurus(String termId)
termId
- The id of termpublic Thesaurus getParentThesaurus(MicroThesaurus microThesaurus)
microThesaurus
- The microthesauruspublic Content getGenericTerm(Content term)
term
- The termpublic AmetysObjectIterable<Content> getChildTerms(String parentId)
parentId
- The parent Idpublic AmetysObjectIterable<Content> getChildTerms(TraversableAmetysObject parent)
parent
- The parentpublic Set<Content> getIndexedContents(String termId)
termId
- The term idpublic int getNumberOfIndexedContents(String termId)
termId
- The term idpublic Map<String,Object> getTermsInformation(List<String> termIds) throws IOException
termIds
- The id of a termsIOException
- when an error occurs while getting the term informationpublic Map<String,Object> getTermInformation(String termId) throws IOException
termId
- The id of a termIOException
- if an error occurs when creating a Source
public Map<String,Object> termsToJSON(List<String> ids)
ids
- The ids of termspublic Map<String,Object> createThesaurus(String label)
label
- The labelpublic Map<String,Object> updateThesaurus(String thesaurusId, String label)
thesaurusId
- The id of microthesauruslabel
- The new labelpublic Map<String,Object> deleteThesaurus(String thesaurusId)
thesaurusId
- The id of thesauruspublic Map<String,Object> getThesaurusLabel(String thesaurusId)
thesaurusId
- The id of thesauruspublic Map<String,Object> createMicrothesaurus(String label, String thesaurusId)
label
- The labelthesaurusId
- The id of parent thesauruspublic Map<String,Object> updateMicrothesaurus(String microthesaurusId, String label)
microthesaurusId
- The id of microthesauruslabel
- The labelpublic Map<String,Object> deleteMicrothesaurus(String microthesaurusId)
microthesaurusId
- The id of microthesauruspublic Map<String,Object> createCandidate(String label, String comment, String lang, String microthesaurusId) throws com.opensymphony.workflow.WorkflowException
label
- The label of candidatecomment
- Comment on candidatelang
- The language codemicrothesaurusId
- The parent microthesauruscom.opensymphony.workflow.WorkflowException
- if an error occurs in the created candidate's workflowpublic Map<String,Object> createCandidate(String label, String comment, String lang, String microthesaurusId, boolean disableIndexation) throws com.opensymphony.workflow.WorkflowException
label
- The label of candidatecomment
- Comment on candidatelang
- The language codemicrothesaurusId
- The parent microthesaurusdisableIndexation
- When true, disable the indexationcom.opensymphony.workflow.WorkflowException
- if an error occurs in the created candidate's workflowpublic Map<String,Object> editCandidate(String id, String label, String comment)
id
- The id of candidatelabel
- The labelcomment
- The commentpublic Map<String,Object> createTerm(String label, String lang, String parentId) throws com.opensymphony.workflow.WorkflowException
label
- The labellang
- The language codeparentId
- The parent id in micro-thesauruscom.opensymphony.workflow.WorkflowException
- if an error occurs in the created terms's workflowpublic Map<String,Object> createTerm(String label, String lang, String parentId, boolean disableIndexation) throws com.opensymphony.workflow.WorkflowException
label
- The labellang
- The language codeparentId
- The parent id in micro-thesaurusdisableIndexation
- true not to index the term, false otherwisecom.opensymphony.workflow.WorkflowException
- if an error occurs in the created terms's workflowpublic void moveTerm(Content term, TraversableAmetysObject parent) throws AmetysRepositoryException
term
- the term to moveparent
- The parent ametys object, to where the term will be movedAmetysRepositoryException
- if an error occurs while manipulating the repositoryprotected String _getContentName(String title)
title
- the content's titlepublic boolean isCandidate(Content content)
content
- The contenttrue
if it is a candidateprivate boolean _checkReferenced(Content term)
public Map<String,Object> getTermsPaths(List<String> termIds)
termIds
- the list of terms idspublic String getTermPath(Content term)
term
- The content termAmetysRepositoryException
- if an error occurs.public ModifiableTraversableAmetysObject getRootNode() throws AmetysRepositoryException
AmetysRepositoryException
- if a repository error occurs.protected ModifiableTraversableAmetysObject _getOrCreateNode(ModifiableTraversableAmetysObject parentNode, String nodeName, String nodeType) throws AmetysRepositoryException
parentNode
- the parent nodenodeName
- the name of the nodenodeType
- the type of the nodeAmetysRepositoryException
- if an error occurs when manipulating the repositorypublic Map<String,Object> filterTermsByRegExp(String value, String parentId)
value
- the value to matchparentId
- the parent node idprivate void _getMatchingTerm(String value, TraversableAmetysObject ao, List<Map<String,Object>> matchingPaths)
value
- the value to matchao
- the ametys objectmatchingPaths
- the matching paths