Package com.skava.service.impl
Class GetAllUserServiceImpl
java.lang.Object
com.skava.service.impl.GetAllUserServiceImpl
- All Implemented Interfaces:
com.skava.core.EcommService<UserRequest,
,UserSearchResponse> GetAllUserService
@Service
@Transactional(propagation=REQUIRED,
readOnly=true,
noRollbackFor=java.lang.Exception.class)
public class GetAllUserServiceImpl
extends Object
implements GetAllUserService
This service class implements GetAllUserService and handles the get all user service request, process
it and save the details in DB. It also implements business logic required to retrieve all users present
in a collection.
- Author:
- Infosys Equinox
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckUserSearchResponse
(UserRequest request, List<UsersEntity> userListEntity, long usersCount) Used to load users based on search criteria.static jakarta.persistence.criteria.Predicate
getCustomPropertiesSearchCriteria
(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Predicate searchAllUserPropertiesPredicate, jakarta.persistence.criteria.Root<UsersEntity> root, SearchCriteria param) This method is used construct search predicate for custom properties searchprotected jakarta.persistence.criteria.Predicate
getPredicateForExactSearchParams
(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<UsersEntity> r, String searchValue, jakarta.persistence.criteria.Predicate currentPredicate, String key) This method is used add conditions based on the search parameter to predicate.protected jakarta.persistence.criteria.Predicate
getPredicateForStringParam
(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<UsersEntity> r, jakarta.persistence.criteria.Predicate predicate, SearchCriteria param, boolean isForNotOpertor) This method is used to get predicate for string parameter.jakarta.persistence.criteria.Predicate
getSearchQueryCondition
(List<SearchCriteria> params, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Predicate searchAllUserPropertiesPredicate, jakarta.persistence.criteria.Root<UsersEntity> root, String locale) This method used to get search query conditionjakarta.persistence.criteria.Predicate
getSearchQueryConditionForNotOperator
(SearchCriteria searchParam, jakarta.persistence.criteria.Predicate searchAllUserPropertiesPredicate, jakarta.persistence.criteria.CriteriaBuilder buildr, jakarta.persistence.criteria.Root<UsersEntity> userRoot, String locale) This method is used to get search query condition for not operatorgetUserListSearchQuery
(UserRequest request, List<SearchCriteria> params, String sortParameter, String sortOrder) This method is used to get list of users with search queryList<com.skava.core.validation.ValidatorComponent>
This method is used to get the respective validator class for this get all user service.methodFallback
(UserRequest input) Circuit breaker fall-back method monitors for failures and once failures reach certain threshold, the circuit breaker trips and returns error response accordingly - Method fallback.process
(UserRequest request) This service is used to search the user profile information of a particular collection either by applying filters or searching for all users irrespective of their status , type etc., within a range for the given page and size parameters.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.skava.core.EcommService
getValidateException, getValidator
-
Constructor Details
-
GetAllUserServiceImpl
public GetAllUserServiceImpl()The class constructor.
-
-
Method Details
-
process
@HystrixCommand(commandKey="user-key", fallbackMethod="methodFallback", ignoreExceptions=com.skava.core.validation.ValidateException.class) public UserSearchResponse process(UserRequest request) This service is used to search the user profile information of a particular collection either by applying filters or searching for all users irrespective of their status , type etc., within a range for the given page and size parameters.- Specified by:
process
in interfacecom.skava.core.EcommService<UserRequest,
UserSearchResponse> - Parameters:
request
- HoldsUserRequest
object which is used to search the user details from database.- Returns:
- The
UserResponse
object which returns the success response code and message on successful fetching of user details and if any validations fails, throws an validate exception.
-
checkUserSearchResponse
public UserSearchResponse checkUserSearchResponse(UserRequest request, List<UsersEntity> userListEntity, long usersCount) Used to load users based on search criteria.- Parameters:
request
- HoldsUserRequest
object which indicates the user request used for searching and sorting.userListEntity
- Holds theList
ofUsersEntity
object which contain list of searched user.usersCount
- Indicates the count of users based on the search criteria.- Returns:
- The
UserSearchResponse
object which returns the success response code and message. if any validations fails, throws validate exception.
-
getUserListSearchQuery
public UserSearchModel getUserListSearchQuery(UserRequest request, List<SearchCriteria> params, String sortParameter, String sortOrder) This method is used to get list of users with search query- Parameters:
request
- HoldsUserRequest
object which is used to load search params and collection id and user id.params
- Holds theList
ofSearchCriteria
object which contains the search params.sortParameter
- aString
sort parameter object.sortOrder
- aString
sort order object.- Returns:
- The
UserSearchModel
object which returns the list of searched users.
-
getSearchQueryCondition
public jakarta.persistence.criteria.Predicate getSearchQueryCondition(List<SearchCriteria> params, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Predicate searchAllUserPropertiesPredicate, jakarta.persistence.criteria.Root<UsersEntity> root, String locale) This method used to get search query condition- Parameters:
params
- Holds theList
ofSearchCriteria
object which contains the list of search criteria objects.builder
- HoldsCriteriaBuilder
object used to form predicate.searchAllUserPropertiesPredicate
- HoldsPredicate
objectroot
- HoldsRoot
ofUsersEntity
object which contains query for root entity.locale
- aString
object. API Response and error messages will be responded in the locale mentioned in this parameter.- Returns:
- The
Predicate
which returns predicate object.
-
getCustomPropertiesSearchCriteria
public static jakarta.persistence.criteria.Predicate getCustomPropertiesSearchCriteria(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Predicate searchAllUserPropertiesPredicate, jakarta.persistence.criteria.Root<UsersEntity> root, SearchCriteria param) This method is used construct search predicate for custom properties search- Parameters:
builder
- - refers to the query buildersearchAllUserPropertiesPredicate
- - refers to the search criteriaroot
- - rootparam
- -param- Returns:
- searchAllUserPropertiesPredicate
-
getSearchQueryConditionForNotOperator
public jakarta.persistence.criteria.Predicate getSearchQueryConditionForNotOperator(SearchCriteria searchParam, jakarta.persistence.criteria.Predicate searchAllUserPropertiesPredicate, jakarta.persistence.criteria.CriteriaBuilder buildr, jakarta.persistence.criteria.Root<UsersEntity> userRoot, String locale) This method is used to get search query condition for not operator- Parameters:
searchParam
- Holds theList
ofSearchCriteria
object which contains the list of search criteria objects.searchAllUserPropertiesPredicate
- HoldsPredicate
objectbuildr
- HoldsCriteriaBuilder
object used to form predicate.userRoot
- HoldsRoot
ofUsersEntity
object which contains query for root entity.locale
- aString
object. API Response and error messages will be responded in the locale mentioned in this parameter.- Returns:
- The
Predicate
which returns predicate object.
-
getPredicateForStringParam
protected jakarta.persistence.criteria.Predicate getPredicateForStringParam(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<UsersEntity> r, jakarta.persistence.criteria.Predicate predicate, SearchCriteria param, boolean isForNotOpertor) This method is used to get predicate for string parameter.- Parameters:
builder
- HoldsCriteriaBuilder
object used to form predicate.r
- Holds theRoot
ofUsersEntity
object which contains query for root entity.predicate
- HoldsPredicate
object which will generate predicate for each search params.param
- HoldsSearchCriteria
object which is used to get search value.isForNotOpertor
- Define the predicate for Not operator or else use default method- Returns:
- The
Predicate
which returns predicate object.
-
getPredicateForExactSearchParams
protected jakarta.persistence.criteria.Predicate getPredicateForExactSearchParams(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<UsersEntity> r, String searchValue, jakarta.persistence.criteria.Predicate currentPredicate, String key) This method is used add conditions based on the search parameter to predicate.- Parameters:
builder
- HoldsCriteriaBuilder
object used to form predicate.r
- Holds theRoot
ofUsersEntity
object which contains query for root entity.searchValue
- Indicates the searched value.currentPredicate
- HoldsPredicate
object which will generate predicate for each search params.key
- Indicates the key value of the searched param.- Returns:
- The
Predicate
which returns predicate.
-
methodFallback
Circuit breaker fall-back method monitors for failures and once failures reach certain threshold, the circuit breaker trips and returns error response accordingly - Method fallback.- Parameters:
input
- HoldsUserRequest
object.- Returns:
- The
UserSearchResponse
object.
-
getValidator
This method is used to get the respective validator class for this get all user service.- Specified by:
getValidator
in interfacecom.skava.core.EcommService<UserRequest,
UserSearchResponse> - Returns:
- The list of
ValidatorComponent
object.
-