Package com.skava.accounts.util
Class AccountsUtil
java.lang.Object
com.skava.accounts.util.AccountsUtil
- All Implemented Interfaces:
Serializable
The utility class AccountsUtil consists of helper and validator methods for accounts entity.
- Author:
- Infosys Equinox
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkIfAnyRoleOtherThanBuyerUser
(com.skava.core.auth.AuthTokenHandler authTokenHandler, long collectionId) checkIfAnyRoleExceptBuyerUserstatic Long
getAdminOrUserId
(com.skava.core.auth.AuthTokenHandler authTokenHandler) This method will return admin userid if it is 0 then return useridstatic CollectionStatus
getCollectionStatus
(Collections request) validateCollectionStatusstatic boolean
isValidAccount
(long accountId, long collectionId, AccountsRepository accountRepository, org.springframework.context.MessageSource messageSource, String locale) Checks if is valid account.static boolean
isValidAccountSize
(String size, PropertiesRepository propertiesRepository, long collectionId) isValidAccountSize - Used to validate the account size.static void
isValidaccountType
(long accountTypeId, long collectionId, AccountTypesRepository accountTypeRepository, org.springframework.context.MessageSource messageSource, String locale) Checks if is validaccount type.static boolean
isValidCostCentre
(long accountId, long costCentreId, CostCentreRepository costCentreRepository, org.springframework.context.MessageSource messageSource, String locale) Checks if is valid cost centre.static boolean
isValidPaymentMethod
(String paymentMethod, PropertiesRepository propertiesRepository, long collectionId) isValidPaymentMethod - Used to validate the payment method.static boolean
isValidSortOrder
(String order) This method is used to validate the sorting order, returns TRUE if valid else FALSE.static boolean
isValidSortParam
(String sortParam) This method is used to validate user sort params.static boolean
isValidTeam
(long teamId, long accountId, TeamRepository teamRepository, org.springframework.context.MessageSource messageSource, String locale) Checks if is valid team.static <T> com.querydsl.core.types.Expression<T>
useParamForSort
(String param)
-
Field Details
-
SPLIT_LENGTH
public static final int SPLIT_LENGTH- See Also:
-
-
Constructor Details
-
AccountsUtil
public AccountsUtil()
-
-
Method Details
-
isValidaccountType
public static void isValidaccountType(long accountTypeId, long collectionId, AccountTypesRepository accountTypeRepository, org.springframework.context.MessageSource messageSource, String locale) Checks if is validaccount type.- Parameters:
accountTypeId
- the account type idcollectionId
- the collection idaccountTypeRepository
- the account type repositorymessageSource
- the message sourcelocale
- API Response and error messages will be responded in the locale mentioned in this parameter.
-
isValidAccount
public static boolean isValidAccount(long accountId, long collectionId, AccountsRepository accountRepository, org.springframework.context.MessageSource messageSource, String locale) Checks if is valid account.- Parameters:
accountId
- the account idcollectionId
- the collection idaccountRepository
- the account repositorymessageSource
- the message sourcelocale
- API Response and error messages will be responded in the locale mentioned in this parameter.- Returns:
- true, if is valid account
-
isValidCostCentre
public static boolean isValidCostCentre(long accountId, long costCentreId, CostCentreRepository costCentreRepository, org.springframework.context.MessageSource messageSource, String locale) Checks if is valid cost centre.- Parameters:
accountId
- the account idcostCentreId
- the cost centre idcostCentreRepository
- the cost centre repositorymessageSource
- the message sourcelocale
- API Response and error messages will be responded in the locale mentioned in this parameter.- Returns:
- true, if is valid cost centre
-
isValidTeam
public static boolean isValidTeam(long teamId, long accountId, TeamRepository teamRepository, org.springframework.context.MessageSource messageSource, String locale) Checks if is valid team.- Parameters:
teamId
- the team idaccountId
- the account idteamRepository
- the team repositorymessageSource
- the message sourcelocale
- API Response and error messages will be responded in the locale mentioned in this parameter.- Returns:
- true, if is valid team
-
getCollectionStatus
validateCollectionStatus
- Parameters:
request
- Instance ofCollections
which is used to get the collection status.- Returns:
- collection status
-
isValidAccountSize
public static boolean isValidAccountSize(String size, PropertiesRepository propertiesRepository, long collectionId) isValidAccountSize - Used to validate the account size.- Parameters:
size
- size of the account which is to be validated.propertiesRepository
- the properties Repository.collectionId
- the unique identifier of the collection.- Returns:
- a boolean value true/false
-
isValidPaymentMethod
public static boolean isValidPaymentMethod(String paymentMethod, PropertiesRepository propertiesRepository, long collectionId) isValidPaymentMethod - Used to validate the payment method.- Parameters:
paymentMethod
- the payment method that will be used by the buyers for that contract.propertiesRepository
- the properties Repository.collectionId
- the unique identifier of the collection.- Returns:
- a boolean value true/false
-
getAdminOrUserId
This method will return admin userid if it is 0 then return userid- Parameters:
authTokenHandler
- authTokenHandler- Returns:
- long adminid or userid
-
checkIfAnyRoleOtherThanBuyerUser
public static boolean checkIfAnyRoleOtherThanBuyerUser(com.skava.core.auth.AuthTokenHandler authTokenHandler, long collectionId) checkIfAnyRoleExceptBuyerUser- Parameters:
authTokenHandler
- authTokenHandlercollectionId
- collectionId- Returns:
- a boolean value
-
isValidSortParam
This method is used to validate user sort params.- Parameters:
sortParam
- Indicates the search and sort params which is used for validating the sort and search params.- Returns:
- boolean value.
-
isValidSortOrder
This method is used to validate the sorting order, returns TRUE if valid else FALSE.- Parameters:
order
- Indicates the order of an user's sorting. eg : ASC or DESC- Returns:
- boolean value
-
useParamForSort
- Type Parameters:
T
-- Parameters:
param
-- Returns:
-