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 9535bc0ec Add custom Configuration class for organisation/staff module 
(FINERACT-1932)
9535bc0ec is described below

commit 9535bc0ec5ee010694ae21ed27f40fc40c485b8b
Author: Sinha, Abhinav <[email protected]>
AuthorDate: Mon Oct 23 18:07:38 2023 -0400

    Add custom Configuration class for organisation/staff module (FINERACT-1932)
---
 .../service/StaffReadPlatformServiceImpl.java      | 14 ++-----
 ...StaffWritePlatformServiceJpaRepositoryImpl.java | 21 +++-------
 .../starter/OrganisationStaffConfiguration.java    | 49 ++++++++++++++++++++++
 3 files changed, 58 insertions(+), 26 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/service/StaffReadPlatformServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/service/StaffReadPlatformServiceImpl.java
index 8439da901..57e6ad93a 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/service/StaffReadPlatformServiceImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/service/StaffReadPlatformServiceImpl.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import lombok.RequiredArgsConstructor;
 import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
 import 
org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
 import 
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
@@ -34,26 +35,19 @@ import 
org.apache.fineract.organisation.staff.exception.StaffNotFoundException;
 import org.apache.fineract.portfolio.client.domain.ClientStatus;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
 import org.apache.fineract.portfolio.savings.domain.SavingsAccountStatusType;
-import org.springframework.beans.factory.annotation.Autowired;
 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 StaffReadPlatformServiceImpl implements StaffReadPlatformService {
 
-    private final JdbcTemplate jdbcTemplate;
     private final PlatformSecurityContext context;
+    private final JdbcTemplate jdbcTemplate;
+
     private static final StaffLookupMapper LOOKUP_MAPPER = new 
StaffLookupMapper();
     private static final StaffInOfficeHierarchyMapper 
STAFF_IN_OFFICE_HIERARCHY_MAPPER = new StaffInOfficeHierarchyMapper();
 
-    @Autowired
-    public StaffReadPlatformServiceImpl(final PlatformSecurityContext context, 
final JdbcTemplate jdbcTemplate) {
-        this.context = context;
-        this.jdbcTemplate = jdbcTemplate;
-    }
-
     private static final class StaffMapper implements RowMapper<StaffData> {
 
         public String schema() {
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java
index 36e168ce9..3985e9f8b 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java
@@ -20,6 +20,8 @@ package org.apache.fineract.organisation.staff.service;
 
 import jakarta.persistence.PersistenceException;
 import java.util.Map;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -32,31 +34,18 @@ import org.apache.fineract.organisation.staff.domain.Staff;
 import org.apache.fineract.organisation.staff.domain.StaffRepository;
 import org.apache.fineract.organisation.staff.exception.StaffNotFoundException;
 import 
org.apache.fineract.organisation.staff.serialization.StaffCommandFromApiJsonDeserializer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-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
+@Slf4j
+@RequiredArgsConstructor
 public class StaffWritePlatformServiceJpaRepositoryImpl implements 
StaffWritePlatformService {
 
-    private static final Logger LOG = 
LoggerFactory.getLogger(StaffWritePlatformServiceJpaRepositoryImpl.class);
-
     private final StaffCommandFromApiJsonDeserializer fromApiJsonDeserializer;
     private final StaffRepository staffRepository;
     private final OfficeRepositoryWrapper officeRepositoryWrapper;
 
-    @Autowired
-    public StaffWritePlatformServiceJpaRepositoryImpl(final 
StaffCommandFromApiJsonDeserializer fromApiJsonDeserializer,
-            final StaffRepository staffRepository, final 
OfficeRepositoryWrapper officeRepositoryWrapper) {
-        this.fromApiJsonDeserializer = fromApiJsonDeserializer;
-        this.staffRepository = staffRepository;
-        this.officeRepositoryWrapper = officeRepositoryWrapper;
-    }
-
     @Transactional
     @Override
     public CommandProcessingResult createStaff(final JsonCommand command) {
@@ -138,7 +127,7 @@ public class StaffWritePlatformServiceJpaRepositoryImpl 
implements StaffWritePla
                     "A staff with the given display name '" + displayName + "' 
already exists", "displayName", displayName);
         }
 
-        LOG.error("Error occured.", dve);
+        log.error("Error occured.", dve);
         throw new 
PlatformDataIntegrityException("error.msg.staff.unknown.data.integrity.issue",
                 "Unknown data integrity issue with resource: " + 
realCause.getMessage());
     }
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/starter/OrganisationStaffConfiguration.java
 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/starter/OrganisationStaffConfiguration.java
new file mode 100644
index 000000000..d037b2b34
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/starter/OrganisationStaffConfiguration.java
@@ -0,0 +1,49 @@
+/**
+ * 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.staff.starter;
+
+import 
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
+import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
+import org.apache.fineract.organisation.staff.domain.StaffRepository;
+import 
org.apache.fineract.organisation.staff.serialization.StaffCommandFromApiJsonDeserializer;
+import org.apache.fineract.organisation.staff.service.StaffReadPlatformService;
+import 
org.apache.fineract.organisation.staff.service.StaffReadPlatformServiceImpl;
+import 
org.apache.fineract.organisation.staff.service.StaffWritePlatformService;
+import 
org.apache.fineract.organisation.staff.service.StaffWritePlatformServiceJpaRepositoryImpl;
+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 OrganisationStaffConfiguration {
+
+    @Bean
+    @ConditionalOnMissingBean(StaffReadPlatformService.class)
+    public StaffReadPlatformService 
staffReadPlatformService(PlatformSecurityContext context, JdbcTemplate 
jdbcTemplate) {
+        return new StaffReadPlatformServiceImpl(context, jdbcTemplate);
+    }
+
+    @Bean
+    @ConditionalOnMissingBean(StaffWritePlatformService.class)
+    public StaffWritePlatformService 
staffWritePlatformService(StaffCommandFromApiJsonDeserializer 
fromApiJsonDeserializer,
+            StaffRepository staffRepository, OfficeRepositoryWrapper 
officeRepositoryWrapper) {
+        return new 
StaffWritePlatformServiceJpaRepositoryImpl(fromApiJsonDeserializer, 
staffRepository, officeRepositoryWrapper);
+    }
+}

Reply via email to