Package org.ametys.runtime.model
Class ElementDefinitionParser
- java.lang.Object
-
- org.ametys.runtime.model.AbstractModelItemParser
-
- org.ametys.runtime.model.ElementDefinitionParser
-
- Direct Known Subclasses:
AbstractStaticSchedulable.SchedulableParameterParser,ConfigParameterDefinitionParser,ContentAttributeDefinitionParser,CredentialProviderFactory.CredentialProviderModelParameterParser,GroupDirectoryFactory.GroupDirectoryModelParameterParser,ServiceParameterDefinitionParser,SiteParameterParser,SkinParameterParser,UserDirectoryFactory.UserDirectoryModelParameterParser,ViewParameterDefinitionParser
public class ElementDefinitionParser extends AbstractModelItemParser
ElementDefinitionparser from an XML configuration.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Logger__LOGGERprivate ThreadSafeComponentManager<Enumerator>_enumeratorManagerprivate Map<ElementDefinition,String>_enumeratorsToLookupprivate ThreadSafeComponentManager<Validator>_validatorManagerprivate Map<ElementDefinition,String>_validatorsToLookup-
Fields inherited from class org.ametys.runtime.model.AbstractModelItemParser
_modelItemTypeExtensionPoint
-
-
Constructor Summary
Constructors Constructor Description ElementDefinitionParser(AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> modelItemTypeExtensionPoint, ThreadSafeComponentManager<Enumerator> enumeratorManager, ThreadSafeComponentManager<Validator> validatorManager)Creates an element definition parser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ElementDefinition_createModelItem(Configuration definitionConfig)Create the model item to populate it.protected void_parseAndSetEnumerator(String pluginName, String catalog, ElementDefinition definition, Configuration definitionConfig)Parses the enumerator.protected void_parseAndSetValidator(String pluginName, ElementDefinition definition, Configuration definitionConfig)Parses the validator.protected Object_parseDefaultValue(Configuration definitionConfig, ElementDefinition definition)Parses the default value.protected DisableConditions_parseDisableConditions(Configuration definitionConfiguration)Parses the disable condition.protected Boolean_parseMultiple(Configuration definitionConfig)Parses the multiple attribute.protected String_parseWidget(Configuration definitionConfig)Parses the widget.protected Map<String,I18nizableText>_parseWidgetParameters(Configuration definitionConfig, String pluginName)Parses the widget's parametersvoidlookupComponents()Retrieves local validators and enumerators components and set them into previous parsed element definition.<T extends ModelItem>
Tparse(ServiceManager serviceManager, String pluginName, String catalog, Configuration definitionConfig, Model model, ModelItemGroup parent)Parses an element definition from a XML configuration.-
Methods inherited from class org.ametys.runtime.model.AbstractModelItemParser
_getNameConfigurationAttribute, _parseI18nizableText, _parseI18nizableText, _parseName, _parseType, parse
-
-
-
-
Field Detail
-
__LOGGER
private static final org.slf4j.Logger __LOGGER
-
_enumeratorManager
private ThreadSafeComponentManager<Enumerator> _enumeratorManager
-
_validatorManager
private ThreadSafeComponentManager<Validator> _validatorManager
-
_validatorsToLookup
private final Map<ElementDefinition,String> _validatorsToLookup
-
_enumeratorsToLookup
private final Map<ElementDefinition,String> _enumeratorsToLookup
-
-
Constructor Detail
-
ElementDefinitionParser
public ElementDefinitionParser(AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> modelItemTypeExtensionPoint, ThreadSafeComponentManager<Enumerator> enumeratorManager, ThreadSafeComponentManager<Validator> validatorManager)
Creates an element definition parser.- Parameters:
modelItemTypeExtensionPoint- the extension point to use to get available element typesenumeratorManager- the enumerator component manager.validatorManager- the validator component manager.
-
-
Method Detail
-
parse
public <T extends ModelItem> T parse(ServiceManager serviceManager, String pluginName, String catalog, Configuration definitionConfig, Model model, ModelItemGroup parent) throws ConfigurationException
Description copied from class:AbstractModelItemParserParses an element definition from a XML configuration.- Overrides:
parsein classAbstractModelItemParser- Type Parameters:
T- type of the parsed item- Parameters:
serviceManager- the service managerpluginName- the plugin name declaring this item.catalog- the catalogdefinitionConfig- 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 ElementDefinition _createModelItem(Configuration definitionConfig) throws ConfigurationException
Description copied from class:AbstractModelItemParserCreate the model item to populate it.- Specified by:
_createModelItemin classAbstractModelItemParser- Parameters:
definitionConfig- the model item configuration to use.- Returns:
- the item instantiated.
- Throws:
ConfigurationException- if the configuration is not valid.
-
_parseDefaultValue
protected Object _parseDefaultValue(Configuration definitionConfig, ElementDefinition definition) throws ConfigurationException
Parses the default value.- Parameters:
definitionConfig- the element definition configuration.definition- the element definition.- Returns:
- the default value or
nullif none defined. - Throws:
ConfigurationException- if the configuration is not valid.
-
_parseMultiple
protected Boolean _parseMultiple(Configuration definitionConfig) throws ConfigurationException
Parses the multiple attribute.- Parameters:
definitionConfig- the element definition configuration to use.- Returns:
- the true if the element is multiple, false otherwise.
- Throws:
ConfigurationException- if the configuration is not valid.
-
_parseWidget
protected String _parseWidget(Configuration definitionConfig) throws ConfigurationException
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.
-
_parseAndSetEnumerator
protected void _parseAndSetEnumerator(String pluginName, String catalog, ElementDefinition definition, Configuration definitionConfig) throws ConfigurationException
Parses the enumerator.- Parameters:
pluginName- the plugin name.catalog- the catalogdefinition- the element definition.definitionConfig- the element definition configuration.- Throws:
ConfigurationException- if the configuration is not valid.
-
_parseAndSetValidator
protected void _parseAndSetValidator(String pluginName, ElementDefinition definition, Configuration definitionConfig) throws ConfigurationException
Parses the validator.- Parameters:
pluginName- the plugin name.definition- the element definition.definitionConfig- the element definition configuration.- 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
-
lookupComponents
public void lookupComponents() throws Exception
Retrieves local validators and enumerators components and set them into previous parsed element definition.- Throws:
Exception- if an error occurs.
-
-