From 66341db853ad68f911d88ddde1bc5e6c1129b374 Mon Sep 17 00:00:00 2001 From: "Sinha, Abhinav" Date: Mon, 23 Oct 2023 18:28:20 -0400 Subject: [PATCH] Add custom Configuration class for organisation/teller module (FINERACT-1932) --- ...llerManagementReadPlatformServiceImpl.java | 2 - .../TellerWritePlatformServiceJpaImpl.java | 10 +-- .../OrganisationTellerConfiguration.java | 71 +++++++++++++++++++ 3 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/organisation/teller/starter/OrganisationTellerConfiguration.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java index 0a40087b496..4effdf9817b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java @@ -56,10 +56,8 @@ import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; -import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -@Service @RequiredArgsConstructor public class TellerManagementReadPlatformServiceImpl implements TellerManagementReadPlatformService { diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerWritePlatformServiceJpaImpl.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerWritePlatformServiceJpaImpl.java index 4a3068019d3..0150cfae71e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerWritePlatformServiceJpaImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerWritePlatformServiceJpaImpl.java @@ -22,6 +22,7 @@ import java.util.Map; import java.util.Set; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity; import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccount; @@ -53,19 +54,14 @@ import org.apache.fineract.organisation.teller.exception.CashierNotFoundException; import org.apache.fineract.organisation.teller.serialization.TellerCommandFromApiJsonDeserializer; import org.apache.fineract.useradministration.domain.AppUser; -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; @AllArgsConstructor -@Service +@Slf4j public class TellerWritePlatformServiceJpaImpl implements TellerWritePlatformService { - private static final Logger LOG = LoggerFactory.getLogger(TellerWritePlatformServiceJpaImpl.class); - private final PlatformSecurityContext context; private final TellerCommandFromApiJsonDeserializer fromApiJsonDeserializer; private final TellerRepositoryWrapper tellerRepositoryWrapper; @@ -193,7 +189,7 @@ private void handleTellerDataIntegrityIssues(final JsonCommand command, final Th "name", name); } - LOG.error("Error occured.", dve); + log.error("Error occured.", dve); throw new PlatformDataIntegrityException("error.msg.teller.unknown.data.integrity.issue", "Unknown data integrity issue with resource."); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/starter/OrganisationTellerConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/starter/OrganisationTellerConfiguration.java new file mode 100644 index 00000000000..fab742fdba6 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/starter/OrganisationTellerConfiguration.java @@ -0,0 +1,71 @@ +/** + * 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.teller.starter; + +import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper; +import org.apache.fineract.accounting.journalentry.domain.JournalEntryRepository; +import org.apache.fineract.infrastructure.core.service.PaginationHelper; +import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.apache.fineract.infrastructure.security.utils.ColumnValidator; +import org.apache.fineract.organisation.monetary.service.CurrencyReadPlatformService; +import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper; +import org.apache.fineract.organisation.office.service.OfficeReadPlatformService; +import org.apache.fineract.organisation.staff.domain.StaffRepository; +import org.apache.fineract.organisation.staff.service.StaffReadPlatformService; +import org.apache.fineract.organisation.teller.data.CashierTransactionDataValidator; +import org.apache.fineract.organisation.teller.domain.CashierRepository; +import org.apache.fineract.organisation.teller.domain.CashierTransactionRepository; +import org.apache.fineract.organisation.teller.domain.TellerRepositoryWrapper; +import org.apache.fineract.organisation.teller.serialization.TellerCommandFromApiJsonDeserializer; +import org.apache.fineract.organisation.teller.service.TellerManagementReadPlatformService; +import org.apache.fineract.organisation.teller.service.TellerManagementReadPlatformServiceImpl; +import org.apache.fineract.organisation.teller.service.TellerWritePlatformService; +import org.apache.fineract.organisation.teller.service.TellerWritePlatformServiceJpaImpl; +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 OrganisationTellerConfiguration { + + @Bean + @ConditionalOnMissingBean(TellerManagementReadPlatformService.class) + public TellerManagementReadPlatformService tellerManagementReadPlatformService(JdbcTemplate jdbcTemplate, + PlatformSecurityContext context, OfficeReadPlatformService officeReadPlatformService, + StaffReadPlatformService staffReadPlatformService, CurrencyReadPlatformService currencyReadPlatformService, + DatabaseSpecificSQLGenerator sqlGenerator, PaginationHelper paginationHelper, ColumnValidator columnValidator) { + return new TellerManagementReadPlatformServiceImpl(jdbcTemplate, context, officeReadPlatformService, staffReadPlatformService, + currencyReadPlatformService, sqlGenerator, paginationHelper, columnValidator); + } + + @Bean + @ConditionalOnMissingBean(TellerWritePlatformService.class) + public TellerWritePlatformService tellerWritePlatformService(PlatformSecurityContext context, + TellerCommandFromApiJsonDeserializer fromApiJsonDeserializer, TellerRepositoryWrapper tellerRepositoryWrapper, + OfficeRepositoryWrapper officeRepositoryWrapper, StaffRepository staffRepository, CashierRepository cashierRepository, + CashierTransactionRepository cashierTxnRepository, JournalEntryRepository glJournalEntryRepository, + FinancialActivityAccountRepositoryWrapper financialActivityAccountRepositoryWrapper, + CashierTransactionDataValidator cashierTransactionDataValidator) { + return new TellerWritePlatformServiceJpaImpl(context, fromApiJsonDeserializer, tellerRepositoryWrapper, officeRepositoryWrapper, + staffRepository, cashierRepository, cashierTxnRepository, glJournalEntryRepository, + financialActivityAccountRepositoryWrapper, cashierTransactionDataValidator); + } +}