From 3aac1339e931882b8115f157be4a9fcd092fd0c7 Mon Sep 17 00:00:00 2001 From: Mohamed Magdi-Abdelmonem Date: Sat, 7 Oct 2023 18:56:08 +0300 Subject: [PATCH] FINERACT-1932: Add stater configuration class for portfolio.loadproduct module services --- .../LoanDropdownReadPlatformServiceImpl.java | 2 - .../LoanProductReadPlatformServiceImpl.java | 2 - ...WritePlatformServiceJpaRepositoryImpl.java | 9 +- .../starter/LoanProductConfiguration.java | 87 +++++++++++++++++++ 4 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/starter/LoanProductConfiguration.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java index a1fa9f192..5dc8f59e6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java @@ -54,9 +54,7 @@ import org.apache.fineract.portfolio.loanproduct.domain.LoanProductValueConditio import org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMethod; import org.apache.fineract.portfolio.loanproduct.domain.RecalculationFrequencyType; import org.apache.fineract.portfolio.loanproduct.domain.RepaymentStartDateType; -import org.springframework.stereotype.Service; -@Service @RequiredArgsConstructor public class LoanDropdownReadPlatformServiceImpl implements LoanDropdownReadPlatformService { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java index a4f990b27..718a615e3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java @@ -60,9 +60,7 @@ import org.jetbrains.annotations.NotNull; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; -import org.springframework.stereotype.Service; -@Service @RequiredArgsConstructor public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatformService { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java index 35ea15ee9..978b3eb91 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.fineract.accounting.producttoaccountmapping.service.ProductToGLAccountMappingWritePlatformService; import org.apache.fineract.infrastructure.core.api.JsonCommand; @@ -61,18 +62,14 @@ import org.apache.fineract.portfolio.loanproduct.exception.LoanProductNotFoundEx import org.apache.fineract.portfolio.loanproduct.serialization.LoanProductDataValidator; import org.apache.fineract.portfolio.rate.domain.Rate; import org.apache.fineract.portfolio.rate.domain.RateRepositoryWrapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -@Service +@Slf4j @RequiredArgsConstructor public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanProductWritePlatformService { - private static final Logger LOG = LoggerFactory.getLogger(LoanProductWritePlatformServiceJpaRepositoryImpl.class); private final PlatformSecurityContext context; private final LoanProductDataValidator fromApiJsonDeserializer; private final LoanProductRepository loanProductRepository; @@ -380,6 +377,6 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro } private void logAsErrorUnexpectedDataIntegrityException(final Exception dve) { - LOG.error("Error occurred.", dve); + log.error("Error occurred.", dve); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/starter/LoanProductConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/starter/LoanProductConfiguration.java new file mode 100644 index 000000000..e1e465e16 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/starter/LoanProductConfiguration.java @@ -0,0 +1,87 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.loanproduct.starter; + +import org.apache.fineract.accounting.producttoaccountmapping.service.ProductToGLAccountMappingWritePlatformService; +import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator; +import org.apache.fineract.infrastructure.entityaccess.service.FineractEntityAccessUtil; +import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper; +import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; +import org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucketRepository; +import org.apache.fineract.portfolio.delinquency.service.DelinquencyReadPlatformService; +import org.apache.fineract.portfolio.floatingrates.domain.FloatingRateRepositoryWrapper; +import org.apache.fineract.portfolio.fund.domain.FundRepository; +import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleTransactionProcessorFactory; +import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper; +import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.AprCalculator; +import org.apache.fineract.portfolio.loanproduct.domain.AdvancedPaymentAllocationsJsonParser; +import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository; +import org.apache.fineract.portfolio.loanproduct.serialization.LoanProductDataValidator; +import org.apache.fineract.portfolio.loanproduct.service.LoanDropdownReadPlatformService; +import org.apache.fineract.portfolio.loanproduct.service.LoanDropdownReadPlatformServiceImpl; +import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService; +import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformServiceImpl; +import org.apache.fineract.portfolio.loanproduct.service.LoanProductWritePlatformService; +import org.apache.fineract.portfolio.loanproduct.service.LoanProductWritePlatformServiceJpaRepositoryImpl; +import org.apache.fineract.portfolio.rate.domain.RateRepositoryWrapper; +import org.apache.fineract.portfolio.rate.service.RateReadService; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.core.JdbcTemplate; + +@Configuration +public class LoanProductConfiguration { + + @Bean + @ConditionalOnMissingBean(LoanDropdownReadPlatformService.class) + public LoanDropdownReadPlatformService loanDropdownReadPlatformService( + LoanRepaymentScheduleTransactionProcessorFactory loanRepaymentScheduleTransactionProcessorFactory) { + return new LoanDropdownReadPlatformServiceImpl(loanRepaymentScheduleTransactionProcessorFactory); + } + + @Bean + @ConditionalOnMissingBean(LoanProductReadPlatformService.class) + public LoanProductReadPlatformService loanProductReadPlatformService(PlatformSecurityContext context, JdbcTemplate jdbcTemplate, + ChargeReadPlatformService chargeReadPlatformService, RateReadService rateReadService, DatabaseSpecificSQLGenerator sqlGenerator, + FineractEntityAccessUtil fineractEntityAccessUtil, DelinquencyReadPlatformService delinquencyReadPlatformService, + LoanProductRepository loanProductRepository) { + return new LoanProductReadPlatformServiceImpl(context, jdbcTemplate, chargeReadPlatformService, rateReadService, sqlGenerator, + fineractEntityAccessUtil, delinquencyReadPlatformService, loanProductRepository); + } + + @Bean + @ConditionalOnMissingBean(LoanProductWritePlatformService.class) + public LoanProductWritePlatformService loanProductWritePlatformService(PlatformSecurityContext context, + LoanProductDataValidator fromApiJsonDeserializer, LoanProductRepository loanProductRepository, AprCalculator aprCalculator, + FundRepository fundRepository, ChargeRepositoryWrapper chargeRepository, RateRepositoryWrapper rateRepository, + ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService, + FineractEntityAccessUtil fineractEntityAccessUtil, FloatingRateRepositoryWrapper floatingRateRepository, + LoanRepositoryWrapper loanRepositoryWrapper, BusinessEventNotifierService businessEventNotifierService, + DelinquencyBucketRepository delinquencyBucketRepository, + LoanRepaymentScheduleTransactionProcessorFactory loanRepaymentScheduleTransactionProcessorFactory, + AdvancedPaymentAllocationsJsonParser advancedPaymentJsonParser) { + return new LoanProductWritePlatformServiceJpaRepositoryImpl(context, fromApiJsonDeserializer, loanProductRepository, aprCalculator, + fundRepository, chargeRepository, rateRepository, accountMappingWritePlatformService, fineractEntityAccessUtil, + floatingRateRepository, loanRepositoryWrapper, businessEventNotifierService, delinquencyBucketRepository, + loanRepaymentScheduleTransactionProcessorFactory, advancedPaymentJsonParser); + } +}