Class DefaultPaginatedGenericDao<M extends ItemModel>
java.lang.Object
de.hybris.platform.servicelayer.search.paginated.dao.impl.DefaultPaginatedGenericDao<M>
- All Implemented Interfaces:
PaginatedGenericDao<M>
public class DefaultPaginatedGenericDao<M extends ItemModel>
extends Object
implements PaginatedGenericDao<M>
Default implementation of
PaginatedGenericDao-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPaginatedGenericDao(String typeCode) SetstypeCodewhere thisDefaultPaginatedGenericDaowill search from. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendWhereClausesToBuilder(StringBuilder builder, Map<String, ?> params) Appends "WHERE" clause to the given builder with given params if it is not empty, otherwise do nothingprotected FlexibleSearchQuerycreateFlexibleSearchQuery(Map<String, ?> params) CreatesFlexibleSearchQueryfor thetypeCodeand append "WHERE" clause with params, if given params is not empty.protected StringBuilderCreates a search query for thetypeCodewhich is set from constructorfind(SearchPageData<M> searchPageData) Search for all instances of model given as a generic type using given sorts inSearchPageDatato sort the results and return paginated results by specified pagination inSearchPageData.find(Map<String, ?> params, SearchPageData searchPageData) Search for all instances of model given as a generic type matching givenFlexibleSearchQueryparameters.protected PaginatedFlexibleSearchServicegetSortCodeToQueryAlias(SearchPageData searchPageData) Creates a map between sortCode to query alias which is required fromPaginatedFlexibleSearchServiceto append "ORDER BY" clause.voidsetPaginatedFlexibleSearchService(PaginatedFlexibleSearchService paginatedFlexibleSearchService)
-
Constructor Details
-
DefaultPaginatedGenericDao
SetstypeCodewhere thisDefaultPaginatedGenericDaowill search from. This constructor is an essential part of this Dao because it creates a query string based on thetypeCode.- Parameters:
typeCode- the typeCode where this Dao will search from.
-
-
Method Details
-
find
Description copied from interface:PaginatedGenericDaoSearch for all instances of model given as a generic type using given sorts inSearchPageDatato sort the results and return paginated results by specified pagination inSearchPageData.- Specified by:
findin interfacePaginatedGenericDao<M extends ItemModel>- Parameters:
searchPageData- the searchPageData including sorts and pagination information to be applied in the results- Returns:
SearchPageDatacontaining paginated and sorted search results
-
find
Description copied from interface:PaginatedGenericDaoSearch for all instances of model given as a generic type matching givenFlexibleSearchQueryparameters.- Specified by:
findin interfacePaginatedGenericDao<M extends ItemModel>- Parameters:
params- parameters to be added in search query's "WHERE" clause asMapwith parameter name as a key and parameter value as a value.searchPageData- the searchPageData including sorts and pagination information to be applied in the results- Returns:
SearchPageDatacontaining paginated and sorted search results
-
createFlexibleSearchQuery
CreatesFlexibleSearchQueryfor thetypeCodeand append "WHERE" clause with params, if given params is not empty.- Parameters:
params- the map containingFlexibleSearchQueryparameters- Returns:
FlexibleSearchQuerywith query and queryParameters added if given params is not empty
-
createQueryString
Creates a search query for thetypeCodewhich is set from constructor- Returns:
StringBuilderwith basic search query for thetypeCode
-
appendWhereClausesToBuilder
Appends "WHERE" clause to the given builder with given params if it is not empty, otherwise do nothing- Parameters:
builder- the query builder containing "SELECT ... FROM ..." portion of queryparams- the map containingFlexibleSearchQueryparameters
-
getSortCodeToQueryAlias
Creates a map between sortCode to query alias which is required fromPaginatedFlexibleSearchServiceto append "ORDER BY" clause. Because DefaultPaginatedGenericDao implementation will query from a singletypeCode, all the sortCode will be mapped to the predefinedQUERY_ALIASWhile creating
sortCodeToQueryAliasmap, it uses lower case of sortData's code to meet the expectation ofSortDataParsingStrategy- Parameters:
searchPageData- the searchPageData containing requested pagination and sorting information- Returns:
- Map<String,String> containing sortCodeToQueryAlias
- See Also:
-
PaginatedFlexibleSearchParameter.sortCodeToQueryAliasSortDataParsingStrategy
-
getPaginatedFlexibleSearchService
-
setPaginatedFlexibleSearchService
public void setPaginatedFlexibleSearchService(PaginatedFlexibleSearchService paginatedFlexibleSearchService)
-