Package org.ametys.cms.data.holder
Class DataHolderDisableConditionsEvaluator<T extends ModelAwareDataHolder>
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.runtime.model.disableconditions.AbstractDisableConditionsEvaluator<T>
org.ametys.cms.data.holder.DataHolderDisableConditionsEvaluator<T>
- Type Parameters:
T
- Type of data holder holding the data to evaluate
- All Implemented Interfaces:
DisableConditionsEvaluator<T>
,LogEnabled
,Component
,Serviceable
public class DataHolderDisableConditionsEvaluator<T extends ModelAwareDataHolder>
extends AbstractDisableConditionsEvaluator<T>
implements Serviceable
Evaluator for
DisableConditions
on model aware DataHolder
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ametys.runtime.model.disableconditions.AbstractDisableConditionsEvaluator
AbstractDisableConditionsEvaluator.DefinitionAndValue
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
The contextual parameter key for ametys objectprotected static final String
The contextual parameter key for old condition pathprotected SystemPropertyExtensionPoint
The system property extension pointstatic final String
The Avalon rolestatic final String
The contextual parameter key for synchronization context -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
_containsElementValue
(ModelItem definition, String dataName, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the conditionprotected boolean
_doesCompositeContainValue
(CompositeDefinition compositeDefinition, String compositeName, String subConditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the conditionprotected boolean
_doesRepeaterContainValue
(RepeaterDefinition repeaterDefinition, String repeaterNameAndPositionSegment, String subConditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the condition_getConditionDefinitionAndValue
(ModelItem definition, DisableCondition condition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> ametsyObject, Map<String, Object> contextualParameters) Retrieve the value corresponding to the identifier of the condition, and its typeprotected Object
_getElementValueFromMap
(ModelItem definition, String dataName, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value from the valuesMap
protected Object
_getValueFromComposite
(CompositeDefinition compositeDefinition, String compositeName, String subConditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value in the given composite, from the valuesMap
protected Object
_getValueFromContentValue
(ContentElementDefinition contentElementDefinition, String dataName, String subConditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value in the given content value, from the valuesMap
protected Object
_getValueFromRepeater
(RepeaterDefinition repeaterDefinition, String repeaterNameAndPositionSegment, String subConditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value in the given repeater, from the valuesMap
protected Object
_getValueFromSynchronizableValue
(ModelItem definition, Object value, SynchronizationContext synchronizationContext, Map<String, Object> contextualParameters) Returns the value of the synchronized value corresponding of the given valueprotected boolean
containsValue
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the conditionprotected ModelItem
getModelItem
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> contextualParameters) Retrieves the model itemprotected Object
getStoredValue
(String conditionDataPath, Optional<String> oldConditionDataPath, T ametysObject, Map<String, Object> contextualParameters) Retrieves the condition value from data stored in the given objectprotected Object
getValueFromMap
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value from the valuesMap
void
service
(ServiceManager manager) Methods inherited from class org.ametys.runtime.model.disableconditions.AbstractDisableConditionsEvaluator
_emptyStringToNull, _resultIsSufficient, evaluateDisableCondition, evaluateDisableConditions, evaluateDisableConditions, evaluateDisableConditions, evaluateDisableConditions, evaluateDisableConditionValue
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role -
SYNCHRONIZATION_CONTEXT_PARAMETER_KEY
The contextual parameter key for synchronization context- See Also:
-
__AMETYS_OBJECT_PARAMETER_KEY
The contextual parameter key for ametys object- See Also:
-
__OLD_CONDITION_PATH_PARAMETER_KEY
The contextual parameter key for old condition path- See Also:
-
_systemPropertyExtensionPoint
The system property extension point
-
-
Constructor Details
-
DataHolderDisableConditionsEvaluator
public DataHolderDisableConditionsEvaluator()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getModelItem
protected ModelItem getModelItem(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> contextualParameters) throws UndefinedItemPathExceptionDescription copied from class:AbstractDisableConditionsEvaluator
Retrieves the model item- Overrides:
getModelItem
in classAbstractDisableConditionsEvaluator<T extends ModelAwareDataHolder>
- Parameters:
modelItemAccessor
- the relative accessor to the given data pathconditionDataPath
- the data path of the model item to retrievecontextualParameters
- the contextual parameters- Returns:
- the model item
- Throws:
UndefinedItemPathException
- If no item is found for the given path
-
_getConditionDefinitionAndValue
protected AbstractDisableConditionsEvaluator.DefinitionAndValue _getConditionDefinitionAndValue(ModelItem definition, DisableCondition condition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> ametsyObject, Map<String, Object> contextualParameters) Description copied from class:AbstractDisableConditionsEvaluator
Retrieve the value corresponding to the identifier of the condition, and its type- Overrides:
_getConditionDefinitionAndValue
in classAbstractDisableConditionsEvaluator<T extends ModelAwareDataHolder>
- Parameters:
definition
- the definition containing the conditioncondition
- the conditiondataPath
- the path of the evaluated dataoldDataPath
- the old path of the evaluated data. Needed to get stored value if the data has been movedvalues
- values to check conditions onametsyObject
- the object holding the data to evaluate and the condition valuecontextualParameters
- the contextual parameters- Returns:
- the
AbstractDisableConditionsEvaluator.DefinitionAndValue
corresponding to the condition identifier
-
containsValue
protected boolean containsValue(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, throws BadItemTypeExceptionObject> contextualParameters) Check if the valuesMap
contains a value for the condition- Specified by:
containsValue
in classAbstractDisableConditionsEvaluator<T extends ModelAwareDataHolder>
- Parameters:
modelItemAccessor
- the relative accessor to the given condition pathconditionDataPath
- the absolute data path of the conditionvalues
- the valuesMap
contextualParameters
- the contextual parameters- Returns:
true
if there is a value (even empty) for the condition in the valuesMap
,false
otherwise- Throws:
BadItemTypeException
- if a value does not correspond to the model of given object
-
_doesCompositeContainValue
protected boolean _doesCompositeContainValue(CompositeDefinition compositeDefinition, String compositeName, String subConditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the condition- Parameters:
compositeDefinition
- the composite definitioncompositeName
- the name of the compositesubConditionDataPath
- the data path of the condition, relative to the compositevalues
- the valuesMap
contextualParameters
- the contextual parameters- Returns:
true
if there is a value (even empty) for the condition in the composite value,false
otherwise- Throws:
BadItemTypeException
- if the found value is not a composite
-
_doesRepeaterContainValue
protected boolean _doesRepeaterContainValue(RepeaterDefinition repeaterDefinition, String repeaterNameAndPositionSegment, String subConditionDataPath, Map<String, Object> values, Map<String, throws BadItemTypeExceptionObject> contextualParameters) Check if the valuesMap
contains a value for the condition- Parameters:
repeaterDefinition
- the repeater definitionrepeaterNameAndPositionSegment
- the segment of the repeater, containing repeater name and entry positionsubConditionDataPath
- the data path of the condition, relative to the repeatervalues
- the valuesMap
contextualParameters
- the contextual parameters- Returns:
true
if there is a value (even empty) for the condition in the repeater value,false
otherwise- Throws:
BadItemTypeException
- if the found value is not a repeater
-
_containsElementValue
protected boolean _containsElementValue(ModelItem definition, String dataName, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the condition- Parameters:
definition
- the definition of the condition elementdataName
- the name of the condition elementvalues
- the valuesMap
contextualParameters
- the contextual parameters- Returns:
true
if there is a value (even empty),false
otherwise
-
getValueFromMap
protected Object getValueFromMap(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, throws BadItemTypeExceptionObject> contextualParameters) Retrieves the condition value from the valuesMap
- Specified by:
getValueFromMap
in classAbstractDisableConditionsEvaluator<T extends ModelAwareDataHolder>
- Parameters:
modelItemAccessor
- the relative accessor to the given condition pathconditionDataPath
- the absolute data path of the conditionvalues
- the valuesMap
contextualParameters
- the contextual parameters- Returns:
- the condition value found in the values
Map
- Throws:
BadItemTypeException
- if a value does not correspond to the model of given object
-
_getValueFromComposite
protected Object _getValueFromComposite(CompositeDefinition compositeDefinition, String compositeName, String subConditionDataPath, Map<String, Object> values, Map<String, throws BadItemTypeExceptionObject> contextualParameters) Retrieves the condition value in the given composite, from the valuesMap
- Parameters:
compositeDefinition
- the composite definitioncompositeName
- the name of the compositesubConditionDataPath
- the data path of the condition, relative to the compositevalues
- the valuesMap
contextualParameters
- the contextual parameters- Returns:
- the condition value if found in the values
Map
- Throws:
BadItemTypeException
- if the found value is not a composite
-
_getValueFromRepeater
protected Object _getValueFromRepeater(RepeaterDefinition repeaterDefinition, String repeaterNameAndPositionSegment, String subConditionDataPath, Map<String, Object> values, Map<String, throws BadItemTypeExceptionObject> contextualParameters) Retrieves the condition value in the given repeater, from the valuesMap
- Parameters:
repeaterDefinition
- the repeater definitionrepeaterNameAndPositionSegment
- the segment of the repeater, containing repeater name and entry positionsubConditionDataPath
- the data path of the condition, relative to the repeatervalues
- the valuesMap
contextualParameters
- the contextual parameters- Returns:
- the condition value if found in the values
Map
- Throws:
BadItemTypeException
- if the found value is not a repeater
-
_getValueFromContentValue
protected Object _getValueFromContentValue(ContentElementDefinition contentElementDefinition, String dataName, String subConditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value in the given content value, from the valuesMap
- Parameters:
contentElementDefinition
- the content element definitiondataName
- the name of the content datasubConditionDataPath
- the data path of the condition, relative to the content valuevalues
- the valuesMap
contextualParameters
- the contextual parameters- Returns:
- the condition value if found in the values
Map
-
_getElementValueFromMap
protected Object _getElementValueFromMap(ModelItem definition, String dataName, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value from the valuesMap
-
_getValueFromSynchronizableValue
protected Object _getValueFromSynchronizableValue(ModelItem definition, Object value, SynchronizationContext synchronizationContext, Map<String, Object> contextualParameters) Returns the value of the synchronized value corresponding of the given value- Parameters:
definition
- the definition of the condition elementvalue
- the valuesynchronizationContext
- the synchronization contextcontextualParameters
- the contextual parameters- Returns:
- the value of the synchronized value
-
getStoredValue
protected Object getStoredValue(String conditionDataPath, Optional<String> oldConditionDataPath, T ametysObject, Map<String, Object> contextualParameters) Description copied from class:AbstractDisableConditionsEvaluator
Retrieves the condition value from data stored in the given object- Specified by:
getStoredValue
in classAbstractDisableConditionsEvaluator<T extends ModelAwareDataHolder>
- Parameters:
conditionDataPath
- the absolute data path of the conditionoldConditionDataPath
- the absolute old data path of the conditionametysObject
- the object holding the data to evaluate and the condition valuecontextualParameters
- the contextual parameters- Returns:
- the condition value from data stored in the object
-