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()
externalizableValuesAsJson
(ModelAwareDataHolder dataHolder, String dataName, DataContext context) Convert the externalizable data with the given namegetAmetysObjectFromContext
(DataContext context) Retrieves theModelAwareDataAwareAmetysObject
from the givenDataContext
static SystemPropertyExtensionPoint
Retrieves theSystemPropertyExtensionPoint
for content system propertiesstatic boolean
hasValue
(ModelAwareDataHolder dataHolder, String dataPath, DataContext context) Check if there is a value to render at the given pathstatic 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
static boolean
renderValue
(ModelAwareDataHolder dataHolder, String dataPath, DataContext context, boolean isEdition) Check if the value at the given path should be renderedvoid
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
-
externalizableValuesAsJson
public static Map<String,Object> externalizableValuesAsJson(ModelAwareDataHolder dataHolder, String dataName, DataContext context) Convert the externalizable data with the given name- Parameters:
dataHolder
- theModelAwareDataHolder
containing the data to convertdataName
- the name of the data to convertcontext
- The context of the data to convert- Returns:
- The data with the given name as JSON
-
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
-
renderValue
public static boolean renderValue(ModelAwareDataHolder dataHolder, String dataPath, DataContext context, boolean isEdition) Check if the value at the given path should be rendered- Parameters:
dataHolder
- the data holder containing the data to checkdataPath
- the path of the data to checkcontext
- the data contextisEdition
-true
if values are rendered in edition mode,false
otherwise- Returns:
true
if the value has to be rendered,false
otherwise
-
hasValue
public static boolean hasValue(ModelAwareDataHolder dataHolder, String dataPath, DataContext context) Check if there is a value to render at the given path- Parameters:
dataHolder
- the data holder containing the data to checkdataPath
- the path of the data to checkcontext
- the data context- Returns:
true
if there is a value to render,false
otherwise
-
getContentSystemPropertyExtensionPoint
Retrieves theSystemPropertyExtensionPoint
for content system properties- Returns:
- the
SystemPropertyExtensionPoint
for content system properties
-