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
FieldsFields inherited from class org.ametys.runtime.model.AbstractModelItem
__serviceManagerFields inherited from interface org.ametys.runtime.model.ElementDefinition
CONFIG_DEFAULT_VALUE_TYPEFields inherited from interface org.ametys.runtime.model.ModelItem
ITEM_PATH_SEPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionDefault 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> XRetrieves the default value, as an object corresponding to the definition's type and cardinality Retrievesnullif 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 parametersbooleanTest if the element is multiple.static DefaultElementDefinitionCreates aDefaultElementDefinitionvoidsetCustomEnumerator(String customEnumerator) Set the custom enumerator's class namevoidsetCustomValidator(String customValidator) Set the custom validator's class namevoidsetDefaultValue(T defaultValue) Set a default value to the definition The default value is single, classic default valuevoidsetEnumerator(Enumerator<T> enumerator) Set the enumerator.voidsetEnumeratorConfiguration(Configuration enumeratorConfiguration) Set the custom enumerator's configurationvoidsetMultiple(boolean isMultiple) Set the element multiple status.voidsetParsedDefaultValues(List<Pair<String, Object>> parsedDefaultValues) Set the parsed default values.voidsetType(ModelItemType type) Set the type.voidsetValidator(Validator validator) Set the validator.voidsetValidatorConfiguration(Configuration validatorConfiguration) Set the custom validator's configurationvoidSet the widget.voidsetWidgetParameters(Map<String, I18nizableText> params) Set the widget's parametersvoidtoSAX(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, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.ametys.runtime.model.ElementDefinition
getCriterionEnumerator, isEditableMethods inherited from interface org.ametys.runtime.util.Labelable
getDescription, getLabel, getNameMethods inherited from interface org.ametys.runtime.model.ModelItem
addItemChecker, getCriterionWidget, getCriterionWidgetParameters, getDisableConditions, getItemCheckers, getModel, getParent, getPath, getPluginName, setDisableConditions, setModel, setParent, setPluginName, toJSONMethods 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- TheElementDefinitionto copy
-
-
Method Details
-
getType
Description copied from interface:ModelItemRetrieves the type.- Specified by:
getTypein interfaceElementDefinition<T>- Specified by:
getTypein interfaceModelItem- Returns:
- the type.
-
setType
Description copied from interface:ModelItemSet the type. -
getEnumerator
Description copied from interface:ElementDefinitionRetrieves the enumerator.- Specified by:
getEnumeratorin interfaceElementDefinition<T>- Returns:
- the enumerator or
nullif none is defined.
-
setEnumerator
Description copied from interface:ElementDefinitionSet the enumerator.- Specified by:
setEnumeratorin interfaceElementDefinition<T>- Parameters:
enumerator- the enumerator.
-
getCustomEnumerator
Description copied from interface:ElementDefinitionRetrieves the custom enumerator's class name- Specified by:
getCustomEnumeratorin interfaceElementDefinition<T>- Returns:
- the custom enumerator's class name
-
setCustomEnumerator
Description copied from interface:ElementDefinitionSet the custom enumerator's class name- Specified by:
setCustomEnumeratorin interfaceElementDefinition<T>- Parameters:
customEnumerator- the custom enumerator's class name
-
getEnumeratorConfiguration
Description copied from interface:ElementDefinitionRetrieves the custom enumerator's configuration- Specified by:
getEnumeratorConfigurationin interfaceElementDefinition<T>- Returns:
- the custom enumerator's configuration
-
setEnumeratorConfiguration
Description copied from interface:ElementDefinitionSet the custom enumerator's configuration- Specified by:
setEnumeratorConfigurationin interfaceElementDefinition<T>- Parameters:
enumeratorConfiguration- the custom enumerator's configuration
-
getValidator
Description copied from interface:ElementDefinitionRetrieves the validator.- Specified by:
getValidatorin interfaceElementDefinition<T>- Returns:
- the validator or
nullif none is defined.
-
setValidator
Description copied from interface:ElementDefinitionSet the validator.- Specified by:
setValidatorin interfaceElementDefinition<T>- Parameters:
validator- the validator.
-
getCustomValidator
Description copied from interface:ElementDefinitionRetrieves the custom validator's class name- Specified by:
getCustomValidatorin interfaceElementDefinition<T>- Returns:
- the custom validator's class name
-
setCustomValidator
Description copied from interface:ElementDefinitionSet the custom validator's class name- Specified by:
setCustomValidatorin interfaceElementDefinition<T>- Parameters:
customValidator- the custom validator's class name
-
getValidatorConfiguration
Description copied from interface:ElementDefinitionRetrieves the custom validator's configuraiton- Specified by:
getValidatorConfigurationin interfaceElementDefinition<T>- Returns:
- the custom validator's configuration
-
getWidget
Description copied from interface:ModelItemRetrieves the widget to use for rendering.- Specified by:
getWidgetin interfaceModelItem- Overrides:
getWidgetin classAbstractModelItem- Returns:
- the widget or
nullif none is defined.
-
setWidget
Description copied from interface:ModelItemSet the widget.- Specified by:
setWidgetin interfaceModelItem- Overrides:
setWidgetin classAbstractModelItem- Parameters:
widget- the widget.
-
getWidgetParameters
Description copied from interface:ModelItemGet the widget's parameters- Specified by:
getWidgetParametersin interfaceModelItem- Overrides:
getWidgetParametersin classAbstractModelItem- Returns:
- the widget's parameters
-
setWidgetParameters
Description copied from interface:ModelItemSet the widget's parameters- Specified by:
setWidgetParametersin interfaceModelItem- Overrides:
setWidgetParametersin classAbstractModelItem- Parameters:
params- the parameters to set
-
setValidatorConfiguration
Description copied from interface:ElementDefinitionSet the custom validator's configuration- Specified by:
setValidatorConfigurationin interfaceElementDefinition<T>- Parameters:
validatorConfiguration- the custom validator's configuration
-
getDefaultValue
Description copied from interface:ElementDefinitionRetrieves the default value, as an object corresponding to the definition's type and cardinality Retrievesnullif no default value is defined for this definition- Specified by:
getDefaultValuein 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:ElementDefinitionSet 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:
setParsedDefaultValuesin interfaceElementDefinition<T>- Parameters:
parsedDefaultValues- the parsed default values.
-
setDefaultValue
Description copied from interface:ElementDefinitionSet a default value to the definition The default value is single, classic default value- Specified by:
setDefaultValuein interfaceElementDefinition<T>- Parameters:
defaultValue- the default value to set
-
_getParsedDefaultValues
Description copied from interface:ElementDefinitionRetrieves the parsed default values- Specified by:
_getParsedDefaultValuesin interfaceElementDefinition<T>- Returns:
- the parsed default values
-
isMultiple
Description copied from interface:ElementDefinitionTest if the element is multiple.- Specified by:
isMultiplein interfaceElementDefinition<T>- Returns:
trueif the metadata is multiple.
-
setMultiple
Description copied from interface:ElementDefinitionSet the element multiple status.- Specified by:
setMultiplein interfaceElementDefinition<T>- Parameters:
isMultiple- the element multiple status.
-
_toJSON
Description copied from class:AbstractModelItemConverts the model item in a JSON map- Overrides:
_toJSONin 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:ModelItemGenerates SAX events for the model item- Specified by:
toSAXin interfaceModelItem- Overrides:
toSAXin classAbstractModelItem- Parameters:
contentHandler- theContentHandlerthat 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 anElementDefinitionServiceException- if an error occurs while getting the extension point of available types
-