FINERACT-2181: No need for explicit serialization

This commit is contained in:
Adam Saghy
2025-06-04 21:24:21 +02:00
parent 83905d627d
commit 6e5c6c4913
4 changed files with 9 additions and 11 deletions
@@ -61,8 +61,8 @@ public class EmbeddableProgressiveLoanScheduleGenerator {
} }
@Override @Override
public String writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model) { public ProgressiveLoanInterestScheduleModel writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model) {
return ""; return null;
} }
@Override @Override
@@ -31,7 +31,7 @@ public interface InterestScheduleModelRepositoryWrapper {
Optional<ProgressiveLoanInterestScheduleModel> extractModel(Optional<ProgressiveLoanModel> progressiveLoanModel); Optional<ProgressiveLoanInterestScheduleModel> extractModel(Optional<ProgressiveLoanModel> progressiveLoanModel);
String writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model); ProgressiveLoanInterestScheduleModel writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model);
Optional<ProgressiveLoanInterestScheduleModel> readProgressiveLoanInterestScheduleModel(Long loanId, Optional<ProgressiveLoanInterestScheduleModel> readProgressiveLoanInterestScheduleModel(Long loanId,
LoanProductMinimumRepaymentScheduleRelatedDetail detail, Integer installmentAmountInMultipliesOf); LoanProductMinimumRepaymentScheduleRelatedDetail detail, Integer installmentAmountInMultipliesOf);
@@ -50,7 +50,7 @@ public class InterestScheduleModelRepositoryWrapperImpl implements InterestSched
@Transactional @Transactional
@Override @Override
public String writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model) { public ProgressiveLoanInterestScheduleModel writeInterestScheduleModel(Loan loan, ProgressiveLoanInterestScheduleModel model) {
if (model == null) { if (model == null) {
return null; return null;
} }
@@ -66,7 +66,7 @@ public class InterestScheduleModelRepositoryWrapperImpl implements InterestSched
progressiveLoanModel.setJsonModel(jsonModel); progressiveLoanModel.setJsonModel(jsonModel);
loanModelRepository.save(progressiveLoanModel); loanModelRepository.save(progressiveLoanModel);
}); });
return jsonModel; return model;
} }
@Override @Override
@@ -76,16 +76,14 @@ public class InternalProgressiveLoanApiResource implements InitializingBean {
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
@Path("{loanId}/model") @Path("{loanId}/model")
@Operation(summary = "Fetch ProgressiveLoanInterestScheduleModel", description = "DO NOT USE THIS IN PRODUCTION!") @Operation(summary = "Fetch ProgressiveLoanInterestScheduleModel", description = "DO NOT USE THIS IN PRODUCTION!")
public String fetchModel(@PathParam("loanId") @Parameter(description = "loanId") long loanId) { public ProgressiveLoanInterestScheduleModel fetchModel(@PathParam("loanId") @Parameter(description = "loanId") long loanId) {
Loan loan = loanRepository.findOneWithNotFoundDetection(loanId); Loan loan = loanRepository.findOneWithNotFoundDetection(loanId);
if (!loan.isProgressiveSchedule()) { if (!loan.isProgressiveSchedule()) {
throw new IllegalArgumentException("The loan is not progressive."); throw new IllegalArgumentException("The loan is not progressive.");
} }
return writePlatformService return writePlatformService.readProgressiveLoanInterestScheduleModel(loanId, loan.getLoanRepaymentScheduleDetail(),
.readProgressiveLoanInterestScheduleModel(loanId, loan.getLoanRepaymentScheduleDetail(), loan.getLoanProduct().getInstallmentAmountInMultiplesOf()).orElse(null);
loan.getLoanProduct().getInstallmentAmountInMultiplesOf())
.map(progressiveLoanInterestScheduleModelParserService::toJson).orElse(null);
} }
private ProgressiveLoanInterestScheduleModel reprocessTransactionsAndGetModel(final Loan loan) { private ProgressiveLoanInterestScheduleModel reprocessTransactionsAndGetModel(final Loan loan) {
@@ -110,7 +108,7 @@ public class InternalProgressiveLoanApiResource implements InitializingBean {
@Path("{loanId}/model") @Path("{loanId}/model")
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Update and Save ProgressiveLoanInterestScheduleModel", description = "DO NOT USE THIS IN PRODUCTION!") @Operation(summary = "Update and Save ProgressiveLoanInterestScheduleModel", description = "DO NOT USE THIS IN PRODUCTION!")
public String updateModel(@PathParam("loanId") @Parameter(description = "loanId") long loanId) { public ProgressiveLoanInterestScheduleModel updateModel(@PathParam("loanId") @Parameter(description = "loanId") long loanId) {
Loan loan = loanRepository.findOneWithNotFoundDetection(loanId); Loan loan = loanRepository.findOneWithNotFoundDetection(loanId);
if (!loan.isProgressiveSchedule()) { if (!loan.isProgressiveSchedule()) {
throw new IllegalArgumentException("The loan is not progressive."); throw new IllegalArgumentException("The loan is not progressive.");