Class DefaultModelAwareRepeater
java.lang.Object
org.ametys.cms.data.holder.group.impl.DefaultModelAwareRepeater
- All Implemented Interfaces:
IndexableRepeater,ModelAwareRepeater,Repeater
- Direct Known Subclasses:
DefaultModifiableModelAwareRepeater
Class for model aware repeaters
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RepeaterDefinitionDefinition of this repeaterprotected IndexableDataHolderParent of the currentRepeaterprotected RepositoryDataRepository data to use to store entries in the repositoryprotected IndexableDataHolderRootDataHolder -
Constructor Summary
ConstructorsConstructorDescriptionDefaultModelAwareRepeater(RepositoryData repositoryData, RepeaterDefinition definition, IndexableDataHolder parent, IndexableDataHolder root) Creates a model aware repeater -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<ModelItem>_getDifferencesInAppendMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) Get the collection of model items where there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is APPENDprotected Collection<ModelItem>_getDifferencesInReplaceAllMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) Get the collection of model items where there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is REPLACE_ALLprotected Collection<ModelItem>_getDifferencesInReplaceMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) Get the collection of model items where there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is REPLACEprotected boolean_hasDifferencesInAppendMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) Check if there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is APPENDprotected boolean_hasDifferencesInReplaceAllMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) Check if there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is REPLACE_ALLprotected boolean_hasDifferencesInReplaceMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) Check if there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is REPLACEvoidcommentsToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor) Generates SAX events for the comments of the data in the given view in the currentDataHoldervoidcopyTo(ModifiableRepeater repeater, DataContext context) Copies the currentRepeaterto the givenModifiableRepeater.dataToJSON(String dataPath, DataContext context) Convert the data at the given path into a JSON objectdataToJSON(DataContext context) Convert into a JSON object the data in the model of the currentRepeaterdataToJSON(ViewItemAccessor viewItemAccessor, DataContext context) Convert into a JSON object the data in the given view of the currentRepeaterdataToJSONForEdition(ViewItemAccessor viewItemAccessor, DataContext context) Convert into a JSON object the data in the given view in edition mode of the currentRepeatervoiddataToSAX(ContentHandler contentHandler, String dataPath, DataContext context) Generates SAX events for the data at the given data path in the currentDataHolderDo not generate any event if there is no values at the given pathvoiddataToSAX(ContentHandler contentHandler, DataContext context) Generates SAX events for the data in the model of the currentDataHoldervoiddataToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) Generates SAX events for the data in the given view in the currentRepeatervoiddataToSAXForEdition(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) Generates SAX events for the data in the given view in edition mode in the currentRepeatergetDifferences(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) Get the collection of model items where there are differences between the given values and the repeater's entriesList<? extends IndexableRepeaterEntry>Retrieves the repeater entries, sorted by positiongetEntry(int position) Retrieves the repeater entry at the given position.getModel()Retrieves the repeater's modelRetrieves the parent of the currentRepeaterRetrieves the repository data used by thisRepeaterRetrieves the rootDataHolderof the current repeaterintgetSize()Retrieves the size of the repeaterbooleanhasDifferences(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) Check if there are differences between the given values and the repeater's entriesbooleanhasEntry(int position) Determines if the repeater has an entry at the given position.booleanhasToMoveEntries(Map<Integer, Integer> positionsMapping, int targetSize) Check if has to be moved according to the given position mapping.List<org.apache.solr.common.SolrInputDocument>indexData(org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument rootDocument, String solrFieldPrefix, IndexableDataContext context) Indexes all data and properties of thisRepeaterMethods 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
indexDataMethods inherited from interface org.ametys.plugins.repository.data.holder.group.ModelAwareRepeater
dataToJSON, dataToJSON, dataToSAX, dataToSAX, getDifferences, hasDifferencesMethods inherited from interface org.ametys.plugins.repository.data.holder.group.Repeater
copyTo, dataToJSON, dataToSAX
-
Field Details
-
_definition
Definition of this repeater -
_parent
Parent of the currentRepeater -
_root
RootDataHolder -
_repositoryData
Repository data to use to store entries in the repository
-
-
Constructor Details
-
DefaultModelAwareRepeater
public DefaultModelAwareRepeater(RepositoryData repositoryData, RepeaterDefinition definition, IndexableDataHolder parent, IndexableDataHolder root) Creates a model aware repeater- Parameters:
repositoryData- the repository data of the repeaterdefinition- the definition of the repeaterparent- 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 interfaceRepeater- 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 interfaceRepeater- Parameters:
position- the position of the entry to retrieve- Returns:
- the repeater entry,
nullif there is no entry at this position
-
getSize
Description copied from interface:RepeaterRetrieves the size of the repeater -
hasEntry
Description copied from interface:RepeaterDetermines if the repeater has an 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) -
getModel
Retrieves the repeater's model- Specified by:
getModelin interfaceModelAwareRepeater- Returns:
- the repeater's model
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, String dataPath, DataContext context) throws SAXException Description copied from interface:RepeaterGenerates SAX events for the data at the given data path in the currentDataHolderDo not generate any event if there is no values at the given path- Specified by:
dataToSAXin interfaceRepeater- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsdataPath- the path of the data to SAXcontext- The context of the data to SAX- Throws:
SAXException- if an error occurs during the SAX events generation
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, DataContext context) throws SAXException, BadItemTypeException Description copied from interface:ModelAwareRepeaterGenerates SAX events for the data in the model of the currentDataHolder- Specified by:
dataToSAXin interfaceModelAwareRepeater- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventscontext- The context of the data to SAX- Throws:
SAXException- if an error occurs during the SAX events generationBadItemTypeException- if the saxed value's type does not matches the stored data
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) throws SAXException, BadItemTypeException Description copied from interface:ModelAwareRepeaterGenerates SAX events for the data in the given view in the currentRepeater- Specified by:
dataToSAXin interfaceModelAwareRepeater- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsviewItemAccessor- theViewItemAccessorreferencing the items for which generate SAX eventscontext- The context of the data to SAX- Throws:
SAXException- if an error occurs during the SAX events generationBadItemTypeException- if the saxed value's type does not matches the stored data
-
dataToSAXForEdition
public void dataToSAXForEdition(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) throws SAXException, BadItemTypeException Description copied from interface:ModelAwareRepeaterGenerates SAX events for the data in the given view in edition mode in the currentRepeater- Specified by:
dataToSAXForEditionin interfaceModelAwareRepeater- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsviewItemAccessor- theViewItemAccessorreferencing the items for which generate SAX eventscontext- The context of the data to SAX- Throws:
SAXException- if an error occurs during the SAX events generationBadItemTypeException- if the saxed value's type does not matches the stored data
-
dataToJSON
Description copied from interface:RepeaterConvert the data at the given path into a JSON object- Specified by:
dataToJSONin interfaceRepeater- Parameters:
dataPath- the path of the data to convertcontext- The context of the data to convert- Returns:
- The value as JSON
- Throws:
IOException- if an error occurs while reading a value using the I/O API
-
dataToJSON
Description copied from interface:ModelAwareRepeaterConvert into a JSON object the data in the model of the currentRepeater- Specified by:
dataToJSONin interfaceModelAwareRepeater- Parameters:
context- The context of the data to convert- Returns:
- The data of the current
DataHolderas JSON - Throws:
BadItemTypeException- if the value's type does not matches the stored data
-
dataToJSON
public Map<String,Object> dataToJSON(ViewItemAccessor viewItemAccessor, DataContext context) throws BadItemTypeException Description copied from interface:ModelAwareRepeaterConvert into a JSON object the data in the given view of the currentRepeater- Specified by:
dataToJSONin interfaceModelAwareRepeater- Parameters:
viewItemAccessor- theViewItemAccessorreferencing the items to convertcontext- The context of the data to convert- Returns:
- The data of the given view as JSON
- Throws:
BadItemTypeException- if the value's type does not matches the stored data
-
dataToJSONForEdition
public Map<String,Object> dataToJSONForEdition(ViewItemAccessor viewItemAccessor, DataContext context) throws BadItemTypeException Description copied from interface:ModelAwareRepeaterConvert into a JSON object the data in the given view in edition mode of the currentRepeater- Specified by:
dataToJSONForEditionin interfaceModelAwareRepeater- Parameters:
viewItemAccessor- theViewItemAccessorreferencing the items to convertcontext- The context of the data to convert- Returns:
- The data of the given view as JSON
- Throws:
BadItemTypeException- if the value's type does not matches the stored data
-
commentsToSAX
public void commentsToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor) throws SAXException Generates SAX events for the comments of the data in the given view in the currentDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsviewItemAccessor- theViewItemAccessorreferencing the items for which generate SAX events- Throws:
SAXException- if an error occurs during the SAX events generation
-
copyTo
public void copyTo(ModifiableRepeater repeater, DataContext context) throws UndefinedItemPathException, BadItemTypeException, UnknownTypeException, NotUniqueTypeException Description copied from interface:RepeaterCopies the currentRepeaterto the givenModifiableRepeater.- Specified by:
copyToin interfaceRepeater- Parameters:
repeater- The destination repeater. Can not be null.context- The context of the data to copy- Throws:
UndefinedItemPathException- if one of the copied data is not defined by the model of the destinationModifiableModelAwareRepeaterBadItemTypeException- if the type defined by the model of the destinationModifiableModelAwareRepeaterdoesn't match the copied valueUnknownTypeExceptionNotUniqueTypeException
-
indexData
public List<org.apache.solr.common.SolrInputDocument> indexData(org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument rootDocument, String solrFieldPrefix, IndexableDataContext context) throws BadItemTypeException Description copied from interface:IndexableRepeaterIndexes all data and properties of thisRepeater- Specified by:
indexDatain interfaceIndexableRepeater- Parameters:
document- the solr document representing thisRepeaterrootDocument- the solr document of the root object.solrFieldPrefix- the prefix of the solr fieldcontext- The context of the data to index- Returns:
- additional solr documents that may have been created (ex: repeater entries)
- Throws:
BadItemTypeException- if the saxed value's type does not matches the stored data
-
hasDifferences
public boolean hasDifferences(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Description copied from interface:ModelAwareRepeaterCheck if there are differences between the given values and the repeater's entries- Specified by:
hasDifferencesin interfaceModelAwareRepeater- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkrepeaterValues- the values of the repeater to checkcontext- the context of the synchronization- Returns:
trueif there are differences,falseotherwise- 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 of the entry's key doesn't match the corresponding value
-
_hasDifferencesInAppendMode
protected boolean _hasDifferencesInAppendMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Check if there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is APPEND- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkrepeaterValues- the values of the repeater to checkcontext- the context of the synchronization- Returns:
trueif there are differences,falseotherwise- 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 of the entry's key doesn't match the corresponding value
-
_hasDifferencesInReplaceMode
protected boolean _hasDifferencesInReplaceMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Check if there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is REPLACE- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkrepeaterValues- the values of the repeater to checkcontext- the context of the synchronization- Returns:
trueif there are differences,falseotherwise- 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 of the entry's key doesn't match the corresponding value
-
_hasDifferencesInReplaceAllMode
protected boolean _hasDifferencesInReplaceAllMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Check if there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is REPLACE_ALL- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkrepeaterValues- the values of the repeater to checkcontext- the context of the synchronization- Returns:
trueif there are differences,falseotherwise- 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 of the entry's key doesn't match the corresponding value
-
getDifferences
public Collection<ModelItem> getDifferences(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Description copied from interface:ModelAwareRepeaterGet the collection of model items where there are differences between the given values and the repeater's entries- Specified by:
getDifferencesin interfaceModelAwareRepeater- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkrepeaterValues- the values of the repeater to checkcontext- the context of the synchronization- Returns:
- a collection of model items with differences
- Throws:
UndefinedItemPathException- if a key in the given Map refers to a data that is not defined by the modelBadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
_getDifferencesInAppendMode
protected Collection<ModelItem> _getDifferencesInAppendMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Get the collection of model items where there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is APPEND- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkrepeaterValues- the values of the repeater to checkcontext- the context of the synchronization- Returns:
- a collection of model items with differences
- Throws:
UndefinedItemPathException- if a key in the given Map refers to a data that is not defined by the modelBadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
_getDifferencesInReplaceMode
protected Collection<ModelItem> _getDifferencesInReplaceMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Get the collection of model items where there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is REPLACE- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkrepeaterValues- the values of the repeater to checkcontext- the context of the synchronization- Returns:
- a collection of model items with differences
- Throws:
UndefinedItemPathException- if a key in the given Map refers to a data that is not defined by the modelBadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
_getDifferencesInReplaceAllMode
protected Collection<ModelItem> _getDifferencesInReplaceAllMode(ViewItemAccessor viewItemAccessor, SynchronizableRepeater repeaterValues, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException Get the collection of model items where there are differences between the given values and the repeater's entries ifSynchronizableRepeater.getMode()is REPLACE_ALL- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkrepeaterValues- the values of the repeater to checkcontext- the context of the synchronization- Returns:
- a collection of model items with differences
- Throws:
UndefinedItemPathException- if a key in the given Map refers to a data that is not defined by the modelBadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
hasToMoveEntries
Description copied from interface:RepeaterCheck if has to be moved 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 should be removed the given size is taken into account to create new empty entries if needed- Specified by:
hasToMoveEntriesin interfaceRepeater- Parameters:
positionsMapping- the position mappingtargetSize- the target size of the repeater- Returns:
trueif some entries have moved,falseotherwise
-
getRepositoryData
Description copied from interface:RepeaterRetrieves the repository data used by thisRepeater- Specified by:
getRepositoryDatain interfaceRepeater- 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 interfaceRepeater- 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 interfaceRepeater- Returns:
- the root
DataHolder
-