com.jalios.jcms
Class QueryManager

java.lang.Object
  extended by com.jalios.jcms.QueryManager
All Implemented Interfaces:
JcmsConstants, JaliosConstants

public class QueryManager
extends Object
implements JcmsConstants

This class manages queries on publications

Since:
jcms-5.0.0
Version:
$Revision: 24388 $
Author:
Olivier Dedieu , Olivier Jaquemet

Nested Class Summary
static class QueryManager.QueryPublicationSelector
           
 
Field Summary
protected  int idCount
           
static String LUCENE_QUERY_ATTRIBUTE
          QueryResultsSet Attribute key of the rewritten text search string for lucene;
protected  Set<QueryFilter> queryFilterSet
           
static String REVISION
           
 
Fields inherited from interface com.jalios.jcms.JcmsConstants
ADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, CRYPT_MD5, CRYPT_UNDEFINED, CRYPT_UNIX, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, ICON_ARCHIVE, ICON_LOCK, ICON_LOCK_STRONG, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, JALIOS_JUNIT_PROP, JCMS_CADDY, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_DEEP_COPY, OP_DEEP_DELETE, OP_DELETE, OP_MERGE, OP_UPDATE, PDATE_SEARCH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SESSION_AUTHORIZED_FILENAMES_SET, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, TEMPLATE_TAB, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, URL_REGEXP, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
 
Fields inherited from interface com.jalios.util.JaliosConstants
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
 
Method Summary
 void addQueryFilter(QueryFilter qf)
          Add the given QueryFilter
protected  Date[] getBeginAndEndDates(QueryHandler qh, javax.servlet.ServletRequest request)
          Compute begin and end date of a query from QueryHandler values.
 CategorySearchEngine getCategorySearchEngine()
           
protected static int getDateType(QueryHandler qh)
          Return an integer describing the type of search date from a QueryHandler.
 FileSearchEngine getFileSearchEngine()
           
static String getLuceneQuery(String text, String mode)
          Build a lucene query from the given parameters.
 PublicationSearchEngine getPublicationSearchEngine()
           
protected  HashSet<Category> getQueryAvoidCategorySet(QueryHandler qh)
          Compute a HashSet of Category to exclude during query grom the "cidsOff" value of the given QueryHandler.
protected  HashSet<Class<? extends Publication>> getQueryAvoidClassSet(QueryHandler qh)
          Compute a HashSet of Class (type) to include during query grom the "typesOff" value of the given QueryHandler.
protected  HashSet<Group> getQueryAvoidGroupSet(QueryHandler qh)
          Compute a HashSet of Group to exclude during query grom the "gidsOff" value of the given QueryHandler.
protected  HashSet<Member> getQueryAvoidMemberSet(QueryHandler qh)
          Compute a HashSet of Member to exclude during query grom the "midsOff" value of the given QueryHandler.
protected  HashSet<Category> getQueryCategorySet(QueryHandler qh)
          Compute a HashSet of Category to include during query grom the "cids" value of the given QueryHandler.
protected  HashSet<Class<? extends Publication>> getQueryClassSet(QueryHandler qh, boolean addFileDoc)
          Compute a HashSet of Class (type) to include during query grom the "types" value of the given QueryHandler.
 Set<QueryFilter> getQueryFilterSet()
          Returns all the query filter.
protected  HashSet<Group> getQueryGroupSet(QueryHandler qh)
          Compute a HashSet of Group to include during query grom the "gids" value of the given QueryHandler.
static QueryManager getQueryManager()
           
protected  HashSet<Member> getQueryMemberSet(QueryHandler qh)
          Compute a HashSet of Member to include during query grom the "mids" value of the given QueryHandler.
protected  HashSet<PortalElement> getQueryPortalElementSet(QueryHandler qh)
          Compute a HashSet of PortalElement including all portal ands its children from the "portalIds" value of the given QueryHandler.
protected  QueryResultSet performJStoreQuery(QueryHandler qh, javax.servlet.http.HttpServletRequest request, Set<? extends Publication> proposedDataSet)
           
 void prepareExternalResult(Publication pub)
          Prepare the given publication to be displayed in the result list.
 QueryResultSet query(QueryHandler qh, javax.servlet.ServletRequest request, Set<? extends Publication> proposedDataSet)
          Perform a query using parameters specified in the given QueryHandler.
protected  void reduceDataSetWithCategories(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed)
          Fill the given HashSet with Data to keep and to exclude using Categories options (cids/cidsOff) of the QueryHandler.
protected  void reduceDataSetWithHistoryRefinement(QueryHandler qh, Set<? extends Publication> proposedDataSet, javax.servlet.http.HttpServletRequest request, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed)
          Fill the given HashSet with Data to keep and to exclude using query History (hist) of the QueryHandler.
protected  void reduceDataSetWithMembers(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed)
          Fill the given HashSet with Data to keep and to exclude using Members options (mids/midsOff) of the QueryHandler.
