Class FlexibleSearch
- All Implemented Interfaces:
ItemLifecycleListener,Serializable
- Direct Known Subclasses:
FlexibleSearchDataSourceTest.TestFlexibleSearch,FlexibleSearchHintsTest.TestFlexibleSearch,ReadOnlyFlexibleSearchCronJobTest.TestFlexibleSearch
An overview on the FlexibleSearch syntax:
<query> = "SELECT" <selects> "FROM" <types> ( "WHERE" <conditions> ( "ORDER BY" <order> )? )?
<selects> = SQL <i>select</i> expression that contains attribute <field> sections
<types> = SQL <i>from</i> expression that contains item <type> and <typejoin> sections
<type> = "{" <single-type-clause> "}"
<typejoin> = "{" <single-type-clause> ( ( "LEFT" )? "JOIN" <single-type-clause> ( "ON" <join-conditions> )? )+ "}"
<single-type-clause> = code of type "!"? ( "AS" <type-alias> )? <type-modifiers>?
<type-alias> = a unique name of this type inside this query
<join-conditions> = SQL boolean condition including <field> sections ( "AND" SQL boolean condition including <field> sections )*
<conditions> = SQL <i>where</i> expression containing attribute <field> sections and <subselect> sections
<order> = SQL <i>order by </i> expression containing attribute <field> sections
<field> = "{" ( <type-alias> ":" )? <attribute-name> <language>( ":" <modifiers> )? "}"
<attribute-name> = the attribute name
<language> = "[" language PK string + "]"
<modifiers> = ( "c" | "l")? "o"? ... core field , localized property, outer joined property
<subselect> = "{{" <query> "}}"
A simple select to find all items of one type can be done like this:
ComposedType unitType = jaloSession.getTypeManager().getComposedType(Unit.class);
String query = "SELECT {" + Item.PK + "} FROM {" + unitType.getCode() + "}";
List units = jaloSession.getFlexibleSearch().search(query, // the query text
Collections.EMPTY_MAP, // no values needed here
Collections.singletonList(Unit.class), // the expected result (row) signature
true, // fail on unknown (untyped) fields
true, // don't need total
0, -1 // result range start = 0, count = -1 (unlimited)
).getResult();
Please note that items are always referenced as "{" + Item.PK + "}" . The actual item type is defined by
the search result signature list, e.g. Collections.singletonList(Item.class).
If you know that a search query is likely to yield a lot of results (such as a search for all products and their variants, for example), we discourage getting all of those search results in a single FlexibleSearch call: the results will be stored in a single Collection, which may result in slow performance. A better way is to split the query into several calls by limiting the number of search results per call, as in the following code snippet:
ComposedType unitType = jaloSession.getTypeManager().getComposedType(Unit.class);
String query = "SELECT {" + Item.PK + "} FROM {" + unitType.getCode() + "}";
int start = 0;
final int range = 3;
int total = -1;
do
{
SearchResult res = jaloSession.getFlexibleSearch().search(query, // the query text
Collections.EMPTY_MAP, // no values needed here
Collections.singletonList(Unit.class), // the expected result (row) signature
true, // fail on unknown (untyped) fields
false, // disable 'don't need total' here !
start, range // result range start = 0, count = -1 (unlimited)
);
List unitRange = res.getResult();
//
// process result
//
total = res.getTotalCount();
start += range;
}
while (start < total);
If you run such an iterated statement, you need to set the dontNeedTotal parameter to false.
If it is set to true, the FlexibleSearch framework runs the query, retrieves a list of Primary Keys, and instantiates
the items referenced by those keys -- which results in a possibly large number of additional database queries.
If dontNeedTotal is set to false, however, the FlexibleSearch does not instantiate the items referenced by the
Primary Keys; instead, it runs an SQL count statement on the list of Primary Keys. That way, you will be able of
quickly getting the number of search results; but you won't be able of accessing the actual items as they are not
instantiated.
Unlike EJB finders, the FlexibleSearch is able of retrieving raw data as well as items. Furthermore, it is possible to select multiple attributes or columns. the result of multi-attribute selections is a list of lists.
ComposedType unitType = jaloSession.getTypeManager().getComposedType(Unit.class);
String query =
// select
"SELECT {" + Item.PK + "} " + // the unit itself
",LOWER({" + Unit.CODE + "})" + // get the code cmp field
",{" + Unit.NAME + "}" + // get the localized name
// from
"FROM {" + unitType.getCode() + "}";
List rows = jaloSession.getFlexibleSearch().search(query, // the query text
Collections.EMPTY_MAP, // no values needed here
Arrays.asList(new Class[]
{ Unit.class, String.class, String.class }), // the expected result row signature: Unit, String, String
true, // fail on unknown (untyped) fields
true, // don't need total
0, -1 // result range start = 0, count = -1 (unlimited)
).getResult();
for (int i = 0, s = rows.size(); i < s; i++)
{
List row = (List) rows.get(i);
Unit u = row.get(0);
String codeLowerCase = row.get(1);
String name = row.get(2);
// ...
}
As seen here it is possible to use any column based SQL functions around flexible search sections (
"LOWER({"+Unit.CODE+"}" ) since only these sections are replaced. the rest of the query is left
untouched. this way even database specific functionality is available (though this might break database
independence).
ordering is as simple as selecting different attributes
ComposedType unitType = jaloSession.getTypeManager().getComposedType(Unit.class);
String query = "SELECT {" + Item.PK + "} FROM {" + unitType.getCode() + "}" + "ORDER BY {" + Unit.CODE + "} ASC";
List unitsOrdered = jaloSession.getFlexibleSearch().search(query.toString, // the query text
Collections.EMPTY_MAP, // no values needed here
Collections.singletonList(Unit.class), // the expected result (row) signature
true, // fail on unknown (untyped) fields
true, // don't need total
0, -1 // result range start = 0, count = -1 (unlimited)
).getResult();
a special note on properties: when order by contains properties which are stored in separate tables these tables are outer joined automatically since non existence of the property would avoid the actual item to be found otherwise.
localized properties require that a language is specified for searching. normally
search(SessionContext, String, Map, List, boolean, boolean, int, int) uses the current session language.
SessionContext myLangCtx = jaloSession.createSessionContext();
myLangCtx.setLanguage( jaloSession.getC2LManager().getLanguage( "FR" ) );
jaloSession.getFlexibleSearch().search( myLangCtx, ... );
further it is possible to specify a fixed language for each localized attribute - even multiple different languages per query. please note that this generates as many joins to localized property tables as languages are specified, so be careful.
Language langDE = jaloSession.getC2LManager().getLanguiage("DE");
Language langEN = jaloSession.getC2LManager().getLanguiage("EN");
String query = "SELECT {PK} FROM {MyType} WHERE {locAttr[" + langDE.getPK() + "]} = 'x' AND " + "{locAttr2[" + langEN.getPK()
+ "]} = 'y' AND " + "{locAttr3} = 'z'";
the example uses infact 3 languages: the session language for locAttr3, langDE for locAttr
and langEN for locAttr2. the fixed languages are passed as language pk strings.
values should be passed similar to JDBC prepared statements. unlike JDBC flexible search allows named values - this way the same value may be referenced at multiple places without the need to build a value list.
String query = "SELECT {PK} FROM {MyType} WHERE {attr} = ?value OR {attr2} = ?value";
Map values = new HashMap();
values.put( "value", "xyz" );
jaloSession.getFlexibleSearch().search( query, values, ... );
besides explicitly defined values a query may reference all session context attributes too. these attributes are
named "session."+attribute name. predefined session attributes are
SessionContext.USER, SessionContext.LANGUAGE and
SessionContext.CURRENCY.
ComposedType orderType = jaloSession.getTypeManager().getComposedType( Order.class );
String query = "SELECT {"Item.PK+"} FROM {"+orderType.getCode()+"} WHERE {"+Order.USER+"} = ?session."+SessionContext.USER +
" AND {"+Order.CURRENCY+"} = ?session."+SessionContext.CURRENCY;
List userOrders = jaloSession.getFlexibleSearch().search(
query,
Collections.EMPTY_MAP, // no values required since we use a session attribute
Collections.singletonList( Order.class ),
true, // fail on unknown
true, // don't need total
0, -1 // get all
).getResult();
further it is possible to access even attributes of the actual (item) values inside the value map.
Map values = new HashMap();
values.put("country", jaloSession.getC2LManager().getCountry("DE"));
values.put("region", jaloSession.getC2LManager().getRegionByCode("sachsen"));
String query = "SELECT {" + Item.PK + "} FROM {" + jaloSession.getTypeManager().getComposedType(Language.class).getCode()
+ "} AS lang " + "WHERE {lang:" + Language.ISOCODE + "} IN( ?country." + Country.ISOCODE + ", ?region." + Region.COUNTRY
+ "." + Country.ISOCODE + " )";
generally stating from one item each readable attribute is usable - if it is an item too further traversal is possible.
joins between types are allowed. currently inner joins and left outer joins are allowed.
String productType = jaloSession.getTypeManager().getComposedType( Product.class ).getCode();
STring cartEntryType = jaloSession.getTypeManager().getComposedType( CartEntry.class ).getCode();
String query =
"SELECT {p:"Item.PK+"}, {e:"CartEntry.UNIT+"}, SUM( {e:"CartEntry.QUANTITY+"} ) AS amount "+
"FROM {"+productType+" AS p JOIN "+cartEntryType+" AS e ON {p:"+Item.PK+"} = {e:"+CartEntry.PRODUCT+"} "+
"ORDER BY amount DESC "+
"GROUP BY {p:"+Item.PK+"}, {e:"CartEntry.UNIT+"};
final List productCartLists = jaloSession.getFlexibleSearch().search(
query,
Collections.EMPTY_MAP,
Arrays.asList( new Class[]{Product.class,Unit.class,Long.class}),
true,
true,
0, -1
).getResult();
System.out.println("products currently in carts");
for( int i = 0, s = productCartLists.size(); i < s ; i++ )
{
List row = (List)productCartLists.get(i);
Product p = (Product)row.get(0);
Unit u = (Unit)row.get(1);
long quantity = ((Long)row.get(2)).longValue();
System.out.println("\t"+p.getCode()+" -> "+quantity+" "+u.getCode());
}
the above example produces a list of all products which are currently held in carts grouped by the ordered unit and
show the total quantity. since this is no left (outer) join all products which are not inside a cart don't show up in
the result.
using properties requires some additional thought when searching for absence of values or properties not
having a certain value.
background: since localized and unoptimized properties are stored in separate tables they have to be joined to be
included them in the query. a non-existing property row (e.g. when no value has been written for the current language
yet) will cause the item not be found (except any property used in order by , see above )
an example:
Language l = jaloSession.getC2LManager().createLanguage( "fresh" );
SessionContext myCtx = jaloSession.createSessionContext();
myCtx.setLanguage( l );
List list = jaloSession.getFlexibleSearch().search(
myCtx,
"SELECT {"+Item.PK+"} FROM {"jaloSession.getTypeManager().getComposedType(Product.class).getCode()+"}"+
"WHERE {"+Product.NAME+"} <> 'tom'";
Collections.EMPTY_MAP,
Collections.singletonList( Product.class ),
true,
true,
0, 1
).getResult();
// list should be empty now since no product can own a property for the newly created language
the solution here is the o attribute modifier. this forces the property table to be outer joined.
nevertheless the query has to be changed as well to achieve the desired result here:
<pre Language l = jaloSession.getC2LManager().createLanguage( "fresh" ); SessionContext myCtx = jaloSession.createSessionContext(); myCtx.setLanguage( l ); List list = jaloSession.getFlexibleSearch().search( myCtx, // modifiers require full qualified attributes so we need an alias "SELECT {"+Item.PK+"} FROM {"jaloSession.getTypeManager().getComposedType(Product.class).getCode()+" AS p }"+ "WHERE ( {p:"+Product.NAME+":o} <> 'tom' OR {p:"+Product.NAME+":o} IS NULL )"; Collections.EMPTY_MAP, Collections.singletonList( Product.class ), true, true, 0, 1 ).getResult(); // now we should have all products inside the list
as seen here a IS NULL check has to be added since even though the property row is outer joined
column <> 'xyz' will fail since the column is in fact NULL.
generally it is advised to avoid such queries whenever possible. trying to set default values is always a far better
solution than searching for absence ( IS NULL ) in properties.
there is a special syntax for subselects too. please note that subselects are not available in case the underlying database doesn't support them!
String productType = jaloSession.getTypeManager().getComoposedType(Product.class).getCode();
String orderEntryType = jaloSession.getTypeManager().getComoposedType(OrderEntry.class).getCode();
String query = "SELECT {" + Item.PK + "} FROM {" + productType + " AS p} WHERE " + " EXISTS ( {{" + "SELECT {" + Item.PK
+ "} FROM {" + orderEntryType + "} WHERE {" + OrderEntry.PRODUCT + "} = {p:" + Item.PK + "} " +
// be sure to have a space between the last '}' and '}}' - this is a know issue right now
"}} )";
subselects may contain all features as normal queries including joins and nested subselects.
the result of a flexible query is always limited to the queried type, which means result items are instances of the
queried type or any of its subtypes. it is possible to select instances of one type exactly by appending a
! to the type code.
String query = "SELECT {PK} FROM {MyType!}";
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated.Special case we do not handle AbstractLegacyRegistrableCacheKey because we need to extend it.protected static classDeprecated.static classDeprecated.Nested classes/interfaces inherited from class de.hybris.platform.jalo.Manager
Manager.GenericManagerSingletonCreator, Manager.ManagerSingletonCreator -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static longDeprecated.static final StringDeprecated.Search option for controlling the result prefetch size.static final StringDeprecated.static final ComparatorDeprecated. -
Constructor Summary
ConstructorsModifierConstructorDescriptionDeprecated.protectedFlexibleSearch(FlexibleSearchExecutor executor) Deprecated.protectedFlexibleSearch(FlexibleSearchExecutor executor, FlexibleSearchHintsProviderFactory hintsProviderFactory) Deprecated.protectedFlexibleSearch(ReadOnlyConditionsHelper readOnlyConditionsHelper) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.voidaddContextQueryFilter(SessionContext ctx, ContextQueryFilter filter) Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.voidaddContextQueryFilters(SessionContext ctx, Collection<ContextQueryFilter> filters) Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.voidDeprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.protected voidcheckBeforeItemRemoval(SessionContext ctx, Item item) Deprecated.Superclass method overridden to avoid call to EJB layercheckQuery(String query, boolean disableRestrictions) Deprecated.since ages - useFlexibleSearchService.translate(de.hybris.platform.servicelayer.search.FlexibleSearchQuery)instead.voidDeprecated.since ages - useSearchRestrictionService.clearSessionSearchRestrictions()instead.voidDeprecated.since ages - useSearchRestrictionService.clearSessionSearchRestrictions()instead.createSavedQuery(String code, ComposedType resultType, String query, Map params) Deprecated.Creates a new saved query upon a given composed type.protected booleanDeprecated.protected booleanDeprecated.protected booleanDeprecated.protected booleanDeprecated.protected booleanDeprecated.protected SearchResultexecuteSearch(TranslatedQuery tQuery, Map values, PK langPK, List<Class<?>> resultClasses, boolean dontNeedTotal, int start, int count, int prefetchSize, Set<PK> prefetchLanguages, boolean doExecuteQuery, List<Hint> hints) Deprecated, for removal: This API element is subject to removal in a future version.protected SearchResultexecuteSearch(TranslatedQuery tQuery, Map values, PK langPK, List<Class<?>> resultClasses, boolean dontNeedTotal, int start, int count, int prefetchSize, Set<PK> prefetchLanguages, boolean doExecuteQuery, List<Hint> hints, DataSource dataSource) Deprecated.static ObjectDeprecated.since 4.8Deprecated.since ages - useSearchRestrictionService.getSessionSearchRestrictions()instead.Deprecated.since ages - useSearchRestrictionService.getSessionSearchRestrictions()instead.protected Collection<ContextQueryFilter>getContextQueryFilters(SessionContext ctx, Collection<ComposedType> types) Deprecated.static FlexibleSearchDeprecated.getQueryFilters(Principal principal, ComposedType type, boolean includeGroups, boolean includeSuperTypes, boolean includeSubtypes) Deprecated.since ages - useSearchRestrictionService.getSessionSearchRestrictions()orSearchRestrictionService.getSearchRestrictions(de.hybris.platform.core.model.security.PrincipalModel, boolean, Collection)orSearchRestrictionService.getSearchRestrictions(de.hybris.platform.core.model.security.PrincipalModel, boolean, Collection)instead.Deprecated.Gets the used query parser which is responsible fpr translating queries and caching them.protected PrincipalDeprecated.getSavedQuery(String code) Deprecated.Finds a saved query by its code.protected PKDeprecated.protected intDeprecated.protected intgetTTL(SessionContext ctx) Deprecated.protected Collection<AbstractQueryFilter>getUserFilters(Principal principal, boolean includeGroups, Collection<ComposedType> types) Deprecated.voidinit()Deprecated.called once for each tenant, so this method fits best to perform some initialization stuffprotected booleanisCachingDisabled(SessionContext localCtx) Deprecated.Deprecated.Checks for the presence ofReadOnlyConditionsHelper.CTX_ENABLE_FS_ON_READ_REPLICAin SessionContext associated with the calling thread, which is the property responsible for enabling read-only datasource.booleanDeprecated.Tells whether or not search restriction evaluation is currently disabled for a specified session context.booleanisTypeRestricted(SessionContext ctx, ComposedType type, boolean includingSubtypes) static booleanDeprecated.protected MapDeprecated.protected voidnotifyItemRemoval(SessionContext ctx, Item item) Deprecated.Superclass method overridden to avoid call to EJB layervoidprocessSearchRows(QueryOptions options, Consumer<Object> rowConsumer) Deprecated.voidDeprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.voidremoveContextQueryFilter(SessionContext ctx, ContextQueryFilter filter) Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.voidremoveContextQueryFilters(SessionContext ctx, Collection<ContextQueryFilter> filters) Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.voidDeprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.search(QueryOptions options) Deprecated.search(SessionContext ctx, String query, List values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, boolean ignoreEmptyProperties, int start, int count, String timeoutCacheKey) Deprecated.since ages - please usesearch(SessionContext, String, Map, List, boolean, boolean, int, int, String)insteadsearch(SessionContext ctx, String query, Map values, Class resultClass) Deprecated.search(SessionContext ctx, String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count) Deprecated.search(SessionContext ctx, String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count, String timeoutCacheKey) Deprecated.since ages - please usesearch(SessionContext, String, Map, List, boolean, boolean, int, int)insteadDeprecated.search(String query, List values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, boolean ignoreEmptyProperties, int start, int count, String timeoutCacheKey) Deprecated.since ages - please usesearch(String, Map, List, boolean, boolean, int, int, String)insteadDeprecated.search(String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count) Deprecated.search(String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count, String timeoutCacheKey) Deprecated.since ages - please usesearch(String, Map, List, boolean, boolean, int, int)insteadvoidsetContextQueryFilters(SessionContext ctx, Collection<ContextQueryFilter> filters) Deprecated.Sets or replaces all dynamic query filters of a specific session context.voidDeprecated.Sets or replaces all dynamic query filters of the current session context.protected TranslatedQuerytranslate(SessionContext ctx, Principal principal, String query, int valueCount, boolean hasLanguage, boolean failOnUnknownFields, boolean disableRestrictions, boolean disableGrouprestrictions, Map values) Deprecated.protected ObjecttranslateObject(SessionContext ctx, Object tmp, String[] qualifiers, int i, String key) Deprecated.protected MaptranslatePathValueKeys(SessionContext ctx, List valueKeys, Map _values) Deprecated.protected SearchResultwrapSearchResult(SearchResult cachedSearchResult) Deprecated.wraps a cache basedSearchResult, return instance which is intended not to share its business internals with others.Deprecated.Methods inherited from class de.hybris.platform.jalo.Manager
afterItemCreation, beforeItemCreation, destroy, extractNonRequiredRemoteFromItem, extractRequiredRemoteFromItem, getAllValuesSessionContext, getAttribute, getAttributeMap, getFirstItemByAttribute, getFirstItemByAttribute, getRemote, getRemoteManagerClass, getSession, getSingletonManagerInstance, getTenant, getTransientObject, getTransientObjectMap, setAttribute, setTenant, setTransientObject, wrap
-
Field Details
-
BEAN_NAME
Deprecated.- See Also:
-
VALUE_COMPARATOR
Deprecated. -
DISABLE_RESTRICTIONS
Deprecated.- See Also:
-
DISABLE_RESTRICTION_GROUP_INHERITANCE
Deprecated.- See Also:
-
DISABLE_SESSION_ATTRIBUTES
Deprecated.- See Also:
-
DISABLE_EXECUTION
Deprecated.- See Also:
-
ENABLE_CACHE_FOR_READ_ONLY_DATA_SOURCE
Deprecated.- See Also:
-
CACHE_TTL
Deprecated.- See Also:
-
CTX_SEARCH_RESTRICTIONS
Deprecated.- See Also:
-
DISABLE_CACHE
Deprecated.- See Also:
-
UNION_ALL_TYPE_HIERARCHY
Deprecated.- See Also:
-
PREFETCH_SIZE
Deprecated.Search option for controlling the result prefetch size. The defaul prefetch size is normally defined within the platform project.properties file paramlazy.pkcollection.prefetchsize.To set a custom prefetch size simply add a PREFETCH_SIZE parameter to the session context passed to the search method.
- See Also:
-
interval
public static long intervalDeprecated.
-
-
Constructor Details
-
FlexibleSearch
public FlexibleSearch()Deprecated. -
FlexibleSearch
Deprecated. -
FlexibleSearch
Deprecated. -
FlexibleSearch
protected FlexibleSearch(FlexibleSearchExecutor executor, FlexibleSearchHintsProviderFactory hintsProviderFactory) Deprecated.
-
-
Method Details
-
getCacheUnit
Deprecated.since 4.8For testing purpose only -
addContextQueryFilter
@Deprecated(since="ages", forRemoval=false) public void addContextQueryFilter(ContextQueryFilter filter) Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.Adds a dynamic query filter to current session context. SeeContextQueryFilterfor details.- Parameters:
filter- the query filter to add
-
addContextQueryFilter
@Deprecated(since="ages", forRemoval=false) public void addContextQueryFilter(SessionContext ctx, ContextQueryFilter filter) Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.Adds a dynamic query filter to specific session context. SeeContextQueryFilterfor details.- Parameters:
ctx- the session context to add tofilter- the filter to add
-
addContextQueryFilters
@Deprecated(since="ages", forRemoval=false) public void addContextQueryFilters(Collection<ContextQueryFilter> filters) Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.Adds dynamic query filters to current session context. SeeContextQueryFilterfor details.- Parameters:
filters- the filters to add
-
addContextQueryFilters
@Deprecated(since="ages", forRemoval=false) public void addContextQueryFilters(SessionContext ctx, Collection<ContextQueryFilter> filters) Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.Adds dynamic query filters to specific session context. SeeContextQueryFilterfor details.- Parameters:
ctx- the context to add tofilters- the filters to add to
-
checkQuery
@Deprecated(since="ages", forRemoval=false) public String checkQuery(String query, boolean disableRestrictions) throws FlexibleSearchException Deprecated.since ages - useFlexibleSearchService.translate(de.hybris.platform.servicelayer.search.FlexibleSearchQuery)instead.tries to translate a query without executing it. after that it is proven that flexible search sections can be replaced successfully - but there is no check if the resulting SQL is accepted by the database.- Parameters:
query- the flexible querydisableRestrictions- if true no restrictions are included even if some exists for the current user and the searched type(s)- Returns:
- the generated SQL code
- Throws:
FlexibleSearchException- in case of a translation error
-
clearContextQueryFilters
Deprecated.since ages - useSearchRestrictionService.clearSessionSearchRestrictions()instead.Removes all dynamic query filters from current session context. SeeContextQueryFilterfor details. -
clearContextQueryFilters
@Deprecated(since="ages", forRemoval=false) public void clearContextQueryFilters(SessionContext ctx) Deprecated.since ages - useSearchRestrictionService.clearSessionSearchRestrictions()instead.Removes all dynamic query filters from specific session context. SeeContextQueryFilterfor details. -
createSavedQuery
public SavedQuery createSavedQuery(String code, ComposedType resultType, String query, Map params) throws FlexibleSearchException Deprecated.Creates a new saved query upon a given composed type. The query is defined as full flexible search with the following restrictions:- the SELECT block must contain a item PK ( e.g.
SELECT {PK} ...) - the FROM block should not contain the resturn type code but
SavedQuery.TYPE_PLACEHOLDERto allow applying the saved query even to subtypes of the specified return type
jaloSession.createSavedQuery( "FindUnnamedProducts", jaloSession.getTypeManager().getComposedType( Product.class ), "SELECT {p:PK} FROM {"+SavedQuery.TYPE_PLACEHOLDER+" AS p} "+ "WHERE {p:name:o} IS NULL" null );- Parameters:
code- the code of the saved queryresultType- the type upon this query can be appliedquery- the query text as full flexible search expressionparams- the value params as map of { qualifier -> Type }- Throws:
FlexibleSearchException- if the query is no valid flexible search query
- the SELECT block must contain a item PK ( e.g.
-
getContextQueryFilters
@Deprecated(since="ages", forRemoval=false) public Collection<ContextQueryFilter> getContextQueryFilters()Deprecated.since ages - useSearchRestrictionService.getSessionSearchRestrictions()instead.Returns all dynamic query filters of the current session context. SeeContextQueryFilterfor details. -
getContextQueryFilters
@Deprecated(since="ages", forRemoval=false) public Collection<ContextQueryFilter> getContextQueryFilters(SessionContext ctx) Deprecated.since ages - useSearchRestrictionService.getSessionSearchRestrictions()instead.Returns all dynamic query filters of a specific session context. SeeContextQueryFilterfor details.- Parameters:
ctx- the session context to check
-
getQueryFilters
@Deprecated(since="ages", forRemoval=false) public Set<AbstractQueryFilter> getQueryFilters(Principal principal, ComposedType type, boolean includeGroups, boolean includeSuperTypes, boolean includeSubtypes) Deprecated.since ages - useSearchRestrictionService.getSessionSearchRestrictions()orSearchRestrictionService.getSearchRestrictions(de.hybris.platform.core.model.security.PrincipalModel, boolean, Collection)orSearchRestrictionService.getSearchRestrictions(de.hybris.platform.core.model.security.PrincipalModel, boolean, Collection)instead. -
getQueryParser
Deprecated.Gets the used query parser which is responsible fpr translating queries and caching them.- Returns:
- used query parser
- Since:
- 3.1-u4
-
getSavedQuery
Deprecated.Finds a saved query by its code. If multiple queries exist with this code the one which was created first is chosen. NOTE: this method returns NULL if no Query was found.- Returns:
- the saved query.
- Since:
- 1.31
-
init
public void init()Deprecated.Description copied from class:Managercalled once for each tenant, so this method fits best to perform some initialization stuff -
isRestrictionEvaluationDisabled
Deprecated.Tells whether or not search restriction evaluation is currently disabled for a specified session context. -
isTypeRestricted
@Deprecated(since="ages", forRemoval=false) public boolean isTypeRestricted(SessionContext ctx, ComposedType type, boolean includingSubtypes) Deprecated.Tells whether or not the given type has got active search restrictions within the specified session context. This method does not check whether or not restriction evaluation has been disabled - useisRestrictionEvaluationDisabled(SessionContext)for that!- Parameters:
ctx- the session context to search for restrictions withintype- the type to check restrictions forincludingSubtypes- iftruethis method also returnstrueif any of the type's sub types has got active restrictions
-
removeContextQueryFilter
@Deprecated(since="ages", forRemoval=false) public void removeContextQueryFilter(ContextQueryFilter filter) Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.Removes a dynamic query filter from the current session context. SeeContextQueryFilterfor details.- Parameters:
filter- the filter to remove
-
removeContextQueryFilter
@Deprecated(since="ages", forRemoval=false) public void removeContextQueryFilter(SessionContext ctx, ContextQueryFilter filter) Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.Removes a dynamic query filter from specific session context. SeeContextQueryFilterfor details.- Parameters:
ctx- the context to remove fromfilter- the filter to remove
-
removeContextQueryFilters
@Deprecated(since="ages", forRemoval=false) public void removeContextQueryFilters(Collection<ContextQueryFilter> filters) Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.Removes dynamic query filters from the current session context. SeeContextQueryFilterfor details.- Parameters:
filters- the filters to remove
-
removeContextQueryFilters
@Deprecated(since="ages", forRemoval=false) public void removeContextQueryFilters(SessionContext ctx, Collection<ContextQueryFilter> filters) Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.Removes dynamic query filters from specific session context. SeeContextQueryFilterfor details.- Parameters:
ctx- the context to remove fromfilters- the filter to remove
-
search
@Deprecated(since="ages", forRemoval=false) public SearchResult search(SessionContext ctx, String query, List values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, boolean ignoreEmptyProperties, int start, int count, String timeoutCacheKey) throws FlexibleSearchException Deprecated.since ages - please usesearch(SessionContext, String, Map, List, boolean, boolean, int, int, String)instead- Parameters:
ctx- the session contextquery- the whole queryvalues- the value map according to all ?<key>resultClasses- a list with the expected result types of this query's result rowsfailOnUnknownFields- causes an error when using an unknown field namedontNeedTotal- optimzed query procesing for large results with small ranges selectedignoreEmptyProperties-start- the start number of the search rangecount- the number of elements in this search rangetimeoutCacheKey-- Returns:
- the search result
- Throws:
FlexibleSearchException
-
search
public SearchResult search(SessionContext ctx, String query, Map values, Class resultClass) throws FlexibleSearchException Deprecated.- Parameters:
ctx- the session context defining which language is used for localized fieldsquery- the whole queryvalues- the value map according to all ?<key>resultClass- a list with the expected result types of this query's result rows- Returns:
- the search result
- Throws:
FlexibleSearchException- in case of a search error
-
search
public SearchResult search(SessionContext ctx, String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count) throws FlexibleSearchException Deprecated.- Parameters:
ctx- the session context defining which language is used for localized fieldsquery- the whole queryvalues- the value map according to all ?<key>resultClasses- a list with the expected result types of this query's result rowsfailOnUnknownFields- causes an error when using an unknown field namedontNeedTotal- optimized query processing for large results with small ranges selectedstart- the start number of the search rangecount- the number of elements in this search range- Returns:
- the search result
- Throws:
FlexibleSearchException- in case of a search error
-
search
Deprecated. -
processSearchRows
Deprecated. -
isReadOnlyDataSourceEnabled
Deprecated.Checks for the presence ofReadOnlyConditionsHelper.CTX_ENABLE_FS_ON_READ_REPLICAin SessionContext associated with the calling thread, which is the property responsible for enabling read-only datasource.- Parameters:
ctx- the session context- Returns:
Optional.of(true)if the session has the attribute set totrue(or string equivalent);Optional.of(false)if the session has the attribute set tofalse(or string equivalent);Optional.empty()if there is no attribute defined in the session or it cannot be parsed to boolean
-
isCachingDisabled
Deprecated. -
isUnionAllForTypeHierarchyEnabled
public static boolean isUnionAllForTypeHierarchyEnabled()Deprecated. -
wrapSearchResult
Deprecated.wraps a cache basedSearchResult, return instance which is intended not to share its business internals with others.- Throws:
Exception
-
search
@Deprecated(since="ages", forRemoval=false) public SearchResult search(SessionContext ctx, String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count, String timeoutCacheKey) throws FlexibleSearchException Deprecated.since ages - please usesearch(SessionContext, String, Map, List, boolean, boolean, int, int)instead- Parameters:
ctx- the search contextquery- the whole queryvalues- the value map according to all ?<key>resultClasses- a list with the expected result types of this query's result rowsfailOnUnknownFields- causes an error when using an unknown field namedontNeedTotal- optimzed query procesing for large results with small ranges selectedstart- the start number of the search rangecount- the number of elements in this search rangetimeoutCacheKey-- Returns:
- the search result
- Throws:
FlexibleSearchException- in case of a search error
-
search
Deprecated.- Parameters:
query- the whole queryresultClass- a list with the expected result types of this query's result rows- Returns:
- the search result
- Throws:
FlexibleSearchException- in case of a search error
-
search
@Deprecated(since="ages", forRemoval=false) public SearchResult search(String query, List values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, boolean ignoreEmptyProperties, int start, int count, String timeoutCacheKey) throws FlexibleSearchException Deprecated.since ages - please usesearch(String, Map, List, boolean, boolean, int, int, String)instead- Parameters:
query- the whole queryvalues- the value map according to all ?<key>resultClasses- a list with the expected result types of this query's result rowsfailOnUnknownFields- causes an error when using an unknown field namedontNeedTotal- optimzed query procesing for large results with small ranges selectedignoreEmptyProperties-start- the start number of the search rangecount- the number of elements in this search rangetimeoutCacheKey-- Returns:
- the search result
- Throws:
FlexibleSearchException
-
search
public SearchResult search(String query, Map values, Class resultClass) throws FlexibleSearchException Deprecated.- Parameters:
query- the whole queryvalues- the value map according to all ?<key>resultClass- a list with the expected result types of this query's result rows- Returns:
- the search result
- Throws:
FlexibleSearchException- in case of a search error
-
search
public SearchResult search(String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count) throws FlexibleSearchException Deprecated.- Parameters:
query- the whole queryvalues- the value map according to all ?<key>resultClasses- a list with the expected result types of this query's result rowsfailOnUnknownFields- causes an error when using an unknown field namedontNeedTotal- optimzed query procesing for large results with small ranges selectedstart- the start number of the search rangecount- the number of elements in this search range- Returns:
- the search result
- Throws:
FlexibleSearchException- in case of a search error
-
search
@Deprecated(since="ages", forRemoval=false) public SearchResult search(String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count, String timeoutCacheKey) throws FlexibleSearchException Deprecated.since ages - please usesearch(String, Map, List, boolean, boolean, int, int)instead- Parameters:
query- the whole queryvalues- the value map according to all ?<key>resultClasses- a list with the expected result types of this query's result rowsfailOnUnknownFields- causes an error when using an unknown field namedontNeedTotal- optimzed query procesing for large results with small ranges selectedstart- the start number of the search rangecount- the number of elements in this search rangetimeoutCacheKey-- Returns:
- the search result
- Throws:
FlexibleSearchException- in case of a search error
-
setContextQueryFilters
Deprecated.Sets or replaces all dynamic query filters of the current session context. SeeContextQueryFilterfor details.- Parameters:
filters- the new filters to set
-
setContextQueryFilters
Deprecated.Sets or replaces all dynamic query filters of a specific session context. SeeContextQueryFilterfor details.- Parameters:
ctx- the context to set filters atfilters- the filters to set
-
writeReplace
Deprecated.- Specified by:
writeReplacein classManager- Throws:
ObjectStreamException
-
checkBeforeItemRemoval
protected void checkBeforeItemRemoval(SessionContext ctx, Item item) throws ConsistencyCheckException Deprecated.Superclass method overridden to avoid call to EJB layer- Overrides:
checkBeforeItemRemovalin classManager- Parameters:
ctx- the current session contextitem- the item which should be removed- Throws:
ConsistencyCheckException- thrown to abort removal due to consistency errors- Since:
- 2.10
-
disableExecution
Deprecated. -
enableExecution
Deprecated. -
disablePrincipalGroupRestrictions
Deprecated. -
disableRestrictions
@Deprecated(since="ages", forRemoval=false) protected boolean disableRestrictions(SessionContext ctx) Deprecated. -
disableSessionAttributes
Deprecated. -
executeSearch
protected SearchResult executeSearch(TranslatedQuery tQuery, Map values, PK langPK, List<Class<?>> resultClasses, boolean dontNeedTotal, int start, int count, int prefetchSize, Set<PK> prefetchLanguages, boolean doExecuteQuery, List<Hint> hints, DataSource dataSource) throws FlexibleSearchException Deprecated.- Throws:
FlexibleSearchException
-
executeSearch
@Deprecated(since="2105", forRemoval=true) protected SearchResult executeSearch(TranslatedQuery tQuery, Map values, PK langPK, List<Class<?>> resultClasses, boolean dontNeedTotal, int start, int count, int prefetchSize, Set<PK> prefetchLanguages, boolean doExecuteQuery, List<Hint> hints) throws FlexibleSearchException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
FlexibleSearchException
-
getContextQueryFilters
@Deprecated(since="ages", forRemoval=false) protected Collection<ContextQueryFilter> getContextQueryFilters(SessionContext ctx, Collection<ComposedType> types) Deprecated. -
getRestrictionPrincipal
Deprecated. -
getSearchLangPK
Deprecated. -
getSearchPrefetchSize
Deprecated. -
getTTL
Deprecated. -
getUserFilters
protected Collection<AbstractQueryFilter> getUserFilters(Principal principal, boolean includeGroups, Collection<ComposedType> types) Deprecated. -
listToMap
Deprecated. -
notifyItemRemoval
Deprecated.Superclass method overridden to avoid call to EJB layer- Overrides:
notifyItemRemovalin classManager- Parameters:
ctx- the currency session contextitem- the item which is going to be removed- Since:
- 2.10
-
translate
protected TranslatedQuery translate(SessionContext ctx, Principal principal, String query, int valueCount, boolean hasLanguage, boolean failOnUnknownFields, boolean disableRestrictions, boolean disableGrouprestrictions, Map values) throws FlexibleSearchException Deprecated.- Throws:
FlexibleSearchException
-
translateObject
protected Object translateObject(SessionContext ctx, Object tmp, String[] qualifiers, int i, String key) Deprecated. -
translatePathValueKeys
Deprecated. -
getInstance
Deprecated.- Returns:
- instance of this manager
-
FlexibleSearchServiceandSearchRestrictionServiceinstead.