-
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 View #363
base: main
Are you sure you want to change the base?
Changes from 2 commits
3cae2d5
610cd36
80ec32f
b505c55
8f7715a
9781baa
c6966e8
d49c85a
8353728
3856a12
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
image: gitpod/workspace-java-17 | ||
image: gitpod/workspace-java-21 | ||
|
||
tasks: | ||
- init: ./gradlew build -x test | ||
|
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
import com.learning.mfscreener.entities.UserTransactionDetailsEntity; | ||
import com.learning.mfscreener.mapper.CasDetailsMapper; | ||
import com.learning.mfscreener.models.PortfolioDetailsDTO; | ||
import com.learning.mfscreener.models.entityviews.UserCASDetailsEntityView; | ||
import com.learning.mfscreener.models.portfolio.CasDTO; | ||
import com.learning.mfscreener.models.portfolio.UserFolioDTO; | ||
import com.learning.mfscreener.models.portfolio.UserSchemeDTO; | ||
|
@@ -133,45 +134,46 @@ UploadResponseHolder findDelta(String email, String name, CasDTO casDTO) { | |
long userTransactionCount = portfolioServiceHelper.countTransactionsByUserFolioDTOList(inputUserFolioDTOList); | ||
List<UserTransactionDetailsEntity> userTransactionDetailsEntityList = | ||
this.userTransactionDetailsService.findAllTransactionsByEmailAndName(email, name); | ||
UserCASDetailsEntity userCASDetailsEntity = userCASDetailsService.findByInvestorEmailAndName(email, name); | ||
UserCASDetailsEntityView userCASDetailsEntityView = | ||
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. Updates to use Would you like assistance in completing the TODO items mentioned in the code? Also applies to: 146-146, 153-153, 164-164, 176-176, 338-338 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. @coderabbitai, please help me with fixing TODO as per above comment 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. @rajadilipkolli, I can help you address the TODO items in your code. Here are the suggested changes: 1. Adding Folios to
|
||
userCASDetailsService.findByInvestorEmailAndName(email, name); | ||
|
||
if (userTransactionCount == userTransactionDetailsEntityList.size()) { | ||
LOGGER.info("No new transactions are added"); | ||
return null; | ||
} | ||
|
||
return processFoliosAndTransactions( | ||
email, name, casDTO, userCASDetailsEntity, userTransactionCount, userTransactionDetailsEntityList); | ||
email, name, casDTO, userCASDetailsEntityView, userTransactionCount, userTransactionDetailsEntityList); | ||
} | ||
|
||
UploadResponseHolder processFoliosAndTransactions( | ||
String email, | ||
String name, | ||
CasDTO casDTO, | ||
UserCASDetailsEntity userCASDetailsEntity, | ||
UserCASDetailsEntityView userCASDetailsEntityView, | ||
long userTransactionDTOListCount, | ||
List<UserTransactionDetailsEntity> userTransactionDetailsEntityList) { | ||
AtomicInteger folioCounter = new AtomicInteger(); | ||
AtomicInteger transactionsCounter = new AtomicInteger(); | ||
|
||
processNewFolios(casDTO.folios(), userCASDetailsEntity, folioCounter, transactionsCounter); | ||
processNewFolios(casDTO.folios(), userCASDetailsEntityView, folioCounter, transactionsCounter); | ||
updateSchemesAndTransactions( | ||
email, | ||
name, | ||
casDTO, | ||
userCASDetailsEntity, | ||
userCASDetailsEntityView, | ||
userTransactionDTOListCount, | ||
userTransactionDetailsEntityList, | ||
transactionsCounter); | ||
|
||
return new UploadResponseHolder(userCASDetailsEntity, folioCounter.get(), transactionsCounter.get()); | ||
return new UploadResponseHolder(null, folioCounter.get(), transactionsCounter.get()); | ||
} | ||
|
||
void updateSchemesAndTransactions( | ||
String email, | ||
String name, | ||
CasDTO casDTO, | ||
UserCASDetailsEntity userCASDetailsEntity, | ||
UserCASDetailsEntityView userCASDetailsEntityView, | ||
long userTransactionDTOListCount, | ||
List<UserTransactionDetailsEntity> userTransactionDetailsEntityList, | ||
AtomicInteger transactionsCounter) { | ||
|
@@ -196,7 +198,8 @@ void updateSchemesAndTransactions( | |
existingFolioSchemesMap, | ||
existingUserFolioDetailsEntityList, | ||
transactionsCounter); | ||
userCASDetailsEntity.setFolioEntities(existingUserFolioDetailsEntityList); | ||
// TODO | ||
// userCASDetailsEntityView.setFolioEntities(existingUserFolioDetailsEntityList); | ||
|
||
// Check if all new transactions are added as part of adding schemes | ||
if (userTransactionDTOListCount == (userTransactionDetailsEntityList.size() + transactionsCounter.get())) { | ||
|
@@ -332,20 +335,21 @@ Map<String, List<UserSchemeDTO>> groupSchemesByFolio(List<UserFolioDTO> userFoli | |
|
||
void processNewFolios( | ||
List<UserFolioDTO> userFolioDTOList, | ||
UserCASDetailsEntity userCASDetailsEntity, | ||
UserCASDetailsEntityView userCASDetailsEntityView, | ||
AtomicInteger folioCounter, | ||
AtomicInteger transactionsCounter) { | ||
// Logic to process new folios | ||
List<String> existingFolioNumbers = userCASDetailsEntity.getFolioEntities().stream() | ||
.map(UserFolioDetailsEntity::getFolio) | ||
List<String> existingFolioNumbers = userCASDetailsEntityView.getFolioEntities().stream() | ||
.map(t -> t.getFolio()) | ||
.toList(); | ||
|
||
userFolioDTOList.forEach(userFolioDTO -> { | ||
String folio = userFolioDTO.folio(); | ||
if (!existingFolioNumbers.contains(folio)) { | ||
LOGGER.info("New folio: {} created that is not present in the database", folio); | ||
userCASDetailsEntity.addFolioEntity( | ||
casDetailsMapper.mapUserFolioDTOToUserFolioDetailsEntity(userFolioDTO)); | ||
// TODO | ||
// userCASDetailsEntityView.addFolioEntity( | ||
// casDetailsMapper.mapUserFolioDTOToUserFolioDetailsEntity(userFolioDTO)); | ||
folioCounter.incrementAndGet(); | ||
int newTransactions = userFolioDTO.schemes().stream() | ||
.map(UserSchemeDTO::transactions) | ||
|
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.
Add exception handling and documentation to
findByInvestorEmailAndName
.Handling exceptions and providing documentation will improve the robustness and maintainability of this method.