Package org.ametys.cms.search.cocoon
Class SearchJsonReader
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.reading.AbstractReader
-
- org.apache.cocoon.reading.ServiceableReader
-
- org.ametys.cms.search.cocoon.SearchJsonReader
-
- All Implemented Interfaces:
Poolable,Recyclable,Component,LogEnabled,Serviceable,Reader,SitemapModelComponent,SitemapOutputComponent
public class SearchJsonReader extends ServiceableReader
JSON reader for search for contents.
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentGridComponent_contentGridComponentThe ContentGridComponent instanceprotected ContentHelper_contentHelperThe content helperprotected ContentTypesHelper_contentTypesHelperThe content types helper.protected JSONUtils_jsonUtilsJSON utilsprotected AmetysObjectResolver_resolverThe Ametys object resolverprotected ServerCommHelper_serverCommHelperThe serverComm helperprivate ContentValuesExtractorFactory_valuesExtractorFactory-
Fields inherited from class org.apache.cocoon.reading.ServiceableReader
manager
-
Fields inherited from class org.apache.cocoon.reading.AbstractReader
objectModel, out, parameters, resolver, source
-
-
Constructor Summary
Constructors Constructor Description SearchJsonReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconvertContents2JsonObject(Map<String,Object> results2Json, List<String> contentIds, SearchUIModel model, Locale defaultLocale)Convert the query results to a JSON objectprotected voidconvertResults2JsonObject(Map<String,Object> results2Json, SearchResults<Content> results, SearchUIModel model, Locale defaultLocale)Convert the query results to a JSON objectvoidgenerate()protected Map<String,Object>getContentData(Content content, ContentValuesExtractorFactory.ContentValuesExtractor extractor, Locale defaultLocale, Map<String,Object> contextualParameters)Generate standard content data.StringgetMimeType()voidservice(ServiceManager smanager)protected intsetContents(Map<String,Object> searchResults, List<String> contentIds, SearchUIModel model, Locale defaultLocale, Map<String,Object> contextualParameters)Extract the desired contents and set them in the search results.protected voidsetContents(Map<String,Object> searchResults, SearchResults<Content> results, SearchUIModel model, Locale defaultLocale, Map<String,Object> contextualParameters)Extract the desired contents from theSearchResultsobject and set them in the search results.protected voidsetFacets(Map<String,Object> searchResults, Map<String,Map<String,Integer>> facetResults, SearchUIModel model, Locale locale, Map<String,Object> contextualParameters)Set the facet results in the search results.-
Methods inherited from class org.apache.cocoon.reading.AbstractReader
getLastModified, recycle, setOutputStream, setup, shouldSetContentLength
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_jsonUtils
protected JSONUtils _jsonUtils
JSON utils
-
_serverCommHelper
protected ServerCommHelper _serverCommHelper
The serverComm helper
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
The content types helper.
-
_contentHelper
protected ContentHelper _contentHelper
The content helper
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
_contentGridComponent
protected ContentGridComponent _contentGridComponent
The ContentGridComponent instance
-
_valuesExtractorFactory
private ContentValuesExtractorFactory _valuesExtractorFactory
-
-
Constructor Detail
-
SearchJsonReader
public SearchJsonReader()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classServiceableReader- Throws:
ServiceException
-
getMimeType
public String getMimeType()
- Specified by:
getMimeTypein interfaceSitemapOutputComponent- Overrides:
getMimeTypein classAbstractReader
-
generate
public void generate() throws IOException, SAXException, ProcessingException
-
convertResults2JsonObject
protected void convertResults2JsonObject(Map<String,Object> results2Json, SearchResults<Content> results, SearchUIModel model, Locale defaultLocale) throws ProcessingException
Convert the query results to a JSON object- Parameters:
results2Json- the JSON object to fill.results- the query resultsmodel- the search modeldefaultLocale- the default locale for localized values if content's language is null.- Throws:
ProcessingException- If an error occurs.
-
convertContents2JsonObject
protected void convertContents2JsonObject(Map<String,Object> results2Json, List<String> contentIds, SearchUIModel model, Locale defaultLocale) throws ProcessingException
Convert the query results to a JSON object- Parameters:
results2Json- the JSON object to fill.contentIds- the ids of contentsmodel- the search modeldefaultLocale- the default locale for localized values if content's language is null.- Throws:
ProcessingException- If an error occurs.
-
setContents
protected void setContents(Map<String,Object> searchResults, SearchResults<Content> results, SearchUIModel model, Locale defaultLocale, Map<String,Object> contextualParameters)
Extract the desired contents from theSearchResultsobject and set them in the search results.- Parameters:
searchResults- the search results to populate.results- theSearchResults.model- the search model.defaultLocale- the default locale for localized values if content's language is null.contextualParameters- the search contextual parameters.
-
setContents
protected int setContents(Map<String,Object> searchResults, List<String> contentIds, SearchUIModel model, Locale defaultLocale, Map<String,Object> contextualParameters)
Extract the desired contents and set them in the search results.- Parameters:
searchResults- the search results to populate.contentIds- the id of desired contentsmodel- the search model.defaultLocale- the default locale for localized values if content's language is null.contextualParameters- the search contextual parameters.- Returns:
- the number of resolved contents without error
-
getContentData
protected Map<String,Object> getContentData(Content content, ContentValuesExtractorFactory.ContentValuesExtractor extractor, Locale defaultLocale, Map<String,Object> contextualParameters)
Generate standard content data.- Parameters:
content- The content.extractor- The content values extractor which generates.defaultLocale- the default locale for localized values if content's language is null.contextualParameters- The search contextual parameters.- Returns:
- A Map containing the content data.
-
setFacets
protected void setFacets(Map<String,Object> searchResults, Map<String,Map<String,Integer>> facetResults, SearchUIModel model, Locale locale, Map<String,Object> contextualParameters)
Set the facet results in the search results.- Parameters:
searchResults- the search results.facetResults- the facet results as a Map<column name, Map<value, result count>>.model- the search model.locale- the locale for localized valuescontextualParameters- the search contextual parameters.
-
-