Class DefaultModifiableDataHolder
java.lang.Object
org.ametys.plugins.repository.data.holder.impl.DefaultDataHolder
org.ametys.plugins.repository.data.holder.impl.DefaultModifiableDataHolder
- All Implemented Interfaces:
DataHolder,ModifiableDataHolder
Default implementation for modifiable data holder without model
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Optional<LockableAmetysObject> Ametys object that can be locked on data modificationprotected Optional<? extends ModifiableDataHolder> Parent of the currentDataHolderprotected ModifiableRepositoryDataRepository data to use to store data in the repositoryprotected ModifiableDataHolderRootDataHolderFields inherited from class org.ametys.plugins.repository.data.holder.impl.DefaultDataHolder
_parent, _repositoryData, _root, _typeExtensionPoint -
Constructor Summary
ConstructorsConstructorDescriptionDefaultModifiableDataHolder(ModelItemTypeExtensionPoint typeExtensionPoint, ModifiableRepositoryData repositoryData) Creates a modifiable default model free data holderDefaultModifiableDataHolder(ModelItemTypeExtensionPoint typeExtensionPoint, ModifiableRepositoryData repositoryData, Optional<LockableAmetysObject> lockableAmetysObject) Creates a modifiable default model free data holderDefaultModifiableDataHolder(ModelItemTypeExtensionPoint typeExtensionPoint, ModifiableRepositoryData repositoryData, Optional<LockableAmetysObject> lockableAmetysObject, Optional<? extends ModifiableDataHolder> parent, Optional<? extends ModifiableDataHolder> root) Creates a modifiable default model free data holder -
Method Summary
Modifier and TypeMethodDescriptionprotected Composite_getComposite(String name) Retrieves the composite with the given nameprotected ModifiableComposite_getComposite(String name, boolean createNew) Retrieves the composite with the given nameprotected static ModifiableDataHolder_getParentValue(ModifiableDataHolder 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 ModifiableDataHolder> Retrieves the optional parent of the currentDataHolderThere can be no parent if the currentDataHolderis the rootRetrieves the repository data used by thisDataHolderRetrieves theDataHolderthat is the root of the current onevoidremoveValue(String dataPath) Removes the stored value of the data at the given pathvoidSets the value of the data at the given pathvoidSets the value of the data at the given path<T extends SynchronizationResult>
TsynchronizeValues(Map<String, Object> values) Synchronizes the given values with the current onesMethods inherited from class org.ametys.plugins.repository.data.holder.impl.DefaultDataHolder
_getParentValue, dataToJSON, dataToJSON, dataToSAX, dataToSAX, getDataNames, getModelItemTypeExtensionPoint, getType, getValue, getValueOfType, getValueOfTypeOrDefault, getValueOrDefault, hasDifferences, hasValue, hasValue, hasValueOrEmpty, isMultiple, isMultipleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ametys.plugins.repository.data.holder.DataHolder
copyTo, copyTo, dataToJSON, dataToJSON, dataToJSON, dataToJSON, dataToSAX, dataToSAX, dataToSAX, dataToSAX, getDataNames, getModelItemTypeExtensionPoint, getType, getValue, getValueOfType, getValueOfTypeOrDefault, getValueOrDefault, hasDifferences, hasValue, hasValue, hasValueOrEmpty, isMultiple, isMultiple
-
Field Details
-
_modifiableRepositoryData
Repository data to use to store data in the repository -
_lockableAmetysObject
Ametys object that can be locked on data modification -
_modifiableParent
Parent of the currentDataHolder -
_modifiableRoot
RootDataHolder
-
-
Constructor Details
-
DefaultModifiableDataHolder
public DefaultModifiableDataHolder(ModelItemTypeExtensionPoint 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
-
DefaultModifiableDataHolder
public DefaultModifiableDataHolder(ModelItemTypeExtensionPoint typeExtensionPoint, ModifiableRepositoryData repositoryData, Optional<LockableAmetysObject> lockableAmetysObject) Creates a modifiable default model free data holder- Parameters:
typeExtensionPoint- the extension point to use to get available element typesrepositoryData- the repository data to uselockableAmetysObject- the ametys object that can be locked on data modification
-
DefaultModifiableDataHolder
public DefaultModifiableDataHolder(ModelItemTypeExtensionPoint typeExtensionPoint, ModifiableRepositoryData repositoryData, Optional<LockableAmetysObject> lockableAmetysObject, Optional<? extends ModifiableDataHolder> parent, Optional<? extends ModifiableDataHolder> root) Creates a modifiable default model free data holder- Parameters:
typeExtensionPoint- the extension point to use to get available element typesrepositoryData- the repository data to uselockableAmetysObject- the ametys object that can be locked on data modificationparent- the parent of the createdDataHolder, can benullif the createdDataHolderis the rootDataHolderroot- the rootDataHolder
-
-
Method Details
-
getComposite
public ModifiableComposite getComposite(String compositePath) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException Description copied from interface:DataHolderRetrieves the composite at the given path- Specified by:
getCompositein interfaceDataHolder- Specified by:
getCompositein interfaceModifiableDataHolder- Overrides:
getCompositein classDefaultDataHolder- Parameters:
compositePath- path of the composite to retrieve- Returns:
- the composite or
nullif not exists or is empty - Throws:
IllegalArgumentException- if the given composite path is null or emptyUnknownTypeException- if the type composite is not available for this data holderBadItemTypeException- if the stored value at the given path is not a composite
-
_getComposite
Description copied from class:DefaultDataHolderRetrieves the composite with the given name- Overrides:
_getCompositein classDefaultDataHolder- 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 ModifiableComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException Description copied from interface:ModifiableDataHolderRetrieves the composite at the given path- Specified by:
getCompositein interfaceModifiableDataHolder- Parameters:
compositePath- path of the composite to retrievecreateNew-trueto create the composite if it does not exist,falseotherwise- Returns:
- the composite or
nullif createNew isfalseand value not exists or is empty - Throws:
IllegalArgumentException- if the given composite path is null or emptyUnknownTypeException- if the type composite is not available for this data holderBadItemTypeException- if the stored value at the given path is not a composite
-
_getComposite
protected ModifiableComposite _getComposite(String name, boolean createNew) throws BadItemTypeException Retrieves the composite with the given name- Parameters:
name- name of the composite to retrievecreateNew-trueto create the composite if it does not exist,falseotherwise- Returns:
- the composite
- Throws:
BadItemTypeException- if the value stored in the repository with the given name is not a composite
-
synchronizeValues
public <T extends SynchronizationResult> T synchronizeValues(Map<String, Object> values) throws UnknownTypeException, NotUniqueTypeException, BadItemTypeExceptionDescription copied from interface:ModifiableDataHolderSynchronizes the given values with the current ones- Specified by:
synchronizeValuesin interfaceModifiableDataHolder- Type Parameters:
T- the type of theSynchronizationResult- Parameters:
values- the values to synchronize- Returns:
- the
SynchronizationResult - 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 pointBadItemTypeException- if type of the a data doesn't match the corresponding given value to set
-
setValue
public void setValue(String dataPath, Object value) throws IllegalArgumentException, UnknownDataException, UnknownTypeException, NotUniqueTypeException, BadItemTypeException Description copied from interface:ModifiableDataHolderSets the value of the data at the given path- Specified by:
setValuein interfaceModifiableDataHolder- Parameters:
dataPath- path of the datavalue- the value to set. To empty a value, useModifiableDataHolder.setValue(String, Object, String)with anullvalue- Throws:
IllegalArgumentException- if the given data path is null or emptyUnknownDataException- if the given the data path is composed of an non existing groupUnknownTypeException- 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 pointBadItemTypeException- if type of the data at the given path doesn't match the given value to set
-
setValue
public void setValue(String dataPath, Object value, String dataTypeId) throws IllegalArgumentException, UnknownDataException, UnknownTypeException, BadItemTypeException Description copied from interface:ModifiableDataHolderSets the value of the data at the given path- Specified by:
setValuein interfaceModifiableDataHolder- Parameters:
dataPath- path of the datavalue- the value to set. Givenullto empty the value.dataTypeId- type identifier of the data- Throws:
IllegalArgumentException- if the given data path is null or emptyUnknownDataException- if the given data path is composed of an non existing groupUnknownTypeException- if the given type is not available for this data holder's type extension pointBadItemTypeException- if the given type doesn't match the given value to set
-
removeValue
public void removeValue(String dataPath) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException Description copied from interface:ModifiableDataHolderRemoves the stored value of the data at the given path- Specified by:
removeValuein interfaceModifiableDataHolder- Parameters:
dataPath- path of the data- Throws:
IllegalArgumentException- if the given data path is null or emptyUnknownTypeException- if the the data to remove is in a group and there is no available type compatible with this groupBadItemTypeException- if the value of the parent of the given path is not an item container
-
_getParentValue
protected static ModifiableDataHolder _getParentValue(ModifiableDataHolder modifiableDataHolder, String dataPath) throws UnknownTypeException, 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:
UnknownTypeException- if the composite type is not available for this data holderBadItemTypeException- if the value at the given data path is not a composite
-
getRepositoryData
Description copied from interface:DataHolderRetrieves the repository data used by thisDataHolder- Specified by:
getRepositoryDatain interfaceDataHolder- Specified by:
getRepositoryDatain interfaceModifiableDataHolder- Overrides:
getRepositoryDatain classDefaultDataHolder- Returns:
- the repository data used by this
DataHolder
-
getParentDataHolder
Description copied from interface:DataHolderRetrieves the optional parent of the currentDataHolderThere can be no parent if the currentDataHolderis the root- Specified by:
getParentDataHolderin interfaceDataHolder- Specified by:
getParentDataHolderin interfaceModifiableDataHolder- Overrides:
getParentDataHolderin classDefaultDataHolder- Returns:
- the parent of the current
DataHolder
-
getRootDataHolder
Description copied from interface:DataHolderRetrieves theDataHolderthat is the root of the current one- Specified by:
getRootDataHolderin interfaceDataHolder- Specified by:
getRootDataHolderin interfaceModifiableDataHolder- Overrides:
getRootDataHolderin classDefaultDataHolder- Returns:
- the root
DataHolder
-