public abstract class AbstractSearchGenerator extends ServiceableGenerator implements Contextualizable, SolrWebFieldNames
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractSearchGenerator.Criterion
Criterion class.
|
Modifier and Type | Field and Description |
---|---|
protected ContentHelper |
_contentHelper
The helper to handler contents
|
protected ContentTypesHelper |
_contentTypesHelper
The helper to handler content types
|
protected Context |
_context
The cocoon context
|
protected ContentTypeExtensionPoint |
_cTypeExtPt
The
ContentType manager |
protected DublinCoreMetadataProvider |
_dcProvider
DublinCore provider
|
protected MetadataManager |
_metadataManager
Metadata manager.
|
protected SAXParser |
_parser
The sax parser
|
protected AmetysObjectResolver |
_resolver
The Ametys resolver
|
protected SearcherFactory |
_searcherFactory
The searcher factory
|
protected SiteManager |
_siteManager
The sites manager
|
protected TagProviderExtensionPoint |
_tagExtPt
The tag extension point
|
protected static Pattern |
_TEXTFIELD_PATTERN
Textfield pattern
|
protected URIResolverExtensionPoint |
_uriResolverEP
The uri resolver extension point
|
manager
objectModel, parameters, resolver, source
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
ANCESTOR_IDS, CONTENT_IDS, CONTENT_INTERESTING_DATES, DATE_FOR_SORTING, DATES_FACET, LASTNAME_FOR_SORTING, LONG_TITLE, ORPHAN, PAGE_DEPTH, PAGE_ID, PAGE_IDS, PAGE_TYPE, PRIVACY, SECTION_PAGE_TITLE, SERVICE_IDS, SHARED, SITE_NAME, SITEMAP_NAME, TEMPLATE, TITLE, TITLE_FOR_SORTING, TYPE_PAGE, TYPE_PAGE_RESOURCE
ACL_READ_ALLOW_ANONYMOUS, ACL_READ_ALLOW_ANY_CONNECTED_USER, ACL_READ_ALLOWED_GROUPS, ACL_READ_ALLOWED_USERS, ACL_READ_DENIED_GROUPS, ACL_READ_DENIED_USERS, ALL_CONTENT_TYPES, ALL_MIXIN_TYPES, ALL_TAGS, CONTENT_COMMENTS, CONTENT_COMMENTS_NONVALIDATED, CONTENT_COMMENTS_VALIDATED, CONTENT_CREATOR, CONTENT_LANGUAGE, CONTENT_LANGUAGES, CONTENT_LAST_CONTRIBUTOR, CONTENT_NAME, CONTENT_TITLES, CONTENT_TYPE_RESOURCE, CONTENT_TYPES, CREATION_DATE, DC_CONTRIBUTOR, DC_COVERAGE, DC_CREATOR, DC_DATE, DC_DESCRIPTION, DC_FORMAT, DC_IDENTIFIER, DC_LANGUAGE, DC_PUBLISHER, DC_RELATION, DC_RIGHTS, DC_SOURCE, DC_SUBJECT, DC_TITLE, DC_TYPE, DOCUMENT_TYPE, EXCERPT, FILENAME, FULL_EXACT_WS, FULL_GENERAL, FULL_PREFIX, FULL_STEMMED_PREFIX, ID, LAST_MAJOR_VALIDATION, LAST_MODIFIED, LAST_VALIDATION, LENGTH, MIME_TYPES, MIXIN_TYPES, PATH, REPEATER_ENTRY_POSITION, RESOURCE_CREATOR, RESOURCE_DATE, RESOURCE_LAST_MODIFIED, RESOURCE_ROOT_ID, SUB_CONTENT, TAGS, TITLE_SORT, TYPE_CONTENT, TYPE_REPEATER, TYPE_RESOURCE, TYPE_WF_ENTRY, TYPE_WF_STEP, WORKFLOW_CURRENT_STEPS, WORKFLOW_CURRENT_STEPS_DV, WORKFLOW_ENTRY_STATE, WORKFLOW_HISTORY_STEPS, WORKFLOW_HISTORY_STEPS_DV, WORKFLOW_NAME, WORKFLOW_REF, WORKFLOW_REF_DV, WORKFLOW_STEP, WORKFLOW_STEP_ACTIONID, WORKFLOW_STEP_CALLER, WORKFLOW_STEP_DUEDATE, WORKFLOW_STEP_FINISHDATE, WORKFLOW_STEP_ID, WORKFLOW_STEP_OWNER, WORKFLOW_STEP_STARTDATE, WORKFLOW_STEP_STATUS
Constructor and Description |
---|
AbstractSearchGenerator() |
Modifier and Type | Method and Description |
---|---|
protected void |
_additionalSearchProcessing(SearcherFactory.Searcher searcher)
Allow to perform other searcher configuration
|
private String |
_encodePath(String path) |
private String |
_getResourceExcerpt(Resource resource) |
private Page |
_getResourcePage(Resource resource) |
private void |
_saxIcon(String filename) |
private void |
_saxLastModifiedDate(Page page) |
private void |
_saxLastValidationDate(Page page) |
private void |
_saxPageContents(Page page) |
private void |
_saxSize(long size) |
void |
contextualize(Context context) |
void |
generate() |
protected abstract Map<String,AbstractSearchGenerator.Criterion> |
getCriteria(Request request,
String siteName,
String lang)
Get the criteria with their value list.
|
protected Map<String,String> |
getCriteriaValues(Map<String,AbstractSearchGenerator.Criterion> criteria,
Request request)
Get the criteria user values.
|
protected abstract Collection<String> |
getDocumentTypes(Request request)
Get the document types.
|
protected Query |
getDocumentTypesQuery(Collection<String> documentTypes)
Build the search query to have results matching at least one of the given document types
|
protected abstract Collection<String> |
getFields()
Get the searchable fields
|
protected abstract Collection<Query> |
getFilterQueries(Request request,
Collection<String> siteNames,
String language)
Get the filter queries from the request parameters.
|
protected int |
getPageIndex(Request request)
Get the page index
|
protected abstract List<Sort> |
getPrimarySortFields(Request request)
Get the primary sort fields
|
protected abstract Query |
getQuery(Request request,
Collection<String> siteNames,
String language)
Get the query from request parameters
|
protected String |
getSearchMode()
Get the search mode.
|
protected abstract Sort |
getSortField(Request request)
Get the sort field
|
protected boolean |
isInputValid()
Check if the input is valid.
|
protected void |
saxAdditionalInfos()
Generate any additional information.
|
protected void |
saxAdditionalInfosOnPageHit(Page page)
SAX additional information on page hit
|
protected void |
saxContent(String contentId,
String metadataSetName)
SAX the metadata set of a content if exists
|
protected void |
saxCriteria(Map<String,AbstractSearchGenerator.Criterion> criteria,
Request request,
SearchResults<AmetysObject> searchResults,
String siteName,
String lang,
boolean withHitCount)
SAX criteria.
|
protected void |
saxCriterion(AbstractSearchGenerator.Criterion criterion,
SearchResults<AmetysObject> searchResults,
String siteName,
String lang)
SAX a single criterion.
|
protected abstract void |
saxFormFields(Request request,
SearchResults<AmetysObject> searchResults,
String siteName,
String lang)
SAX the form search criteria
|
protected void |
saxFormParameters(Request request,
SearchResults<AmetysObject> searchResults,
int start,
int offset,
String siteName,
String lang)
SAX the search parameters from the request parameters
|
protected abstract void |
saxFormValues(Request request,
SearchResults<AmetysObject> searchResults,
int start,
int offset)
SAX the form search criteria values
|
protected abstract void |
saxHits(SearchResults<AmetysObject> results,
int start,
int maxResults)
SAX the result hits
|
protected void |
saxPageHit(float score,
float maxScore,
Page page)
SAX a hit of type page.
|
protected void |
saxPagination(long totalHits,
int start,
int offset)
SAX elements for pagination
|
protected void |
saxResourceHit(float score,
float maxScore,
Resource resource)
SAX a hit of type "resource".
|
protected void |
saxServiceIdentifiers()
Generate the service identifiers: service group ID, ZoneItem ID, ...
|
protected SearchResults<AmetysObject> |
search(Request request,
Collection<String> siteNames,
String language,
int pageIndex,
int start,
int maxResults)
Search
|
protected SearchResults<AmetysObject> |
search(Request request,
Collection<String> siteNames,
String language,
int pageIndex,
int start,
int maxResults,
boolean saxResults)
Search
|
void |
service(ServiceManager smanager) |
dispose
recycle, setup
setConsumer, setContentHandler, setLexicalHandler
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setConsumer
protected static final Pattern _TEXTFIELD_PATTERN
protected ContentTypeExtensionPoint _cTypeExtPt
ContentType
managerprotected SiteManager _siteManager
protected TagProviderExtensionPoint _tagExtPt
protected AmetysObjectResolver _resolver
protected DublinCoreMetadataProvider _dcProvider
protected ContentTypesHelper _contentTypesHelper
protected ContentHelper _contentHelper
protected URIResolverExtensionPoint _uriResolverEP
protected MetadataManager _metadataManager
protected SearcherFactory _searcherFactory
public AbstractSearchGenerator()
public void service(ServiceManager smanager) throws ServiceException
service
in interface Serviceable
service
in class ServiceableGenerator
ServiceException
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void generate() throws IOException, SAXException, ProcessingException
generate
in interface Generator
IOException
SAXException
ProcessingException
protected SearchResults<AmetysObject> search(Request request, Collection<String> siteNames, String language, int pageIndex, int start, int maxResults) throws Exception
request
- the requestsiteNames
- The name of the sites to search inlanguage
- The language code to searchpageIndex
- the page indexstart
- The offset for search resultsmaxResults
- The maximum number of resultsException
- If an error occurred during searchprotected SearchResults<AmetysObject> search(Request request, Collection<String> siteNames, String language, int pageIndex, int start, int maxResults, boolean saxResults) throws Exception
request
- the requestsiteNames
- The name of the sites to search inlanguage
- The language code to searchpageIndex
- the page indexstart
- The offset for search resultsmaxResults
- The maximum number of resultssaxResults
- false to not sax resultsException
- If an error occurred during searchprotected void _additionalSearchProcessing(SearcherFactory.Searcher searcher)
searcher
- The searcher that will be used for the search operationprotected Query getDocumentTypesQuery(Collection<String> documentTypes)
documentTypes
- The document typesprotected abstract Collection<String> getDocumentTypes(Request request)
request
- The request.protected abstract Sort getSortField(Request request)
request
- The requestprotected abstract List<Sort> getPrimarySortFields(Request request)
request
- The requestprotected void saxFormParameters(Request request, SearchResults<AmetysObject> searchResults, int start, int offset, String siteName, String lang) throws SAXException
request
- The requestsearchResults
- The search resultsstart
- The start indexoffset
- The number of resultssiteName
- The current site namelang
- The current languageSAXException
- If an error occurs while SAXingprotected abstract void saxFormFields(Request request, SearchResults<AmetysObject> searchResults, String siteName, String lang) throws SAXException
request
- The requestsearchResults
- The search resultssiteName
- The current site namelang
- The current languageSAXException
- if an error occurs while SAXingprotected void saxCriteria(Map<String,AbstractSearchGenerator.Criterion> criteria, Request request, SearchResults<AmetysObject> searchResults, String siteName, String lang, boolean withHitCount) throws SAXException
criteria
- the criteria list.request
- the requestsearchResults
- The search resultssiteName
- the name of the sitelang
- the languagewithHitCount
- true to sax the hit count as wellSAXException
- If an error occurred while saxing the criteriaprotected void saxCriterion(AbstractSearchGenerator.Criterion criterion, SearchResults<AmetysObject> searchResults, String siteName, String lang) throws SAXException, IOException
criterion
- the criterion.searchResults
- The search resultssiteName
- the site name.lang
- the language.SAXException
- If a sax error occurredIOException
- If another error occurredprotected abstract void saxFormValues(Request request, SearchResults<AmetysObject> searchResults, int start, int offset) throws SAXException
request
- The requestsearchResults
- The search resultsstart
- The start indexoffset
- The number of resultsSAXException
- if an error occurs while SAXingprotected abstract Query getQuery(Request request, Collection<String> siteNames, String language) throws IllegalArgumentException
request
- The requestsiteNames
- The site names.language
- The languageIllegalArgumentException
- If the search field is invalid.protected abstract Collection<Query> getFilterQueries(Request request, Collection<String> siteNames, String language) throws IllegalArgumentException
request
- The request.siteNames
- The site names.language
- The language.IllegalArgumentException
- If a search field is invalid.protected abstract void saxHits(SearchResults<AmetysObject> results, int start, int maxResults) throws SAXException, IOException
results
- The search results.start
- The start indexmaxResults
- The number of results to generate.SAXException
- If an error occurs while SAXingIOException
- If there is a low-level IO errorprotected abstract Collection<String> getFields()
protected abstract Map<String,AbstractSearchGenerator.Criterion> getCriteria(Request request, String siteName, String lang)
request
- the request.siteName
- the site name.lang
- the languageprotected Map<String,String> getCriteriaValues(Map<String,AbstractSearchGenerator.Criterion> criteria, Request request)
criteria
- the criteria list.request
- the request object.protected void saxPageHit(float score, float maxScore, Page page) throws SAXException
score
- The score of the pagemaxScore
- The maximum score of the search resultspage
- The pageSAXException
- If an error occurs while SAXingprivate void _saxPageContents(Page page) throws SAXException
SAXException
private void _saxLastModifiedDate(Page page) throws SAXException
SAXException
private void _saxLastValidationDate(Page page) throws SAXException
SAXException
protected void saxAdditionalInfosOnPageHit(Page page) throws SAXException
page
- the pageSAXException
- if something goes wrong when saxing the informationprotected void saxResourceHit(float score, float maxScore, Resource resource) throws SAXException
score
- The score of the pagemaxScore
- The maximum score of the search resultsresource
- The resourceSAXException
- If an error occurs while SAXingprivate String _getResourceExcerpt(Resource resource)
private Page _getResourcePage(Resource resource)
private String _encodePath(String path)
protected void saxPagination(long totalHits, int start, int offset) throws SAXException
totalHits
- The total number of resultstart
- The start index of searchoffset
- The max number of results per pageSAXException
- SAXException If an error occurs while SAXingprotected int getPageIndex(Request request)
request
- The requestprivate void _saxIcon(String filename) throws SAXException
SAXException
private void _saxSize(long size) throws SAXException
SAXException
protected void saxServiceIdentifiers() throws SAXException, IOException, ProcessingException
SAXException
- if an error occurs SAXing data.IOException
- if an error occurs SAXing data.ProcessingException
- if a processing error occurs.protected void saxAdditionalInfos() throws SAXException, IOException, ProcessingException
SAXException
- if an error occurs SAXing data.IOException
- if an error occurs SAXing data.ProcessingException
- if a processing error occurs.protected String getSearchMode()
protected boolean isInputValid()
protected void saxContent(String contentId, String metadataSetName) throws SAXException
contentId
- the id of the contentmetadataSetName
- The name of metadata set to saxSAXException
- if an exception occurs while saxing