protected  void reduceDataSetWithPortalElements(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed)
          Fill the given HashSet with Data to keep and to exclude using PortalElement options (mids/midsOff) of the QueryHandler.
protected  void reduceDataSetWithTextEngine(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed)
          Fill the given HashSet with Data to keep and to exclude using Text Search options of the QueryHandler.
protected  boolean reduceDataSetWithTypes(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed)
          Fill the given HashSet with Data to keep and to exclude using Types options (types/typesOff) of the QueryHandler.
 void removeQueryFilter(QueryFilter qf)
          Remove the given QueryFilter
protected  void replaceFileDocByReferrers(QueryResultSet resultSet, Member loggedMember, Set<Class<? extends Publication>> classSet)
          This method replace any FileDocuments inside the given QueryResultSet by their referrer (see getLinkIndexedDataSet(Publication.class)).
protected  boolean searchFulltext(QueryHandler qh, HashSet<Publication> dataSet, QueryResultSet resultSet)
          Perform a full-text search.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

LUCENE_QUERY_ATTRIBUTE

public static final String LUCENE_QUERY_ATTRIBUTE
QueryResultsSet Attribute key of the rewritten text search string for lucene;

See Also:
Constant Field Values

queryFilterSet

protected Set<QueryFilter> queryFilterSet

idCount

protected int idCount
Method Detail

getQueryManager

public static QueryManager getQueryManager()
                                    throws Exception
Throws:
Exception

getFileSearchEngine

public FileSearchEngine getFileSearchEngine()
Returns:
the FileSearchEngine
Since:
jcms-5.0.0

getPublicationSearchEngine

public PublicationSearchEngine getPublicationSearchEngine()
Returns:
the PublicationSearchEngine
Since:
jcms-5.5.0

getCategorySearchEngine

public CategorySearchEngine getCategorySearchEngine()
Returns:
the CategorySearchEngine
Since:
jcms-5.5.0

addQueryFilter

public void addQueryFilter(QueryFilter qf)
Add the given QueryFilter

Parameters:
qf - the QueryFilter to be added
Since:
jcms-5.0.0

removeQueryFilter

public void removeQueryFilter(QueryFilter qf)
Remove the given QueryFilter

Parameters:
qf - the QueryFilter to be removed
Since:
jcms-5.0.0

getQueryFilterSet

public Set<QueryFilter> getQueryFilterSet()
Returns all the query filter. DO NOT alter the returned set, clone prior modification.

Returns:
the queryFilterSet
Since:
jcms-5.5.0

prepareExternalResult

public void prepareExternalResult(Publication pub)
Prepare the given publication to be displayed in the result list. Fill the publication with fake id, cdate, mdate and pdate, and author.

Parameters:
pub - the publication to be prepared
Since:
jcms-5.0.0

query

public QueryResultSet query(QueryHandler qh,
                            javax.servlet.ServletRequest request,
                            Set<? extends Publication> proposedDataSet)
Perform a query using parameters specified in the given QueryHandler.
Search in the given Collection of Publication or in all Publication if not specified.

Parameters:
qh - the QueryHandler from which to retrieve the query parameters, MUST NOT be null.
request - the ServletHttpRequest used to set some error or warning messages in the attributes, can be null.
proposedDataSet - the Collection of Publication in which to search and apply query parameters, if null, search is done in all Publication.
Returns:
a QueryResultSet containing all results of this query, it is a HashSet and therefore it is NOT sorted. use either QueryResultSet.getAsSortedSet() or QueryResultSet.getAsSortedSet(java.util.Comparator) to obtain a sorted Set.
Since:
jcms-5.0.0

performJStoreQuery

protected QueryResultSet performJStoreQuery(QueryHandler qh,
                                            javax.servlet.http.HttpServletRequest request,
                                            Set<? extends Publication> proposedDataSet)
See Also:
query(QueryHandler, ServletRequest, Set)

getDateType

protected static int getDateType(QueryHandler qh)
Return an integer describing the type of search date from a QueryHandler.

Parameters:
qh - the QueryHandler to use.
Returns:
an integer, see ?DATE_SEARCH constants.

getBeginAndEndDates

protected Date[] getBeginAndEndDates(QueryHandler qh,
                                     javax.servlet.ServletRequest request)
Compute begin and end date of a query from QueryHandler values.

Parameters:
qh - the QueryHandler to use.
request - the request to set optional error message (may be null).
Returns:
an array of two Date, the first is the begin date, the second the end Date.

getQueryCategorySet

protected HashSet<Category> getQueryCategorySet(QueryHandler qh)
Compute a HashSet of Category to include during query grom the "cids" value of the given QueryHandler.


getQueryAvoidCategorySet

protected HashSet<Category> getQueryAvoidCategorySet(QueryHandler qh)
Compute a HashSet of Category to exclude during query grom the "cidsOff" value of the given QueryHandler.


getQueryMemberSet

protected HashSet<Member> getQueryMemberSet(QueryHandler qh)
Compute a HashSet of Member to include during query grom the "mids" value of the given QueryHandler.


