Class DefaultModifiableModelLessDataHolder
java.lang.Object
org.ametys.plugins.repository.data.holder.impl.DefaultModelLessDataHolder
org.ametys.plugins.repository.data.holder.impl.DefaultModifiableModelLessDataHolder
- All Implemented Interfaces:
DataHolder
,ModelLessDataHolder
,ModifiableDataHolder
,ModifiableModelLessDataHolder
public class DefaultModifiableModelLessDataHolder
extends DefaultModelLessDataHolder
implements ModifiableModelLessDataHolder
Default implementation for modifiable data holder without model
-
Field Summary
Modifier and TypeFieldDescriptionprotected Optional<? extends ModifiableModelLessDataHolder>
Parent of the currentDataHolder
protected ModifiableRepositoryData
Repository data to use to store data in the repositoryprotected ModifiableModelLessDataHolder
RootDataHolder
Fields inherited from class org.ametys.plugins.repository.data.holder.impl.DefaultModelLessDataHolder
_parent, _repositoryData, _root, _typeExtensionPoint
-
Constructor Summary
ConstructorDescriptionDefaultModifiableModelLessDataHolder
(AbstractThreadSafeComponentExtensionPoint<RepositoryModelItemType> typeExtensionPoint, ModifiableRepositoryData repositoryData) Creates a modifiable default model free data holderDefaultModifiableModelLessDataHolder
(AbstractThreadSafeComponentExtensionPoint<RepositoryModelItemType> typeExtensionPoint, ModifiableRepositoryData repositoryData, Optional<? extends ModifiableModelLessDataHolder> parent, Optional<? extends ModifiableModelLessDataHolder> root) Creates a modifiable default model free data holder -
Method Summary
Modifier and TypeMethodDescriptionprotected ModelLessComposite
_getComposite
(String name) Retrieves the composite with the given nameprotected ModifiableModelLessComposite
_getComposite
(String name, boolean createNew) Retrieves the composite with the given nameprotected static ModifiableModelLessDataHolder
_getParentValue
(ModifiableModelLessDataHolder modifiableDataHolder, String dataPath) Retrieves the modifiable data holder, last parent segment of the given data path Example : call this method with a path like 'my-composite1/my-composite2/my-data' will retrieve the composite 'my-composite2' in the composite 'my-composite1'getComposite
(String compositePath) Retrieves the composite at the given pathgetComposite
(String compositePath, boolean createNew) Retrieves the composite at the given pathOptional<? extends ModifiableModelLessDataHolder>
Retrieves the optional parent of the currentDataHolder
There can be no parent if the currentDataHolder
is the rootRetrieves the repository data used by thisDataHolder
Retrieves theDataHolder
that is the root of the current onevoid
removeValue
(String dataPath) Removes the stored value of the data at the given pathvoid
Sets the value of the data at the given pathvoid
Sets the value of the data at the given pathboolean
synchronizeValues
(Map<String, Object> values) Synchronizes the given values with the current onesMethods inherited from class org.ametys.plugins.repository.data.holder.impl.DefaultModelLessDataHolder
_getParentValue, _hasValue, dataToSAX, dataToSAX, getDataNames, getType, getValue, getValue, getValueOfType, getValueOfType, hasValue, hasValueOrEmpty, isMultiple
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.plugins.repository.data.holder.DataHolder
copyTo, dataToSAX, dataToSAX, getDataNames
Methods inherited from interface org.ametys.plugins.repository.data.holder.ModelLessDataHolder
dataToSAX, dataToSAX, getType, getValue, getValue, getValueOfType, getValueOfType, hasValue, hasValueOrEmpty, isMultiple
-
Field Details
-
_modifiableRepositoryData
Repository data to use to store data in the repository -
_modifiableParent
Parent of the currentDataHolder
-
_modifiableRoot
RootDataHolder
-
-
Constructor Details
-
DefaultModifiableModelLessDataHolder
public DefaultModifiableModelLessDataHolder(AbstractThreadSafeComponentExtensionPoint<RepositoryModelItemType> typeExtensionPoint, ModifiableRepositoryData repositoryData) Creates a modifiable default model free data holder- Parameters:
typeExtensionPoint
- the extension point to use to get available element typesrepositoryData
- the repository data to use
-
DefaultModifiableModelLessDataHolder
public DefaultModifiableModelLessDataHolder(AbstractThreadSafeComponentExtensionPoint<RepositoryModelItemType> typeExtensionPoint, ModifiableRepositoryData repositoryData, Optional<? extends ModifiableModelLessDataHolder> parent, Optional<? extends ModifiableModelLessDataHolder> root) Creates a modifiable default model free data holder- Parameters:
typeExtensionPoint
- the extension point to use to get available element typesparent
- the parent of the createdDataHolder
, can benull
if the createdDataHolder
is the rootDataHolder
root
- the rootDataAwareAmetysObject
repositoryData
- the repository data to use
-
-
Method Details
-
getComposite
public ModifiableModelLessComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException Description copied from interface:ModelLessDataHolder
Retrieves the composite at the given path- Specified by:
getComposite
in interfaceDataHolder
- Specified by:
getComposite
in interfaceModelLessDataHolder
- Specified by:
getComposite
in interfaceModifiableDataHolder
- Specified by:
getComposite
in interfaceModifiableModelLessDataHolder
- Overrides:
getComposite
in classDefaultModelLessDataHolder
- Parameters:
compositePath
- path of the composite to retrieve- Returns:
- the composite or
null
if not exists or is empty - Throws:
IllegalArgumentException
- if the given composite path is null or emptyBadItemTypeException
- if the stored value at the given path is not a composite
-
_getComposite
Description copied from class:DefaultModelLessDataHolder
Retrieves the composite with the given name- Overrides:
_getComposite
in classDefaultModelLessDataHolder
- Parameters:
name
- name of the composite to retrieve- Returns:
- the composite
- Throws:
BadItemTypeException
- if the value stored in the repository with the given name is not a composite
-
getComposite
public ModifiableModelLessComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, BadItemTypeException Description copied from interface:ModifiableModelLessDataHolder
Retrieves the composite at the given path- Specified by:
getComposite
in interfaceModifiableDataHolder
- Specified by:
getComposite
in interfaceModifiableModelLessDataHolder
- Parameters:
compositePath
- path of the composite to retrievecreateNew
-true
to create the composite if it does not exist,false
otherwise- Returns:
- the composite or
null
if createNew isfalse
and value not exists or is empty - Throws:
IllegalArgumentException
- if the given composite path is null or emptyBadItemTypeException
- if the stored value at the given path is not a composite
-
_getComposite
protected ModifiableModelLessComposite _getComposite(String name, boolean createNew) throws BadItemTypeException Retrieves the composite with the given name- Parameters:
name
- name of the composite to retrievecreateNew
-true
to create the composite if it does not exist,false
otherwise- Returns:
- the composite
- Throws:
BadItemTypeException
- if the value stored in the repository with the given name is not a composite
-
synchronizeValues
public boolean synchronizeValues(Map<String, Object> values) throws UnknownTypeException, NotUniqueTypeExceptionDescription copied from interface:ModifiableModelLessDataHolder
Synchronizes the given values with the current ones- Specified by:
synchronizeValues
in interfaceModifiableModelLessDataHolder
- Parameters:
values
- the values to synchronize- Returns:
true
if some values have changed,false
otherwise- Throws:
UnknownTypeException
- if there is no available type compatible with a given value for this data holder's type extension pointNotUniqueTypeException
- if there is more than one available types compatibles with the a value for this data holder's type extension point
-
setValue
public void setValue(String dataPath, Object value) throws IllegalArgumentException, UnknownTypeException, NotUniqueTypeException, UnknownDataException Description copied from interface:ModifiableModelLessDataHolder
Sets the value of the data at the given path- Specified by:
setValue
in interfaceModifiableModelLessDataHolder
- Parameters:
dataPath
- path of the datavalue
- the value to set. To empty a value, useModifiableModelLessDataHolder.setValue(String, Object, String)
with anull
value- Throws:
IllegalArgumentException
- if the given data path is null or emptyUnknownTypeException
- if there is no available type compatible with the given value for this data holder's type extension pointNotUniqueTypeException
- if there is more than one available types compatibles with the given value for this data holder's type extension pointUnknownDataException
- if given the data path is composed of an inexisting group
-
setValue
public void setValue(String dataPath, Object value, String dataTypeId) throws IllegalArgumentException, BadItemTypeException, UnknownDataException Description copied from interface:ModifiableModelLessDataHolder
Sets the value of the data at the given path- Specified by:
setValue
in interfaceModifiableModelLessDataHolder
- Parameters:
dataPath
- path of the datavalue
- the value to set. Givenull
to empty the value.dataTypeId
- type identifier of the data- Throws:
IllegalArgumentException
- if the given data path is null or emptyBadItemTypeException
- if the given type doesn't match the given value to setUnknownDataException
- if the given data path is composed of an inexisting group
-
removeValue
Description copied from interface:ModifiableModelLessDataHolder
Removes the stored value of the data at the given path- Specified by:
removeValue
in interfaceModifiableDataHolder
- Specified by:
removeValue
in interfaceModifiableModelLessDataHolder
- Parameters:
dataPath
- path of the data- Throws:
IllegalArgumentException
- if the given data path is null or emptyBadItemTypeException
- if the value of the parent of the given path is not an item container
-
_getParentValue
protected static ModifiableModelLessDataHolder _getParentValue(ModifiableModelLessDataHolder modifiableDataHolder, String dataPath) throws BadDataPathCardinalityException, BadItemTypeException Retrieves the modifiable data holder, last parent segment of the given data path Example : call this method with a path like 'my-composite1/my-composite2/my-data' will retrieve the composite 'my-composite2' in the composite 'my-composite1'- Parameters:
modifiableDataHolder
- the modifiable data holderdataPath
- the data path- Returns:
- the parent data holder
- Throws:
BadDataPathCardinalityException
- if the value of a part of the data path is multiple. Only the last part can be multipleBadItemTypeException
- if the value at the given data path is not a composite
-
getRepositoryData
Description copied from interface:DataHolder
Retrieves the repository data used by thisDataHolder
- Specified by:
getRepositoryData
in interfaceDataHolder
- Specified by:
getRepositoryData
in interfaceModifiableDataHolder
- Overrides:
getRepositoryData
in classDefaultModelLessDataHolder
- Returns:
- the repository data used by this
DataHolder
-
getParentDataHolder
Description copied from interface:DataHolder
Retrieves the optional parent of the currentDataHolder
There can be no parent if the currentDataHolder
is the root- Specified by:
getParentDataHolder
in interfaceDataHolder
- Specified by:
getParentDataHolder
in interfaceModelLessDataHolder
- Specified by:
getParentDataHolder
in interfaceModifiableDataHolder
- Specified by:
getParentDataHolder
in interfaceModifiableModelLessDataHolder
- Overrides:
getParentDataHolder
in classDefaultModelLessDataHolder
- Returns:
- the parent of the current
DataHolder
-
getRootDataHolder
Description copied from interface:DataHolder
Retrieves theDataHolder
that is the root of the current one- Specified by:
getRootDataHolder
in interfaceDataHolder
- Specified by:
getRootDataHolder
in interfaceModelLessDataHolder
- Specified by:
getRootDataHolder
in interfaceModifiableDataHolder
- Specified by:
getRootDataHolder
in interfaceModifiableModelLessDataHolder
- Overrides:
getRootDataHolder
in classDefaultModelLessDataHolder
- Returns:
- the root
DataHolder
-