From 01e68e34ceda9fbc19c68854ce2563cfc0c00277 Mon Sep 17 00:00:00 2001 From: Mohamed Magdi-Abdelmonem Date: Sun, 1 Oct 2023 21:17:56 +0300 Subject: [PATCH] FINERACT-1932: Add starter configuration class for portfolio.repaymentwithpostdatedchecks module --- ...RepaymentWithPostDatedChecksAssembler.java | 10 +--- ...ostDatedChecksReadPlatformServiceImpl.java | 14 +---- ...stDatedChecksWritePlatformServiceImpl.java | 13 +---- ...ymentWithPostDatedChecksConfiguration.java | 58 +++++++++++++++++++ 4 files changed, 64 insertions(+), 31 deletions(-) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/starter/RepaymentWithPostDatedChecksConfiguration.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksAssembler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksAssembler.java index 8282ce987..002e21c8c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksAssembler.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksAssembler.java @@ -27,23 +27,17 @@ import java.util.List; import java.util.Locale; import java.util.Set; import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -@Service +@RequiredArgsConstructor public class RepaymentWithPostDatedChecksAssembler { private final FromJsonHelper fromApiJsonHelper; - @Autowired - public RepaymentWithPostDatedChecksAssembler(final FromJsonHelper fromJsonHelper) { - this.fromApiJsonHelper = fromJsonHelper; - } - public Set fromParsedJson(final String json, final Loan loan) { final Set postDatedChecks = new HashSet<>(); final JsonElement jsonElement = this.fromApiJsonHelper.parse(json); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksReadPlatformServiceImpl.java index b3f160720..e2995f600 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksReadPlatformServiceImpl.java @@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallmentRepository; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository; @@ -30,11 +31,9 @@ import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.data.PostDated import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecksRepository; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.exception.PostDatedCheckNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -@Service +@RequiredArgsConstructor @Transactional(readOnly = true) public class RepaymentWithPostDatedChecksReadPlatformServiceImpl implements RepaymentWithPostDatedChecksReadPlatformService { @@ -42,15 +41,6 @@ public class RepaymentWithPostDatedChecksReadPlatformServiceImpl implements Repa private final LoanRepository loanRepository; private final LoanRepaymentScheduleInstallmentRepository loanRepaymentScheduleInstallmentRepository; - @Autowired - public RepaymentWithPostDatedChecksReadPlatformServiceImpl(final PostDatedChecksRepository postDatedChecksRepository, - final LoanRepository loanRepository, - final LoanRepaymentScheduleInstallmentRepository loanRepaymentScheduleInstallmentRepository) { - this.postDatedChecksRepository = postDatedChecksRepository; - this.loanRepository = loanRepository; - this.loanRepaymentScheduleInstallmentRepository = loanRepaymentScheduleInstallmentRepository; - } - @Override public List getPostDatedChecks(final Long id) { final Loan loan = this.loanRepository.findById(id).orElseThrow(() -> new LoanNotFoundException(id)); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksWritePlatformServiceImpl.java index 5c26cbe7e..6b778f022 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/service/RepaymentWithPostDatedChecksWritePlatformServiceImpl.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; +import lombok.RequiredArgsConstructor; import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; @@ -45,13 +46,11 @@ import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.data.PostDated import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecksRepository; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.exception.PostDatedCheckNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -@Service +@RequiredArgsConstructor public class RepaymentWithPostDatedChecksWritePlatformServiceImpl implements RepaymentWithPostDatedChecksWritePlatformService { public static final String NAME = "name"; @@ -71,14 +70,6 @@ public class RepaymentWithPostDatedChecksWritePlatformServiceImpl implements Rep private final FromJsonHelper fromApiJsonHelper; private final LoanRepository loanRepository; - @Autowired - public RepaymentWithPostDatedChecksWritePlatformServiceImpl(final PostDatedChecksRepository postDatedChecksRepository, - final FromJsonHelper fromApiJsonHelper, final LoanRepository loanRepository) { - this.postDatedChecksRepository = postDatedChecksRepository; - this.fromApiJsonHelper = fromApiJsonHelper; - this.loanRepository = loanRepository; - } - @Transactional @Override public CommandProcessingResult updatePostDatedChecks(JsonCommand command) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/starter/RepaymentWithPostDatedChecksConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/starter/RepaymentWithPostDatedChecksConfiguration.java new file mode 100644 index 000000000..de3594c4d --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/repaymentwithpostdatedchecks/starter/RepaymentWithPostDatedChecksConfiguration.java @@ -0,0 +1,58 @@ +/** + * 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.repaymentwithpostdatedchecks.starter; + +import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; +import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallmentRepository; +import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository; +import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecksRepository; +import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksAssembler; +import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksReadPlatformService; +import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksReadPlatformServiceImpl; +import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksWritePlatformService; +import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksWritePlatformServiceImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RepaymentWithPostDatedChecksConfiguration { + + @Bean + @ConditionalOnMissingBean(RepaymentWithPostDatedChecksAssembler.class) + public RepaymentWithPostDatedChecksAssembler repaymentWithPostDatedChecksAssembler(FromJsonHelper fromJsonHelper) { + return new RepaymentWithPostDatedChecksAssembler(fromJsonHelper); + } + + @Bean + @ConditionalOnMissingBean(RepaymentWithPostDatedChecksReadPlatformService.class) + public RepaymentWithPostDatedChecksReadPlatformService repaymentWithPostDatedChecksReadPlatformService( + PostDatedChecksRepository postDatedChecksRepository, LoanRepository loanRepository, + LoanRepaymentScheduleInstallmentRepository loanRepaymentScheduleInstallmentRepository) { + return new RepaymentWithPostDatedChecksReadPlatformServiceImpl(postDatedChecksRepository, loanRepository, + loanRepaymentScheduleInstallmentRepository); + } + + @Bean + @ConditionalOnMissingBean(RepaymentWithPostDatedChecksWritePlatformService.class) + public RepaymentWithPostDatedChecksWritePlatformService repaymentWithPostDatedChecksWritePlatformService( + PostDatedChecksRepository postDatedChecksRepository, FromJsonHelper fromApiJsonHelper, LoanRepository loanRepository) { + return new RepaymentWithPostDatedChecksWritePlatformServiceImpl(postDatedChecksRepository, fromApiJsonHelper, loanRepository); + } +}