Class DefaultSearchRestrictionService
- java.lang.Object
-
- de.hybris.platform.search.restriction.impl.DefaultSearchRestrictionService
-
- All Implemented Interfaces:
SearchRestrictionService
public class DefaultSearchRestrictionService extends java.lang.Object implements SearchRestrictionService
Default implementation ofSearchRestrictionService
interface.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CTX_SEARCH_RESTRICTIONS
static java.lang.String
DISABLE_RESTRICTIONS
-
Constructor Summary
Constructors Constructor Description DefaultSearchRestrictionService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSessionSearchRestrictions(SessionSearchRestriction... restrictions)
Adds session search restrictions to current session context.void
addSessionSearchRestrictions(java.util.Collection<SessionSearchRestriction> restrictions)
Adds session search restrictions to current session context.void
clearSessionSearchRestrictions()
Clear session search restrictions in current session context.void
disableSearchRestrictions()
Disable search restrictions in current session context.void
enableSearchRestrictions()
Enable search restrictions in current session context.java.util.Collection<SearchRestrictionModel>
getActiveSearchRestrictions(PrincipalModel principal, boolean includePrincipalGroups, java.util.Collection<ComposedTypeModel> types)
Gets only active search restrictions for givenComposedTypeModel
.java.util.Collection<SearchRestrictionModel>
getInactiveSearchRestrictions(PrincipalModel principal, boolean includePrincipalGroups, java.util.Collection<ComposedTypeModel> types)
Gets only inactive search restrictions for givenComposedTypeModel
.java.util.Collection<SearchRestrictionModel>
getSearchRestrictions(PrincipalModel principal, boolean includePrincipalGroups, java.util.Collection<ComposedTypeModel> types)
Gets all (active and inactive) search restrictions for givenComposedTypeModel
.java.util.Collection<SearchRestrictionModel>
getSearchRestrictionsForType(ComposedTypeModel type)
Gets all search restrictions for type.java.util.Collection<SessionSearchRestriction>
getSessionSearchRestrictions()
Gets the session search restrictions from current session context.java.util.Collection<SessionSearchRestriction>
getSessionSearchRestrictions(ComposedTypeModel type)
Gets the session search restrictions from current session context for particularComposedTypeModel
object.boolean
hasRestrictions(PrincipalModel principal, boolean includePrincipalGroups, ComposedTypeModel type)
Checks whether type has search restrictions (session and persisted).boolean
isSearchRestrictionsEnabled()
Checks if search restrictions feature in current session context is enabled.void
removalAllSessionSearchRestrictions()
Removes all session-scoped search restrictions from the current session.void
removeSessionSearchRestrictions(java.util.Collection<SessionSearchRestriction> restrictions)
Remove session search restrictions from current session context.void
setConverter(SessionSearchRestrictionConverter converter)
void
setSearchRestrictionDao(SearchRestrictionDao searchRestrictionDao)
void
setSessionService(SessionService sessionService)
-
-
-
Field Detail
-
CTX_SEARCH_RESTRICTIONS
public static final java.lang.String CTX_SEARCH_RESTRICTIONS
- See Also:
- Constant Field Values
-
DISABLE_RESTRICTIONS
public static final java.lang.String DISABLE_RESTRICTIONS
- See Also:
- Constant Field Values
-
-
Method Detail
-
addSessionSearchRestrictions
public void addSessionSearchRestrictions(java.util.Collection<SessionSearchRestriction> restrictions)
Adds session search restrictions to current session context. If currently there are some session search restrictions, passed as parameter collection of restrictions will be added to current one.
Example usage:
final ComposedTypeModel restrictedType = typeService.getComposedTypeForClass(LanguageModel.class); final SessionSearchRestriction restriction = new SessionSearchRestriction("someUniqueCode", "{active} IS TRUE", restrictedType); final Collection<SessionSearchRestriction> restrictions = new ArrayList<SessionSearchRestriction>(); restrictions.add(restriction); searchRestrictionService.addSessionSearchRestrictions(restrictions);
- Specified by:
addSessionSearchRestrictions
in interfaceSearchRestrictionService
- Parameters:
restrictions
- the restrictions collection to add to session.
-
addSessionSearchRestrictions
public void addSessionSearchRestrictions(SessionSearchRestriction... restrictions)
Adds session search restrictions to current session context. If currently there are some session search restrictions, passed as parameter restriction(s) will be added to current one.
Example usage:
final ComposedTypeModel restrictedType = typeService.getComposedTypeForClass(LanguageModel.class); final SessionSearchRestriction restriction1 = new SessionSearchRestriction("someUniqueCode1", "{active} IS TRUE", restrictedType); final SessionSearchRestriction restriction2 = new SessionSearchRestriction("someUniqueCode2", "{foo}={bar}", restrictedType); searchRestrictionService.addSessionSearchRestrictions(restriction1, restriction2);
- Specified by:
addSessionSearchRestrictions
in interfaceSearchRestrictionService
- Parameters:
restrictions
- the restrictions to add
-
clearSessionSearchRestrictions
public void clearSessionSearchRestrictions()
Clear session search restrictions in current session context.- Specified by:
clearSessionSearchRestrictions
in interfaceSearchRestrictionService
-
disableSearchRestrictions
public void disableSearchRestrictions()
Disable search restrictions in current session context.- Specified by:
disableSearchRestrictions
in interfaceSearchRestrictionService
-
enableSearchRestrictions
public void enableSearchRestrictions()
Enable search restrictions in current session context.- Specified by:
enableSearchRestrictions
in interfaceSearchRestrictionService
-
getActiveSearchRestrictions
public java.util.Collection<SearchRestrictionModel> getActiveSearchRestrictions(PrincipalModel principal, boolean includePrincipalGroups, java.util.Collection<ComposedTypeModel> types)
Gets only active search restrictions for givenComposedTypeModel
.- Specified by:
getActiveSearchRestrictions
in interfaceSearchRestrictionService
- Parameters:
principal
- the principal for which restrictions will be searchedincludePrincipalGroups
- determines whether include principal groups in searchtypes
- Collection ofComposedTypeModel
objects for which restriction will be obtained.- Returns:
- the active search restrictions collection.
-
getInactiveSearchRestrictions
public java.util.Collection<SearchRestrictionModel> getInactiveSearchRestrictions(PrincipalModel principal, boolean includePrincipalGroups, java.util.Collection<ComposedTypeModel> types)
Gets only inactive search restrictions for givenComposedTypeModel
.- Specified by:
getInactiveSearchRestrictions
in interfaceSearchRestrictionService
- Parameters:
principal
- the principal for which restrictions will be searchedincludePrincipalGroups
- determines whether include principal groups in searchtypes
- Collection ofComposedTypeModel
objects for which restriction will be obtained.- Returns:
- the active search restrictions collection.
-
getSearchRestrictions
public java.util.Collection<SearchRestrictionModel> getSearchRestrictions(PrincipalModel principal, boolean includePrincipalGroups, java.util.Collection<ComposedTypeModel> types)
Gets all (active and inactive) search restrictions for givenComposedTypeModel
.- Specified by:
getSearchRestrictions
in interfaceSearchRestrictionService
- Parameters:
principal
- the principal for which restrictions will be searchedincludePrincipalGroups
- determines whether include principal groups in searchtypes
- Collection ofComposedTypeModel
objects for which restriction will be obtained.- Returns:
- the all search restrictions.
-
getSearchRestrictionsForType
public java.util.Collection<SearchRestrictionModel> getSearchRestrictionsForType(ComposedTypeModel type)
Description copied from interface:SearchRestrictionService
Gets all search restrictions for type.- Specified by:
getSearchRestrictionsForType
in interfaceSearchRestrictionService
- Parameters:
type
- the type- Returns:
- the search restrictions for type
-
getSessionSearchRestrictions
public java.util.Collection<SessionSearchRestriction> getSessionSearchRestrictions()
Gets the session search restrictions from current session context.- Specified by:
getSessionSearchRestrictions
in interfaceSearchRestrictionService
- Returns:
- the session search restrictions collection.
-
getSessionSearchRestrictions
public java.util.Collection<SessionSearchRestriction> getSessionSearchRestrictions(ComposedTypeModel type)
Gets the session search restrictions from current session context for particularComposedTypeModel
object.- Specified by:
getSessionSearchRestrictions
in interfaceSearchRestrictionService
- Parameters:
type
- the type for which which restriction will be obtained.- Returns:
- the session search restrictions collection.
-
hasRestrictions
public boolean hasRestrictions(PrincipalModel principal, boolean includePrincipalGroups, ComposedTypeModel type)
Checks whether type has search restrictions (session and persisted).- Specified by:
hasRestrictions
in interfaceSearchRestrictionService
- Parameters:
principal
- the principal for which restrictions will be searchedincludePrincipalGroups
- determines whether include principal groups in searchtype
- the type for which check will be triggered.- Returns:
- true if has restrictions, false otherwise.
-
isSearchRestrictionsEnabled
public boolean isSearchRestrictionsEnabled()
Checks if search restrictions feature in current session context is enabled.- Specified by:
isSearchRestrictionsEnabled
in interfaceSearchRestrictionService
- Returns:
- true is search restrictions are enabled
-
removeSessionSearchRestrictions
public void removeSessionSearchRestrictions(java.util.Collection<SessionSearchRestriction> restrictions)
Remove session search restrictions from current session context.- Specified by:
removeSessionSearchRestrictions
in interfaceSearchRestrictionService
- Parameters:
restrictions
- the restrictions collection to remove from session.
-
removalAllSessionSearchRestrictions
public void removalAllSessionSearchRestrictions()
Removes all session-scoped search restrictions from the current session.- Specified by:
removalAllSessionSearchRestrictions
in interfaceSearchRestrictionService
-
setConverter
public void setConverter(SessionSearchRestrictionConverter converter)
-
setSearchRestrictionDao
public void setSearchRestrictionDao(SearchRestrictionDao searchRestrictionDao)
-
setSessionService
public void setSessionService(SessionService sessionService)
-
-