Package org.ametys.web.parameters
Class ParametersManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.web.parameters.ParametersManager
-
- All Implemented Interfaces:
LogEnabled
,Component
public class ParametersManager extends AbstractLogEnabled implements Component
Manager to handle parameters
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
_PARAM_UNTOUCHED_BINARY
Constant for untouched binary metadata.static String
ROLE
Avalon Role
-
Constructor Summary
Constructors Constructor Description ParametersManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_addParameterValues(ModelItem item, ModelAwareDataHolder dataHolder, String prefix, Map<String,Object> values)
Add the parameter values to all valuesprotected Map<String,DefinitionAndValue>
_getBrothersDefinitionAndValues(String prefix, Map<String,Object> values, ElementDefinition definition)
Get the definition and value pairs of the given definition brothers.protected boolean
_hasParameterValueOrDefaultValue(String parameterPath, ModelAwareDataHolder dataHolder, Object defaultValue)
True if the parameter has a value or a default valueprotected void
_moveRepeaterEntries(ModifiableModelAwareRepeater repeater, Map<String,Object> values, String repeaterPath)
Moves the repeater entries according to the given values.protected void
_setParameterValues(ModelItem def, Map<String,Object> values, ModifiableModelAwareDataHolder dataHolder, String prefix, Map<String,List<I18nizableText>> allErrors)
Set parameters values of the model itemMap<String,Object>
addPrefixToParameters(Map<String,Object> parameterValues, String prefix)
Add prefix to all parametersMap<String,Object>
getParametersStartWithPrefix(Map<String,Object> parameterValues, String prefix)
Get all parameters which start with prefix and change the name of the attribute removing this prefixMap<String,Object>
getParametersValues(Collection<? extends ModelItem> items, ModelAwareDataHolder dataHolder, String prefix)
Get the parameters valuesList<Map<String,Object>>
getRepeatersValues(Collection<ModelItem> items, ModelAwareDataHolder dataHolder, String prefix)
Get the repeaters valuesMap<String,List<I18nizableText>>
setParameterValues(ModifiableModelAwareDataHolder dataHolder, Collection<? extends ModelItem> modelItems, Map<String,Object> values)
Set parameters values to the data holder for each model items-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_PARAM_UNTOUCHED_BINARY
protected static final String _PARAM_UNTOUCHED_BINARY
Constant for untouched binary metadata.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ParametersManager
public ParametersManager()
-
-
Method Detail
-
setParameterValues
public Map<String,List<I18nizableText>> setParameterValues(ModifiableModelAwareDataHolder dataHolder, Collection<? extends ModelItem> modelItems, Map<String,Object> values)
Set parameters values to the data holder for each model items- Parameters:
dataHolder
- the data holdermodelItems
- the list of model itemsvalues
- the values- Returns:
- the map of possible errors
-
_setParameterValues
protected void _setParameterValues(ModelItem def, Map<String,Object> values, ModifiableModelAwareDataHolder dataHolder, String prefix, Map<String,List<I18nizableText>> allErrors)
Set parameters values of the model item- Parameters:
def
- the model item definitionvalues
- the valuedataHolder
- the data holderprefix
- the prefix to get the parameter valuesallErrors
- the map of possible errors
-
_getBrothersDefinitionAndValues
protected Map<String,DefinitionAndValue> _getBrothersDefinitionAndValues(String prefix, Map<String,Object> values, ElementDefinition definition)
Get the definition and value pairs of the given definition brothers. The definition and value pairs are indexed by the parameter name- Parameters:
prefix
- prefix to get the parameter valuesvalues
- all the parameter valuesdefinition
- the definition- Returns:
- the definition and value pairs of the given definition brother
-
_moveRepeaterEntries
protected void _moveRepeaterEntries(ModifiableModelAwareRepeater repeater, Map<String,Object> values, String repeaterPath)
Moves the repeater entries according to the given values. Removes or add entries if needed. After the call of this method, the given repeater will contain the right entries- Parameters:
repeater
- the repeatervalues
- the valuesrepeaterPath
- the repeater path
-
getParametersValues
public Map<String,Object> getParametersValues(Collection<? extends ModelItem> items, ModelAwareDataHolder dataHolder, String prefix)
Get the parameters values- Parameters:
items
- the list of model itemdataHolder
- the data holderprefix
- prefix to get the parameter values- Returns:
- the parameters values
-
_addParameterValues
protected void _addParameterValues(ModelItem item, ModelAwareDataHolder dataHolder, String prefix, Map<String,Object> values)
Add the parameter values to all values- Parameters:
item
- the model itemdataHolder
- the data holderprefix
- prefix to get the parameter valuesvalues
- all the values
-
getRepeatersValues
public List<Map<String,Object>> getRepeatersValues(Collection<ModelItem> items, ModelAwareDataHolder dataHolder, String prefix)
Get the repeaters values- Parameters:
items
- the list of model itemdataHolder
- the data holderprefix
- prefix to get the parameter values- Returns:
- the repeaters values
-
_hasParameterValueOrDefaultValue
protected boolean _hasParameterValueOrDefaultValue(String parameterPath, ModelAwareDataHolder dataHolder, Object defaultValue)
True if the parameter has a value or a default value- Parameters:
parameterPath
- the parameter pathdataHolder
- the data holderdefaultValue
- the default value- Returns:
- true if the parameter has a value or a default value
-
getParametersStartWithPrefix
public Map<String,Object> getParametersStartWithPrefix(Map<String,Object> parameterValues, String prefix)
Get all parameters which start with prefix and change the name of the attribute removing this prefix- Parameters:
parameterValues
- the parameter valuesprefix
- the prefix- Returns:
- the map of filtered parameters
-
-