Package org.ametys.runtime.model
Class ElementDefinition<T>
- java.lang.Object
-
- org.ametys.runtime.model.AbstractModelItem
-
- org.ametys.runtime.model.ElementDefinition<T>
-
- Type Parameters:
T
- Type of the element value
- All Implemented Interfaces:
Comparable<ModelItem>
,ModelItem
,Labelable
,ModifiableLabelable
- Direct Known Subclasses:
AttributeDefinition
,CompareView.CompareElementDefinition
,ServiceParameter
,ViewParameter
public class ElementDefinition<T> extends AbstractModelItem
The definition of a single model item (parameter, attribute)
-
-
Field Summary
Fields Modifier and Type Field Description private String
_customEnumerator
private String
_customValidator
private T
_defaultValue
private DisableConditions
_disableConditions
private Enumerator<T>
_enumerator
private Configuration
_enumeratorConfiguration
private boolean
_isMultiple
private String
_pluginName
private ElementType<T>
_type
private Validator
_validator
private Configuration
_validatorConfiguration
private String
_widget
private Map<String,I18nizableText>
_widgetParams
-
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 ElementDefinition()
Default constructor.ElementDefinition(String name, boolean isMultiple, ElementType<T> type)
Constructor used to create simple models and itemsElementDefinition(ElementDefinition<T> definitionToCopy)
Constructor by copying an existingElementDefinition
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private Map<String,Object>
_disableConditionstoJSON(DisableConditions disableConditions)
Converts the definition's disable conditions in a JSON mapprivate static Map<String,String>
_disableConditiontoJSON(DisableCondition disableCondition)
String
getCustomEnumerator()
Retrieves the custom enumerator's class nameString
getCustomValidator()
Retrieves the custom validator's class nameT
getDefaultValue()
Retrieves the default value.DisableConditions
getDisableConditions()
Retrieves the disable condition.Enumerator<T>
getEnumerator()
Retrieves the enumerator.Configuration
getEnumeratorConfiguration()
Retrieves the custom enumerator's configurationString
getPluginName()
Retrieves the name of the plugin declaring this element.ElementType<T>
getType()
Retrieves the type.Validator
getValidator()
Retrieves the validator.Configuration
getValidatorConfiguration()
Retrieves the custom validator's configuraitonString
getWidget()
Retrieves the widget to use for rendering.Map<String,I18nizableText>
getWidgetParameters()
Get the widget's parametersboolean
isMultiple()
Test if the element is multiple.static ElementDefinition
of(String name, boolean isMultiple, String typeId, String availableTypesExtensionPoint)
Creates anElementDefinition
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 the default value.void
setDisableConditions(DisableConditions disableConditions)
Sets the disable condition.void
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
setPluginName(String pluginName)
Set the name of the plugin declaring this element.void
setType(ModelItemType type)
Set the type.void
setValidator(Validator validator)
Set the validator.void
setValidatorConfiguration(Configuration validatorConfiguration)
Set the custom validator's configurationvoid
setWidget(String widget)
Set the widget.void
setWidgetParameters(Map<String,I18nizableText> params)
Set the widget's parametersMap<String,Object>
toJSON()
Converts the model item in a JSON map-
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, toString
-
-
-
-
Field Detail
-
_pluginName
private String _pluginName
-
_type
private ElementType<T> _type
-
_widgetParams
private Map<String,I18nizableText> _widgetParams
-
_enumerator
private Enumerator<T> _enumerator
-
_customEnumerator
private String _customEnumerator
-
_enumeratorConfiguration
private Configuration _enumeratorConfiguration
-
_validator
private Validator _validator
-
_customValidator
private String _customValidator
-
_validatorConfiguration
private Configuration _validatorConfiguration
-
_defaultValue
private T _defaultValue
-
_isMultiple
private boolean _isMultiple
-
_disableConditions
private DisableConditions _disableConditions
-
-
Constructor Detail
-
ElementDefinition
public ElementDefinition()
Default constructor.
-
ElementDefinition
public ElementDefinition(String name, boolean isMultiple, ElementType<T> type)
Constructor used to create simple models and items- Parameters:
name
- the name of the definitionisMultiple
- the element multiple statustype
- the type of the definition
-
ElementDefinition
public ElementDefinition(ElementDefinition<T> definitionToCopy)
Constructor by copying an existingElementDefinition
.- Parameters:
definitionToCopy
- TheElementDefinition
to copy
-
-
Method Detail
-
getPluginName
public String getPluginName()
Retrieves the name of the plugin declaring this element.- Returns:
- the plugin name.
-
setPluginName
public void setPluginName(String pluginName)
Set the name of the plugin declaring this element.- Parameters:
pluginName
- the plugin name.
-
getType
public ElementType<T> getType()
Description copied from interface:ModelItem
Retrieves the type.- Returns:
- the type.
-
setType
public void setType(ModelItemType type)
Description copied from interface:ModelItem
Set the type.- Parameters:
type
- the type.
-
getWidget
public String getWidget()
Retrieves the widget to use for rendering.- Returns:
- the widget or
null
if none is defined.
-
getWidgetParameters
public Map<String,I18nizableText> getWidgetParameters()
Get the widget's parameters- Returns:
- the widget's parameters
-
setWidgetParameters
public void setWidgetParameters(Map<String,I18nizableText> params)
Set the widget's parameters- Parameters:
params
- the parameters to set
-
getEnumerator
public Enumerator<T> getEnumerator()
Retrieves the enumerator.- Returns:
- the enumerator or
null
if none is defined.
-
setEnumerator
public void setEnumerator(Enumerator<T> enumerator)
Set the enumerator.- Parameters:
enumerator
- the enumerator.
-
getCustomEnumerator
public String getCustomEnumerator()
Retrieves the custom enumerator's class name- Returns:
- the custom enumerator's class name
-
setCustomEnumerator
public void setCustomEnumerator(String customEnumerator)
Set the custom enumerator's class name- Parameters:
customEnumerator
- the custom enumerator's class name
-
getEnumeratorConfiguration
public Configuration getEnumeratorConfiguration()
Retrieves the custom enumerator's configuration- Returns:
- the custom enumerator's configuration
-
setEnumeratorConfiguration
public void setEnumeratorConfiguration(Configuration enumeratorConfiguration)
Set the custom enumerator's configuration- Parameters:
enumeratorConfiguration
- the custom enumerator's configuration
-
getValidator
public Validator getValidator()
Retrieves the validator.- Returns:
- the validator or
null
if none is defined.
-
setValidator
public void setValidator(Validator validator)
Set the validator.- Parameters:
validator
- the validator.
-
getCustomValidator
public String getCustomValidator()
Retrieves the custom validator's class name- Returns:
- the custom validator's class name
-
setCustomValidator
public void setCustomValidator(String customValidator)
Set the custom validator's class name- Parameters:
customValidator
- the custom validator's class name
-
getValidatorConfiguration
public Configuration getValidatorConfiguration()
Retrieves the custom validator's configuraiton- Returns:
- the custom validator's configuration
-
setValidatorConfiguration
public void setValidatorConfiguration(Configuration validatorConfiguration)
Set the custom validator's configuration- Parameters:
validatorConfiguration
- the custom validator's configuration
-
getDefaultValue
public T getDefaultValue()
Retrieves the default value.- Returns:
- the default value or
null
if none is defined.
-
setDefaultValue
public void setDefaultValue(T defaultValue)
Set the default value.- Parameters:
defaultValue
- the default value.
-
isMultiple
public boolean isMultiple()
Test if the element is multiple.- Returns:
true
if the metadata is multiple.
-
setMultiple
public void setMultiple(boolean isMultiple)
Set the element multiple status.- Parameters:
isMultiple
- the element multiple status.
-
getDisableConditions
public DisableConditions getDisableConditions()
Retrieves the disable condition.- Returns:
- the disable condition or
null
if none is defined.
-
setDisableConditions
public void setDisableConditions(DisableConditions disableConditions)
Sets the disable condition.- Parameters:
disableConditions
- the disable condition.
-
toJSON
public Map<String,Object> toJSON() throws ProcessingException
Description copied from interface:ModelItem
Converts the model item in a JSON map- Specified by:
toJSON
in interfaceModelItem
- Overrides:
toJSON
in classAbstractModelItem
- Returns:
- The model item as a JSON map
- Throws:
ProcessingException
- If an error occurs when converting the model item
-
_disableConditionstoJSON
private Map<String,Object> _disableConditionstoJSON(DisableConditions disableConditions)
Converts the definition's disable conditions in a JSON map- Parameters:
disableConditions
- the disable conditions to convert- Returns:
- The definition's disable conditions as a JSON map
-
_disableConditiontoJSON
private static Map<String,String> _disableConditiontoJSON(DisableCondition disableCondition)
-
of
public static ElementDefinition of(String name, boolean isMultiple, String typeId, String availableTypesExtensionPoint) throws UnknownTypeException, BadItemTypeException, ServiceException
Creates anElementDefinition
- 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 thisElementDefinition
- Returns:
- the created
ElementDefinition
- 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
-
-