Package org.ametys.runtime.model
Class AbstractModelItemParser
- java.lang.Object
-
- org.ametys.runtime.model.AbstractModelItemParser
-
- Direct Known Subclasses:
CompositeDefinitionParser
,ElementDefinitionParser
,RepeaterDefinitionParser
public abstract class AbstractModelItemParser extends Object
ModelItem
parser from an XML configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType>
_modelItemTypeExtensionPoint
The extension point to use to get available model items types
-
Constructor Summary
Constructors Constructor Description AbstractModelItemParser(AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> modelItemTypeExtensionPoint)
Creates a model item parser.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ModelItem
_createModelItem(Configuration itemConfig)
Create the model item to populate it.protected String
_getNameConfigurationAttribute()
Retrieves the name of the configuration attribute that contains the name of the model itemprotected DisableConditions
_parseDisableConditions(Configuration definitionConfiguration)
Parses the disable condition.protected I18nizableText
_parseI18nizableText(Configuration config, String catalog, String name)
Parses a mandatory i18n text configuration, throwing an exception if empty.protected I18nizableText
_parseI18nizableText(Configuration config, String catalog, String name, String defaultValueCatalog, String defaultValue)
Parse an optional i18n text configuration, with a default i18n text value.protected String
_parseName(Configuration itemConfig)
Parses the name of the model item.protected ModelItemType
_parseType(Configuration config)
Parses the type.protected String
_parseWidget(Configuration definitionConfig)
Parses the widget.protected Map<String,I18nizableText>
_parseWidgetParameters(Configuration definitionConfig, String pluginName)
Parses the widget's parameters<T extends ModelItem>
Tparse(ServiceManager serviceManager, String pluginName, String catalog, Configuration itemConfig, Model model, ModelItemGroup parent)
Parses an element definition from a XML configuration.<T extends ModelItem>
Tparse(ServiceManager serviceManager, String pluginName, Configuration itemConfig, Model model, ModelItemGroup parent)
Parses an element definition from a XML configuration.
-
-
-
Field Detail
-
_modelItemTypeExtensionPoint
protected AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> _modelItemTypeExtensionPoint
The extension point to use to get available model items types
-
-
Constructor Detail
-
AbstractModelItemParser
public AbstractModelItemParser(AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> modelItemTypeExtensionPoint)
Creates a model item parser.- Parameters:
modelItemTypeExtensionPoint
- the extension point to use to get available model items types
-
-
Method Detail
-
parse
public <T extends ModelItem> T parse(ServiceManager serviceManager, String pluginName, Configuration itemConfig, Model model, ModelItemGroup parent) throws ConfigurationException
Parses an element definition from a XML configuration.- Type Parameters:
T
- type of the parsed item- Parameters:
serviceManager
- the service managerpluginName
- the plugin name declaring this item.itemConfig
- the XML configuration of the model item.model
- the model which defines the model itemparent
- the parent of the model item to create. Can be null if the model item to parse has no parent- Returns:
- the parsed model item.
- Throws:
ConfigurationException
- if the configuration is not valid.
-
parse
public <T extends ModelItem> T parse(ServiceManager serviceManager, String pluginName, String catalog, Configuration itemConfig, Model model, ModelItemGroup parent) throws ConfigurationException
Parses an element definition from a XML configuration.- Type Parameters:
T
- type of the parsed item- Parameters:
serviceManager
- the service managerpluginName
- the plugin name declaring this item.catalog
- the catalogitemConfig
- the XML configuration of the model item.model
- the model which defines the model itemparent
- the parent of the model item to create. Can be null if the model item to parse has no parent- Returns:
- the parsed model item.
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_createModelItem
protected abstract ModelItem _createModelItem(Configuration itemConfig) throws ConfigurationException
Create the model item to populate it.- Parameters:
itemConfig
- the model item configuration to use.- Returns:
- the item instantiated.
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseName
protected String _parseName(Configuration itemConfig) throws ConfigurationException
Parses the name of the model item.- Parameters:
itemConfig
- the model item configuration to use.- Returns:
- the name of the model item.
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_getNameConfigurationAttribute
protected String _getNameConfigurationAttribute()
Retrieves the name of the configuration attribute that contains the name of the model item- Returns:
- the name of the configuration attribute that contains the name of the model item
-
_parseI18nizableText
protected I18nizableText _parseI18nizableText(Configuration config, String catalog, String name) throws ConfigurationException
Parses a mandatory i18n text configuration, throwing an exception if empty.- Parameters:
config
- the configuration to use.catalog
- the catalogname
- the child name.- Returns:
- the i18n text.
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseI18nizableText
protected I18nizableText _parseI18nizableText(Configuration config, String catalog, String name, String defaultValueCatalog, String defaultValue)
Parse an optional i18n text configuration, with a default i18n text value.- Parameters:
config
- the configuration to use.catalog
- the catalogname
- the child name.defaultValueCatalog
- the catalog of the default i18n text valuedefaultValue
- the default i18n text value.- Returns:
- the i18n text.
-
_parseType
protected ModelItemType _parseType(Configuration config) throws ConfigurationException
Parses the type.- Parameters:
config
- the model item configuration to use.- Returns:
- the type.
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseDisableConditions
protected DisableConditions _parseDisableConditions(Configuration definitionConfiguration) throws ConfigurationException
Parses the disable condition.- Parameters:
definitionConfiguration
- the configuration of the disable condition- Returns:
- result the parsed disable condition to be converted in JSON
- Throws:
ConfigurationException
- if an error occurred
-
_parseWidget
protected String _parseWidget(Configuration definitionConfig) throws ConfigurationException
Parses the widget.- Parameters:
definitionConfig
- the element definition configuration to use.- Returns:
- the widget or
null
if none defined. - Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseWidgetParameters
protected Map<String,I18nizableText> _parseWidgetParameters(Configuration definitionConfig, String pluginName) throws ConfigurationException
Parses the widget's parameters- Parameters:
definitionConfig
- the parameter ele;ent definition to use.pluginName
- the current plugin name.- Returns:
- the widget's parameters in a Map
- Throws:
ConfigurationException
- if the configuration is not valid.
-
-