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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondataToJSON(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) Convert the data in the given view of the givenDataHolderdataToMap(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context) Returns all data of the given DataHolder as a typed-values Map.static voiddataToSAX(ModelAwareDataHolder dataHolder, ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) Generates SAX events for the data in the given view in the givenDataHoldervoiddispose()externalizableValuesAsJson(ModelAwareDataHolder dataHolder, String dataName, DataContext context) Convert the externalizable data with the given namegetAmetysObjectFromContext(DataContext context) Retrieves theModelAwareDataAwareAmetysObjectfrom the givenDataContextstatic SystemPropertyExtensionPointRetrieves theSystemPropertyExtensionPointfor content system propertiesstatic booleanhasValue(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 givenIndexableDataHolderstatic booleanrenderValue(ModelAwareDataHolder dataHolder, String dataPath, DataContext context, boolean isEdition) Check if the value at the given path should be renderedvoidservice(ServiceManager manager)
-
Constructor Details
-
IndexableDataHolderHelper
public IndexableDataHolderHelper()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
dispose
- Specified by:
disposein 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- theIndexableDataHolderto indexviewItemAccessor- the view item accessor to exploredocument- the solr document representing thisIndexableDataHolderrootDocument- 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- theModelAwareDataHolderto SAXcontentHandler- theContentHandlerthat will receive the SAX eventsviewItemAccessor- theViewItemAccessorreferencing the items for which generate SAX eventscontext- The context of the data to SAXisEdition-trueif SAX events are generated in edition mode,falseotherwise- 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- theModelAwareDataHoldercontaining the data to convertviewItemAccessor- theViewItemAccessorreferencing the items to convertcontext- The context of the data to convertisEdition-trueto convert in edition mode,falseotherwise- 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- theModelAwareDataHoldercontaining 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- theViewItemAccessorreferencing the items to include in the resulting Mapcontext- The context of the data- Returns:
- a Map containing all data.
-
getAmetysObjectFromContext
Retrieves theModelAwareDataAwareAmetysObjectfrom the givenDataContext- Parameters:
context- the context containing the ametys object- Returns:
- the ametys object, or
nullif 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-trueif values are rendered in edition mode,falseotherwise- Returns:
trueif the value has to be rendered,falseotherwise
-
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:
trueif there is a value to render,falseotherwise
-
getContentSystemPropertyExtensionPoint
Retrieves theSystemPropertyExtensionPointfor content system properties- Returns:
- the
SystemPropertyExtensionPointfor content system properties
-