Package org.ametys.cms.data.holder
Class DataHolderRelativeDisableConditionsHelper
java.lang.Object
org.ametys.cms.data.holder.DataHolderRelativeDisableConditionsHelper
- All Implemented Interfaces:
Component
,Serviceable
public class DataHolderRelativeDisableConditionsHelper
extends Object
implements Component, Serviceable
DisableCondition
for model aware DataHolder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
The contextual parameter key for data holderprotected static final String
The contextual parameter key for old condition pathstatic final String
The JSON info containing exploded conditions when a condition points to an element that is in a distant contentstatic final String
The component role.static final String
The contextual parameter key for synchronization context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkModelItemPathSegment
(DisableCondition condition, Model model, ModelItem definition, ModelItem segmentModelItem, int segmentIndex, int conditionPathSize) Check a segment of the condition pathboolean
containsValue
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Check if the valuesMap
contains a value for the conditiongetAdditionalContextualParameters
(DisableCondition condition, Optional<String> oldDataPath, ModelAwareDataHolder dataHolder) Retrieves the additional contextual parameters to use to extract valuesgetAllModelItemsInPathToSystemProperty
(DisableCondition condition, String conditionPath, Model model, ModelItem definition, SystemProperty systemProperty) Retrieves all model items of the given relative path to the system propertygetSystemProperty
(ModelItemAccessor modelItemAccessor, String dataPath) Retrieves theSystemProperty
if the given data path represents onegetValueFromMap
(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, Object> contextualParameters) Retrieves the condition value from the valuesMap
boolean
isExternal
(DisableCondition condition, DefinitionContext context) Check if the given disable condition is external The condition is external if there is a view in the context and the relative element pointed by the condition is not in the viewvoid
service
(ServiceManager manager)
-
Field Details
-
ROLE
The component role. -
SYNCHRONIZATION_CONTEXT_PARAMETER_KEY
The contextual parameter key for synchronization context- See Also:
-
EXPLODED_DISABLE_CONDITIONS
The JSON info containing exploded conditions when a condition points to an element that is in a distant content- See Also:
-
__DATA_HOLDER_PARAMETER_KEY
The contextual parameter key for data holder- See Also:
-
__OLD_CONDITION_PATH_PARAMETER_KEY
The contextual parameter key for old condition path- See Also:
-
-
Constructor Details
-
DataHolderRelativeDisableConditionsHelper
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getSystemProperty
Retrieves theSystemProperty
if the given data path represents one- Parameters:
modelItemAccessor
- the relative accessor to the given data pathdataPath
- the data path of the system property to retrieve- Returns:
- the system property or
null
if the given data path does not represent a system property
-
getAllModelItemsInPathToSystemProperty
public List<ModelItem> getAllModelItemsInPathToSystemProperty(DisableCondition condition, String conditionPath, Model model, ModelItem definition, SystemProperty systemProperty) throws UndefinedItemPathException, IllegalArgumentException Retrieves all model items of the given relative path to the system property- Parameters:
condition
- the disable conditionconditionPath
- the absolute path of the disable conditionmodel
- the model containing the definitiondefinition
- the model item defining this disable conditionsystemProperty
- the system property targeted by the 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
public void checkModelItemPathSegment(DisableCondition condition, Model model, ModelItem definition, ModelItem segmentModelItem, int segmentIndex, int conditionPathSize) throws ConfigurationException Check a segment of the condition path- Parameters:
condition
- the disable conditionmodel
- 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
-
getAdditionalContextualParameters
public Map<String,Object> getAdditionalContextualParameters(DisableCondition condition, Optional<String> oldDataPath, ModelAwareDataHolder dataHolder) Retrieves the additional contextual parameters to use to extract values- Parameters:
condition
- the disable conditionoldDataPath
- the old path of the evaluated data. Needed to get stored value if the data has been moveddataHolder
- the data holder- Returns:
- the
DefinitionAndValue
corresponding to the condition identifier
-
containsValue
public 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- 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
-
getValueFromMap
public Object getValueFromMap(ModelItemAccessor modelItemAccessor, String conditionDataPath, Map<String, Object> values, Map<String, throws BadItemTypeExceptionObject> contextualParameters) Retrieves the condition value from the valuesMap
- 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
-
isExternal
Check if the given disable condition is external The condition is external if there is a view in the context and the relative element pointed by the condition is not in the view- Parameters:
condition
- the disable condition to checkcontext
- the definition context- Returns:
true
if the given disable condition is external,false
otherwise
-