Package org.ametys.runtime.model
Class DefaultElementDefinition<T>
java.lang.Object
org.ametys.runtime.model.AbstractModelItem
org.ametys.runtime.model.DefaultElementDefinition<T>
- Type Parameters:
T
- Type of the element value
- All Implemented Interfaces:
Comparable<ModelItem>
,ElementDefinition<T>
,ModelItem
,Labelable
,ModifiableLabelable
- Direct Known Subclasses:
AbstractProperty
,AttributeDefinition
,DefaultContentElementDefinition
,ServiceParameter
,ViewParameter
The definition of a single model item (parameter, attribute)
-
Field Summary
Fields inherited from class org.ametys.runtime.model.AbstractModelItem
__serviceManager
Fields inherited from interface org.ametys.runtime.model.ElementDefinition
CONFIG_DEFAULT_VALUE_TYPE
Fields inherited from interface org.ametys.runtime.model.ModelItem
ITEM_PATH_SEPARATOR
-
Constructor Summary
ConstructorDescriptionDefault constructor.DefaultElementDefinition
(String name, boolean isMultiple, ElementType<T> type) Constructor used to create simple models and itemsDefaultElementDefinition
(ElementDefinition<T> definitionToCopy) Constructor by copying an existingElementDefinition
. -
Method Summary
Modifier and TypeMethodDescriptionprotected T
_getDefaultValue
(String defaultValueType, Object parsedDefaultValue) Retrieves the default value from the parsed one, according to the type of the default valueRetrieves the parsed default values_toJSON
(DefinitionContext context) Converts the model item in a JSON mapRetrieves the custom enumerator's class nameRetrieves the custom validator's class name<X> X
Retrieves the default value, as an object corresponding to the definition's type and cardinality Retrievesnull
if no default value is defined for this definitionRetrieves the enumerator.Retrieves the custom enumerator's configurationgetType()
Retrieves the type.Retrieves the validator.Retrieves the custom validator's configuraitonRetrieves the widget to use for rendering.Get the widget's parametersboolean
Test if the element is multiple.static DefaultElementDefinition
Creates aDefaultElementDefinition
void
setCustomEnumerator
(String customEnumerator) Set the custom enumerator's class namevoid
setCustomValidator
(String customValidator) Set the custom validator's class namevoid
setDefaultValue
(T defaultValue) Set a default value to the definition The default value is single, classic default valuevoid
setEnumerator
(Enumerator<T> enumerator) Set the enumerator.void
setEnumeratorConfiguration
(Configuration enumeratorConfiguration) Set the custom enumerator's configurationvoid
setMultiple
(boolean isMultiple) Set the element multiple status.void
setParsedDefaultValues
(List<Pair<String, Object>> parsedDefaultValues) Set the parsed default values.void
setType
(ModelItemType type) Set the type.void
setValidator
(Validator validator) Set the validator.void
setValidatorConfiguration
(Configuration validatorConfiguration) Set the custom validator's configurationvoid
Set the widget.void
setWidgetParameters
(Map<String, I18nizableText> params) Set the widget's parametersvoid
toSAX
(ContentHandler contentHandler, DefinitionContext context) Generates SAX events for the model itemMethods inherited from class org.ametys.runtime.model.AbstractModelItem
_shouldJSONBeEmpty, _widgetParameterToSAX, _widgetToSAX, addItemChecker, compareTo, equals, getDescription, getDisableConditions, getItemCheckers, getLabel, getModel, getName, getParent, getPath, getPluginName, hashCode, setDescription, setDisableConditions, setLabel, setModel, setName, setParent, setPluginName, 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.model.ElementDefinition
getCriterionEnumerator, isEditable
Methods inherited from interface org.ametys.runtime.util.Labelable
getDescription, getLabel, getName
Methods inherited from interface org.ametys.runtime.model.ModelItem
addItemChecker, getCriterionWidget, getCriterionWidgetParameters, getDisableConditions, getItemCheckers, getModel, getParent, getPath, getPluginName, setDisableConditions, setModel, setParent, setPluginName, toJSON
Methods inherited from interface org.ametys.runtime.util.ModifiableLabelable
setDescription, setLabel, setName
-
Field Details
-
_logger
The definition logger
-
-
Constructor Details
-
DefaultElementDefinition
public DefaultElementDefinition()Default constructor. -
DefaultElementDefinition
Constructor used to create simple models and items- Parameters:
name
- the name of the definitionisMultiple
- the element multiple statustype
- the type of the definition
-
DefaultElementDefinition
Constructor by copying an existingElementDefinition
.- Parameters:
definitionToCopy
- TheElementDefinition
to copy
-
-
Method Details
-
getType
Description copied from interface:ModelItem
Retrieves the type.- Specified by:
getType
in interfaceElementDefinition<T>
- Specified by:
getType
in interfaceModelItem
- Returns:
- the type.
-
setType
Description copied from interface:ModelItem
Set the type. -
getEnumerator
Description copied from interface:ElementDefinition
Retrieves the enumerator.- Specified by:
getEnumerator
in interfaceElementDefinition<T>
- Returns:
- the enumerator or
null
if none is defined.
-
setEnumerator
Description copied from interface:ElementDefinition
Set the enumerator.- Specified by:
setEnumerator
in interfaceElementDefinition<T>
- Parameters:
enumerator
- the enumerator.
-
getCustomEnumerator
Description copied from interface:ElementDefinition
Retrieves the custom enumerator's class name- Specified by:
getCustomEnumerator
in interfaceElementDefinition<T>
- Returns:
- the custom enumerator's class name
-
setCustomEnumerator
Description copied from interface:ElementDefinition
Set the custom enumerator's class name- Specified by:
setCustomEnumerator
in interfaceElementDefinition<T>
- Parameters:
customEnumerator
- the custom enumerator's class name
-
getEnumeratorConfiguration
Description copied from interface:ElementDefinition
Retrieves the custom enumerator's configuration- Specified by:
getEnumeratorConfiguration
in interfaceElementDefinition<T>
- Returns:
- the custom enumerator's configuration
-
setEnumeratorConfiguration
Description copied from interface:ElementDefinition
Set the custom enumerator's configuration- Specified by:
setEnumeratorConfiguration
in interfaceElementDefinition<T>
- Parameters:
enumeratorConfiguration
- the custom enumerator's configuration
-
getValidator
Description copied from interface:ElementDefinition
Retrieves the validator.- Specified by:
getValidator
in interfaceElementDefinition<T>
- Returns:
- the validator or
null
if none is defined.
-
setValidator
Description copied from interface:ElementDefinition
Set the validator.- Specified by:
setValidator
in interfaceElementDefinition<T>
- Parameters:
validator
- the validator.
-
getCustomValidator
Description copied from interface:ElementDefinition
Retrieves the custom validator's class name- Specified by:
getCustomValidator
in interfaceElementDefinition<T>
- Returns:
- the custom validator's class name
-
setCustomValidator
Description copied from interface:ElementDefinition
Set the custom validator's class name- Specified by:
setCustomValidator
in interfaceElementDefinition<T>
- Parameters:
customValidator
- the custom validator's class name
-
getValidatorConfiguration
Description copied from interface:ElementDefinition
Retrieves the custom validator's configuraiton- Specified by:
getValidatorConfiguration
in interfaceElementDefinition<T>
- Returns:
- the custom validator's configuration
-
getWidget
Description copied from interface:ModelItem
Retrieves the widget to use for rendering.- Specified by:
getWidget
in interfaceModelItem
- Overrides:
getWidget
in classAbstractModelItem
- Returns:
- the widget or
null
if none is defined.
-
setWidget
Description copied from interface:ModelItem
Set the widget.- Specified by:
setWidget
in interfaceModelItem
- Overrides:
setWidget
in classAbstractModelItem
- Parameters:
widget
- the widget.
-
getWidgetParameters
Description copied from interface:ModelItem
Get the widget's parameters- Specified by:
getWidgetParameters
in interfaceModelItem
- Overrides:
getWidgetParameters
in classAbstractModelItem
- Returns:
- the widget's parameters
-
setWidgetParameters
Description copied from interface:ModelItem
Set the widget's parameters- Specified by:
setWidgetParameters
in interfaceModelItem
- Overrides:
setWidgetParameters
in classAbstractModelItem
- Parameters:
params
- the parameters to set
-
setValidatorConfiguration
Description copied from interface:ElementDefinition
Set the custom validator's configuration- Specified by:
setValidatorConfiguration
in interfaceElementDefinition<T>
- Parameters:
validatorConfiguration
- the custom validator's configuration
-
getDefaultValue
Description copied from interface:ElementDefinition
Retrieves the default value, as an object corresponding to the definition's type and cardinality Retrievesnull
if no default value is defined for this definition- Specified by:
getDefaultValue
in interfaceElementDefinition<T>
- Type Parameters:
X
- The type of the default value- Returns:
- the default value.
-
_getDefaultValue
Retrieves the default value from the parsed one, according to the type of the default value- Parameters:
parsedDefaultValue
- the parsed default value (can be anI18nizableText
, a config parameter name, ... depending on the default value type)defaultValueType
- the type of the default value- Returns:
- the default value.
-
setParsedDefaultValues
Description copied from interface:ElementDefinition
Set the parsed default values. If the definition is not multiple, the list should contain only one element A parsed default value is described by its type and an object depending on the type- Specified by:
setParsedDefaultValues
in interfaceElementDefinition<T>
- Parameters:
parsedDefaultValues
- the parsed default values.
-
setDefaultValue
Description copied from interface:ElementDefinition
Set a default value to the definition The default value is single, classic default value- Specified by:
setDefaultValue
in interfaceElementDefinition<T>
- Parameters:
defaultValue
- the default value to set
-
_getParsedDefaultValues
Description copied from interface:ElementDefinition
Retrieves the parsed default values- Specified by:
_getParsedDefaultValues
in interfaceElementDefinition<T>
- Returns:
- the parsed default values
-
isMultiple
Description copied from interface:ElementDefinition
Test if the element is multiple.- Specified by:
isMultiple
in interfaceElementDefinition<T>
- Returns:
true
if the metadata is multiple.
-
setMultiple
Description copied from interface:ElementDefinition
Set the element multiple status.- Specified by:
setMultiple
in interfaceElementDefinition<T>
- Parameters:
isMultiple
- the element multiple status.
-
_toJSON
Description copied from class:AbstractModelItem
Converts the model item in a JSON map- Overrides:
_toJSON
in classAbstractModelItem
- 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
-
toSAX
Description copied from interface:ModelItem
Generates SAX events for the model item- Specified by:
toSAX
in interfaceModelItem
- Overrides:
toSAX
in classAbstractModelItem
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventscontext
- the context of the definition- Throws:
SAXException
- if an error occurs during the SAX events generation
-
of
public static DefaultElementDefinition of(String name, boolean isMultiple, String typeId, String availableTypesExtensionPoint) throws UnknownTypeException, BadItemTypeException, ServiceException Creates aDefaultElementDefinition
- Parameters:
name
- the definition's nameisMultiple
- the definition's cardinalitytypeId
- the definition's type identifieravailableTypesExtensionPoint
- the role of the extension point containing all available types for thisDefaultElementDefinition
- Returns:
- the created
DefaultElementDefinition
- Throws:
UnknownTypeException
- if the given type identifier is not available in the extension pointBadItemTypeException
- if the given type identifier can not be used for anElementDefinition
ServiceException
- if an error occurs while getting the extension point of available types
-