This is an automated email from the ASF dual-hosted git repository.

aleks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new ff8a186b5 Add custom Configuration class for organisation/monetary  
module (FINERACT-1932)
ff8a186b5 is described below

commit ff8a186b5cbd6756d0602ccc2622d131e9ff3d84
Author: Sinha, Abhinav <[email protected]>
AuthorDate: Mon Oct 23 17:11:12 2023 -0400

    Add custom Configuration class for organisation/monetary  module 
(FINERACT-1932)
---
 .../service/CurrencyReadPlatformServiceImpl.java   | 16 ++----
 ...rencyWritePlatformServiceJpaRepositoryImpl.java | 20 +------
 ...rganisationCurrencyReadPlatformServiceImpl.java | 10 +---
 .../starter/OrganisationMonetaryConfiguration.java | 65 ++++++++++++++++++++++
 4 files changed, 73 insertions(+), 38 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/CurrencyReadPlatformServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/CurrencyReadPlatformServiceImpl.java
index d42db5759..26bd1e7ae 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/CurrencyReadPlatformServiceImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/CurrencyReadPlatformServiceImpl.java
@@ -21,27 +21,19 @@ package org.apache.fineract.organisation.monetary.service;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Collection;
+import lombok.RequiredArgsConstructor;
 import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
 import 
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
 import org.apache.fineract.organisation.monetary.data.CurrencyData;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
-import org.springframework.stereotype.Service;
 
-@Service
+@RequiredArgsConstructor
 public class CurrencyReadPlatformServiceImpl implements 
