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
Modifier and TypeFieldDescriptionprotected RepeaterDefinition
Definition of this repeaterprotected IndexableDataHolder
Parent of the currentRepeater
protected RepositoryData
Repository data to use to store entries in the repositoryprotected IndexableDataHolder
RootDataHolder
-
Constructor Summary
ConstructorDescriptionDefaultModelAwareRepeater
(RepositoryData repositoryData, IndexableDataHolder parent, IndexableDataHolder root, RepeaterDefinition definition) Creates a model aware repeater -
Method Summary
Modifier and TypeMethodDescriptionvoid
commentsToSAX
(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor) Generates SAX events for the comments of the data in the given view in the currentDataHolder
void
copyTo
(ModifiableRepeater repeater) Copies the currentRepeater
to 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 currentRepeater
dataToJSON
(ViewItemAccessor viewItemAccessor, DataContext context) Convert into a JSON object the data in the given view of the currentRepeater
void
dataToSAX
(ContentHandler contentHandler, String dataPath, DataContext context) Generates SAX events for the data at the given data path in the currentDataHolder
Do not generate any event if there is no values at the given pathvoid
dataToSAX
(ContentHandler contentHandler, DataContext context) Generates SAX events for the data in the model of the currentDataHolder
void
dataToSAX
(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) Generates SAX events for the data in the given view in the currentRepeater
List<? 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 currentRepeater
Retrieves the repository data used by thisRepeater
Retrieves the rootDataHolder
of the current repeaterint
getSize()
Retrieves the size of the repeaterboolean
hasEntry
(int position) Determines if the repeater has an entry at the given position.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 thisRepeater
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
Methods inherited from interface org.ametys.plugins.repository.data.holder.group.ModelAwareRepeater
dataToJSON, dataToJSON, dataToSAX, dataToSAX
Methods inherited from interface org.ametys.plugins.repository.data.holder.group.Repeater
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, IndexableDataHolder parent, IndexableDataHolder root, RepeaterDefinition definition) Creates a 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 interfaceRepeater
- 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 interfaceRepeater
- Parameters:
position
- the position of the entry to retrieve- Returns:
- the repeater entry,
null
if there is no entry at this position
-
getSize
Description copied from interface:Repeater
Retrieves the size of the repeater -
hasEntry
Description copied from interface:Repeater
Determines 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:
getModel
in interfaceModelAwareRepeater
- Returns:
- the repeater's model
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, String dataPath, DataContext context) throws SAXException Description copied from interface:Repeater
Generates SAX events for the data at the given data path in the currentDataHolder
Do not generate any event if there is no values at the given path- Specified by:
dataToSAX
in interfaceRepeater
- Parameters:
contentHandler
- theContentHandler
that 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:ModelAwareRepeater
Generates SAX events for the data in the model of the currentDataHolder
- Specified by:
dataToSAX
in interfaceModelAwareRepeater
- Parameters:
contentHandler
- theContentHandler
that 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:ModelAwareRepeater
Generates SAX events for the data in the given view in the currentRepeater
- Specified by:
dataToSAX
in interfaceModelAwareRepeater
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventsviewItemAccessor
- theViewItemAccessor
referencing 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:Repeater
Convert the data at the given path into a JSON object- Specified by:
dataToJSON
in 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:ModelAwareRepeater
Convert into a JSON object the data in the model of the currentRepeater
- Specified by:
dataToJSON
in interfaceModelAwareRepeater
- Parameters:
context
- The context of the data to convert- Returns:
- The data of the current
DataHolder
as 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:ModelAwareRepeater
Convert into a JSON object the data in the given view of the currentRepeater
- Specified by:
dataToJSON
in interfaceModelAwareRepeater
- Parameters:
viewItemAccessor
- theViewItemAccessor
referencing 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
- theContentHandler
that will receive the SAX eventsviewItemAccessor
- theViewItemAccessor
referencing the items for which generate SAX events- Throws:
SAXException
- if an error occurs during the SAX events generation
-
copyTo
public void copyTo(ModifiableRepeater repeater) throws UndefinedItemPathException, BadItemTypeException, UnknownTypeException, NotUniqueTypeException Description copied from interface:Repeater
Copies the currentRepeater
to the givenModifiableRepeater
.- Specified by:
copyTo
in interfaceRepeater
- Parameters:
repeater
- The destination repeater. Can not be null.- Throws:
UndefinedItemPathException
- if one of the copied data is not defined by the model of the destinationModifiableModelAwareRepeater
BadItemTypeException
- if the type defined by the model of the destinationModifiableModelAwareRepeater
doesn't match the copied valueUnknownTypeException
NotUniqueTypeException
-
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:IndexableRepeater
Indexes all data and properties of thisRepeater
- Specified by:
indexData
in interfaceIndexableRepeater
- Parameters:
document
- the solr document representing thisRepeater
rootDocument
- 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
-
getRepositoryData
Description copied from interface:Repeater
Retrieves the repository data used by thisRepeater
- Specified by:
getRepositoryData
in interfaceRepeater
- 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 interfaceRepeater
- 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 interfaceRepeater
- Returns:
- the root
DataHolder
-