Skip to content

Commit

Permalink
FINERACT-1932: Add starter Configuration class for portfolio.interest…
Browse files Browse the repository at this point in the history
…ratechart module
  • Loading branch information
mmagdiab authored and galovics committed Oct 30, 2023
1 parent 0abb60c commit 245c00b
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,20 @@
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.interestratechart.domain.InterestIncentives;
import org.apache.fineract.portfolio.interestratechart.domain.InterestIncentivesFields;
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlab;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class InterestIncentiveAssembler {

private final FromJsonHelper fromApiJsonHelper;

@Autowired
public InterestIncentiveAssembler(final FromJsonHelper fromApiJsonHelper) {
this.fromApiJsonHelper = fromApiJsonHelper;
}

public Collection<InterestIncentives> assembleIncentivesFrom(final JsonElement element, InterestRateChartSlab interestRateChartSlab,
final Locale locale) {
final Collection<InterestIncentives> interestIncentivesSet = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
package org.apache.fineract.portfolio.interestratechart.service;

import java.util.Collection;
import lombok.NoArgsConstructor;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.portfolio.common.domain.ConditionType;
import org.apache.fineract.portfolio.common.service.CommonEnumerations;
import org.apache.fineract.portfolio.interestratechart.incentive.InterestIncentiveAttributeName;
import org.apache.fineract.portfolio.interestratechart.incentive.InterestIncentiveEntityType;
import org.apache.fineract.portfolio.interestratechart.incentive.InterestIncentiveType;
import org.springframework.stereotype.Service;

@Service
@NoArgsConstructor
public class InterestIncentivesDropdownReadPlatformServiceImpl implements InterestIncentiveDropdownReadPlatformService {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
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.DataValidatorBuilder;
Expand All @@ -40,25 +41,14 @@
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartFields;
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartRepositoryWrapper;
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlab;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class InterestRateChartAssembler {

private final FromJsonHelper fromApiJsonHelper;
private final InterestRateChartRepositoryWrapper interestRateChartRepositoryWrapper;
private final InterestRateChartSlabAssembler chartSlabAssembler;

@Autowired
public InterestRateChartAssembler(final FromJsonHelper fromApiJsonHelper,
final InterestRateChartRepositoryWrapper interestRateChartRepositoryWrapper,
final InterestRateChartSlabAssembler chartSlabAssembler) {
this.fromApiJsonHelper = fromApiJsonHelper;
this.interestRateChartRepositoryWrapper = interestRateChartRepositoryWrapper;
this.chartSlabAssembler = chartSlabAssembler;
}

/**
* Assembles a new {@link InterestRateChart} from JSON Slabs passed in request
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
package org.apache.fineract.portfolio.interestratechart.service;

import java.util.Collection;
import lombok.NoArgsConstructor;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.springframework.stereotype.Service;

@Service
@NoArgsConstructor
public class InterestRateChartDropdownReadPlatformServiceImpl implements InterestRateChartDropdownReadPlatformService {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@
import org.apache.fineract.portfolio.interestratechart.exception.InterestRateChartNotFoundException;
import org.apache.fineract.portfolio.interestratechart.incentive.InterestIncentiveAttributeName;
import org.apache.fineract.portfolio.savings.data.DepositProductData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

@Service
public class InterestRateChartReadPlatformServiceImpl implements InterestRateChartReadPlatformService {

private final PlatformSecurityContext context;
Expand All @@ -59,7 +56,6 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
private final InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService;
private final CodeValueReadPlatformService codeValueReadPlatformService;

@Autowired
public InterestRateChartReadPlatformServiceImpl(PlatformSecurityContext context, final JdbcTemplate jdbcTemplate,
InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService,
final InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
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.DataValidatorBuilder;
Expand All @@ -49,25 +50,14 @@
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabFields;
import org.apache.fineract.portfolio.interestratechart.exception.InterestRateChartSlabNotFoundException;
import org.apache.fineract.portfolio.savings.SavingsPeriodFrequencyType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class InterestRateChartSlabAssembler {

private final FromJsonHelper fromApiJsonHelper;
private final InterestRateChartRepositoryWrapper interestRateChartRepositoryWrapper;
private final InterestIncentiveAssembler incentiveAssembler;

@Autowired
public InterestRateChartSlabAssembler(final FromJsonHelper fromApiJsonHelper,
final InterestRateChartRepositoryWrapper interestRateChartRepositoryWrapper,
final InterestIncentiveAssembler incentiveAssembler) {
this.fromApiJsonHelper = fromApiJsonHelper;
this.interestRateChartRepositoryWrapper = interestRateChartRepositoryWrapper;
this.incentiveAssembler = incentiveAssembler;
}

/**
* Assembles a new {@link InterestRateChartSlab} from JSON Slabs passed in request
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
Expand All @@ -37,14 +38,13 @@
import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabData;
import org.apache.fineract.portfolio.interestratechart.exception.InterestRateChartSlabNotFoundException;
import org.apache.fineract.portfolio.interestratechart.incentive.InterestIncentiveAttributeName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor

public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRateChartSlabReadPlatformService {

private final PlatformSecurityContext context;
Expand All @@ -53,21 +53,6 @@ public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRat
private final InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService;
private final InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService;
private final CodeValueReadPlatformService codeValueReadPlatformService;
private final DatabaseSpecificSQLGenerator sqlGenerator;

@Autowired
public InterestRateChartSlabReadPlatformServiceImpl(PlatformSecurityContext context, final JdbcTemplate jdbcTemplate,
InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService,
final InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService,
final CodeValueReadPlatformService codeValueReadPlatformService, DatabaseSpecificSQLGenerator sqlGenerator) {
this.context = context;
this.jdbcTemplate = jdbcTemplate;
this.chartDropdownReadPlatformService = chartDropdownReadPlatformService;
this.interestIncentiveDropdownReadPlatformService = interestIncentiveDropdownReadPlatformService;
this.codeValueReadPlatformService = codeValueReadPlatformService;
this.sqlGenerator = sqlGenerator;
chartSlabExtractor = new InterestRateChartSlabExtractor(sqlGenerator);
}

@Override
public Collection<InterestRateChartSlabData> retrieveAll(Long chartId) {
Expand Down Expand Up @@ -187,7 +172,7 @@ public InterestRateChartSlabData mapRow(ResultSet rs, @SuppressWarnings("unused"

}

private static final class InterestRateChartSlabExtractor implements ResultSetExtractor<Collection<InterestRateChartSlabData>> {
public static final class InterestRateChartSlabExtractor implements ResultSetExtractor<Collection<InterestRateChartSlabData>> {

InterestRateChartSlabsMapper chartSlabsMapper;
InterestIncentiveMapper incentiveMapper = new InterestIncentiveMapper();
Expand All @@ -198,7 +183,7 @@ public String schema() {
return this.schemaSql;
}

private InterestRateChartSlabExtractor(DatabaseSpecificSQLGenerator sqlGenerator) {
public InterestRateChartSlabExtractor(DatabaseSpecificSQLGenerator sqlGenerator) {
chartSlabsMapper = new InterestRateChartSlabsMapper(sqlGenerator);
this.schemaSql = chartSlabsMapper.schema();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
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;
Expand All @@ -30,17 +31,11 @@
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlab;
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabRepository;
import org.apache.fineract.portfolio.savings.domain.SavingsProductRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl implements InterestRateChartSlabWritePlatformService {

@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl.class);
@SuppressWarnings("unused")
private final PlatformSecurityContext context;
private final InterestRateChartSlabDataValidator interestRateChartSlabDataValidator;
Expand All @@ -53,22 +48,6 @@ public class InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl implemen
@SuppressWarnings("unused")
private final SavingsProductRepository savingsProductRepository;

@Autowired
public InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl(PlatformSecurityContext context,
final InterestRateChartSlabDataValidator interestRateChartSlabDataValidator,
final InterestRateChartAssembler interestRateChartAssembler,
final InterestRateChartRepositoryWrapper interestRateChartRepository, final SavingsProductRepository savingsProductRepository,
final InterestRateChartSlabRepository chartSlabRepository,
final InterestRateChartSlabAssembler interestRateChartSlabAssembler) {
this.context = context;
this.interestRateChartSlabDataValidator = interestRateChartSlabDataValidator;
this.interestRateChartAssembler = interestRateChartAssembler;
this.interestRateChartRepository = interestRateChartRepository;
this.savingsProductRepository = savingsProductRepository;
this.chartSlabRepository = chartSlabRepository;
this.interestRateChartSlabAssembler = interestRateChartSlabAssembler;
}

@Override
@Transactional
public CommandProcessingResult create(JsonCommand command) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,25 @@

import java.util.LinkedHashMap;
import java.util.Map;
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;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDataValidator;
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChart;
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartRepositoryWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class InterestRateChartWritePlatformServiceJpaRepositoryImpl implements InterestRateChartWritePlatformService {

@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(InterestRateChartWritePlatformServiceJpaRepositoryImpl.class);
@SuppressWarnings("unused")
private final PlatformSecurityContext context;
private final InterestRateChartDataValidator interestRateChartDataValidator;
private final InterestRateChartAssembler interestRateChartAssembler;
private final InterestRateChartRepositoryWrapper interestRateChartRepository;

@Autowired
public InterestRateChartWritePlatformServiceJpaRepositoryImpl(PlatformSecurityContext context,
final InterestRateChartDataValidator interestRateChartDataValidator,
final InterestRateChartAssembler interestRateChartAssembler,
final InterestRateChartRepositoryWrapper interestRateChartRepository) {
this.context = context;
this.interestRateChartDataValidator = interestRateChartDataValidator;
this.interestRateChartAssembler = interestRateChartAssembler;
this.interestRateChartRepository = interestRateChartRepository;
}

@Override
@Transactional
public CommandProcessingResult create(JsonCommand command) {
Expand Down
Loading

0 comments on commit 245c00b

Please sign in to comment.