Class AbstractDisableConditionsEvaluator<T>
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.runtime.model.disableconditions.AbstractDisableConditionsEvaluator<T>
- Type Parameters:
T
- Type of object holding the data to evaluate
- All Implemented Interfaces:
DisableConditionsEvaluator<T>
,LogEnabled
,Component
- Direct Known Subclasses:
ConfigDisableConditionsEvaluator
,DataHolderDisableConditionsEvaluator
,SkinDisableConditionsEvaluator
,UsersAndGroupsDataDisableConditionsEvaluator
public abstract class AbstractDisableConditionsEvaluator<T>
extends AbstractLogEnabled
implements Component, DisableConditionsEvaluator<T>
Abstract evaluator for
DisableConditions
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static final record
Definition and value corresponding to aDisableCondition
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static Object
_emptyStringToNull
(Object value) Convert empty string to null object, or retrieve the given value_getConditionDefinitionAndValue
(ModelItem definition, DisableCondition condition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> object, Map<String, Object> contextualParameters) Retrieve the value corresponding to the identifier of the condition, and its typeprotected boolean
_resultIsSufficient
(boolean andOperator, boolean result) Check if the given result is sufficient to evaluate the current disable conditionprotected abstract boolean
containsValue
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the conditionprotected boolean
evaluateDisableCondition
(ModelItem definition, DisableCondition condition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> object, Map<String, Object> contextualParameters) Evaluate the givenDisableCondition
against the given valuesboolean
Recursively evaluate theDisableConditions
of the given model item, against the given values.boolean
evaluateDisableConditions
(ModelItem definition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, T object, Map<String, Object> contextualParameters) Recursively evaluate theDisableConditions
of the given model item, against the given values.boolean
evaluateDisableConditions
(ModelItem definition, String dataPath, T object) Recursively evaluate theDisableConditions
of the given model item, against the values stored in the given objectprotected boolean
evaluateDisableConditions
(ModelItem definition, DisableConditions disableConditions, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> object, Map<String, Object> contextualParameters) Recursively evaluate the givenDisableConditions
against the given valuesprotected boolean
evaluateDisableConditionValue
(Object conditionValue, DisableCondition.OPERATOR conditionOperator, Object value) Evaluate the given condition value against the given valueprotected ModelItem
getModelItem
(ModelItemAccessor modelItemAccessor, String dataPath, Map<String, Object> contextualParameters) Retrieves the model itemprotected abstract Object
getStoredValue
(String conditionDataPath, Optional<String> oldConditionDataPath, T object, Map<String, Object> contextualParameters) Retrieves the condition value from data stored in the given objectprotected abstract Object
getValueFromMap
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value from the valuesMap
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Constructor Details
-
AbstractDisableConditionsEvaluator
public AbstractDisableConditionsEvaluator()
-
-
Method Details
-
evaluateDisableConditions
public boolean evaluateDisableConditions(ModelItem definition, String dataPath, Map<String, Object> values) throws UndefinedItemPathException, BadItemTypeExceptionDescription copied from interface:DisableConditionsEvaluator
Recursively evaluate theDisableConditions
of the given model item, against the given values.- Specified by:
evaluateDisableConditions
in interfaceDisableConditionsEvaluator<T>
- Parameters:
definition
- the definition of the evaluated datadataPath
- the path of the evaluated data. Needed to get the value to compare as condition ids are relative to this onevalues
- values to check conditions on- Returns:
true
if the disable conditions aretrue
,false
otherwise- Throws:
UndefinedItemPathException
- If no item is found corresponding to one of the conditionsBadItemTypeException
- If the item referenced by one of the conditions is not an element
-
evaluateDisableConditions
public boolean evaluateDisableConditions(ModelItem definition, String dataPath, T object) throws UndefinedItemPathException, BadItemTypeException Description copied from interface:DisableConditionsEvaluator
Recursively evaluate theDisableConditions
of the given model item, against the values stored in the given object- Specified by:
evaluateDisableConditions
in interfaceDisableConditionsEvaluator<T>
- Parameters:
definition
- the definition of the evaluated datadataPath
- the path of the evaluated data. Needed to get the value to compare as condition ids are relative to this oneobject
- the object holding the data to evaluate and the condition value- Returns:
true
if the disable conditions aretrue
,false
otherwise- Throws:
UndefinedItemPathException
- If no item is found corresponding to one of the conditionsBadItemTypeException
- If the item referenced by one of the conditions is not an element
-
evaluateDisableConditions
public boolean evaluateDisableConditions(ModelItem definition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, T object, Map<String, throws UndefinedItemPathException, BadItemTypeExceptionObject> contextualParameters) Description copied from interface:DisableConditionsEvaluator
Recursively evaluate theDisableConditions
of the given model item, against the given values. If the value of the condition is not present in the givenMap
, search in the stored values in the given object- Specified by:
evaluateDisableConditions
in interfaceDisableConditionsEvaluator<T>
- Parameters:
definition
- the definition of the evaluated datadataPath
- the path of the evaluated data. Needed to get the value to compare as condition ids are relative to this oneoldDataPath
- the old path of the evaluated data. Needed to get stored value if the data has been movedvalues
- values to check conditions onobject
- the object holding the data to evaluate and the condition valuecontextualParameters
- the contextual parameters- Returns:
true
if the disable conditions aretrue
,false
otherwise- Throws:
UndefinedItemPathException
- If no item is found corresponding to one of the conditionsBadItemTypeException
- If the item referenced by one of the conditions is not an element
-
evaluateDisableConditions
protected boolean evaluateDisableConditions(ModelItem definition, DisableConditions disableConditions, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> object, Map<String, throws UndefinedItemPathException, BadItemTypeExceptionObject> contextualParameters) Recursively evaluate the givenDisableConditions
against the given values- Parameters:
definition
- the definition of the evaluated datadisableConditions
- the conditions to evaluatedataPath
- the path of the evaluated data. Needed to get the value to compare as condition ids are relative to this oneoldDataPath
- the old path of the evaluated data. Needed to get stored value if the data has been movedvalues
- values to check conditions onobject
- the object holding the data to evaluate and the condition valuecontextualParameters
- the contextual parameters- Returns:
true
if the disable conditions aretrue
,false
otherwise- Throws:
UndefinedItemPathException
- If no item is found corresponding to one of the given conditionsBadItemTypeException
- If the item referenced by one of the conditions is not an element
-
_resultIsSufficient
Check if the given result is sufficient to evaluate the current disable condition- Parameters:
andOperator
- the conditions operatorresult
- the result of the current condition- Returns:
true
if the result of evaluation is sufficient,false
otherwise
-
evaluateDisableCondition
protected boolean evaluateDisableCondition(ModelItem definition, DisableCondition condition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> object, Map<String, throws UndefinedItemPathException, BadItemTypeExceptionObject> contextualParameters) Evaluate the givenDisableCondition
against the given values- Parameters:
definition
- the definition of the evaluated datacondition
- the condition to evaluatedataPath
- the path of the evaluated data. Needed to get the value to compare as condition ids are relative to this oneoldDataPath
- the old path of the evaluated data. Needed to get stored value if the data has been movedvalues
- values to check conditions onobject
- the object holding the data to evaluate and the condition valuecontextualParameters
- the contextual parameters- Returns:
true
if the disable condition istrue
,false
otherwise- Throws:
UndefinedItemPathException
- If no item is found corresponding to the given conditionBadItemTypeException
- If the item referenced by the condition is not an element
-
_getConditionDefinitionAndValue
protected AbstractDisableConditionsEvaluator.DefinitionAndValue _getConditionDefinitionAndValue(ModelItem definition, DisableCondition condition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> object, Map<String, throws UndefinedItemPathException, BadItemTypeExceptionObject> contextualParameters) Retrieve the value corresponding to the identifier of the condition, and its type- Parameters:
object
- the object holding the data to evaluate and the condition valuedefinition
- 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 oncontextualParameters
- the contextual parameters- Returns:
- the
AbstractDisableConditionsEvaluator.DefinitionAndValue
corresponding to the condition identifier - Throws:
UndefinedItemPathException
- If no item is found with the given conditionIdBadItemTypeException
- If the item referenced by the conditionId is not an element
-
getModelItem
protected ModelItem getModelItem(ModelItemAccessor modelItemAccessor, String dataPath, Map<String, Object> contextualParameters) throws UndefinedItemPathExceptionRetrieves the model item- Parameters:
modelItemAccessor
- the relative accessor to the given data pathdataPath
- 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
-
containsValue
protected abstract boolean containsValue(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the condition- 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
-
getValueFromMap
protected abstract Object getValueFromMap(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value from the valuesMap
-
getStoredValue
protected abstract Object getStoredValue(String conditionDataPath, Optional<String> oldConditionDataPath, T object, Map<String, Object> contextualParameters) Retrieves the condition value from data stored in the given object- Parameters:
conditionDataPath
- the absolute data path of the conditionoldConditionDataPath
- the absolute old data path of the conditionobject
- the object holding the data to evaluate and the condition valuecontextualParameters
- the contextual parameters- Returns:
- the condition value from data stored in the object
-
evaluateDisableConditionValue
protected boolean evaluateDisableConditionValue(Object conditionValue, DisableCondition.OPERATOR conditionOperator, Object value) Evaluate the given condition value against the given value- Parameters:
conditionValue
- the condition valueconditionOperator
- the condition operatorvalue
- the value to check- Returns:
true
if the condition istrue
,false
otherwise
-
_emptyStringToNull
Convert empty string to null object, or retrieve the given value- Parameters:
value
- the value- Returns:
- null if the given value is an empty string, the value itself otherwise
-