Class FlexibleSearch
- java.lang.Object
-
- de.hybris.platform.jalo.Manager
-
- de.hybris.platform.jalo.flexiblesearch.FlexibleSearch
-
- All Implemented Interfaces:
ItemLifecycleListener,java.io.Serializable
@Deprecated public class FlexibleSearch extends Manager
Deprecated.since ages - useFlexibleSearchServiceandSearchRestrictionServiceinstead.The FlexibleSearch is an SQL-based search on item types which allows to search on attribute values as well as directly on database columns. Unlike SQL statements, a FlexibleSearch query can contain references to items in the hybris Platform (products, units, customers, and so on) as parts of the query statement (marked by { and }). Therefore, a FlexibleSearch query is first interpreted (resolving the references) and then executed. During the interpretation phase, the FlexibleSearch framework resolves those references and replaces them with the actual names of columns and tables. This phase also does automatic joins of property tables where necessary.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 forlocAttrand langEN forlocAttr2. 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 areSessionContext.USER,SessionContext.LANGUAGEandSessionContext.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 languagethe solution here is the
oattribute 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:as seen here a
IS NULLcheck has to be added since even though the property row is outer joinedcolumn <> '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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFlexibleSearch.FlexibleSearchCacheKeyDeprecated.Special case we do not handle AbstractLegacyRegistrableCacheKey because we need to extend it.protected static classFlexibleSearch.FlexibleSearchSerializableDTODeprecated.-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.Manager
Manager.GenericManagerSingletonCreator, Manager.ManagerSingletonCreator
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBEAN_NAMEDeprecated.static java.lang.StringCACHE_TTLDeprecated.static java.lang.StringCTX_SEARCH_RESTRICTIONSDeprecated.static java.lang.StringDISABLE_CACHEDeprecated.static java.lang.StringDISABLE_EXECUTIONDeprecated.static java.lang.StringDISABLE_RESTRICTION_GROUP_INHERITANCEDeprecated.static java.lang.StringDISABLE_RESTRICTIONSDeprecated.static java.lang.StringDISABLE_SESSION_ATTRIBUTESDeprecated.static longintervalDeprecated.static java.lang.StringPREFETCH_SIZEDeprecated.Search option for controlling the result prefetch size.static java.lang.StringUNION_ALL_TYPE_HIERARCHYDeprecated.static java.util.ComparatorVALUE_COMPARATORDeprecated.
-
Constructor Summary
Constructors Modifier Constructor Description FlexibleSearch()Deprecated.protectedFlexibleSearch(FlexibleSearchExecutor executor)Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddContextQueryFilter(ContextQueryFilter filter)Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.voidaddContextQueryFilter(SessionContext ctx, ContextQueryFilter filter)Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.voidaddContextQueryFilters(SessionContext ctx, java.util.Collection<ContextQueryFilter> filters)Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.voidaddContextQueryFilters(java.util.Collection<ContextQueryFilter> filters)Deprecated.since ages - useSearchRestrictionService.addSessionSearchRestrictions(Collection)instead.protected voidcheckBeforeItemRemoval(SessionContext ctx, Item item)Deprecated.Superclass method overridden to avoid call to EJB layerjava.lang.StringcheckQuery(java.lang.String query, boolean disableRestrictions)Deprecated.since ages - useFlexibleSearchService.translate(de.hybris.platform.servicelayer.search.FlexibleSearchQuery)instead.voidclearContextQueryFilters()Deprecated.since ages - useSearchRestrictionService.clearSessionSearchRestrictions()instead.voidclearContextQueryFilters(SessionContext ctx)Deprecated.since ages - useSearchRestrictionService.clearSessionSearchRestrictions()instead.SavedQuerycreateSavedQuery(java.lang.String code, ComposedType resultType, java.lang.String query, java.util.Map params)Deprecated.Creates a new saved query upon a given composed type.protected booleandisableExecution(SessionContext ctx)Deprecated.protected booleandisablePrincipalGroupRestrictions(SessionContext ctx)Deprecated.protected booleandisableRestrictions(SessionContext ctx)Deprecated.protected booleandisableSessionAttributes(SessionContext ctx)Deprecated.protected booleanenableExecution(SessionContext ctx)Deprecated.protected SearchResultexecuteSearch(TranslatedQuery tQuery, java.util.Map values, PK langPK, java.util.List<java.lang.Class<?>> resultClasses, boolean dontNeedTotal, int start, int count, int prefetchSize, java.util.Set<PK> prefetchLanguages, boolean doExecuteQuery, java.util.List<Hint> hints)Deprecated.static java.lang.ObjectgetCacheUnit()Deprecated.since 4.8java.util.Collection<ContextQueryFilter>getContextQueryFilters()Deprecated.since ages - useSearchRestrictionService.getSessionSearchRestrictions()instead.java.util.Collection<ContextQueryFilter>getContextQueryFilters(SessionContext ctx)Deprecated.since ages - useSearchRestrictionService.getSessionSearchRestrictions()instead.protected java.util.Collection<ContextQueryFilter>getContextQueryFilters(SessionContext ctx, java.util.Collection<ComposedType> types)Deprecated.static FlexibleSearchgetInstance()Deprecated.java.util.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.QueryParsergetQueryParser()Deprecated.Gets the used query parser which is responsible fpr translating queries and caching them.protected PrincipalgetRestrictionPrincipal(SessionContext ctx)Deprecated.SavedQuerygetSavedQuery(java.lang.String code)Deprecated.Finds a saved query by its code.protected PKgetSearchLangPK(SessionContext ctx)Deprecated.protected intgetSearchPrefetchSize(SessionContext ctx)Deprecated.protected intgetTTL(SessionContext ctx)Deprecated.protected java.util.Collection<AbstractQueryFilter>getUserFilters(Principal principal, boolean includeGroups, java.util.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.booleanisRestrictionEvaluationDisabled(SessionContext ctx)Deprecated.Tells whether or not search restriction evaluation is currently disabled for a specified session context.booleanisTypeRestricted(SessionContext ctx, ComposedType type, boolean includingSubtypes)static booleanisUnionAllForTypeHierarchyEnabled()Deprecated.protected java.util.MaplistToMap(java.util.List list)Deprecated.protected voidnotifyItemRemoval(SessionContext ctx, Item item)Deprecated.Superclass method overridden to avoid call to EJB layervoidremoveContextQueryFilter(ContextQueryFilter filter)Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.voidremoveContextQueryFilter(SessionContext ctx, ContextQueryFilter filter)Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.voidremoveContextQueryFilters(SessionContext ctx, java.util.Collection<ContextQueryFilter> filters)Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.voidremoveContextQueryFilters(java.util.Collection<ContextQueryFilter> filters)Deprecated.since ages - useSearchRestrictionService.removeSessionSearchRestrictions(Collection)instead.SearchResultsearch(QueryOptions options)Deprecated.SearchResultsearch(SessionContext ctx, java.lang.String query, java.util.List values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, boolean ignoreEmptyProperties, int start, int count, java.lang.String timeoutCacheKey)Deprecated.since ages - please usesearch(SessionContext, String, Map, List, boolean, boolean, int, int, String)insteadSearchResultsearch(SessionContext ctx, java.lang.String query, java.util.Map values, java.lang.Class resultClass)Deprecated.SearchResultsearch(SessionContext ctx, java.lang.String query, java.util.Map values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count)Deprecated.SearchResultsearch(SessionContext ctx, java.lang.String query, java.util.Map values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count, java.lang.String timeoutCacheKey)Deprecated.since ages - please usesearch(SessionContext, String, Map, List, boolean, boolean, int, int)insteadSearchResultsearch(java.lang.String query, java.lang.Class resultClass)Deprecated.SearchResultsearch(java.lang.String query, java.util.List values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, boolean ignoreEmptyProperties, int start, int count, java.lang.String timeoutCacheKey)Deprecated.since ages - please usesearch(String, Map, List, boolean, boolean, int, int, String)insteadSearchResultsearch(java.lang.String query, java.util.Map values, java.lang.Class resultClass)Deprecated.SearchResultsearch(java.lang.String query, java.util.Map values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count)Deprecated.SearchResultsearch(java.lang.String query, java.util.Map values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count, java.lang.String timeoutCacheKey)Deprecated.since ages - please usesearch(String, Map, List, boolean, boolean, int, int)insteadvoidsetContextQueryFilters(SessionContext ctx, java.util.Collection<ContextQueryFilter> filters)Deprecated.Sets or replaces all dynamic query filters of a specific session context.voidsetContextQueryFilters(java.util.Collection<ContextQueryFilter> filters)Deprecated.Sets or replaces all dynamic query filters of the current session context.protected TranslatedQuerytranslate(SessionContext ctx, Principal principal, java.lang.String query, int valueCount, boolean hasLanguage, boolean failOnUnknownFields, boolean disableRestrictions, boolean disableGrouprestrictions, java.util.Map values)Deprecated.protected java.lang.ObjecttranslateObject(SessionContext ctx, java.lang.Object tmp, java.lang.String[] qualifiers, int i, java.lang.String key)Deprecated.protected java.util.MaptranslatePathValueKeys(SessionContext ctx, java.util.List valueKeys, java.util.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.java.lang.ObjectwriteReplace()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 Detail
-
BEAN_NAME
public static final java.lang.String BEAN_NAME
Deprecated.- See Also:
- Constant Field Values
-
VALUE_COMPARATOR
public static final java.util.Comparator VALUE_COMPARATOR
Deprecated.
-
DISABLE_RESTRICTIONS
public static final java.lang.String DISABLE_RESTRICTIONS
Deprecated.- See Also:
- Constant Field Values
-
DISABLE_RESTRICTION_GROUP_INHERITANCE
public static final java.lang.String DISABLE_RESTRICTION_GROUP_INHERITANCE
Deprecated.- See Also:
- Constant Field Values
-
DISABLE_SESSION_ATTRIBUTES
public static final java.lang.String DISABLE_SESSION_ATTRIBUTES
Deprecated.- See Also:
- Constant Field Values
-
DISABLE_EXECUTION
public static final java.lang.String DISABLE_EXECUTION
Deprecated.- See Also:
- Constant Field Values
-
CACHE_TTL
public static final java.lang.String CACHE_TTL
Deprecated.- See Also:
- Constant Field Values
-
CTX_SEARCH_RESTRICTIONS
public static final java.lang.String CTX_SEARCH_RESTRICTIONS
Deprecated.- See Also:
- Constant Field Values
-
DISABLE_CACHE
public static final java.lang.String DISABLE_CACHE
Deprecated.- See Also:
- Constant Field Values
-
UNION_ALL_TYPE_HIERARCHY
public static final java.lang.String UNION_ALL_TYPE_HIERARCHY
Deprecated.- See Also:
- Constant Field Values
-
PREFETCH_SIZE
public static final java.lang.String 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:
- Constant Field Values
-
interval
public static long interval
Deprecated.
-
-
Constructor Detail
-
FlexibleSearch
public FlexibleSearch()
Deprecated.
-
FlexibleSearch
protected FlexibleSearch(FlexibleSearchExecutor executor)
Deprecated.
-
-
Method Detail
-
getCacheUnit
@Deprecated public static java.lang.Object getCacheUnit()
Deprecated.since 4.8For testing purpose only
-
addContextQueryFilter
@Deprecated 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 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 public void addContextQueryFilters(java.util.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 public void addContextQueryFilters(SessionContext ctx, java.util.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 public java.lang.String checkQuery(java.lang.String query, boolean disableRestrictions) throws FlexibleSearchExceptionDeprecated.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 public void clearContextQueryFilters()
Deprecated.since ages - useSearchRestrictionService.clearSessionSearchRestrictions()instead.Removes all dynamic query filters from current session context. SeeContextQueryFilterfor details.
-
clearContextQueryFilters
@Deprecated 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(java.lang.String code, ComposedType resultType, java.lang.String query, java.util.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 public java.util.Collection<ContextQueryFilter> getContextQueryFilters()
Deprecated.since ages - useSearchRestrictionService.getSessionSearchRestrictions()instead.Returns all dynamic query filters of the current session context. SeeContextQueryFilterfor details.
-
getContextQueryFilters
@Deprecated public java.util.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 public java.util.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
public QueryParser 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
public SavedQuery getSavedQuery(java.lang.String code)
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
public boolean isRestrictionEvaluationDisabled(SessionContext ctx)
Deprecated.Tells whether or not search restriction evaluation is currently disabled for a specified session context.
-
isTypeRestricted
@Deprecated 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 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 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 public void removeContextQueryFilters(java.util.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 public void removeContextQueryFilters(SessionContext ctx, java.util.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 public SearchResult search(SessionContext ctx, java.lang.String query, java.util.List values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, boolean ignoreEmptyProperties, int start, int count, java.lang.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, java.lang.String query, java.util.Map values, java.lang.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, java.lang.String query, java.util.Map values, java.util.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
public SearchResult search(QueryOptions options)
Deprecated.
-
isCachingDisabled
protected boolean isCachingDisabled(SessionContext localCtx)
Deprecated.
-
isUnionAllForTypeHierarchyEnabled
public static boolean isUnionAllForTypeHierarchyEnabled()
Deprecated.
-
wrapSearchResult
protected SearchResult wrapSearchResult(SearchResult cachedSearchResult) throws java.lang.Exception
Deprecated.wraps a cache basedSearchResult, return instance which is intended not to share its business internals with others.- Throws:
java.lang.Exception
-
search
@Deprecated public SearchResult search(SessionContext ctx, java.lang.String query, java.util.Map values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count, java.lang.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
public SearchResult search(java.lang.String query, java.lang.Class resultClass) throws FlexibleSearchException
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 public SearchResult search(java.lang.String query, java.util.List values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, boolean ignoreEmptyProperties, int start, int count, java.lang.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(java.lang.String query, java.util.Map values, java.lang.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(java.lang.String query, java.util.Map values, java.util.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 public SearchResult search(java.lang.String query, java.util.Map values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count, java.lang.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
public void setContextQueryFilters(java.util.Collection<ContextQueryFilter> filters)
Deprecated.Sets or replaces all dynamic query filters of the current session context. SeeContextQueryFilterfor details.- Parameters:
filters- the new filters to set
-
setContextQueryFilters
public void setContextQueryFilters(SessionContext ctx, java.util.Collection<ContextQueryFilter> filters)
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
public java.lang.Object writeReplace() throws java.io.ObjectStreamExceptionDeprecated.- Specified by:
writeReplacein classManager- Throws:
java.io.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
protected boolean disableExecution(SessionContext ctx)
Deprecated.
-
enableExecution
protected boolean enableExecution(SessionContext ctx)
Deprecated.
-
disablePrincipalGroupRestrictions
protected boolean disablePrincipalGroupRestrictions(SessionContext ctx)
Deprecated.
-
disableRestrictions
@Deprecated protected boolean disableRestrictions(SessionContext ctx)
Deprecated.
-
disableSessionAttributes
protected boolean disableSessionAttributes(SessionContext ctx)
Deprecated.
-
executeSearch
protected SearchResult executeSearch(TranslatedQuery tQuery, java.util.Map values, PK langPK, java.util.List<java.lang.Class<?>> resultClasses, boolean dontNeedTotal, int start, int count, int prefetchSize, java.util.Set<PK> prefetchLanguages, boolean doExecuteQuery, java.util.List<Hint> hints) throws FlexibleSearchException
Deprecated.- Throws:
FlexibleSearchException
-
getContextQueryFilters
@Deprecated protected java.util.Collection<ContextQueryFilter> getContextQueryFilters(SessionContext ctx, java.util.Collection<ComposedType> types)
Deprecated.
-
getRestrictionPrincipal
protected Principal getRestrictionPrincipal(SessionContext ctx)
Deprecated.
-
getSearchLangPK
protected PK getSearchLangPK(SessionContext ctx)
Deprecated.
-
getSearchPrefetchSize
protected int getSearchPrefetchSize(SessionContext ctx)
Deprecated.
-
getTTL
protected int getTTL(SessionContext ctx)
Deprecated.
-
getUserFilters
protected java.util.Collection<AbstractQueryFilter> getUserFilters(Principal principal, boolean includeGroups, java.util.Collection<ComposedType> types)
Deprecated.
-
listToMap
protected java.util.Map listToMap(java.util.List list)
Deprecated.
-
notifyItemRemoval
protected void notifyItemRemoval(SessionContext ctx, Item item)
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, java.lang.String query, int valueCount, boolean hasLanguage, boolean failOnUnknownFields, boolean disableRestrictions, boolean disableGrouprestrictions, java.util.Map values) throws FlexibleSearchException
Deprecated.- Throws:
FlexibleSearchException
-
translateObject
protected java.lang.Object translateObject(SessionContext ctx, java.lang.Object tmp, java.lang.String[] qualifiers, int i, java.lang.String key)
Deprecated.
-
translatePathValueKeys
protected java.util.Map translatePathValueKeys(SessionContext ctx, java.util.List valueKeys, java.util.Map _values)
Deprecated.
-
getInstance
public static FlexibleSearch getInstance()
Deprecated.- Returns:
- instance of this manager
-
-