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
Modifier and TypeFieldDescriptionprotected ModifiableIndexableDataHolder
Parent of the currentRepeater
protected ModifiableRepositoryData
Modifiable repository data to use to store entries in the repositoryprotected ModifiableIndexableDataHolder
RootDataHolder
Fields inherited from class org.ametys.cms.data.holder.group.impl.DefaultModelAwareRepeater
_definition, _parent, _repositoryData, _root
-
Constructor Summary
ConstructorDescriptionDefaultModifiableModelAwareRepeater
(ModifiableRepositoryData repositoryData, ModifiableIndexableDataHolder parent, ModifiableIndexableDataHolder root, RepeaterDefinition definition) 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 currentRepeater
Retrieves the repository data used by thisRepeater
Retrieves the rootDataHolder
of the current repeaterboolean
moveEntries
(Map<Integer, Integer> positionsMapping, int targetSize) Moves the entries according to the given position mapping.void
removeEntries
(Set<Integer> positions) Removes the repeater entries at the given positions.void
removeEntry
(int position) Removes the repeater entry at the given position.<T extends SynchronizationResult>
TsynchronizeValues
(ViewItemContainer viewItemContainer, SynchronizableRepeater repeaterValues) Synchronizes the given values with each repeater's entry<T extends SynchronizationResult>
TsynchronizeValues
(ViewItemContainer viewItemContainer, SynchronizableRepeater repeaterValues, SynchronizationContext context) Synchronizes the given values with each repeater's entryMethods inherited from class org.ametys.cms.data.holder.group.impl.DefaultModelAwareRepeater
commentsToSAX, copyTo, dataToJSON, dataToJSON, dataToJSON, dataToSAX, dataToSAX, dataToSAX, getModel, getSize, hasEntry, indexData
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.cms.data.holder.group.IndexableRepeater
indexData, indexData
Methods inherited from interface org.ametys.plugins.repository.data.holder.group.ModelAwareRepeater
dataToJSON, dataToJSON, dataToJSON, dataToJSON, dataToSAX, dataToSAX, dataToSAX, dataToSAX, getModel
Methods inherited from interface org.ametys.plugins.repository.data.holder.group.Repeater
copyTo, dataToJSON, dataToJSON, dataToSAX, dataToSAX, getSize, hasEntry
-
Field Details
-
_modifiableRepositoryData
Modifiable repository data to use to store entries in the repository -
_modifiableParent
Parent of the currentRepeater
-
_modifiableRoot
RootDataHolder
-
-
Constructor Details
-
DefaultModifiableModelAwareRepeater
public DefaultModifiableModelAwareRepeater(ModifiableRepositoryData repositoryData, ModifiableIndexableDataHolder parent, ModifiableIndexableDataHolder root, RepeaterDefinition definition) Creates a modifiable model aware repeater- Parameters:
repositoryData
- the repository data of the repeaterparent
- the parent of the createdRepeater
root
- the rootDataHolder
definition
- the definition of the repeater
-
-
Method Details
-
getEntries
Description copied from interface:Repeater
Retrieves the repeater entries, sorted by position- Specified by:
getEntries
in interfaceIndexableRepeater
- Specified by:
getEntries
in interfaceModelAwareRepeater
- Specified by:
getEntries
in interfaceModifiableIndexableRepeater
- Specified by:
getEntries
in interfaceModifiableModelAwareRepeater
- Specified by:
getEntries
in interfaceRepeater
- Overrides:
getEntries
in classDefaultModelAwareRepeater
- Returns:
- the repeater entries
-
getEntry
Description copied from interface:Repeater
Retrieves 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:
getEntry
in interfaceIndexableRepeater
- Specified by:
getEntry
in interfaceModelAwareRepeater
- Specified by:
getEntry
in interfaceModifiableIndexableRepeater
- Specified by:
getEntry
in interfaceModifiableModelAwareRepeater
- Specified by:
getEntry
in interfaceModifiableRepeater
- Specified by:
getEntry
in interfaceRepeater
- Overrides:
getEntry
in classDefaultModelAwareRepeater
- Parameters:
position
- the position of the entry to retrieve- Returns:
- the repeater entry,
null
if there is no entry at this position
-
addEntry
Description copied from interface:ModifiableRepeater
Creates a Repeater entry at the last position.- Specified by:
addEntry
in interfaceModifiableIndexableRepeater
- Specified by:
addEntry
in interfaceModifiableModelAwareRepeater
- Specified by:
addEntry
in interfaceModifiableRepeater
- Returns:
- the created entry
-
addEntry
Description copied from interface:ModifiableRepeater
Creates 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:
addEntry
in interfaceModifiableIndexableRepeater
- Specified by:
addEntry
in interfaceModifiableModelAwareRepeater
- Specified by:
addEntry
in 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(ViewItemContainer viewItemContainer, SynchronizableRepeater repeaterValues) throws UndefinedItemPathException, BadItemTypeException Synchronizes the given values with each repeater's entry- Specified by:
synchronizeValues
in interfaceModifiableModelAwareRepeater
- Type Parameters:
T
- the type of theSynchronizationResult
- Parameters:
viewItemContainer
- TheViewItemContainer
containing all items to synchronizerepeaterValues
- the values of the repeater to synchronize- 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
-
synchronizeValues
public <T extends SynchronizationResult> T synchronizeValues(ViewItemContainer viewItemContainer, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Synchronizes the given values with each repeater's entry- Specified by:
synchronizeValues
in interfaceModifiableModelAwareRepeater
- Type Parameters:
T
- the type of theSynchronizationResult
- Parameters:
viewItemContainer
- TheViewItemContainer
containing 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:ModifiableRepeater
Moves 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:
moveEntries
in interfaceModifiableRepeater
- Parameters:
positionsMapping
- the position mappingtargetSize
- the target size of the repeater- Returns:
true
if some entries have moved,false
otherwise
-
removeEntries
Description copied from interface:ModifiableRepeater
Removes 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:
removeEntries
in 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:ModifiableRepeater
Removes 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:
removeEntry
in 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:Repeater
Retrieves the repository data used by thisRepeater
- Specified by:
getRepositoryData
in interfaceModifiableRepeater
- Specified by:
getRepositoryData
in interfaceRepeater
- Overrides:
getRepositoryData
in classDefaultModelAwareRepeater
- Returns:
- the repository data used by this
Repeater
-
getParentDataHolder
Description copied from interface:Repeater
Retrieves the parent of the currentRepeater
- Specified by:
getParentDataHolder
in interfaceIndexableRepeater
- Specified by:
getParentDataHolder
in interfaceModelAwareRepeater
- Specified by:
getParentDataHolder
in interfaceModifiableIndexableRepeater
- Specified by:
getParentDataHolder
in interfaceModifiableModelAwareRepeater
- Specified by:
getParentDataHolder
in interfaceModifiableRepeater
- Specified by:
getParentDataHolder
in interfaceRepeater
- Overrides:
getParentDataHolder
in classDefaultModelAwareRepeater
- Returns:
- the parent of the current
Repeater
-
getRootDataHolder
Description copied from interface:Repeater
Retrieves the rootDataHolder
of the current repeater- Specified by:
getRootDataHolder
in interfaceIndexableRepeater
- Specified by:
getRootDataHolder
in interfaceModelAwareRepeater
- Specified by:
getRootDataHolder
in interfaceModifiableIndexableRepeater
- Specified by:
getRootDataHolder
in interfaceModifiableModelAwareRepeater
- Specified by:
getRootDataHolder
in interfaceModifiableRepeater
- Specified by:
getRootDataHolder
in interfaceRepeater
- Overrides:
getRootDataHolder
in classDefaultModelAwareRepeater
- Returns:
- the root
DataHolder
-