public abstract class AbstractQuery extends Object
Base class for any search query containers which keeps common informations needed for executing search.
Attention: For performance reasons the default value for isNeedTotal() is false!
This means: When using setCount(int) in the SearchResult the SearchResult.getTotalCount() will be
equal to the used value.
Please note that this class is not thread-safe and not intended to be living longer than one request.
| Constructor and Description |
|---|
AbstractQuery() |
| Modifier and Type | Method and Description |
|---|---|
Collection<CatalogVersionModel> |
getCatalogVersions()
Returns a collection with catalog versions for this FlexibleSearchQuery which were explicitly set by
setCatalogVersions(Collection). |
int |
getCount() |
LanguageModel |
getLanguage()
Deprecated.
use
getLocale() and setLocale(Locale) instead of LanguageModel directly. |
Locale |
getLocale()
Gets the locale which will be used for executing query.
|
<T extends Class> |
getResultClassList()
This list contains the expected types/classes of the result objects.
|
Collection<SessionSearchRestriction> |
getSessionSearchRestrictions()
Gets the session search restrictions will be used for executing query.
|
int |
getStart()
Default value for the start range is 0 (first element).
|
UserModel |
getUser()
Gets the user for which query will be executed.
|
boolean |
isDisableCaching()
Checks if caching for current query is disabled.
|
boolean |
isDisableSearchRestrictions() |
Boolean |
isDisableSpecificDbLimitSupport()
Checks if specific DB limit support is disabled or enabled for current query.
|
boolean |
isFailOnUnknownFields() |
boolean |
isNeedTotal()
Checks if is need total.
|
void |
setCatalogVersions(CatalogVersionModel... catalogVersions)
Overwrites the global search restrictions for catalog versions.
|
void |
setCatalogVersions(Collection<CatalogVersionModel> catalogVersions)
Overwrites the global search restrictions for catalog versions.
|
void |
setCount(int count)
Set the number of elements in the search range.
|
void |
setDisableCaching(boolean disableCaching)
Sets caching of this query disabled or enabled.
|
void |
setDisableSearchRestrictions(boolean disableSearchRestrictions)
Set this value to
true if you want to disable search restrictions. |
void |
setDisableSpecificDbLimitSupport(Boolean disableSpecificDbLimitSupport)
Sets the specific DB limit support disabled or enabled for current query.
|
void |
setFailOnUnknownFields(boolean isFailOnUnknownFields)
Set this value to
true (default value) and it causes an error when using an unknown field name. |
void |
setLanguage(LanguageModel language)
Deprecated.
use
getLocale() and setLocale(Locale) instead of LanguageModel directly. |
void |
setLocale(Locale locale)
Sets the locale which will be used for executing query.
|
void |
setNeedTotal(boolean needTotal)
Sets the
isNeedTotal. |
<T extends Class> |
setResultClassList(List<T> resultClassList)
Sets the expected result types signature as list.
|
void |
setSessionSearchRestrictions(Collection<SessionSearchRestriction> sessionSearchRestrictions)
Adds the session search restrictions which will be used for executing query.
|
void |
setSessionSearchRestrictions(SessionSearchRestriction... sessionSearchRestrictions)
Adds the session search restrictions which will be used for executing query.
|
void |
setStart(int start)
Sets the start number of the search range.
|
void |
setUser(UserModel user)
Sets the user to the search session context.
|
public boolean isDisableSearchRestrictions()
false.public void setDisableSearchRestrictions(boolean disableSearchRestrictions)
true if you want to disable search restrictions.public void setFailOnUnknownFields(boolean isFailOnUnknownFields)
true (default value) and it causes an error when using an unknown field name.isFailOnUnknownFields - Set to false if unknown field names should be ignoredpublic boolean isFailOnUnknownFields()
true if the search should fail by unknown fields.public int getCount()
@Deprecated public LanguageModel getLanguage()
getLocale() and setLocale(Locale) instead of LanguageModel directly.Gets the language which will be used for executing query.
If the language has not been set then current session language will be used for executing query.
public Locale getLocale()
Gets the locale which will be used for executing query.
If the locale has not been set then current session locale will be used for executing query.
public Collection<SessionSearchRestriction> getSessionSearchRestrictions()
Please notice that any search restrictions are ignored if current logged user is admin or any other user with admin rights.
public int getStart()
public boolean isNeedTotal()
Attention: For performance reasons the default value for isNeedTotal() is false
!
This means: When using setCount(int) in the SearchResult the SearchResult.getTotalCount() will be
equal to the used value in setCount(int). When isNeedTotal() is true then
total count will be returned from method SearchResult.getTotalCount(). This parameter is especially
important for paging mechanism.
public void setCount(int count)
isNeedTotal()=
false! The total count of the result will be equal to this value. The default value is -1 which means
all elements.count - Sets the number of elements for the search range.@Deprecated public void setLanguage(LanguageModel language)
getLocale() and setLocale(Locale) instead of LanguageModel directly.Sets the language to the search session context.
If the language has not been set then current session language will be used for executing query.
language - the languagepublic void setLocale(Locale locale)
Sets the locale which will be used for executing query.
If the locale has not been set then current session locale will be used for executing query.
Please keep in mind that Locale have to be created properly with language code and/or country code
and/or variant code as follows:
Locale loc = new Locale("en", "US", "NY");
Do not create Locale object as follows:
Locale loc = new Locale("en_US");
It will not split language and country code automatically. To split ISO code string properly use
Utilities.parseLocaleCodes(String) method as follows:
final String[] codes = Utilities.parseLocaleCodes("en_US");
Locale loc = new Locale(codes[0], codes[1]);
locale - the new localepublic void setNeedTotal(boolean needTotal)
Sets the isNeedTotal.
Attention: For performance reasons the default value for isNeedTotal() is false
!
This means: When using setCount(int) in the SearchResult the SearchResult.getTotalCount() will be
equal to the used value in setCount(int). When isNeedTotal() is true then
total count will be returned from method SearchResult.getTotalCount(). This parameter is especially
important for paging mechanism.
needTotal - the new need totalpublic void setSessionSearchRestrictions(Collection<SessionSearchRestriction> sessionSearchRestrictions)
Adds the session search restrictions which will be used for executing query.
Please notice that any search restrictions are ignored if current logged user is admin or any other user with admin rights.
public void setSessionSearchRestrictions(SessionSearchRestriction... sessionSearchRestrictions)
Adds the session search restrictions which will be used for executing query.
Please notice that any search restrictions are ignored if current logged user is admin or any other user with admin rights.
public void setStart(int start)
start - the start number of the search rangepublic <T extends Class> List<T> getResultClassList()
public <T extends Class> void setResultClassList(List<T> resultClassList)
resultClassList - the result type listpublic Collection<CatalogVersionModel> getCatalogVersions()
setCatalogVersions(Collection). This collection is used for the search restrictions. If this method
returns null the global search restrictions are used for the search (which are stored at the search
session using
de.hybris.platform.catalog.CatalogVersionService#addSessionCatalogVersion(CatalogVersionModel))public void setCatalogVersions(Collection<CatalogVersionModel> catalogVersions)
de.hybris.platform.catalog.CatalogVersionService#addSessionCatalogVersion(CatalogVersionModel)) are
overwritten by the given collection.catalogVersions - a collection with catalog versions which are the new catalog version restriction for the search session
contextpublic void setCatalogVersions(CatalogVersionModel... catalogVersions)
de.hybris.platform.catalog.CatalogVersionService#addSessionCatalogVersion(CatalogVersionModel)) are
overwritten by the given collection.catalogVersions - catalog versions which are the new catalog version restriction for the search session contextpublic UserModel getUser()
Gets the user for which query will be executed.
If the user has not been set by setUser(UserModel) then the user from the current session is used for
executing query.
public void setUser(UserModel user)
Sets the user to the search session context. The search is executed with the restrictions for this user.
If the user is null or this method was not used at all then the user from the current session is used
for executing query.
user - the user which will be used for executing query.public Boolean isDisableSpecificDbLimitSupport()
public void setDisableSpecificDbLimitSupport(Boolean disableSpecificDbLimitSupport)
public boolean isDisableCaching()
public void setDisableCaching(boolean disableCaching)
Copyright © 2017 SAP SE. All Rights Reserved.