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 ContentTypeExtensionPoint |
_contentTypeEP
The extension point for content types
|
protected AmetysObjectResolver |
_resolver
The Ametys objet resolver
|
private BiMap<ContentType,ContentType> |
_topLevelTypeByLeafType
The map leafContentType -> topLevelContentType
|
static String |
ROLE
The Avalon role
|
Constructor and Description |
---|
HierarchicalReferenceTablesHelper() |
Modifier and Type | Method and Description |
---|---|
private boolean |
_checkNoCycle(ContentType parent,
ContentType child) |
private void |
_setMetadata(MetadataDefinition metadataDefinition,
ModifiableContent content,
Content value) |
void |
dispose() |
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.
|
List<ContentType> |
getChildContentTypes(Content refTableEntry)
Gets the content types the children of the given content can have.
|
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 |
getPathInHierarchy(String refTableEntryId)
Get the path of reference table entry in its hierarchy
|
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 |
isHierarchical(ContentType contentType)
Returs true if the given content type is hierarchical, i.e.
|
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) |
void |
setParentMetadata(ModifiableContent content,
Content parent)
Sets the "parent" metadata of the given content
See also
ContentType.getParentMetadata() |
getLogger, setLogger
protected ContentTypeExtensionPoint _contentTypeEP
protected AmetysObjectResolver _resolver
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 Serviceable
ServiceException
public void dispose()
dispose
in interface Disposable
public 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(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 String getPathInHierarchy(String refTableEntryId)
refTableEntryId
- The id of entrypublic List<ContentType> getChildContentTypes(Content refTableEntry)
refTableEntry
- The contentpublic void setParentMetadata(ModifiableContent content, Content parent)
ContentType.getParentMetadata()
content
- The contentparent
- The value of the "parent" metadataprivate void _setMetadata(MetadataDefinition metadataDefinition, ModifiableContent content, Content value)
public String getParent(Content content)
ContentType.getParentMetadata()
content
- The contentpublic List<String> getAllParents(Content content)
content
- The content