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
JSON reader for search for contents.
-
Field Summary
Modifier and TypeFieldDescriptionprotected ContentGridComponent
The ContentGridComponent instanceprotected ContentHelper
The content helperprotected ContentTypesHelper
The content types helper.protected JSONUtils
JSON utilsprotected AmetysObjectResolver
The Ametys object resolverprotected ServerCommHelper
The serverComm helperFields 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
convertContents2JsonObject
(Map<String, Object> results2Json, List<String> contentIds, SearchUIModel model, Locale defaultLocale) Convert the query results to a JSON objectprotected void
convertResults2JsonObject
(Map<String, Object> results2Json, SearchResults<Content> results, SearchUIModel model, Locale defaultLocale) Convert the query results to a JSON objectvoid
generate()
getContentData
(Content content, ContentValuesExtractorFactory.ContentValuesExtractor extractor, Locale defaultLocale, Map<String, Object> contextualParameters) Generate standard content data.void
service
(ServiceManager smanager) 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.protected void
setContents
(Map<String, Object> searchResults, SearchResults<Content> results, SearchUIModel model, Locale defaultLocale, Map<String, Object> contextualParameters) Extract the desired contents from theSearchResults
object and set them in the search results.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.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 Details
-
_jsonUtils
JSON utils -
_serverCommHelper
The serverComm helper -
_contentTypesHelper
The content types helper. -
_contentHelper
The content helper -
_resolver
The Ametys object resolver -
_contentGridComponent
The ContentGridComponent instance
-
-
Constructor Details
-
SearchJsonReader
public SearchJsonReader()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableReader
- Throws:
ServiceException
-
getMimeType
- Specified by:
getMimeType
in interfaceSitemapOutputComponent
- Overrides:
getMimeType
in classAbstractReader
-
generate
-
convertResults2JsonObject
protected void convertResults2JsonObject(Map<String, Object> results2Json, SearchResults<Content> results, SearchUIModel model, Locale defaultLocale) throws ProcessingExceptionConvert 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 ProcessingExceptionConvert 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 theSearchResults
object 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.
-