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 TypeMethodDescriptionvoiddispose()static IndexableAmetysObjectgetAmetysObjectFromContext(DataContext context) Retrieves theIndexableAmetysObjectfrom the givenDataContextstatic IndexableAmetysObjectgetPropertyAmetysObject(IndexableDataHolder dataHolder, String dataPath) Retrieves the ametys object containing the property at the given pathstatic <T> TgetPropertyValue(IndexableDataHolder dataHolder, Property property) Retrieves the value of the given property from the root data holder of the given data holderstatic Optional<SystemProperty> getSystemProperty(IndexableDataHolder dataHolder, String path) Retrieves theSystemPropertycorresponding to the given path, if it existsstatic booleanhasPropertyValue(IndexableDataHolder dataHolder, Property property) Checks if the given property has a value on the root data holder of the given data holderstatic 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, CMSDataContext context) Indexes data of the givenIndexableDataHolderstatic List<org.apache.solr.common.SolrInputDocument> indexRepeaterData(IndexableRepeater repeater, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument rootDocument, String solrFieldPrefix, CMSDataContext context) Indexes all data and properties of the givenRepeatervoidservice(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, CMSDataContext 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
-
indexRepeaterData
public static List<org.apache.solr.common.SolrInputDocument> indexRepeaterData(IndexableRepeater repeater, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument rootDocument, String solrFieldPrefix, CMSDataContext context) throws BadItemTypeException Indexes all data and properties of the givenRepeater- Parameters:
repeater- theRepeaterto indexdocument- the solr document representing theRepeaterrootDocument- 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
-
getAmetysObjectFromContext
Retrieves theIndexableAmetysObjectfrom the givenDataContext- Parameters:
context- the context containing the ametys object- Returns:
- the ametys object, or
nullif there is no object id in the context
-
hasPropertyValue
Checks if the given property has a value on the root data holder of the given data holder- Parameters:
dataHolder- the data holder to check the property onproperty- the property to check- Returns:
trueif the property has a value,falseotherwise
-
getPropertyValue
Retrieves the value of the given property from the root data holder of the given data holder- Type Parameters:
T- the type of the property value- Parameters:
dataHolder- the data holder to get the property value fromproperty- the property to get the value of- Returns:
- the value of the property, or
nullif the property has no value
-
getSystemProperty
public static Optional<SystemProperty> getSystemProperty(IndexableDataHolder dataHolder, String path) Retrieves theSystemPropertycorresponding to the given path, if it exists- Parameters:
dataHolder- the data holder to check the system property onpath- the path of the system property, relative to the given data holder- Returns:
- the
SystemPropertycorresponding to the given path, or an emptyOptionalif it does not exist
-
getPropertyAmetysObject
public static IndexableAmetysObject getPropertyAmetysObject(IndexableDataHolder dataHolder, String dataPath) throws UndefinedItemPathException Retrieves the ametys object containing the property at the given path- Parameters:
dataHolder- the data holder to check the property ondataPath- the path of the property- Returns:
- the ametys object containing the property
- Throws:
UndefinedItemPathException- if the given path does not represent a property
-