Package com.jalios.jcms
Class QueryManager
java.lang.Object
com.jalios.jcms.QueryManager
- All Implemented Interfaces:
JcmsConstants,JaliosConstants
This class manages queries on publications
- Since:
- jcms-5.0.0
- Author:
- Olivier Dedieu, Olivier Jaquemet
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumQuery manager steps, used to determintate which query processing is being performed. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intstatic final StringQueryHandler attribute key of the current QueryManager processing step of the QueryManager.protected Set<QueryFilter> 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_YEARFields inherited from interface com.jalios.jcms.JcmsConstants
ADATE_SEARCH, ADVANCED_TAB, AJAX_MODE_ATTR, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, CLASS_PROPERTY, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, COUNTRY_SPRITE, CS_TYPOLOGY_ROOT_CAT_VID, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DATA_DIRECTORY, DEFAULT_PHOTO_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, GENERATIONAL_STORE_DIRECTORY, GLYPH_ICON_PREFIX, ICON_ARCHIVE, ICON_ICON_PREFIX, ICON_LOCK, ICON_LOCK_STRONG, ICON_PREFIX_PROP, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, IS_IN_FRONT_OFFICE, JALIOS_JUNIT_PROP, JCMS_CADDY, JCMS_MSG_LIST, JCMS_TOASTR_COLLECTION, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LANG_SPRITE, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_CREATE_STR, OP_DEEP_COPY, OP_DEEP_COPY_STR, OP_DEEP_DELETE, OP_DEEP_DELETE_STR, OP_DELETE, OP_DELETE_STR, OP_MERGE, OP_MERGE_STR, OP_UPDATE, OP_UPDATE_STR, ORGANIZATION_ROOT_GROUP_PROP, PDATE_SEARCH, PHOTO_DIR, PHOTO_ICON, PHOTO_ICON_HEIGHT, PHOTO_ICON_PROP_PREFIX, PHOTO_ICON_WIDTH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_PROP_PREFIX, PHOTO_LARGE_WIDTH, PHOTO_MINI, PHOTO_MINI_HEIGHT, PHOTO_MINI_PROP_PREFIX, PHOTO_MINI_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_PROP_PREFIX, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_PROP_PREFIX, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_PROP_PREFIX, PHOTO_TINY_WIDTH, PHOTO_XLARGE, PHOTO_XLARGE_HEIGHT, PHOTO_XLARGE_PROP_PREFIX, PHOTO_XLARGE_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, RAW_CONTENT_ICON_PREFIX, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SECURITY_LOG_FILE, SESSION_AUTHORIZED_FILENAMES_SET, SPRITE_ICON_PREFIX, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, SUCCESS_MSG, SVG_ICON_PREFIX, SVGINLINE_ICON_PREFIX, SVGSPRITE_ICON_PREFIX, TEMPLATE_TAB, THEME_DIR, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, TTCARD_MEDIA_HEIGHT, TTCARD_MEDIA_WIDTH, TYPES_ICON_ALT_PROP, TYPES_ICON_SUFFIX_PROP, TYPES_ICON_TITLE_PROP, TYPES_PREFIX_PROP, TYPES_THUMB_SUFFIX_PROP, TYPES_UNKNOWN_CLASS_PROP, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, UPLOAD_PERMISSION_COUNT_PROP_PREFIX, UPLOAD_PERMISSION_SIZE_PROP_PREFIX, URL_REGEXP, VID_LOGGED_MEMBER, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the given QueryFilter.booleancallFilterDBResult(PublicationCriteria pubCriteria) voidfilterCriteria(PublicationCriteria pubCriteria, org.hibernate.Criteria criteria) Invoke all QueryFilter to allow them to modify the Hibernate Criteria used for a DB Query.booleanfilterDBResult(Publication pub, Map context) protected Date[]Compute begin and end date of a query from QueryHandler values.protected static intReturn an integer describing the type of search date from a QueryHandler.static QueryManagerCompute aHashSetofCategoryto exclude during query from the "cidsOff" value of the given QueryHandler.protected HashSet<Class<? extends Publication>> Compute aHashSetofClass(type) to include during query from the "typesOff" value of the given QueryHandler.Compute aHashSetofGroupto exclude during query from the "gidsOff" value of the given QueryHandler.Compute aHashSetofMemberto exclude during query from the "midsOff" value of the given QueryHandler.Compute aHashSetofCategoryto include during query from the "cids" value of the given QueryHandler.protected HashSet<Class<? extends Publication>> getQueryClassSet(QueryHandler qh, boolean addFileDoc) Compute aHashSetofClass(type) to include during query from the "types" value of the given QueryHandler.Returns all the query filter.Compute aHashSetofGroupto include during query from the "gids" value of the given QueryHandler.static QueryManagerCompute aHashSetofMemberto include during query from the "mids" value of the given QueryHandler.protected HashSet<PortalElement> Compute aHashSetofPortalElementincluding all portal ands its children from the "portalIds" value of the given QueryHandler.SortedSet<? extends Publication> Returns a set of publications related to the given publication and the given query handler.SortedSet<? extends Publication> getRelatedPublicationSet(Publication pub, Member mbr, Class... classes) Returns a set of publications related to the given publication and the given types for the given member.SortedSet<? extends Publication> getRelatedPublicationSet(Set<Category> catSet, QueryHandler qh, Comparator<? extends Publication> superComparator) Returns a set of publications related to the given category set and the given query handler.SortedSet<? extends Publication> getRelatedPublicationSet(Set<Category> catSet, QueryHandler qh, Comparator<? extends Publication> superComparator, int max) Returns a set of publications related to the given category set and the given query handler.static booleanprotected QueryResultSetperformJStoreQuery(QueryHandler qh, javax.servlet.http.HttpServletRequest request, Set<? extends Publication> proposedDataSet) voidPrepare the given publication to be displayed in the result list.query(QueryHandler qh, javax.servlet.ServletRequest request, Set<? extends Publication> proposedDataSet) Perform a query using parameters specified in the givenQueryHandler.protected voidreduceDataSetWithCategories(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using Categories options (cids/cidsOff) of the QueryHandler.protected voidreduceDataSetWithHistoryRefinement(QueryHandler qh, Set<? extends Publication> proposedDataSet, javax.servlet.http.HttpServletRequest request, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using query History (hist) of the QueryHandler.protected voidreduceDataSetWithMembers(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using Members options (mids/midsOff) of the QueryHandler.protected voidreduceDataSetWithPortalElements(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using PortalElement options (mids/midsOff) of the QueryHandler.protected voidreduceDataSetWithTextEngine(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using Text Search options of the QueryHandler.protected booleanreduceDataSetWithTypes(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using Types options (types/typesOff) of the QueryHandler.voidRemove the given QueryFilter.protected booleansearchFulltext(QueryHandler qh, HashSet<Publication> dataSet, QueryResultSet resultSet) Perform a full-text search.
-
Field Details
-
QUERY_MANAGER_STEP_ATTRIBUTE
QueryHandler attribute key of the current QueryManager processing step of the QueryManager.- See Also:
-
queryFilterSet
-
idCount
protected int idCount
-
-
Method Details
-
getQueryManager
-
getInstance
-
getPublicationSearchEngine
- Returns:
- the PublicationSearchEngine
- Since:
- jcms-5.5.0
-
getCategorySearchEngine
- Returns:
- the CategorySearchEngine
- Since:
- jcms-5.5.0
-
addQueryFilter
Add the given QueryFilter.- Parameters:
qf- the QueryFilter to be added- Since:
- jcms-5.0.0
-
removeQueryFilter
Remove the given QueryFilter.- Parameters:
qf- the QueryFilter to be removed- Since:
- jcms-5.0.0
-
getQueryFilterSet
Returns all the query filter. DO NOT alter the returned set, clone prior modification.- Returns:
- the queryFilterSet
- Since:
- jcms-5.5.0
-
prepareExternalResult
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 givenQueryHandler.
Search in the givenCollectionofPublicationor in allPublicationif not specified.- Parameters:
qh- theQueryHandlerfrom which to retrieve the query parameters, MUST NOT be null.request- theServletHttpRequestused to set some error or warning messages in the attributes, can be null.proposedDataSet- theCollectionofPublicationin which to search and apply query parameters, if null, search is done in allPublication.- Returns:
- a
QueryResultSetcontaining all results of this query, it is aHashSetand therefore it is NOT sorted. use eitherQueryResultSet.getAsSortedSet()orQueryResultSet.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) - Parameters:
qh- the queryHandlerrequest- the requestproposedDataSet- the proposed data set- Returns:
- see QueryManager#query(QueryHandler, ServletRequest, Set)
- See Also:
-
getDateType
Return an integer describing the type of search date from a QueryHandler.- Parameters:
qh- theQueryHandlerto use.- Returns:
- an integer, see ?DATE_SEARCH constants.
-
getBeginAndEndDates
Compute begin and end date of a query from QueryHandler values.- Parameters:
qh- theQueryHandlerto use.- Returns:
- an array of two
Date, the first is the begin date, the second the end Date.
-
getQueryCategorySet
Compute aHashSetofCategoryto include during query from the "cids" value of the given QueryHandler.- Parameters:
qh- the QueryHandler- Returns:
- a
HashSetofCategory
-
getQueryAvoidCategorySet
Compute aHashSetofCategoryto exclude during query from the "cidsOff" value of the given QueryHandler.- Parameters:
qh- the QueryHandler- Returns:
- a
HashSetofCategory
-
getQueryMemberSet
Compute aHashSetofMemberto include during query from the "mids" value of the given QueryHandler.- Parameters:
qh- the QueryHandler- Returns:
- a
HashSetofMember
-
getQueryAvoidMemberSet
Compute aHashSetofMemberto exclude during query from the "midsOff" value of the given QueryHandler.- Parameters:
qh- the QueryHandler- Returns:
- a
HashSetofMember
-
getQueryGroupSet
Compute aHashSetofGroupto include during query from the "gids" value of the given QueryHandler. Return null if the computed hashset is empty.- Parameters:
qh- the QueryHandler- Returns:
- a
HashSetofGroup
-
getQueryAvoidGroupSet
Compute aHashSetofGroupto exclude during query from the "gidsOff" value of the given QueryHandler.- Parameters:
qh- the QueryHandler- Returns:
- a
HashSetofGroup
-
getQueryPortalElementSet
Compute aHashSetofPortalElementincluding all portal ands its children from the "portalIds" value of the given QueryHandler.- Parameters:
qh- the QueryHandler- Returns:
- a
HashSetofPortalElement
-
getQueryClassSet
protected HashSet<Class<? extends Publication>> getQueryClassSet(QueryHandler qh, boolean addFileDoc) Compute aHashSetofClass(type) to include during query from the "types" value of the given QueryHandler.- Parameters:
qh- the QueryHandleraddFileDoc- if true add the FileDocument class- Returns:
- a
HashSetofClass
-
getQueryAvoidClassSet
Compute aHashSetofClass(type) to include during query from the "typesOff" value of the given QueryHandler.- Parameters:
qh- the QueryHandler- Returns:
- a
HashSetofClass
-
reduceDataSetWithTextEngine
protected void reduceDataSetWithTextEngine(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using Text Search options of the QueryHandler.- Parameters:
qh- the QueryHandlerdataToKeepSet- the set of data to keepdataToExcludeSet- the set of data to excludeindexUsed- a flag to mark if data set is to keep or to exclude- Since:
- jcms-6.1.0
-
reduceDataSetWithTypes
protected boolean reduceDataSetWithTypes(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using Types options (types/typesOff) of the QueryHandler.- Parameters:
qh- the QueryHandlerdataToKeepSet- the set of data to keepdataToExcludeSet- the set of data to excludeindexUsed- a flag to mark if data set is to keep or to exclude- 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 givenHashSetwithDatato keep and to exclude using Categories options (cids/cidsOff) of the QueryHandler.- Parameters:
qh- the QueryHandlerdataToKeepSet- the set of data to keepdataToExcludeSet- the set of data to excludeindexUsed- a flag to mark if data set is to keep or to exclude
-
reduceDataSetWithMembers
protected void reduceDataSetWithMembers(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using Members options (mids/midsOff) of the QueryHandler.- Parameters:
qh- the QueryHandlerdataToKeepSet- the set of data to keepdataToExcludeSet- the set of data to excludeindexUsed- a flag to mark if data set is to keep or to exclude
-
reduceDataSetWithPortalElements
protected void reduceDataSetWithPortalElements(QueryHandler qh, HashSet<Publication> dataToKeepSet, HashSet<Publication> dataToExcludeSet, boolean[] indexUsed) Fill the givenHashSetwithDatato keep and to exclude using PortalElement options (mids/midsOff) of the QueryHandler.- Parameters:
qh- the QueryHandlerdataToKeepSet- the set of data to keepdataToExcludeSet- the set of data to excludeindexUsed- a flag to mark if data set is to keep or to exclude
-
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 givenHashSetwithDatato keep and to exclude using query History (hist) of the QueryHandler.- Parameters:
qh- the QueryHandlerproposedDataSet- the proposed set of data to seach on.request- the requestdataToKeepSet- the set of data to keepdataToExcludeSet- the set of data to excludeindexUsed- a flag to mark if data set is to keep or to exclude
-
searchFulltext
protected boolean searchFulltext(QueryHandler qh, HashSet<Publication> dataSet, QueryResultSet resultSet) Perform a full-text search. It fills the givenresultSetwith results from the dataSet matching critera of qh.- Parameters:
qh- the QueryhandlerdataSet- aHashSetcontaining all the publication to search.resultSet- aQueryResultSetin which to put all the results.- Returns:
- true if the search has been performed.
- Since:
- jcms-5.0.0
-
matchLucenePublicationRefinement
-
callFilterDBResult
-
filterCriteria
Invoke all QueryFilter to allow them to modify the Hibernate Criteria used for a DB Query.- Parameters:
pubCriteria- the criteria of the query.criteria- the hibernate criteria computed by JPlatform core- Since:
- jcms-10.0.7 / JCMS-9561
-
filterDBResult
-
getRelatedPublicationSet
public SortedSet<? extends Publication> getRelatedPublicationSet(Publication pub, Member mbr, Class... classes) Returns a set of publications related to the given publication and the given types for the given member.- Parameters:
pub- the publication to search related publications.mbr- the logged memberclasses- an array of publication classes- Returns:
- a set of publications related to the given publication and the given types for the given member.
- Since:
- jcms-10.0.4
-
getRelatedPublicationSet
Returns a set of publications related to the given publication and the given query handler.- Parameters:
pub- the publication to search related publications.qh- the QueryHandler- Returns:
- a set of publications related to the given publication and the given query handler.
- Since:
- jcms-10.0.0
-
getRelatedPublicationSet
public SortedSet<? extends Publication> getRelatedPublicationSet(Set<Category> catSet, QueryHandler qh, Comparator<? extends Publication> superComparator) Returns a set of publications related to the given category set and the given query handler.- Parameters:
catSet- the set of category to search related publications.qh- the QueryHandlersuperComparator- if not null use this comparator in case of equality on the common category count.- Returns:
- a set of publications related to the given category set and the given query handler.
- Since:
- jcms-10.0.0
-
getRelatedPublicationSet
public SortedSet<? extends Publication> getRelatedPublicationSet(Set<Category> catSet, QueryHandler qh, Comparator<? extends Publication> superComparator, int max) Returns a set of publications related to the given category set and the given query handler.- Parameters:
catSet- the set of category to search related publications.qh- the QueryHandlersuperComparator- if not null use this comparator in case of equality on the common category count.max- the max of related publication returned- Returns:
- a set of publications related to the given category set and the given query handler.
- Since:
- jcms-11.0.0
-