Package org.ametys.cms.data.holder.impl
Class IndexableDataHolderHelper
java.lang.Object
org.ametys.cms.data.holder.impl.IndexableDataHolderHelper
- All Implemented Interfaces:
Disposable
,Component
,Serviceable
public final class IndexableDataHolderHelper
extends Object
implements Component, Serviceable, Disposable
Helper for implementations of indexable data holder
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondataToJSON
(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) Convert the data in the given view of the givenDataHolder
dataToMap
(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context) Returns all data of the given DataHolder as a typed-values Map.static void
dataToSAX
(ModelAwareDataHolder dataHolder, ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) Generates SAX events for the data in the given view in the givenDataHolder
void
dispose()
getAmetysObjectFromContext
(DataContext context) Retrieves theModelAwareDataAwareAmetysObject
from the givenDataContext
static SystemPropertyExtensionPoint
Retrieves theSystemPropertyExtensionPoint
for content system propertiesstatic List<org.apache.solr.common.SolrInputDocument>
indexData
(IndexableDataHolder dataHolder, ViewItemAccessor viewItemAccessor, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument rootDocument, String solrFieldPrefix, IndexableDataContext context) Indexes data of the givenIndexableDataHolder
void
service
(ServiceManager manager)
-
Constructor Details
-
IndexableDataHolderHelper
public IndexableDataHolderHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
dispose
- Specified by:
dispose
in interfaceDisposable
-
indexData
public static List<org.apache.solr.common.SolrInputDocument> indexData(IndexableDataHolder dataHolder, ViewItemAccessor viewItemAccessor, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument rootDocument, String solrFieldPrefix, IndexableDataContext context) throws BadItemTypeException Indexes data of the givenIndexableDataHolder
- Parameters:
dataHolder
- theIndexableDataHolder
to indexviewItemAccessor
- the view item accessor to exploredocument
- the solr document representing thisIndexableDataHolder
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
-
dataToSAX
public static void dataToSAX(ModelAwareDataHolder dataHolder, ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) throws SAXException, BadItemTypeException, UndefinedItemPathException Generates SAX events for the data in the given view in the givenDataHolder
- Parameters:
dataHolder
- theModelAwareDataHolder
to SAXcontentHandler
- theContentHandler
that will receive the SAX eventsviewItemAccessor
- theViewItemAccessor
referencing the items for which generate SAX eventscontext
- The context of the data to SAXisEdition
-true
if SAX events are generated in edition mode,false
otherwise- Throws:
SAXException
- if an error occurs during the SAX events generationBadItemTypeException
- if the saxed value's type does not matches the stored dataUndefinedItemPathException
- if an item in the view is not part of the model
-
dataToJSON
public static Map<String,Object> dataToJSON(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) throws BadItemTypeException, UndefinedItemPathException Convert the data in the given view of the givenDataHolder
- Parameters:
dataHolder
- theModelAwareDataHolder
containing the data to convertviewItemAccessor
- theViewItemAccessor
referencing the items to convertcontext
- The context of the data to convertisEdition
-true
to convert in edition mode,false
otherwise- Returns:
- The data of the given view as JSON
- Throws:
BadItemTypeException
- if the value's type does not matches the stored dataUndefinedItemPathException
- if an item in the view is not part of the model
-
dataToMap
public static Map<String,Object> dataToMap(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context) Returns all data of the given DataHolder as a typed-values Map.- Parameters:
dataHolder
- the DataHolder to exportviewItemAccessor
- theViewItemAccessor
referencing the items to include in the resulting Mapcontext
- The context of the data- Returns:
- a Map containing all data.
-
getAmetysObjectFromContext
Retrieves theModelAwareDataAwareAmetysObject
from the givenDataContext
- Parameters:
context
- the context containing the ametys object- Returns:
- the ametys object, or
null
if there is no object id in the context
-
getContentSystemPropertyExtensionPoint
Retrieves theSystemPropertyExtensionPoint
for content system properties- Returns:
- the
SystemPropertyExtensionPoint
for content system properties
-