CurrencyReadPlatformService {
 
-    private final JdbcTemplate jdbcTemplate;
     private final PlatformSecurityContext context;
-    private final CurrencyMapper currencyRowMapper;
-
-    @Autowired
-    public CurrencyReadPlatformServiceImpl(final PlatformSecurityContext 
context, final JdbcTemplate jdbcTemplate) {
-        this.context = context;
-        this.jdbcTemplate = jdbcTemplate;
-        this.currencyRowMapper = new CurrencyMapper();
-    }
+    private final JdbcTemplate jdbcTemplate;
+    private final CurrencyMapper currencyRowMapper = new CurrencyMapper();
 
     @Override
     public Collection<CurrencyData> retrieveAllowedCurrencies() {
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java
index 1657c4757..8ae1e81b7 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java
@@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
 import java.util.List;
 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.CommandProcessingResult;
 import 
org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
@@ -37,11 +38,9 @@ import 
org.apache.fineract.organisation.office.domain.OrganisationCurrencyReposi
 import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService;
 import 
org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService;
 import 
org.apache.fineract.portfolio.savings.service.SavingsProductReadPlatformService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-@Service
+@RequiredArgsConstructor
 public class CurrencyWritePlatformServiceJpaRepositoryImpl implements 
CurrencyWritePlatformService {
 
     private final PlatformSecurityContext context;
@@ -52,21 +51,6 @@ public class CurrencyWritePlatformServiceJpaRepositoryImpl 
implements CurrencyWr
     private final SavingsProductReadPlatformService savingsProductService;
     private final ChargeReadPlatformService chargeService;
 
-    @Autowired
-    public CurrencyWritePlatformServiceJpaRepositoryImpl(final 
PlatformSecurityContext context,
-            final CurrencyCommandFromApiJsonDeserializer 
fromApiJsonDeserializer,
-            final ApplicationCurrencyRepositoryWrapper 
applicationCurrencyRepository,
-            final OrganisationCurrencyRepository 
organisationCurrencyRepository, final LoanProductReadPlatformService 
loanProductService,
-            final SavingsProductReadPlatformService savingsProductService, 
final ChargeReadPlatformService chargeService) {
-        this.context = context;
-        this.fromApiJsonDeserializer = fromApiJsonDeserializer;
-        this.applicationCurrencyRepository = applicationCurrencyRepository;
-        this.organisationCurrencyRepository = organisationCurrencyRepository;
-        this.loanProductService = loanProductService;
-        this.savingsProductService = savingsProductService;
-        this.chargeService = chargeService;
-    }
-
     @Transactional
     @Override
     public CommandProcessingResult updateAllowedCurrencies(final JsonCommand 
command) {
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/OrganisationCurrencyReadPlatformServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/OrganisationCurrencyReadPlatformServiceImpl.java
index 9135c11f7..ee756d2b6 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/OrganisationCurrencyReadPlatformServiceImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/service/OrganisationCurrencyReadPlatformServiceImpl.java
@@ -19,21 +19,15 @@
 package org.apache.fineract.organisation.monetary.service;
 
 import java.util.Collection;
+import lombok.RequiredArgsConstructor;
 import 
org.apache.fineract.organisation.monetary.data.ApplicationCurrencyConfigurationData;
 import org.apache.fineract.organisation.monetary.data.CurrencyData;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 
-@Service
+@RequiredArgsConstructor
 public class OrganisationCurrencyReadPlatformServiceImpl implements 
OrganisationCurrencyReadPlatformService {
 
     private final CurrencyReadPlatformService currencyReadPlatformService;
 
-    @Autowired
-    public OrganisationCurrencyReadPlatformServiceImpl(final 
CurrencyReadPlatformService currencyReadPlatformService) {
-        this.currencyReadPlatformService = currencyReadPlatformService;
-    }
-
     @Override
     public ApplicationCurrencyConfigurationData 
retrieveCurrencyConfiguration() {
 
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/starter/OrganisationMonetaryConfiguration.java
 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/starter/OrganisationMonetaryConfiguration.java
new file mode 100644
index 000000000..cc5e62197
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/monetary/starter/OrganisationMonetaryConfiguration.java
@@ -0,0 +1,65 @@
+/**
+ * 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.organisation.monetary.starter;
+
+import 
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
+import 
org.apache.fineract.organisation.monetary.domain.ApplicationCurrencyRepositoryWrapper;
+import 
org.apache.fineract.organisation.monetary.serialization.CurrencyCommandFromApiJsonDeserializer;
+import 
org.apache.fineract.organisation.monetary.service.CurrencyReadPlatformService;
+import 
org.apache.fineract.organisation.monetary.service.CurrencyReadPlatformServiceImpl;
+import 
org.apache.fineract.organisation.monetary.service.CurrencyWritePlatformService;
+import 
org.apache.fineract.organisation.monetary.service.CurrencyWritePlatformServiceJpaRepositoryImpl;
+import 
org.apache.fineract.organisation.monetary.service.OrganisationCurrencyReadPlatformService;
+import 
org.apache.fineract.organisation.monetary.service.OrganisationCurrencyReadPlatformServiceImpl;
+import 
org.apache.fineract.organisation.office.domain.OrganisationCurrencyRepository;
+import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService;
+import 
org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService;
+import 
org.apache.fineract.portfolio.savings.service.SavingsProductReadPlatformService;
+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 OrganisationMonetaryConfiguration {
+
+    @Bean
+    @ConditionalOnMissingBean(CurrencyReadPlatformService.class)
+    public CurrencyReadPlatformService 
currencyReadPlatformService(PlatformSecurityContext context, JdbcTemplate 
jdbcTemplate) {
+        return new CurrencyReadPlatformServiceImpl(context, jdbcTemplate);
+    }
+
+    @Bean
+    @ConditionalOnMissingBean(CurrencyWritePlatformService.class)
+    public CurrencyWritePlatformService 
currencyWritePlatformService(PlatformSecurityContext context,
+            ApplicationCurrencyRepositoryWrapper applicationCurrencyRepository,
+            OrganisationCurrencyRepository organisationCurrencyRepository, 
CurrencyCommandFromApiJsonDeserializer fromApiJsonDeserializer,
+            LoanProductReadPlatformService loanProductService, 
SavingsProductReadPlatformService savingsProductService,
+            ChargeReadPlatformService chargeService) {
+        return new CurrencyWritePlatformServiceJpaRepositoryImpl(context, 
applicationCurrencyRepository, organisationCurrencyRepository,
+                fromApiJsonDeserializer, loanProductService, 
savingsProductService, chargeService);
+    }
+
+    @Bean
+    @ConditionalOnMissingBean(OrganisationCurrencyReadPlatformService.class)
+    public OrganisationCurrencyReadPlatformService 
organisationCurrencyReadPlatformService(
+            CurrencyReadPlatformService currencyReadPlatformService) {
+        return new 
OrganisationCurrencyReadPlatformServiceImpl(currencyReadPlatformService);
+    }
+}

Reply via email to