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
FieldsModifier and TypeFieldDescriptionprotected Optional<LockableAmetysObject> Ametys object that can be locked on data modificationprotected Optional<? extends ModifiableModelLessDataHolder> Parent of the currentDataHolderprotected ModifiableRepositoryDataRepository data to use to store data in the repositoryprotected ModifiableModelLessDataHolderRootDataHolderFields inherited from class org.ametys.plugins.repository.data.holder.impl.DefaultModelLessDataHolder
_parent, _repositoryData, _root, _typeExtensionPoint -
Constructor Summary
ConstructorsConstructorDescriptionDefaultModifiableModelLessDataHolder(ModelItemTypeExtensionPoint typeExtensionPoint, ModifiableRepositoryData repositoryData) Creates a modifiable default model free data holderDefaultModifiableModelLessDataHolder(ModelItemTypeExtensionPoint typeExtensionPoint, ModifiableRepositoryData repositoryData, Optional<LockableAmetysObject> lockableAmetysObject) Creates a modifiable default model free data holderDefaultModifiableModelLessDataHolder(ModelItemTypeExtensionPoint typeExtensionPoint, ModifiableRepositoryData repositoryData, Optional<LockableAmetysObject> lockableAmetysObject, 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 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 pathbooleansynchronizeValues(Map<String, Object> values) Synchronizes the given values with the current onesMethods inherited from class org.ametys.plugins.repository.data.holder.impl.DefaultModelLessDataHolder
_getParentValue, dataToJSON, dataToJSON, dataToSAX, dataToSAX, getDataNames, getModelItemTypeExtensionPoint, getType, getValue, getValue, getValueOfType, getValueOfType, 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, dataToSAX, dataToSAX, getDataNamesMethods inherited from interface org.ametys.plugins.repository.data.holder.ModelLessDataHolder
dataToJSON, dataToJSON, dataToSAX, dataToSAX, getModelItemTypeExtensionPoint, getType, getValue, getValue, getValueOfType, getValueOfType, 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
-
DefaultModifiableModelLessDataHolder
public DefaultModifiableModelLessDataHolder(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
-
DefaultModifiableModelLessDataHolder
public DefaultModifiableModelLessDataHolder(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
-
DefaultModifiableModelLessDataHolder
public DefaultModifiableModelLessDataHolder(ModelItemTypeExtensionPoint typeExtensionPoint, ModifiableRepositoryData repositoryData, Optional<LockableAmetysObject> lockableAmetysObject, 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 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 ModifiableModelLessComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException Description copied from interface:ModelLessDataHolderRetrieves the composite at the given path- Specified by:
getCompositein interfaceDataHolder- Specified by:
getCompositein interfaceModelLessDataHolder- Specified by:
getCompositein interfaceModifiableDataHolder- Specified by:
getCompositein interfaceModifiableModelLessDataHolder- Overrides:
getCompositein classDefaultModelLessDataHolder- 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 emptyBadItemTypeException- if the stored value at the given path is not a composite
-
_getComposite
Description copied from class:DefaultModelLessDataHolderRetrieves the composite with the given name- Overrides:
_getCompositein 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:ModifiableModelLessDataHolderRetrieves the composite at the given path- Specified by:
getCompositein interfaceModifiableDataHolder- Specified by:
getCompositein interfaceModifiableModelLessDataHolder- 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 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-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 boolean synchronizeValues(Map<String, Object> values) throws UnknownTypeException, NotUniqueTypeExceptionDescription copied from interface:ModifiableModelLessDataHolderSynchronizes the given values with the current ones- Specified by:
synchronizeValuesin interfaceModifiableModelLessDataHolder- Parameters:
values- the values to synchronize- Returns:
trueif some values have changed,falseotherwise- 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:ModifiableModelLessDataHolderSets the value of the data at the given path- Specified by:
setValuein interfaceModifiableModelLessDataHolder- Parameters:
dataPath- path of the datavalue- the value to set. To empty a value, useModifiableModelLessDataHolder.setValue(String, Object, String)with anullvalue- 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:ModifiableModelLessDataHolderSets the value of the data at the given path- Specified by:
setValuein interfaceModifiableModelLessDataHolder- 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 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:ModifiableModelLessDataHolderRemoves the stored value of the data at the given path- Specified by:
removeValuein interfaceModifiableDataHolder- Specified by:
removeValuein 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:DataHolderRetrieves the repository data used by thisDataHolder- Specified by:
getRepositoryDatain interfaceDataHolder- Specified by:
getRepositoryDatain interfaceModifiableDataHolder- Overrides:
getRepositoryDatain classDefaultModelLessDataHolder- 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 interfaceModelLessDataHolder- Specified by:
getParentDataHolderin interfaceModifiableDataHolder- Specified by:
getParentDataHolderin interfaceModifiableModelLessDataHolder- Overrides:
getParentDataHolderin classDefaultModelLessDataHolder- 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 interfaceModelLessDataHolder- Specified by:
getRootDataHolderin interfaceModifiableDataHolder- Specified by:
getRootDataHolderin interfaceModifiableModelLessDataHolder- Overrides:
getRootDataHolderin classDefaultModelLessDataHolder- Returns:
- the root
DataHolder
-