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
FieldsModifier and TypeFieldDescriptionprotected ContentGridComponentThe ContentGridComponent instanceprotected ContentHelperThe content helperprotected ContentTypesHelperThe content types helper.protected JSONUtilsJSON utilsprotected AmetysObjectResolverThe Ametys object resolverprotected ServerCommHelperThe serverComm helperFields inherited from class org.apache.cocoon.reading.ServiceableReader
managerFields inherited from class org.apache.cocoon.reading.AbstractReader
objectModel, out, parameters, resolver, source -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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()getContentData(Content content, ContentValuesExtractorFactory.ContentValuesExtractor extractor, Locale defaultLocale, Map<String, Object> contextualParameters) Generate standard content data.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, shouldSetContentLengthMethods 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:
servicein interfaceServiceable- Overrides:
servicein classServiceableReader- Throws:
ServiceException
-
getMimeType
- Specified by:
getMimeTypein interfaceSitemapOutputComponent- Overrides:
getMimeTypein 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 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.
-