Package org.ametys.runtime.model
Class AbstractModelItemParser
java.lang.Object
org.ametys.runtime.model.AbstractModelItemParser
- Direct Known Subclasses:
CompositeDefinitionParser,ElementDefinitionParser,RepeaterDefinitionParser
ModelItem parser from an XML configuration.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ModelItemTypeExtensionPointThe extension point to use to get available model items types -
Constructor Summary
ConstructorsConstructorDescriptionAbstractModelItemParser(ModelItemTypeExtensionPoint modelItemTypeExtensionPoint) Creates a model item parser. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ModelItem_createModelItem(Configuration itemConfig) Create the model item to populate it.protected StringRetrieves the name of the configuration attribute that contains the name of the model itemprotected DisableConditions_parseConditions(Configuration disableConditionsConfiguration) Parses the disable condition.protected 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 Details
-
_modelItemTypeExtensionPoint
The extension point to use to get available model items types
-
-
Constructor Details
-
AbstractModelItemParser
Creates a model item parser.- Parameters:
modelItemTypeExtensionPoint- the extension point to use to get available model items types
-
-
Method Details
-
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
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
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
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 model item- Returns:
- result the parsed disable condition to be converted in JSON
- Throws:
ConfigurationException- if an error occurred
-
_parseConditions
protected DisableConditions _parseConditions(Configuration disableConditionsConfiguration) throws ConfigurationException Parses the disable condition.- Parameters:
disableConditionsConfiguration- the configuration of the disable condition- Returns:
- result the parsed disable condition to be converted in JSON
- Throws:
ConfigurationException- if an error occurred
-
_parseWidget
Parses the widget.- Parameters:
definitionConfig- the element definition configuration to use.- Returns:
- the widget or
nullif 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.
-