Package org.ametys.cms.data.holder
Class DataHolderRelativeDisableCondition
java.lang.Object
org.ametys.runtime.model.disableconditions.AbstractRelativeDisableCondition
org.ametys.cms.data.holder.DataHolderRelativeDisableCondition
- All Implemented Interfaces:
DisableCondition
DisableCondition
for model aware DataHolder
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ametys.runtime.model.disableconditions.AbstractRelativeDisableCondition
AbstractRelativeDisableCondition.RelativeDefinitionAndValue
Nested classes/interfaces inherited from interface org.ametys.runtime.model.disableconditions.DisableCondition
DisableCondition.OPERATOR
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe data holder relative disable condition helperFields inherited from class org.ametys.runtime.model.disableconditions.AbstractRelativeDisableCondition
_id, _name, _operator, _value
Fields inherited from interface org.ametys.runtime.model.disableconditions.DisableCondition
EXTERNAL_CONDITION_ID_PREFIX
-
Constructor Summary
ConstructorsConstructorDescriptionDataHolderRelativeDisableCondition
(String name, DisableCondition.OPERATOR operator, String value, DataHolderRelativeDisableConditionsHelper disableConditionsHelper) Creates a data holder disable condition -
Method Summary
Modifier and TypeMethodDescription_getConditionDefinitionAndValue
(ModelItem definition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> dataHolder, Map<String, Object> contextualParameters) Retrieve the value corresponding to the identifier of the condition, and its typeprotected void
checkModelItemPathSegment
(Model model, ModelItem definition, ModelItem segmentModelItem, int segmentIndex, int conditionPathSize) Check a segment of the condition pathprotected boolean
containsRelativeValue
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the relative conditiongetAllModelItemsInPath
(Model model, ModelItem definition) Retrieves all model items of the given relative pathprotected ModelItem
getModelItem
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> contextualParameters) Retrieves the model itemprotected Object
getRelativeValueFromMap
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the relative condition value from the valuesMap
protected <T> Object
getStoredRelativeValue
(String conditionDataPath, Optional<String> oldConditionDataPath, T dataHolder, Map<String, Object> contextualParameters) Retrieves the condition value from data stored in the given objectboolean
isExternal
(DefinitionContext context) Check if the current disable condition is external An external condition can not be computed only from the object's valuesMethods inherited from class org.ametys.runtime.model.disableconditions.AbstractRelativeDisableCondition
_emptyStringToNull, evaluate, evaluateDisableConditionValue, getId, getName, getOperator, getValue, init
-
Field Details
-
_disableConditionsHelper
The data holder relative disable condition helper
-
-
Constructor Details
-
DataHolderRelativeDisableCondition
public DataHolderRelativeDisableCondition(String name, DisableCondition.OPERATOR operator, String value, DataHolderRelativeDisableConditionsHelper disableConditionsHelper) Creates a data holder disable condition- Parameters:
name
- The condition nameoperator
- comparison operator of the condition ('eq'...)value
- value to compare todisableConditionsHelper
- the data holder relative disable condition helper
-
-
Method Details
-
getAllModelItemsInPath
protected List<ModelItem> getAllModelItemsInPath(Model model, ModelItem definition) throws UndefinedItemPathException, IllegalArgumentException Description copied from class:AbstractRelativeDisableCondition
Retrieves all model items of the given relative path- Overrides:
getAllModelItemsInPath
in classAbstractRelativeDisableCondition
- Parameters:
model
- the model containing the definitiondefinition
- the model item defining this disable condition- Returns:
- all model items of the given relative path
- Throws:
UndefinedItemPathException
- if there is no item defined at the given pathIllegalArgumentException
- if the given path is null or empty
-
checkModelItemPathSegment
protected void checkModelItemPathSegment(Model model, ModelItem definition, ModelItem segmentModelItem, int segmentIndex, int conditionPathSize) throws ConfigurationException Description copied from class:AbstractRelativeDisableCondition
Check a segment of the condition path- Overrides:
checkModelItemPathSegment
in classAbstractRelativeDisableCondition
- Parameters:
model
- the model containing the definitiondefinition
- the model item defining this disable conditionsegmentModelItem
- the model item concerned by the segmentsegmentIndex
- the index of the segment in the pathconditionPathSize
- the number of segments in the condition path- Throws:
ConfigurationException
- if the segment can not be used in the condition path
-
_getConditionDefinitionAndValue
protected <T> AbstractRelativeDisableCondition.RelativeDefinitionAndValue _getConditionDefinitionAndValue(ModelItem definition, String dataPath, Optional<String> oldDataPath, Map<String, Object> values, Optional<T> dataHolder, Map<String, Object> contextualParameters) Description copied from class:AbstractRelativeDisableCondition
Retrieve the value corresponding to the identifier of the condition, and its type- Overrides:
_getConditionDefinitionAndValue
in classAbstractRelativeDisableCondition
- Type Parameters:
T
- Type of object holding the data to evaluate- Parameters:
definition
- the definition containing 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 ondataHolder
- the object holding the data to evaluate and the condition valuecontextualParameters
- the contextual parameters- Returns:
- the
AbstractRelativeDisableCondition.RelativeDefinitionAndValue
corresponding to the condition identifier
-
getModelItem
protected ModelItem getModelItem(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> contextualParameters) throws UndefinedItemPathExceptionDescription copied from class:AbstractRelativeDisableCondition
Retrieves the model item- Overrides:
getModelItem
in classAbstractRelativeDisableCondition
- 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
-
containsRelativeValue
protected boolean containsRelativeValue(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, throws BadItemTypeExceptionObject> contextualParameters) Check if the valuesMap
contains a value for the relative condition- Overrides:
containsRelativeValue
in classAbstractRelativeDisableCondition
- 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
-
getRelativeValueFromMap
protected Object getRelativeValueFromMap(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, throws BadItemTypeExceptionObject> contextualParameters) Retrieves the relative condition value from the valuesMap
- Overrides:
getRelativeValueFromMap
in classAbstractRelativeDisableCondition
- 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
-
getStoredRelativeValue
protected <T> Object getStoredRelativeValue(String conditionDataPath, Optional<String> oldConditionDataPath, T dataHolder, Map<String, Object> contextualParameters) Description copied from class:AbstractRelativeDisableCondition
Retrieves the condition value from data stored in the given object- Specified by:
getStoredRelativeValue
in classAbstractRelativeDisableCondition
- Type Parameters:
T
- Type of object holding the data to evaluate- Parameters:
conditionDataPath
- the absolute data path of the conditionoldConditionDataPath
- the absolute old data path of the conditiondataHolder
- the object holding the data to evaluate and the condition valuecontextualParameters
- the contextual parameters- Returns:
- the condition value from data stored in the object
-
isExternal
Description copied from interface:DisableCondition
Check if the current disable condition is external An external condition can not be computed only from the object's values- Parameters:
context
- the definition context- Returns:
true
if the disable condition is external,false
otherwise
-