Class ProductsService
java.lang.Object
es.kukenan.smartfi.microservice.contracts.service.ProductsService
Products related services.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classInternal class used to store the context of a back office product search in a single back office client. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BackofficeClientManagerBack office clients manager.private BackofficeSubsystemRepositoryBackofficeSubsystem artificial entity repository.private es.kukenan.smartfi.common.service.validation.BeanValidatorServicebean Validator Service.private static final IntegerCore backoffice identifier.private DtoObfuscatorSecurity util to obfuscate sensible data in DTOs.private EbContractRepositoryEb Contract Repository.private ProductRepositoryProducts DB repository.private SubsystemRepositorySubsystem DB repository.private UserBackofficeRepositoryUser back office DB repository.private UuidGeneratorUuid generator component. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiones.kukenan.smartfi.microservice.contracts.api.products.ProductDtocreateProductCard(String sessionId, String userId, String userToken, es.kukenan.smartfi.common.security.WalletAuthentication auth) Create a single product.static ProductSearchRequestcreateProductSearchRequest(es.kukenan.smartfi.common.security.WalletAuthentication auth, String productId, Product product) Request for product search.es.kukenan.smartfi.microservice.contracts.api.products.ProductDtocreateProductWallet(String sessionId, String userId, String userToken, es.kukenan.smartfi.common.security.WalletAuthentication auth) Create a single product.private List<ProductDomain>filterInvalidProducts(List<ProductDomain> products) Filtering valid products.private HashMap<String,ArrayList<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto>> findAndSaveBackofficesNewProducts(String userId, List<ProductsService.BackofficeClientProductSearchContext> clientProductSearchContexts, ProductSearchFilter productSearchFilter, boolean internal, String userToken, String userIp, String contractId) Find all the products in the given client product search contexts, and store them in the database.private List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto>findAndSaveBackofficesProducts(String userId, List<ProductsService.BackofficeClientProductSearchContext> clientProductSearchContexts, ProductSearchFilter productSearchFilter, boolean internal, String userToken, String userIp, String contractId) Find all the products in the given client product search contexts, and store them in the database.findNewProducts(String sessionId, String userId, String userToken, String userIp, String contractId, String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, String byService, boolean internal) Find products service method.es.kukenan.smartfi.microservice.contracts.api.products.ProductDtofindProduct(String sessionId, String userId, String userToken, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth) Find a single product details.List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto>findProductComposition(String sessionId, String userId, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth, String userToken) Find a single product composition (products managed by the given product).es.kukenan.smartfi.microservice.contracts.api.products.ProductDtofindProductPosition(String sessionId, String userId, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth, String userToken) Find a single product position.List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto>findProducts(String sessionId, String userId, String userToken, String userIp, String contractId, String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, String byService) Find products service method.List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto>findProducts(String sessionId, String userId, String userToken, String userIp, String contractId, String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, String byService, boolean internal) Find products service method.List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto>findProductsForced(String userId, String userToken, String userIp, String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, boolean internal) Find products forced service method.es.kukenan.smartfi.microservice.contracts.api.products.ProductDtofindProductWithAssetsTypes(String sessionId, String userId, String userToken, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth) Find a single product details with assets types.es.kukenan.smartfi.microservice.contracts.api.receipt.ReceiptsResponseDtofindReceipts(String sessionId, String userId, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth, String paginationKey, String token) Find product receipts.es.kukenan.smartfi.microservice.contracts.api.repayment.LoanRepaymentsResponseDtofindRepayments(String sessionId, String userId, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth, String userToken, String dateFrom, String dateTo) Find Repayments.intgenerateCvvOperationId(String userId, String bankCode, String panToken, es.kukenan.smartfi.common.security.WalletAuthentication auth) Retrieve cvv card.intgeneratePinOperationId(String userId, String bankCode, String panToken, es.kukenan.smartfi.common.security.WalletAuthentication auth) Retrieve pin operation id.private ProductSearchFiltergenerateProductSearchByFilter(String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, String byService) Generate product search filter.private voidmergeBackofficeSubsystemsLists(List<BackofficeSubsystems> originList, List<BackofficeSubsystems> destinationList) Merged two list of Subsystems.prepareBackofficeProductSearch(String userId, List<BackofficeSubsystems> backofficeSubsystemsList) Prepare backoffice product search context.Prepare backoffice product search context with all Subsystems.private List<BackofficeSubsystems>retrieveBackofficeSubsystems(String userId, String contractId, ProductSearchFilter productSearchFilter) Get the subsystems that the customer has in their products.saveProduct(String backofficeUserId, Integer backofficeId, String productId, String productType) Save new product.private voidsynchronizeUserProducts(String userId, List<ProductDomain> newProducts, UserBackoffice userBackoffice, boolean mustUpdateDatabase, String contractId) Synchronize the given product list with the previously existing for the given user and back office.verifyingUserProduct(String userId, String productId) verifying user product.
-
Field Details
-
CORE_BACKOFFICE_ID
Core backoffice identifier. -
productRepository
Products DB repository. -
backofficeSubsystemRepository
BackofficeSubsystem artificial entity repository. -
userBackofficeRepository
User back office DB repository. -
subsystemRepository
Subsystem DB repository. -
backofficeClientManager
Back office clients manager. -
dtoObfuscator
Security util to obfuscate sensible data in DTOs. -
uuidGenerator
Uuid generator component. -
beanValidatorService
@Autowired private es.kukenan.smartfi.common.service.validation.BeanValidatorService beanValidatorServicebean Validator Service. -
ebContractRepository
Eb Contract Repository.
-
-
Constructor Details
-
ProductsService
public ProductsService()
-
-
Method Details
-
createProductSearchRequest
public static ProductSearchRequest createProductSearchRequest(es.kukenan.smartfi.common.security.WalletAuthentication auth, String productId, Product product) Request for product search.- Parameters:
auth- Authentication bearer with data sesion.productId- unique product identifier.product- Product dto.- Returns:
- Product search request.
-
findProducts
public List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto> findProducts(String sessionId, String userId, String userToken, String userIp, String contractId, String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, String byService) Find products service method. Two different cases are considered:- 1. The user has no products registered. We perform a full search through all back office.
- 2. The user, at least, one product. We perform a search in each subsystem of each back office that has, at lease, one product registered.
- Parameters:
sessionId- session identifier.userId- user identifier.userToken- user beareruserIp- user ip.contractId- contract identifier.byType- types to filterwithPostedBalance- flag to filter for posted balancebyStatus- status to filterbySignature- signatures to filterbyCurrency- currency to filterbyService- service to filter- Returns:
- product list.
-
findProducts
public List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto> findProducts(String sessionId, String userId, String userToken, String userIp, String contractId, String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, String byService, boolean internal) Find products service method. Two different cases are considered:- 1. The user has no products registered. We perform a full search through all back office.
- 2. The user, at least, one product. We perform a search in each subsystem of each back office that has, at lease, one product registered.
- Parameters:
sessionId- session identifier.userId- user identifier.userToken- user beareruserIp- user ip.contractId- contract identifierbyType- types to filterwithPostedBalance- flag to filter for posted balancebyStatus- status to filterbySignature- signatures to filterbyCurrency- currency to filterbyService- service to filterinternal- product internal identificator- Returns:
- product list.
-
findNewProducts
public HashMap<String,ArrayList<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto>> findNewProducts(String sessionId, String userId, String userToken, String userIp, String contractId, String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, String byService, boolean internal) Find products service method. Two different cases are considered:- 1. The user has no products registered. We perform a full search through all back office.
- 2. The user, at least, one product. We perform a search in each subsystem of each back office that has, at lease, one product registered.
- Parameters:
sessionId- session identifier.userId- user identifier.userToken- user beareruserIp- user ip.contractId- contract identifierbyType- types to filterwithPostedBalance- flag to filter for posted balancebyStatus- status to filterbySignature- signatures to filterbyCurrency- currency to filterbyService- service to filterinternal- product internal identificator- Returns:
- product list.
-
findProductsForced
public List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto> findProductsForced(String userId, String userToken, String userIp, String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, boolean internal) Find products forced service method.- Perform a full search through all back office.
- Parameters:
userId- user identifier.userToken- user bearer.userIp- user IpbyType- types to filterwithPostedBalance- flag to filter for posted balancebyStatus- status to filterbySignature- signatures to filterbyCurrency- currency to filterinternal- product internal identificator- Returns:
- product list.
-
verifyingUserProduct
verifying user product.- Parameters:
userId- user identifier.productId- product identifier.- Returns:
- product details. If the product is not found, an
EntityNotFoundExceptionis thrown.
-
findProduct
@Cacheable(cacheResolver="cacheResolver", key="#sessionId+\'/api/v1/products/\'+#productId") public es.kukenan.smartfi.microservice.contracts.api.products.ProductDto findProduct(String sessionId, String userId, String userToken, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth) Find a single product details.- Parameters:
sessionId- session identifier.userId- user identifier.userToken- user bearer.productId- product identifier.auth- authentication, required to extract user bank entity.- Returns:
- product details. If the product is not found.
-
createProductWallet
public es.kukenan.smartfi.microservice.contracts.api.products.ProductDto createProductWallet(String sessionId, String userId, String userToken, es.kukenan.smartfi.common.security.WalletAuthentication auth) Create a single product.- Parameters:
sessionId- session identifier.userId- user identifier.userToken- user bearer.auth- authentication, required to extract user bank entity.- Returns:
- product details. If the product is not found.
-
createProductCard
public es.kukenan.smartfi.microservice.contracts.api.products.ProductDto createProductCard(String sessionId, String userId, String userToken, es.kukenan.smartfi.common.security.WalletAuthentication auth) Create a single product.- Parameters:
sessionId- session identifier.userId- user identifier.userToken- user bearer.auth- authentication, required to extract user bank entity.- Returns:
- product details. If the product is not found.
-
findProductPosition
@Cacheable(cacheResolver="cacheResolver", key="#sessionId+\'/api/v1/products/\'+#productId+\'/position\'") public es.kukenan.smartfi.microservice.contracts.api.products.ProductDto findProductPosition(String sessionId, String userId, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth, String userToken) Find a single product position.- Parameters:
sessionId- session identifier.userId- user identifier.productId- product identifier.auth- authentication, required to extract user bank entity.userToken- userToken.- Returns:
- product position. If the product is not found.
-
findRepayments
@Cacheable(cacheResolver="cacheResolver", key="#sessionId+\'/api/v1/products/\'+#productId+\'/repayments\'", unless="#result.getElements().size() == 0") public es.kukenan.smartfi.microservice.contracts.api.repayment.LoanRepaymentsResponseDto findRepayments(String sessionId, String userId, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth, String userToken, String dateFrom, String dateTo) Find Repayments.- Parameters:
sessionId- session identifier.userId- user identifier.productId- product identifier.auth- authentication, required to extract user bank entity.userToken- userToken.dateFrom- dateFrom.dateTo- dateTo.- Returns:
- product details. If the product is not found.
-
retrieveBackofficeSubsystems
private List<BackofficeSubsystems> retrieveBackofficeSubsystems(String userId, String contractId, ProductSearchFilter productSearchFilter) Get the subsystems that the customer has in their products.- Parameters:
userId- userId.contractId- contractId.productSearchFilter- productSearchFilter.- Returns:
- list of BackofficeSubsystems.
-
mergeBackofficeSubsystemsLists
private void mergeBackofficeSubsystemsLists(List<BackofficeSubsystems> originList, List<BackofficeSubsystems> destinationList) Merged two list of Subsystems.- Parameters:
originList- originList.destinationList- destinationList.
-
prepareBackofficeProductSearch
private List<ProductsService.BackofficeClientProductSearchContext> prepareBackofficeProductSearch(String userId, List<BackofficeSubsystems> backofficeSubsystemsList) Prepare backoffice product search context. That is: find all back office clients in the given list or all of them if the list is empty.- Parameters:
userId- user identifier.backofficeSubsystemsList- known user backoffice subsystems.- Returns:
- a list of product search context, one for each back office that must be queried.
-
prepareBackofficeProductSearchContextWithAllSubsystem
private List<ProductsService.BackofficeClientProductSearchContext> prepareBackofficeProductSearchContextWithAllSubsystem(String userId) Prepare backoffice product search context with all Subsystems.- Parameters:
userId- user identifier.- Returns:
- a list of product search context, one for each back office that must be queried.
-
findAndSaveBackofficesNewProducts
private HashMap<String,ArrayList<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto>> findAndSaveBackofficesNewProducts(String userId, List<ProductsService.BackofficeClientProductSearchContext> clientProductSearchContexts, ProductSearchFilter productSearchFilter, boolean internal, String userToken, String userIp, String contractId) Find all the products in the given client product search contexts, and store them in the database.- Parameters:
userId- user identifier.clientProductSearchContexts- a list of clients to query products from with then proper search context.productSearchFilter- the criteria to filter the products.internal- to show internal products properties.userToken- user bearer.userIp- user Ip.contractId- session identifier.- Returns:
- all the products found in the given contexts and stored for the given user with.
-
findAndSaveBackofficesProducts
private List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto> findAndSaveBackofficesProducts(String userId, List<ProductsService.BackofficeClientProductSearchContext> clientProductSearchContexts, ProductSearchFilter productSearchFilter, boolean internal, String userToken, String userIp, String contractId) Find all the products in the given client product search contexts, and store them in the database.- Parameters:
userId- user identifier.clientProductSearchContexts- a list of clients to query products from with then proper search context.productSearchFilter- the criteria to filter the products.internal- to show internal products properties.userToken- user bearer.userIp- user Ip.contractId- session identifier.- Returns:
- all the products found in the given contexts and stored for the given user with.
-
synchronizeUserProducts
private void synchronizeUserProducts(String userId, List<ProductDomain> newProducts, UserBackoffice userBackoffice, boolean mustUpdateDatabase, String contractId) Synchronize the given product list with the previously existing for the given user and back office.- Parameters:
userId- user identifier.newProducts- actual known user products in the given back office.userBackoffice- back office which products are being synchronized.mustUpdateDatabase- flag to update BBDD.contractId- contract identifier.
-
filterInvalidProducts
Filtering valid products.- Parameters:
products- products domain.- Returns:
- list valid products
-
findReceipts
@Cacheable(cacheResolver="cacheResolver",key="#sessionId+\'/api/v1/products/\'+#productId+\'/receipts\'",condition="#paginationKey == null",unless="#result.getData().size() == 0") @Cacheable(cacheResolver="cacheResolver",key="#sessionId+\'/api/v1/products/\'+#productId+\'/receipts?paginationKey=\'+#paginationKey",condition="#paginationKey != null",unless="#result.getData().size() == 0") public es.kukenan.smartfi.microservice.contracts.api.receipt.ReceiptsResponseDto findReceipts(String sessionId, String userId, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth, String paginationKey, String token) Find product receipts.- Parameters:
sessionId- session identifier.userId- user identifier.productId- product identifier.auth- authentication, required to extract user bank entity.paginationKey- pagination Key value.token- token.- Returns:
- product receipts.
-
findProductComposition
@Cacheable(cacheResolver="cacheResolver", key="#sessionId+\'/api/v1/products/\'+#productId+\'/composition\'") public List<es.kukenan.smartfi.microservice.contracts.api.products.ProductDto> findProductComposition(String sessionId, String userId, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth, String userToken) Find a single product composition (products managed by the given product).- Parameters:
sessionId- session identifier.userId- user identifier.productId- product identifier.auth- authentication, required to extract user bank entity.userToken- user bearer token.- Returns:
- product composition. If the product is not found.
-
generatePinOperationId
public int generatePinOperationId(String userId, String bankCode, String panToken, es.kukenan.smartfi.common.security.WalletAuthentication auth) Retrieve pin operation id.- Parameters:
userId- user identifier.bankCode- entity code.panToken- token.auth- authentication info.- Returns:
- pin operation id.
-
generateCvvOperationId
public int generateCvvOperationId(String userId, String bankCode, String panToken, es.kukenan.smartfi.common.security.WalletAuthentication auth) Retrieve cvv card.- Parameters:
userId- user identifier.bankCode- bankCode.panToken- panToken.auth- auth.- Returns:
- cvv
-
saveProduct
public Product saveProduct(String backofficeUserId, Integer backofficeId, String productId, String productType) Save new product.- Parameters:
backofficeUserId- core user id.backofficeId- back identifier.productId- product identifier.productType- product type.- Returns:
- new prodyct saved.
-
generateProductSearchByFilter
private ProductSearchFilter generateProductSearchByFilter(String byType, Boolean withPostedBalance, String byStatus, String bySignature, String byCurrency, String byService) Generate product search filter.- Parameters:
byType- types to filterwithPostedBalance- flag to filter for posted balancebyStatus- status to filterbySignature- signatures to filterbyCurrency- currency to filterbyService- service to filter- Returns:
- generic product search filter or specific search filter.
-
findProductWithAssetsTypes
public es.kukenan.smartfi.microservice.contracts.api.products.ProductDto findProductWithAssetsTypes(String sessionId, String userId, String userToken, String productId, es.kukenan.smartfi.common.security.WalletAuthentication auth) Find a single product details with assets types.- Parameters:
sessionId- session identifier.userId- user identifier.userToken- user bearer.productId- product identifier.auth- authentication, required to extract user bank entity.- Returns:
- product details. If the product is not found.
-