Package org.ametys.cms.contenttype
Class ContentAttributeDefinition
- java.lang.Object
-
- org.ametys.runtime.model.AbstractModelItem
-
- org.ametys.runtime.model.ElementDefinition<T>
-
- org.ametys.cms.contenttype.AttributeDefinition<ContentValue>
-
- org.ametys.cms.contenttype.ContentAttributeDefinition
-
- All Implemented Interfaces:
Comparable<ModelItem>
,RestrictedModelItem<Content>
,ModelItem
,ModelItemAccessor
,Labelable
,ModifiableLabelable
public class ContentAttributeDefinition extends AttributeDefinition<ContentValue> implements ModelItemAccessor
Definition of content types attributes of type Content
-
-
Field Summary
Fields Modifier and Type Field Description private ContentTypeExtensionPoint
_contentTypeExtensionPoint
private String
_contentTypeId
private ContentTypesHelper
_contentTypesHelper
private boolean
_forceInvert
private String
_invertRelationPath
private boolean
_isDefaultValueAlreadyChecked
static String
ATTRIBUTE_DEFAULT_VALUE_TYPE
attribute type for default values-
Fields inherited from class org.ametys.runtime.model.ElementDefinition
_logger, CONFIG_DEFAULT_VALUE_TYPE
-
Fields inherited from class org.ametys.runtime.model.AbstractModelItem
__serviceManager
-
Fields inherited from interface org.ametys.runtime.model.ModelItem
ITEM_PATH_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description ContentAttributeDefinition(ContentTypeExtensionPoint contentTypeExtensionPoint, ContentTypesHelper contentAttributeTypeExtensionPoint)
Defintion's constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Object
_checkAndParseAttributeDefaultValue(String attributeName, Configuration defaultValueConfiguration)
protected ContentValue
_getDefaultValue(String defaultValueType, Object parsedDefaultValue)
Retrieves the default value from the parsed one, according to the type of the default valueprotected Map<String,Object>
_toJSON(DefinitionContext context)
Converts the model item in a JSON mapvoid
checkDefaultValue()
Checks the default value of this definitionString
getContentTypeId()
Get the attribute's content type identifier.boolean
getForceInvert()
Returns true if mutual relationship should be set regardless of user's rightsString
getInvertRelationPath()
Get the attribute's mutual relationship path.Collection<? extends ModelItem>
getModelItems()
Retrieves all the model items of this accessorvoid
setContentTypeId(String contentTypeId)
Set the attribute's content type identifier.void
setForceInvert(boolean force)
Force mutual relationship regardless of user's rights (only applicable for an attribute with invert relation path).void
setInvertRelationPath(String invertRelationPath)
Set the attribute's mutual relationship path.-
Methods inherited from class org.ametys.cms.contenttype.AttributeDefinition
_getExternalizableDataProviderExtensionPoint, _getRestrictedModelItemHelper, _shouldJSONBeEmpty, canRead, canWrite, setRestrictions
-
Methods inherited from class org.ametys.runtime.model.ElementDefinition
_getParsedDefaultValues, getCustomEnumerator, getCustomValidator, getDefaultValue, getDisableConditions, getEnumerator, getEnumeratorConfiguration, getPluginName, getType, getValidator, getValidatorConfiguration, getWidget, getWidgetParameters, isMultiple, of, setCustomEnumerator, setCustomValidator, setDefaultValue, setDisableConditions, setEnumerator, setEnumeratorConfiguration, setMultiple, setParsedDefaultValues, setPluginName, setType, setValidator, setValidatorConfiguration, setWidget, setWidgetParameters
-
Methods inherited from class org.ametys.runtime.model.AbstractModelItem
addItemChecker, compareTo, equals, getDescription, getItemCheckers, getLabel, getModel, getName, getParent, getPath, hashCode, setDescription, setLabel, setModel, setName, setParent, setServiceManager, toJSON, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface org.ametys.runtime.util.Labelable
getDescription, getLabel, getName
-
Methods inherited from interface org.ametys.runtime.model.ModelItem
addItemChecker, getItemCheckers, getModel, getParent, getPath, getType, setModel, setParent, setType, toJSON
-
Methods inherited from interface org.ametys.runtime.model.ModelItemAccessor
getChild, getModelItem, hasModelItem
-
Methods inherited from interface org.ametys.runtime.util.ModifiableLabelable
setDescription, setLabel, setName
-
-
-
-
Field Detail
-
ATTRIBUTE_DEFAULT_VALUE_TYPE
public static final String ATTRIBUTE_DEFAULT_VALUE_TYPE
attribute type for default values- See Also:
- Constant Field Values
-
_contentTypesHelper
private ContentTypesHelper _contentTypesHelper
-
_contentTypeExtensionPoint
private ContentTypeExtensionPoint _contentTypeExtensionPoint
-
_contentTypeId
private String _contentTypeId
-
_invertRelationPath
private String _invertRelationPath
-
_forceInvert
private boolean _forceInvert
-
_isDefaultValueAlreadyChecked
private boolean _isDefaultValueAlreadyChecked
-
-
Constructor Detail
-
ContentAttributeDefinition
public ContentAttributeDefinition(ContentTypeExtensionPoint contentTypeExtensionPoint, ContentTypesHelper contentAttributeTypeExtensionPoint)
Defintion's constructor- Parameters:
contentTypeExtensionPoint
- the content type extension pointcontentAttributeTypeExtensionPoint
- the content attribute type extension point
-
-
Method Detail
-
getContentTypeId
public String getContentTypeId()
Get the attribute's content type identifier.- Returns:
- the attribute's content type identifier.
-
setContentTypeId
public void setContentTypeId(String contentTypeId)
Set the attribute's content type identifier.- Parameters:
contentTypeId
- the content type identifier to set.
-
checkDefaultValue
public void checkDefaultValue() throws ConfigurationException
Checks the default value of this definition- Throws:
ConfigurationException
- if there is a problem with default value declaration
-
_checkAndParseAttributeDefaultValue
private Object _checkAndParseAttributeDefaultValue(String attributeName, Configuration defaultValueConfiguration) throws ConfigurationException
- Throws:
ConfigurationException
-
_getDefaultValue
protected ContentValue _getDefaultValue(String defaultValueType, Object parsedDefaultValue)
Description copied from class:ElementDefinition
Retrieves the default value from the parsed one, according to the type of the default value- Overrides:
_getDefaultValue
in classElementDefinition<ContentValue>
- Parameters:
defaultValueType
- the type of the default valueparsedDefaultValue
- the parsed default value (can be anI18nizableText
, a config parameter name, ... depending on the default value type)- Returns:
- the default value.
-
getInvertRelationPath
public String getInvertRelationPath()
Get the attribute's mutual relationship path.- Returns:
- the attribute's mutual relationship path.
-
setInvertRelationPath
public void setInvertRelationPath(String invertRelationPath)
Set the attribute's mutual relationship path.- Parameters:
invertRelationPath
- the attribute's mutual relationship path, separated by slashes.
-
setForceInvert
public void setForceInvert(boolean force)
Force mutual relationship regardless of user's rights (only applicable for an attribute with invert relation path).- Parameters:
force
- true to force mutual relationship regardless of user's rights
-
getForceInvert
public boolean getForceInvert()
Returns true if mutual relationship should be set regardless of user's rights- Returns:
- true if mutual relationship should be set regardless of user's rights
-
getModelItems
public Collection<? extends ModelItem> getModelItems()
Description copied from interface:ModelItemAccessor
Retrieves all the model items of this accessor- Specified by:
getModelItems
in interfaceModelItemAccessor
- Returns:
- the model items
-
_toJSON
protected Map<String,Object> _toJSON(DefinitionContext context) throws ProcessingException
Description copied from class:AbstractModelItem
Converts the model item in a JSON map- Overrides:
_toJSON
in classAttributeDefinition<ContentValue>
- Parameters:
context
- the context of the definition- Returns:
- The model item as a JSON map
- Throws:
ProcessingException
- If an error occurs when converting the model item
-
-