Add custom Configuration class for floatingrates module (FINERACT-1932)
This commit is contained in:
committed by
Arnold Gálovics
parent
01e68e34ce
commit
e41d7635e0
+5
-14
@@ -20,6 +20,8 @@ package org.apache.fineract.portfolio.floatingrates.service;
|
||||
|
||||
import jakarta.persistence.PersistenceException;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
@@ -28,28 +30,17 @@ import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityEx
|
||||
import org.apache.fineract.portfolio.floatingrates.domain.FloatingRate;
|
||||
import org.apache.fineract.portfolio.floatingrates.domain.FloatingRateRepositoryWrapper;
|
||||
import org.apache.fineract.portfolio.floatingrates.serialization.FloatingRateDataValidator;
|
||||
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
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class FloatingRateWritePlatformServiceImpl implements FloatingRateWritePlatformService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FloatingRateWritePlatformServiceImpl.class);
|
||||
private final FloatingRateDataValidator fromApiJsonDeserializer;
|
||||
private final FloatingRateRepositoryWrapper floatingRateRepository;
|
||||
|
||||
@Autowired
|
||||
public FloatingRateWritePlatformServiceImpl(final FloatingRateDataValidator fromApiJsonDeserializer,
|
||||
final FloatingRateRepositoryWrapper floatingRateRepository) {
|
||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||
this.floatingRateRepository = floatingRateRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult createFloatingRate(final JsonCommand command) {
|
||||
@@ -118,7 +109,7 @@ public class FloatingRateWritePlatformServiceImpl implements FloatingRateWritePl
|
||||
}
|
||||
|
||||
private void logAsErrorUnexpectedDataIntegrityException(Exception dve) {
|
||||
LOG.error("Error occured.", dve);
|
||||
log.error("Error occured.", dve);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-8
@@ -25,27 +25,21 @@ import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
|
||||
import org.apache.fineract.portfolio.floatingrates.data.FloatingRateData;
|
||||
import org.apache.fineract.portfolio.floatingrates.data.FloatingRatePeriodData;
|
||||
import org.apache.fineract.portfolio.floatingrates.data.InterestRatePeriodData;
|
||||
import org.apache.fineract.portfolio.floatingrates.exception.FloatingRateNotFoundException;
|
||||
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 FloatingRatesReadPlatformServiceImpl implements FloatingRatesReadPlatformService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public FloatingRatesReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FloatingRateData> retrieveAll() {
|
||||
FloatingRateRowMapper rateMapper = new FloatingRateRowMapper(false);
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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.floatingrates.starter;
|
||||
|
||||
import org.apache.fineract.portfolio.floatingrates.domain.FloatingRateRepositoryWrapper;
|
||||
import org.apache.fineract.portfolio.floatingrates.serialization.FloatingRateDataValidator;
|
||||
import org.apache.fineract.portfolio.floatingrates.service.FloatingRateWritePlatformService;
|
||||
import org.apache.fineract.portfolio.floatingrates.service.FloatingRateWritePlatformServiceImpl;
|
||||
import org.apache.fineract.portfolio.floatingrates.service.FloatingRatesReadPlatformService;
|
||||
import org.apache.fineract.portfolio.floatingrates.service.FloatingRatesReadPlatformServiceImpl;
|
||||
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 FloatingRatesConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(FloatingRatesReadPlatformService.class)
|
||||
public FloatingRatesReadPlatformService floatingRatesReadPlatformService(JdbcTemplate jdbcTemplate) {
|
||||
return new FloatingRatesReadPlatformServiceImpl(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(FloatingRateWritePlatformService.class)
|
||||
public FloatingRateWritePlatformService floatingRateWritePlatformService(FloatingRateDataValidator fromApiJsonDeserializer,
|
||||
FloatingRateRepositoryWrapper floatingRateRepository) {
|
||||
return new FloatingRateWritePlatformServiceImpl(fromApiJsonDeserializer, floatingRateRepository);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user