-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat : using blaze multiselect views #287
Changes from 5 commits
5f33418
be87f38
78b455e
c2134d6
08c9004
0223d3e
9ad9860
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.learning.mfscreener.repository; | ||
|
||
import com.learning.mfscreener.models.entityviews.UserCASDetailsEntityView; | ||
|
||
public interface CustomUserCASDetailsEntityRepository { | ||
|
||
UserCASDetailsEntityView findByInvestorEmailAndName(String email, String name); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.learning.mfscreener.repository; | ||
|
||
import com.blazebit.persistence.CriteriaBuilderFactory; | ||
import com.blazebit.persistence.view.EntityViewManager; | ||
import com.blazebit.persistence.view.EntityViewSetting; | ||
import com.learning.mfscreener.entities.UserCASDetailsEntity; | ||
import com.learning.mfscreener.models.entityviews.UserCASDetailsEntityView; | ||
import jakarta.persistence.EntityManager; | ||
|
||
public class CustomUserCASDetailsEntityRepositoryImpl implements CustomUserCASDetailsEntityRepository { | ||
|
||
private final EntityManager entityManager; | ||
|
||
private final CriteriaBuilderFactory criteriaBuilderFactory; | ||
|
||
private final EntityViewManager entityViewManager; | ||
|
||
public CustomUserCASDetailsEntityRepositoryImpl( | ||
EntityManager entityManager, | ||
CriteriaBuilderFactory criteriaBuilderFactory, | ||
EntityViewManager entityViewManager) { | ||
this.entityManager = entityManager; | ||
this.criteriaBuilderFactory = criteriaBuilderFactory; | ||
this.entityViewManager = entityViewManager; | ||
} | ||
|
||
@Override | ||
public UserCASDetailsEntityView findByInvestorEmailAndName(String email, String name) { | ||
return entityViewManager | ||
.applySetting( | ||
EntityViewSetting.create(UserCASDetailsEntityView.class), | ||
criteriaBuilderFactory.create(entityManager, UserCASDetailsEntity.class)) | ||
.where("investorInfoEntity.email") | ||
.eq(email) | ||
.where("investorInfoEntity.name") | ||
.eq(name) // Adding condition for the name | ||
.getSingleResult(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
import com.learning.mfscreener.mapper.CasDetailsMapper; | ||
import com.learning.mfscreener.models.MFSchemeDTO; | ||
import com.learning.mfscreener.models.PortfolioDetailsDTO; | ||
import com.learning.mfscreener.models.entityviews.UserCASDetailsEntityView; | ||
import com.learning.mfscreener.models.entityviews.UserFolioDetailsEntityView; | ||
import com.learning.mfscreener.models.portfolio.CasDTO; | ||
import com.learning.mfscreener.models.portfolio.UserFolioDTO; | ||
import com.learning.mfscreener.models.portfolio.UserSchemeDTO; | ||
|
@@ -101,7 +103,8 @@ UploadResponseHolder findDelta(String email, String name, CasDTO casDTO) { | |
List<UserTransactionDetailsEntity> userTransactionDetailsEntityList = | ||
this.userTransactionDetailsEntityRepository.findAllTransactionsByEmailAndName(email, name); | ||
|
||
UserCASDetailsEntity userCASDetailsEntity = casDetailsEntityRepository.findByInvestorEmailAndName(email, name); | ||
UserCASDetailsEntityView userCASDetailsEntityView = | ||
casDetailsEntityRepository.findByInvestorEmailAndName(email, name); | ||
|
||
if (userTransactionDTOListCount == userTransactionDetailsEntityList.size()) { | ||
log.info("No new transactions are added"); | ||
|
@@ -112,16 +115,16 @@ UploadResponseHolder findDelta(String email, String name, CasDTO casDTO) { | |
AtomicInteger transactionsCounter = new AtomicInteger(); | ||
|
||
// Verify if new folios are added | ||
List<String> existingFolios = userCASDetailsEntity.getFolioEntities().stream() | ||
.map(UserFolioDetailsEntity::getFolio) | ||
List<String> existingFolios = userCASDetailsEntityView.getFolioEntities().stream() | ||
.map(UserFolioDetailsEntityView::getFolio) | ||
.toList(); | ||
|
||
folioDTOList.forEach(userFolioDTO -> { | ||
String folio = userFolioDTO.folio(); | ||
if (!existingFolios.contains(folio)) { | ||
log.info("New folio: {} created that is not present in the database", folio); | ||
userCASDetailsEntity.addFolioEntity( | ||
casDetailsMapper.mapUserFolioDTOToUserFolioDetailsEntity(userFolioDTO)); | ||
// userCASDetailsEntityView.addFolioEntity( | ||
// casDetailsMapper.mapUserFolioDTOToUserFolioDetailsEntity(userFolioDTO)); | ||
folioCounter.incrementAndGet(); | ||
int newTransactions = userFolioDTO.schemes().stream() | ||
.map(UserSchemeDTO::transactions) | ||
|
@@ -184,7 +187,8 @@ UploadResponseHolder findDelta(String email, String name, CasDTO casDTO) { | |
}); | ||
} | ||
}); | ||
userCASDetailsEntity.setFolioEntities(existingUserFolioDetailsEntityList); | ||
// TODO | ||
// userCASDetailsEntityView.setFolioEntities(existingUserFolioDetailsEntityList); | ||
Comment on lines
+214
to
+215
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The TODO comment indicates unfinished work or a placeholder for future implementation. It's crucial to track these tasks to ensure they are completed or addressed in subsequent updates. Would you like assistance in implementing the functionality mentioned in the TODO comment, or should it be tracked as an issue for future resolution? |
||
|
||
// Check if all new transactions are added as part of adding schemes | ||
if (userTransactionDTOListCount == (userTransactionDetailsEntityList.size() + transactionsCounter.get())) { | ||
|
@@ -244,7 +248,7 @@ UploadResponseHolder findDelta(String email, String name, CasDTO casDTO) { | |
}); | ||
} | ||
} | ||
return new UploadResponseHolder(userCASDetailsEntity, folioCounter.get(), transactionsCounter.get()); | ||
return new UploadResponseHolder(null, folioCounter.get(), transactionsCounter.get()); | ||
} | ||
|
||
public PortfolioResponse getPortfolioByPAN(String panNumber, LocalDate asOfDate) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class declaration, fields, and constructor are correctly implemented, ensuring proper dependency management. The method
findByInvestorEmailAndName
usesEntityViewManager
andCriteriaBuilderFactory
effectively to queryUserCASDetailsEntity
based on email and name. However, consider handlingNoResultException
thatgetSingleResult()
may throw if no entity matches the criteria.