getQueryAvoidMemberSet

protected HashSet<Member> getQueryAvoidMemberSet(QueryHandler qh)
Compute a HashSet of Member to exclude during query grom the "midsOff" value of the given QueryHandler.


getQueryGroupSet

protected HashSet<Group> getQueryGroupSet(QueryHandler qh)
Compute a HashSet of Group to include during query grom the "gids" value of the given QueryHandler. Return null if the computed hashset is empty.


getQueryAvoidGroupSet

protected HashSet<Group> getQueryAvoidGroupSet(QueryHandler qh)
Compute a HashSet of Group to exclude during query grom the "gidsOff" value of the given QueryHandler.


getQueryPortalElementSet

protected HashSet<PortalElement> getQueryPortalElementSet(QueryHandler qh)
Compute a HashSet of PortalElement including all portal ands its children from the "portalIds" value of the given QueryHandler.


getQueryClassSet

protected HashSet<Class<? extends Publication>> getQueryClassSet(QueryHandler qh,
                                                                 boolean addFileDoc)
Compute a HashSet of Class (type) to include during query grom the "types" value of the given QueryHandler.


getQueryAvoidClassSet

protected HashSet<Class<? extends Publication>> getQueryAvoidClassSet(QueryHandler qh)
Compute a HashSet of Class (type) to include during query grom the "typesOff" value of the given QueryHandler.


reduceDataSetWithTextEngine

protected void reduceDataSetWithTextEngine(QueryHandler qh,
                                           HashSet<Publication> dataToKeepSet,
                                           HashSet<Publication> dataToExcludeSet,
                                           boolean[] indexUsed)
Fill the given HashSet with Data to keep and to exclude using Text Search options of the QueryHandler.

Since:
jcms-6.1.0

reduceDataSetWithTypes

protected boolean reduceDataSetWithTypes(QueryHandler qh,
                                         HashSet<Publication> dataToKeepSet,
                                         HashSet<Publication> dataToExcludeSet,
                                         boolean[] indexUsed)
Fill the given HashSet with Data to keep and to exclude using Types options (types/typesOff) of the QueryHandler.

Returns:
true if the reduction using dataToKeepSet was performed, false otherwise.

reduceDataSetWithCategories

protected void reduceDataSetWithCategories(QueryHandler qh,
                                           HashSet<Publication> dataToKeepSet,
                                           HashSet<Publication> dataToExcludeSet,
                                           boolean[] indexUsed)
Fill the given HashSet with Data to keep and to exclude using Categories options (cids/cidsOff) of the QueryHandler.


reduceDataSetWithMembers

protected void reduceDataSetWithMembers(QueryHandler qh,
                                        HashSet<Publication> dataToKeepSet,
                                        HashSet<Publication> dataToExcludeSet,
                                        boolean[] indexUsed)
Fill the given HashSet with Data to keep and to exclude using Members options (mids/midsOff) of the QueryHandler.


reduceDataSetWithPortalElements

protected void reduceDataSetWithPortalElements(QueryHandler qh,
                                               HashSet<Publication> dataToKeepSet,
                                               HashSet<Publication> dataToExcludeSet,
                                               boolean[] indexUsed)
Fill the given HashSet with Data to keep and to exclude using PortalElement options (mids/midsOff) of the QueryHandler.


reduceDataSetWithHistoryRefinement

protected void reduceDataSetWithHistoryRefinement(QueryHandler qh,
                                                  Set<? extends Publication> proposedDataSet,
                                                  javax.servlet.http.HttpServletRequest request,
                                                  HashSet<Publication> dataToKeepSet,
                                                  HashSet<Publication> dataToExcludeSet,
                                                  boolean[] indexUsed)
Fill the given HashSet with Data to keep and to exclude using query History (hist) of the QueryHandler.


replaceFileDocByReferrers

protected void replaceFileDocByReferrers(QueryResultSet resultSet,
                                         Member loggedMember,
                                         Set<Class<? extends Publication>> classSet)
This method replace any FileDocuments inside the given QueryResultSet by their referrer (see getLinkIndexedDataSet(Publication.class)). It keeps score of original FileDocument It removes FileDocument from the resultSet and add other Publications.

Since:
jcms-4.1

searchFulltext

protected boolean searchFulltext(QueryHandler qh,
                                 HashSet<Publication> dataSet,
                                 QueryResultSet resultSet)
Perform a full-text search. It fills the given resultSet with results from the dataSet matching critera of qh.

Parameters:
qh - the Queryhandler
dataSet - a HashSet containing all the publication to search.
resultSet - a QueryResultSet in which to put all the results.
Since:
jcms-5.0.0

getLuceneQuery

public static String getLuceneQuery(String text,
                                    String mode)
Build a lucene query from the given parameters.

Parameters:
text - the search string
mode - the query mode (all, any, word, exact)
Returns:
a String which contains the lucene-compliant query


Copyright © 2001-2007 Jalios SA. All Rights Reserved.