Class AutocompletionSearchAction
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.acting.AbstractAction
-
- org.apache.cocoon.acting.ServiceableAction
-
- org.ametys.plugins.odfweb.service.search.AutocompletionSearchAction
-
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,Action
public class AutocompletionSearchAction extends ServiceableAction
Get the proposed program's pages and skills for auto-completion while beginning a search
-
-
Field Summary
Fields Modifier and Type Field Description private ContentHelper
_contentHelper
private AmetysObjectResolver
_resolver
protected SearcherFactory
_searcherFactory
The search factoryprotected SearchServiceInstanceManager
_searchServiceInstanceManager
Component for search serviceprotected static int
NB_MAX_RESULTS
The default max number of results-
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
-
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
-
Constructor Summary
Constructors Constructor Description AutocompletionSearchAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private String
_escapeQuery(String text)
Map
act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters)
protected List<String>
getCatalogNames(String zoneItemId)
Get the configured catalog in search criteriaprotected Map<String,Object>
getContentHit(Content content)
Get the JSON representation of a content hitprotected AmetysObjectIterable<Page>
getContentPages(String cType, String siteName, String lang, List<String> catalogNames, String escapedQuery, int limit)
Get the content pages matching the queryprotected Map<String,Object>
getPageHit(Page page)
Get the JSON representation of a page hitprotected AmetysObjectIterable<Content>
getSkills(String escapedQuery, String lang, int limit)
Get the skills contents matching the queryvoid
service(ServiceManager serviceManager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
NB_MAX_RESULTS
protected static final int NB_MAX_RESULTS
The default max number of results- See Also:
- Constant Field Values
-
_searcherFactory
protected SearcherFactory _searcherFactory
The search factory
-
_searchServiceInstanceManager
protected SearchServiceInstanceManager _searchServiceInstanceManager
Component for search service
-
_contentHelper
private ContentHelper _contentHelper
-
_resolver
private AmetysObjectResolver _resolver
-
-
Constructor Detail
-
AutocompletionSearchAction
public AutocompletionSearchAction()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableAction
- Throws:
ServiceException
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
- Throws:
Exception
-
getCatalogNames
protected List<String> getCatalogNames(String zoneItemId)
Get the configured catalog in search criteria- Parameters:
zoneItemId
- The id of zone item- Returns:
- the catalog's name
-
getContentPages
protected AmetysObjectIterable<Page> getContentPages(String cType, String siteName, String lang, List<String> catalogNames, String escapedQuery, int limit) throws Exception
Get the content pages matching the query- Parameters:
cType
- The content type of pages to searchsiteName
- the site namelang
- the languagecatalogNames
- The name of catalog to take into account. Can be emptyescapedQuery
- the querylimit
- the max number of results- Returns:
- the matching pages
- Throws:
Exception
- if an error occurred during search
-
getSkills
protected AmetysObjectIterable<Content> getSkills(String escapedQuery, String lang, int limit) throws Exception
Get the skills contents matching the query- Parameters:
escapedQuery
- the querylang
- the languagelimit
- the max number of results- Returns:
- the matching contents
- Throws:
Exception
- if an error occurred during search
-
_escapeQuery
private String _escapeQuery(String text)
-
getPageHit
protected Map<String,Object> getPageHit(Page page)
Get the JSON representation of a page hit- Parameters:
page
- the page- Returns:
- the page as json
-
getContentHit
protected Map<String,Object> getContentHit(Content content)
Get the JSON representation of a content hit- Parameters:
content
- the content- Returns:
- the content as json
-
-