Package org.ametys.cms.data.holder
Class DataHolderStaticRelativeDisableCondition
java.lang.Object
org.ametys.runtime.model.disableconditions.AbstractRelativeDisableCondition
org.ametys.runtime.model.disableconditions.AbstractStaticRelativeDisableCondition
org.ametys.cms.data.holder.DataHolderStaticRelativeDisableCondition
- All Implemented Interfaces:
DisableCondition,Initializable,Component,Configurable,Serviceable
public class DataHolderStaticRelativeDisableCondition
extends AbstractStaticRelativeDisableCondition
implements Serviceable
DisableCondition for model aware DataHolder
This is a static (i.e. coming from configurable component) implementation-
Nested Class Summary
Nested classes/interfaces inherited from class org.ametys.runtime.model.disableconditions.AbstractRelativeDisableCondition
AbstractRelativeDisableCondition.RelativeDefinitionAndValueNested 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, _valueFields inherited from interface org.ametys.runtime.model.disableconditions.DisableCondition
EXTERNAL_CONDITION_ID_PREFIX -
Constructor Summary
Constructors -
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 voidcheckModelItemPathSegment(Model model, ModelItem definition, ModelItem segmentModelItem, int segmentIndex, int conditionPathSize) Check a segment of the condition pathprotected booleancontainsRelativeValue(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMapcontains a value for the relative conditiongetAllModelItemsInPath(Model model, ModelItem definition) Retrieves all model items of the given relative pathprotected ModelItemgetModelItem(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> contextualParameters) Retrieves the model itemprotected ObjectgetRelativeValueFromMap(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the relative condition value from the valuesMapprotected <T> ObjectgetStoredRelativeValue(String conditionDataPath, Optional<String> oldConditionDataPath, T dataHolder, Map<String, Object> contextualParameters) Retrieves the condition value from data stored in the given objectbooleanisExternal(DefinitionContext context) Check if the current disable condition is external An external condition can not be computed only from the object's valuesvoidservice(ServiceManager manager) Methods inherited from class org.ametys.runtime.model.disableconditions.AbstractStaticRelativeDisableCondition
configure, initializeMethods 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
-
DataHolderStaticRelativeDisableCondition
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getAllModelItemsInPath
protected List<ModelItem> getAllModelItemsInPath(Model model, ModelItem definition) throws UndefinedItemPathException, IllegalArgumentException Description copied from class:AbstractRelativeDisableConditionRetrieves all model items of the given relative path- Overrides:
getAllModelItemsInPathin 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:AbstractRelativeDisableConditionCheck a segment of the condition path- Overrides:
checkModelItemPathSegmentin 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:AbstractRelativeDisableConditionRetrieve the value corresponding to the identifier of the condition, and its type- Overrides:
_getConditionDefinitionAndValuein 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.RelativeDefinitionAndValuecorresponding to the condition identifier
-
getModelItem
protected ModelItem getModelItem(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> contextualParameters) throws UndefinedItemPathExceptionDescription copied from class:AbstractRelativeDisableConditionRetrieves the model item- Overrides:
getModelItemin 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 valuesMapcontains a value for the relative condition- Overrides:
containsRelativeValuein classAbstractRelativeDisableCondition- 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- 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:
getRelativeValueFromMapin classAbstractRelativeDisableCondition- Parameters:
modelItemAccessor- the relative accessor to the given condition pathconditionDataPath- the absolute data path of the conditionvalues- the valuesMapcontextualParameters- 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:AbstractRelativeDisableConditionRetrieves the condition value from data stored in the given object- Specified by:
getStoredRelativeValuein 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:DisableConditionCheck if the current disable condition is external An external condition can not be computed only from the object's values- Specified by:
isExternalin interfaceDisableCondition- Parameters:
context- the definition context- Returns:
trueif the disable condition is external,falseotherwise
-