Class DefaultModifiableModelAwareRepeater
java.lang.Object
org.ametys.cms.data.holder.group.impl.DefaultModelAwareRepeater
org.ametys.cms.data.holder.group.impl.DefaultModifiableModelAwareRepeater
- All Implemented Interfaces:
IndexableRepeater,ModifiableIndexableRepeater,ModelAwareRepeater,ModifiableModelAwareRepeater,ModifiableRepeater,Repeater
public class DefaultModifiableModelAwareRepeater
extends DefaultModelAwareRepeater
implements ModifiableIndexableRepeater
CLass for modifiable model aware repeaters
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Optional<LockableAmetysObject> Ametys object that can be locked on data modificationprotected ModifiableIndexableDataHolderParent of the currentRepeaterprotected ModifiableRepositoryDataModifiable repository data to use to store entries in the repositoryprotected ModifiableIndexableDataHolderRootDataHolderFields inherited from class org.ametys.cms.data.holder.group.impl.DefaultModelAwareRepeater
_definition, _parent, _repositoryData, _root -
Constructor Summary
ConstructorsConstructorDescriptionDefaultModifiableModelAwareRepeater(ModifiableRepositoryData repositoryData, RepeaterDefinition definition, Optional<LockableAmetysObject> lockableAmetysObject, ModifiableIndexableDataHolder parent, ModifiableIndexableDataHolder root) Creates a modifiable model aware repeater -
Method Summary
Modifier and TypeMethodDescriptionaddEntry()Creates a Repeater entry at the last position.addEntry(int position) Creates a Repeater entry at the given position.List<? extends ModifiableIndexableRepeaterEntry> Retrieves the repeater entries, sorted by positiongetEntry(int position) Retrieves the repeater entry at the given position.Retrieves the parent of the currentRepeaterRetrieves the repository data used by thisRepeaterRetrieves the rootDataHolderof the current repeaterbooleanmoveEntries(Map<Integer, Integer> positionsMapping, int targetSize) Moves the entries according to the given position mapping.voidremoveEntries(Set<Integer> positions) Removes the repeater entries at the given positions.voidremoveEntry(int position) Removes the repeater entry at the given position.<T extends SynchronizationResult>
TsynchronizeValues(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) Synchronizes the given values with each repeater's entryMethods inherited from class org.ametys.cms.data.holder.group.impl.DefaultModelAwareRepeater
_getDifferencesInAppendMode, _getDifferencesInReplaceAllMode, _getDifferencesInReplaceMode, _hasDifferencesInAppendMode, _hasDifferencesInReplaceAllMode, _hasDifferencesInReplaceMode, copyTo, dataToJSON, dataToJSON, dataToJSON, dataToJSONForEdition, dataToSAX, dataToSAX, dataToSAX, dataToSAXForEdition, getDifferences, getModel, getSize, hasDifferences, hasEntry, hasToMoveEntries, indexDataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ametys.cms.data.holder.group.IndexableRepeater
indexData, indexDataMethods inherited from interface org.ametys.plugins.repository.data.holder.group.ModelAwareRepeater
dataToJSON, dataToJSON, dataToJSON, dataToJSON, dataToJSONForEdition, dataToSAX, dataToSAX, dataToSAX, dataToSAX, dataToSAXForEdition, getDifferences, getDifferences, getModel, hasDifferences, hasDifferencesMethods inherited from interface org.ametys.plugins.repository.data.holder.group.ModifiableModelAwareRepeater
synchronizeValuesMethods inherited from interface org.ametys.plugins.repository.data.holder.group.Repeater
copyTo, copyTo, dataToJSON, dataToJSON, dataToSAX, dataToSAX, getSize, hasEntry, hasToMoveEntries
-
Field Details
-
_modifiableRepositoryData
Modifiable repository data to use to store entries in the repository -
_lockableAmetysObject
Ametys object that can be locked on data modification -
_modifiableParent
Parent of the currentRepeater -
_modifiableRoot
RootDataHolder
-
-
Constructor Details
-
DefaultModifiableModelAwareRepeater
public DefaultModifiableModelAwareRepeater(ModifiableRepositoryData repositoryData, RepeaterDefinition definition, Optional<LockableAmetysObject> lockableAmetysObject, ModifiableIndexableDataHolder parent, ModifiableIndexableDataHolder root) Creates a modifiable model aware repeater- Parameters:
repositoryData- the repository data of the repeaterdefinition- the definition of the repeaterlockableAmetysObject- the ametys object that can be locked on data modificationparent- the parent of the createdRepeaterroot- the rootDataHolder
-
-
Method Details
-
getEntries
Description copied from interface:RepeaterRetrieves the repeater entries, sorted by position- Specified by:
getEntriesin interfaceIndexableRepeater- Specified by:
getEntriesin interfaceModelAwareRepeater- Specified by:
getEntriesin interfaceModifiableIndexableRepeater- Specified by:
getEntriesin interfaceModifiableModelAwareRepeater- Specified by:
getEntriesin interfaceRepeater- Overrides:
getEntriesin classDefaultModelAwareRepeater- Returns:
- the repeater entries
-
getEntry
Description copied from interface:RepeaterRetrieves the repeater entry at the given position. The position starts at index 1. The position can be an integer between 1 and the repeater size to get an entry from the beginning Or the position can an integer between 0 and - the repeater size to get an entry from the end (0 means at the end, -1 means before the last one and so on)- Specified by:
getEntryin interfaceIndexableRepeater- Specified by:
getEntryin interfaceModelAwareRepeater- Specified by:
getEntryin interfaceModifiableIndexableRepeater- Specified by:
getEntryin interfaceModifiableModelAwareRepeater- Specified by:
getEntryin interfaceModifiableRepeater- Specified by:
getEntryin interfaceRepeater- Overrides:
getEntryin classDefaultModelAwareRepeater- Parameters:
position- the position of the entry to retrieve- Returns:
- the repeater entry,
nullif there is no entry at this position
-
addEntry
Description copied from interface:ModifiableRepeaterCreates a Repeater entry at the last position.- Specified by:
addEntryin interfaceModifiableIndexableRepeater- Specified by:
addEntryin interfaceModifiableModelAwareRepeater- Specified by:
addEntryin interfaceModifiableRepeater- Returns:
- the created entry
-
addEntry
Description copied from interface:ModifiableRepeaterCreates a Repeater entry at the given position. The position starts at index 1. The position can be an integer between 1 and the repeater size + 1 to insert an entry from the beginning Or the position can an integer between 0 and - the repeater size to insert an entry from the end (0 means at the end, -1 means before the last one and so on)- Specified by:
addEntryin interfaceModifiableIndexableRepeater- Specified by:
addEntryin interfaceModifiableModelAwareRepeater- Specified by:
addEntryin interfaceModifiableRepeater- Parameters:
position- The position of the new entry- Returns:
- the created entry
- Throws:
IllegalArgumentException- if the position is not between the negative and positive repeater size
-
synchronizeValues
public <T extends SynchronizationResult> T synchronizeValues(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Description copied from interface:ModifiableModelAwareRepeaterSynchronizes the given values with each repeater's entry- Specified by:
synchronizeValuesin interfaceModifiableModelAwareRepeater- Type Parameters:
T- the type of theSynchronizationResult- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to synchronizerepeaterValues- the values of the repeater to synchronizecontext- the context of the synchronization- Returns:
- the
SynchronizationResult - Throws:
UndefinedItemPathException- if an entry's key refers to a data that is not defined by the modelBadItemTypeException- if the type defined by the model of one entry's key doesn't match the corresponding value
-
moveEntries
Description copied from interface:ModifiableRepeaterMoves the entries according to the given position mapping. The given position mapping's key is the previous position and the value is the new one The existent entries with no corresponding entry in the position mapping will be removed the given size is taken into account to create new empty entries if needed- Specified by:
moveEntriesin interfaceModifiableRepeater- Parameters:
positionsMapping- the position mappingtargetSize- the target size of the repeater- Returns:
trueif some entries have moved,falseotherwise
-
removeEntries
Description copied from interface:ModifiableRepeaterRemoves the repeater entries at the given positions. The position starts at index 1. The positions can be integers between 1 and the repeater size to remove an entry from the beginning Or the positions can integers between 0 and - the repeater size to remove an entry from the end (0 means the last entry, -1 means before the last one and so on)- Specified by:
removeEntriesin interfaceModifiableRepeater- Parameters:
positions- The positions of the entries to remove- Throws:
UnknownDataException- if there is no entry for one of the given positions
-
removeEntry
Description copied from interface:ModifiableRepeaterRemoves the repeater entry at the given position. The position starts at index 1. The position can be an integer between 1 and the repeater size to remove an entry from the beginning Or the position can an integer between 0 and - the repeater size to remove an entry from the end (0 means the last entry, -1 means before the last one and so on)- Specified by:
removeEntryin interfaceModifiableRepeater- Parameters:
position- The position of the entry to remove- Throws:
UnknownDataException- if there is no entry at the given position
-
getRepositoryData
Description copied from interface:RepeaterRetrieves the repository data used by thisRepeater- Specified by:
getRepositoryDatain interfaceModifiableRepeater- Specified by:
getRepositoryDatain interfaceRepeater- Overrides:
getRepositoryDatain classDefaultModelAwareRepeater- Returns:
- the repository data used by this
Repeater
-
getParentDataHolder
Description copied from interface:RepeaterRetrieves the parent of the currentRepeater- Specified by:
getParentDataHolderin interfaceIndexableRepeater- Specified by:
getParentDataHolderin interfaceModelAwareRepeater- Specified by:
getParentDataHolderin interfaceModifiableIndexableRepeater- Specified by:
getParentDataHolderin interfaceModifiableModelAwareRepeater- Specified by:
getParentDataHolderin interfaceModifiableRepeater- Specified by:
getParentDataHolderin interfaceRepeater- Overrides:
getParentDataHolderin classDefaultModelAwareRepeater- Returns:
- the parent of the current
Repeater
-
getRootDataHolder
Description copied from interface:RepeaterRetrieves the rootDataHolderof the current repeater- Specified by:
getRootDataHolderin interfaceIndexableRepeater- Specified by:
getRootDataHolderin interfaceModelAwareRepeater- Specified by:
getRootDataHolderin interfaceModifiableIndexableRepeater- Specified by:
getRootDataHolderin interfaceModifiableModelAwareRepeater- Specified by:
getRootDataHolderin interfaceModifiableRepeater- Specified by:
getRootDataHolderin interfaceRepeater- Overrides:
getRootDataHolderin classDefaultModelAwareRepeater- Returns:
- the root
DataHolder
-