public class HierarchicalReferenceTablesHelper extends AbstractLogEnabled implements Component, Serviceable, Disposable
registerRelation(ContentType, ContentType) in order to register a relation between a parent content type and its child content type.| Modifier and Type | Field and Description |
|---|---|
private Set<ContentType> |
_autoReferencingContentTypes
The content types pointing at themselves
|
private BiMap<ContentType,ContentType> |
_childByContentType
The map parent -> child (excepted content types pointing on themselves)
|
protected ContentDAO |
_contentDAO
The content DAO
|
protected ContentHelper |
_contentHelper
Content helper
|
protected ContentTypeExtensionPoint |
_contentTypeEP
The extension point for content types
|
protected ContentTypesHelper |
_cTypeHelper
The content types helper
|
protected AmetysObjectResolver |
_resolver
The Ametys objet resolver
|
private BiMap<ContentType,ContentType> |
_topLevelTypeByLeafType
The map leafContentType -> topLevelContentType
|
static String |
CANDIDATE_CONTENT_TYPE
the candidate content type id
|
static String |
ROLE
The Avalon role
|
private static String |
TAG_CANDIDATE
Tag for reference table
|
| Constructor and Description |
|---|
HierarchicalReferenceTablesHelper() |
| Modifier and Type | Method and Description |
|---|---|
private boolean |
_checkNoCycle(ContentType parent,
ContentType child) |
private void |
_getMatchingPathsFromContent(Content parent,
String value,
List<String> result) |
protected boolean |
_isContentReferenced(Content content,
List<String> contentsId)
Test if content is referenced by other contents than its parent and children
|
private boolean |
_isContentReferenced(Content content,
List<String> contentsId,
Set<String> alreadyVisited) |
protected boolean |
_isParent(String referencingContentId,
Content content)
Check if the referencing content is the parent of the content
|
void |
dispose() |
List<String> |
filterReferenceTablesByRegExp(String value,
String contentId,
String leafContentType)
Get the path of node which match filter regexp
|
Set<String> |
getAllChildren(Content content)
Returns a Set of all the descendants
|
List<String> |
getAllParents(Content content)
Recursively returns the "parent" metadata value for the given content, i.e; will return the parent, the parent of the parent, etc.
|
AmetysObjectIterable<Content> |
getCandidates(String cTypeId)
Return the candidates for given content type
|
Map<String,Object> |
getCandidateValues(String contentId)
Get the metadata values of a candidate
|
List<ContentType> |
getChildContentTypes(Content refTableEntry)
Gets the content types the children of the given content can have.
|
AmetysObjectIterable<Content> |
getDirectChildren(Content content)
Returns the direct children of a content
|
Set<String> |
getHierarchicalContentTypes(String leafContentTypeId)
Get the hierarchy of content types (distinct content types)
|
String |
getParent(Content content)
Returns the "parent" metadata value for the given content, or null if it is not defined for its content types
See also
ContentType.getParentMetadata() |
String |
getParentMetadata(Content content)
Get the parent metadata
|
String |
getParentMetadata(String contentId)
Get the parent metadata
|
Map<String,String> |
getPathInHierarchy(List<String> refTableEntryId)
Get the path of reference table entry in its hierarchy
|
String |
getPathInHierarchy(String refTableEntryId)
Get the path of reference table entry in its hierarchy
|
AmetysObjectIterable<Content> |
getRootChildren(ContentType rootContentType)
Return the contents at the root
|
AmetysObjectIterable<Content> |
getRootChildren(ContentType rootContentType,
boolean excludeCandidates)
Return the contents at the root
|
ContentType |
getTopLevelType(ContentType leafContentType)
Gets the top level content type for the given leaf content type (which defines the hierarchy)
|
boolean |
hasAtLeastOneHierarchy()
Returns true if at least one hierarchy was registered (i.e.
|
boolean |
hasChildContentType(ContentType contentType)
Returns true if the given content type has a child content type
|
boolean |
isCandidate(Content content)
Check if the content is a candidate
|
boolean |
isHierarchical(Content content)
Returns true if the given content has a hierarchical content type, i.e.
|
boolean |
isHierarchical(ContentType contentType)
Returns true if the given content type is hierarchical, i.e.
|
boolean |
isHierarchicalSimpleTree(String contentTypeLeaf)
Return a boolean value to determine if all the contents are simple
|
boolean |
isLeaf(ContentType contentType)
Returns true if the given content type is a leaf content type
|
boolean |
registerRelation(ContentType parent,
ContentType child)
Register a relation between a parent and its child, and update the internal model if it is a valid one.
|
void |
service(ServiceManager manager) |
boolean |
supportCandidates(ContentType contentType)
Determines if this content type supports candidates
|
boolean |
supportCandidates(String contentTypeId)
Determines if this content type supports candidates
|
getLogger, setLoggerpublic static final String CANDIDATE_CONTENT_TYPE
private static final String TAG_CANDIDATE
protected ContentTypeExtensionPoint _contentTypeEP
protected AmetysObjectResolver _resolver
protected ContentHelper _contentHelper
protected ContentTypesHelper _cTypeHelper
protected ContentDAO _contentDAO
private BiMap<ContentType,ContentType> _childByContentType
private Set<ContentType> _autoReferencingContentTypes
private BiMap<ContentType,ContentType> _topLevelTypeByLeafType
public HierarchicalReferenceTablesHelper()
public void service(ServiceManager manager) throws ServiceException
service in interface ServiceableServiceExceptionpublic void dispose()
dispose in interface Disposablepublic boolean registerRelation(ContentType parent, ContentType child)
parent - The parent content typechild - The child content typepublic boolean hasAtLeastOneHierarchy()
public ContentType getTopLevelType(ContentType leafContentType)
leafContentType - the leaf cotnent typeprivate boolean _checkNoCycle(ContentType parent, ContentType child)
public boolean hasChildContentType(ContentType contentType)
contentType - The content typepublic boolean isHierarchical(Content content)
content - The contentpublic boolean isHierarchical(ContentType contentType)
contentType - The content typepublic boolean isLeaf(ContentType contentType)
contentType - The content typepublic Set<String> getHierarchicalContentTypes(String leafContentTypeId)
leafContentTypeId - The id of leaf content typepublic Map<String,String> getPathInHierarchy(List<String> refTableEntryId)
refTableEntryId - The id of entrypublic String getPathInHierarchy(String refTableEntryId)
refTableEntryId - The id of entrypublic List<ContentType> getChildContentTypes(Content refTableEntry)
refTableEntry - The contentpublic Map<String,Object> getCandidateValues(String contentId)
contentId - the id of candidatepublic String getParentMetadata(String contentId)
contentId - The content idpublic String getParentMetadata(Content content)
content - The contentpublic String getParent(Content content)
ContentType.getParentMetadata()content - The contentpublic List<String> getAllParents(Content content)
content - The contentpublic AmetysObjectIterable<Content> getDirectChildren(Content content)
content - the content to get the direct children frompublic Set<String> getAllChildren(Content content)
content - the content to get the children frompublic boolean isHierarchicalSimpleTree(String contentTypeLeaf)
contentTypeLeaf - the contentType id of the leaf contentpublic AmetysObjectIterable<Content> getRootChildren(ContentType rootContentType)
rootContentType - the content type of the contents at the rootpublic AmetysObjectIterable<Content> getRootChildren(ContentType rootContentType, boolean excludeCandidates)
rootContentType - the content type of the contents at the rootexcludeCandidates - true to exclude candidatespublic AmetysObjectIterable<Content> getCandidates(String cTypeId)
cTypeId - the id of content typepublic List<String> filterReferenceTablesByRegExp(String value, String contentId, String leafContentType)
value - the value to matchcontentId - the content id from where we will filterleafContentType - the leaf content typeprivate void _getMatchingPathsFromContent(Content parent, String value, List<String> result)
public boolean supportCandidates(ContentType contentType)
contentType - the content typepublic boolean supportCandidates(String contentTypeId)
contentTypeId - the id of content typepublic boolean isCandidate(Content content)
content - the content to testprotected boolean _isParent(String referencingContentId, Content content)
referencingContentId - The referencing content if to check if it's the parent or notcontent - the child contentprotected boolean _isContentReferenced(Content content, List<String> contentsId)
content - The content to testcontentsId - The list of contents id to delete