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
Nested ClassesModifier and TypeClassDescriptionprotected static final recordDefinition and value corresponding to aDisableCondition -
Constructor Summary
Constructors -
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 booleancontainsValue(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMapcontains a value for the conditionprotected booleanevaluateDisableCondition(ModelItem definition, DisableCondition condition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> object, Map<String, Object> contextualParameters) Evaluate the givenDisableConditionagainst the given valuesbooleanRecursively evaluate theDisableConditionsof the given model item, against the given values.booleanevaluateDisableConditions(ModelItem definition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, T object, Map<String, Object> contextualParameters) Recursively evaluate theDisableConditionsof the given model item, against the given values.booleanevaluateDisableConditions(ModelItem definition, String dataPath, T object) Recursively evaluate theDisableConditionsof the given model item, against the values stored in the given objectprotected booleanevaluateDisableConditions(ModelItem definition, DisableConditions disableConditions, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> object, Map<String, Object> contextualParameters) Recursively evaluate the givenDisableConditionsagainst the given valuesprotected booleanevaluateDisableConditionValue(Object conditionValue, DisableCondition.OPERATOR conditionOperator, Object value) Evaluate the given condition value against the given valueprotected ModelItemgetModelItem(ModelItemAccessor modelItemAccessor, String dataPath, Map<String, Object> contextualParameters) Retrieves the model itemprotected abstract ObjectgetStoredValue(String conditionDataPath, Optional<String> oldConditionDataPath, T object, Map<String, Object> contextualParameters) Retrieves the condition value from data stored in the given objectprotected abstract ObjectgetValueFromMap(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value from the valuesMapMethods 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:DisableConditionsEvaluatorRecursively evaluate theDisableConditionsof the given model item, against the given values.- Specified by:
evaluateDisableConditionsin 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:
trueif the disable conditions aretrue,falseotherwise- 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:DisableConditionsEvaluatorRecursively evaluate theDisableConditionsof the given model item, against the values stored in the given object- Specified by:
evaluateDisableConditionsin 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:
trueif the disable conditions aretrue,falseotherwise- 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:DisableConditionsEvaluatorRecursively evaluate theDisableConditionsof 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:
evaluateDisableConditionsin 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:
trueif the disable conditions aretrue,falseotherwise- 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 givenDisableConditionsagainst 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:
trueif the disable conditions aretrue,falseotherwise- 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:
trueif the result of evaluation is sufficient,falseotherwise
-
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 givenDisableConditionagainst 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:
trueif the disable condition istrue,falseotherwise- 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.DefinitionAndValuecorresponding 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 valuesMapcontains a value for the condition- Parameters:
modelItemAccessor- the relative accessor to the given condition pathconditionDataPath- the absolute data path of the conditionvalues- the valuesMapcontextualParameters- the contextual parameters- Returns:
trueif there is a value (even empty) for the condition in the valuesMap,falseotherwise
-
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:
trueif the condition istrue,falseotherwise
-
_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
-