FINERACT-1483: fix //NOSONAR positions

This commit is contained in:
taskain7
2022-04-27 16:18:47 +02:00
committed by Arnold Gálovics
parent 56d14a1d69
commit 136ef55519
23 changed files with 114 additions and 244 deletions
@@ -111,8 +111,8 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where entry_date < ? group by account_id) je3 ON je.entry_date = je3.date " + "inner join (select max(entry_date) as date from acc_gl_journal_entry where entry_date < ? group by account_id) je3 ON je.entry_date = je3.date "
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0); + "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
List<Map<String, Object>> list = jdbcTemplate.queryForList(organizationRunningBalanceQuery, List<Map<String, Object>> list = jdbcTemplate.queryForList(organizationRunningBalanceQuery, // NOSONAR
new Object[] { entityDate, entityDate }); // NOSONAR new Object[] { entityDate, entityDate });
for (Map<String, Object> entries : list) { for (Map<String, Object> entries : list) {
Long accountId = Long.parseLong(entries.get("accountId").toString()); // Drizzle Long accountId = Long.parseLong(entries.get("accountId").toString()); // Drizzle
@@ -136,8 +136,8 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where entry_date < ? group by office_id,account_id) je3 ON je.entry_date = je3.date " + "inner join (select max(entry_date) as date from acc_gl_journal_entry where entry_date < ? group by office_id,account_id) je3 ON je.entry_date = je3.date "
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0); + "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
List<Map<String, Object>> officesRunningBalanceList = jdbcTemplate.queryForList(offlineRunningBalanceQuery, List<Map<String, Object>> officesRunningBalanceList = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR
new Object[] { entityDate, entityDate }); // NOSONAR new Object[] { entityDate, entityDate });
for (Map<String, Object> entries : officesRunningBalanceList) { for (Map<String, Object> entries : officesRunningBalanceList) {
Long accountId = Long.parseLong(entries.get("accountId").toString()); Long accountId = Long.parseLong(entries.get("accountId").toString());
Long officeId = Long.parseLong(entries.get("officeId").toString()); Long officeId = Long.parseLong(entries.get("officeId").toString());
@@ -197,8 +197,8 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id) je3 ON je.entry_date = je3.date " + "inner join (select max(entry_date) as date from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id) je3 ON je.entry_date = je3.date "
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0); + "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
List<Map<String, Object>> list = jdbcTemplate.queryForList(offlineRunningBalanceQuery, List<Map<String, Object>> list = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR
new Object[] { officeId, entityDate, officeId, entityDate }); // NOSONAR new Object[] { officeId, entityDate, officeId, entityDate });
for (Map<String, Object> entries : list) { for (Map<String, Object> entries : list) {
Long accountId = (Long) entries.get("accountId"); Long accountId = (Long) entries.get("accountId");
if (!runningBalanceMap.containsKey(accountId)) { if (!runningBalanceMap.containsKey(accountId)) {
@@ -103,8 +103,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper(); final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is null and mapping.charge_id is null"; final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is null and mapping.charge_id is null";
final List<Map<String, Object>> listOfProductToGLAccountMaps = this.jdbcTemplate.query(sql, rm, final List<Map<String, Object>> listOfProductToGLAccountMaps = this.jdbcTemplate.query(sql, rm, // NOSONAR
new Object[] { PortfolioProductType.LOAN.getValue(), loanProductId }); // NOSONAR new Object[] { PortfolioProductType.LOAN.getValue(), loanProductId });
if (AccountingRuleType.CASH_BASED.getValue().equals(accountingType)) { if (AccountingRuleType.CASH_BASED.getValue().equals(accountingType)) {
@@ -189,8 +189,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper(); final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is null and mapping.charge_id is null "; final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is null and mapping.charge_id is null ";
final List<Map<String, Object>> listOfProductToGLAccountMaps = this.jdbcTemplate.query(sql, rm, final List<Map<String, Object>> listOfProductToGLAccountMaps = this.jdbcTemplate.query(sql, rm, // NOSONAR
new Object[] { PortfolioProductType.SAVING.getValue(), savingsProductId }); // NOSONAR new Object[] { PortfolioProductType.SAVING.getValue(), savingsProductId });
if (AccountingRuleType.CASH_BASED.getValue().equals(accountingType)) { if (AccountingRuleType.CASH_BASED.getValue().equals(accountingType)) {
@@ -250,8 +250,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper(); final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is not null"; final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is not null";
final List<Map<String, Object>> paymentTypeToFundSourceMappingsList = this.jdbcTemplate.query(sql, rm, final List<Map<String, Object>> paymentTypeToFundSourceMappingsList = this.jdbcTemplate.query(sql, rm, // NOSONAR
new Object[] { portfolioProductType.getValue(), loanProductId }); // NOSONAR new Object[] { portfolioProductType.getValue(), loanProductId });
List<PaymentTypeToGLAccountMapper> paymentTypeToGLAccountMappers = null; List<PaymentTypeToGLAccountMapper> paymentTypeToGLAccountMappers = null;
for (final Map<String, Object> productToGLAccountMap : paymentTypeToFundSourceMappingsList) { for (final Map<String, Object> productToGLAccountMap : paymentTypeToFundSourceMappingsList) {
@@ -303,8 +303,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
sql = sql + " false"; sql = sql + " false";
} }
final List<Map<String, Object>> chargeToFundSourceMappingsList = this.jdbcTemplate.query(sql, rm, final List<Map<String, Object>> chargeToFundSourceMappingsList = this.jdbcTemplate.query(sql, rm, // NOSONAR
new Object[] { portfolioProductType.getValue(), loanProductId }); // NOSONAR new Object[] { portfolioProductType.getValue(), loanProductId });
List<ChargeToGLAccountMapper> chargeToGLAccountMappers = null; List<ChargeToGLAccountMapper> chargeToGLAccountMappers = null;
for (final Map<String, Object> chargeToIncomeAccountMap : chargeToFundSourceMappingsList) { for (final Map<String, Object> chargeToIncomeAccountMap : chargeToFundSourceMappingsList) {
if (chargeToGLAccountMappers == null) { if (chargeToGLAccountMappers == null) {
@@ -332,8 +332,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper(); final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is null and mapping.charge_id is null "; final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is null and mapping.charge_id is null ";
final List<Map<String, Object>> listOfProductToGLAccountMaps = this.jdbcTemplate.query(sql, rm, final List<Map<String, Object>> listOfProductToGLAccountMaps = this.jdbcTemplate.query(sql, rm, // NOSONAR
new Object[] { PortfolioProductType.SHARES.getValue(), productId }); // NOSONAR new Object[] { PortfolioProductType.SHARES.getValue(), productId });
if (AccountingRuleType.CASH_BASED.getValue().equals(accountingType)) { if (AccountingRuleType.CASH_BASED.getValue().equals(accountingType)) {
for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) { for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) {
@@ -169,8 +169,8 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
this.glAccountReadPlatformService, false); this.glAccountReadPlatformService, false);
final String sql = "select " + resultSetExtractor.schema() + " and rule.id = ?"; final String sql = "select " + resultSetExtractor.schema() + " and rule.id = ?";
final Map<Long, AccountingRuleData> extractedData = this.jdbcTemplate.query(sql, resultSetExtractor, final Map<Long, AccountingRuleData> extractedData = this.jdbcTemplate.query(sql, resultSetExtractor, // NOSONAR
new Object[] { accountingRuleId }); // NOSONAR new Object[] { accountingRuleId });
final AccountingRuleData accountingRuleData = extractedData.get(accountingRuleId); final AccountingRuleData accountingRuleData = extractedData.get(accountingRuleId);
if (accountingRuleData == null) { if (accountingRuleData == null) {
throw new AccountingRuleNotFoundException(accountingRuleId); throw new AccountingRuleNotFoundException(accountingRuleId);
@@ -26,6 +26,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.accountnumberformat.data.AccountNumberFormatData; import org.apache.fineract.infrastructure.accountnumberformat.data.AccountNumberFormatData;
import org.apache.fineract.infrastructure.accountnumberformat.domain.AccountNumberFormatEnumerations; import org.apache.fineract.infrastructure.accountnumberformat.domain.AccountNumberFormatEnumerations;
import org.apache.fineract.infrastructure.accountnumberformat.domain.AccountNumberFormatEnumerations.AccountNumberPrefixType; import org.apache.fineract.infrastructure.accountnumberformat.domain.AccountNumberFormatEnumerations.AccountNumberPrefixType;
@@ -35,13 +36,13 @@ import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor
public class AccountNumberFormatReadPlatformServiceImpl implements AccountNumberFormatReadPlatformService { public class AccountNumberFormatReadPlatformServiceImpl implements AccountNumberFormatReadPlatformService {
private static final Logger LOG = LoggerFactory.getLogger(AccountNumberFormatReadPlatformServiceImpl.class); private static final Logger LOG = LoggerFactory.getLogger(AccountNumberFormatReadPlatformServiceImpl.class);
@@ -51,11 +52,6 @@ public class AccountNumberFormatReadPlatformServiceImpl implements AccountNumber
// data mapper // data mapper
private final AccountNumberFormatMapper accountNumberFormatMapper = new AccountNumberFormatMapper(); private final AccountNumberFormatMapper accountNumberFormatMapper = new AccountNumberFormatMapper();
@Autowired
public AccountNumberFormatReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
private static final class AccountNumberFormatMapper implements RowMapper<AccountNumberFormatData> { private static final class AccountNumberFormatMapper implements RowMapper<AccountNumberFormatData> {
private final String schema; private final String schema;
@@ -102,8 +98,8 @@ public class AccountNumberFormatReadPlatformServiceImpl implements AccountNumber
try { try {
final String sql = "select " + this.accountNumberFormatMapper.schema() + " where anf.id = ?"; final String sql = "select " + this.accountNumberFormatMapper.schema() + " where anf.id = ?";
final AccountNumberFormatData accountNumberFormatData = this.jdbcTemplate.queryForObject(sql, this.accountNumberFormatMapper, final AccountNumberFormatData accountNumberFormatData = this.jdbcTemplate.queryForObject(sql, this.accountNumberFormatMapper, // NOSONAR
new Object[] { id }); // NOSONAR new Object[] { id });
return accountNumberFormatData; return accountNumberFormatData;
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
throw new AccountNumberFormatNotFoundException(id, e); throw new AccountNumberFormatNotFoundException(id, e);
@@ -240,8 +240,8 @@ public class EmailCampaignReadPlatformServiceImpl implements EmailCampaignReadPl
final String sql = "select " + this.businessRuleMapper.schema() + " where sr.report_type = ? and sr.id = ?"; final String sql = "select " + this.businessRuleMapper.schema() + " where sr.report_type = ? and sr.id = ?";
List<EmailBusinessRulesData> retrieveOne = this.jdbcTemplate.query(sql, this.businessRuleMapper, List<EmailBusinessRulesData> retrieveOne = this.jdbcTemplate.query(sql, this.businessRuleMapper, // NOSONAR
new Object[] { searchType, resourceId }); // NOSONAR new Object[] { searchType, resourceId });
try { try {
EmailBusinessRulesData emailBusinessRulesData = retrieveOne.get(0); EmailBusinessRulesData emailBusinessRulesData = retrieveOne.get(0);
return emailBusinessRulesData; return emailBusinessRulesData;
@@ -111,8 +111,8 @@ public class SmsCampaignReadPlatformServiceImpl implements SmsCampaignReadPlatfo
if (!StringUtils.isEmpty(reportType)) { if (!StringUtils.isEmpty(reportType)) {
sql = sql + " where sr.report_type = ?"; sql = sql + " where sr.report_type = ?";
} }
final Collection<SmsBusinessRulesData> businessRulesOptions = this.jdbcTemplate.query(sql, this.businessRuleMapper, final Collection<SmsBusinessRulesData> businessRulesOptions = this.jdbcTemplate.query(sql, this.businessRuleMapper, // NOSONAR
new Object[] { reportType }); // NOSONAR new Object[] { reportType });
final Collection<SmsProviderData> smsProviderOptions = this.smsCampaignDropdownReadPlatformService.retrieveSmsProviders(); final Collection<SmsProviderData> smsProviderOptions = this.smsCampaignDropdownReadPlatformService.retrieveSmsProviders();
final Collection<EnumOptionData> campaignTypeOptions = this.smsCampaignDropdownReadPlatformService.retrieveCampaignTypes(); final Collection<EnumOptionData> campaignTypeOptions = this.smsCampaignDropdownReadPlatformService.retrieveCampaignTypes();
final Collection<EnumOptionData> campaignTriggerTypeOptions = this.smsCampaignDropdownReadPlatformService final Collection<EnumOptionData> campaignTriggerTypeOptions = this.smsCampaignDropdownReadPlatformService
@@ -120,9 +120,6 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate; private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
private final SqlInjectionPreventerService preventSqlInjectionService; private final SqlInjectionPreventerService preventSqlInjectionService;
// private final GlobalConfigurationWritePlatformServiceJpaRepositoryImpl
// configurationWriteService;
@Autowired(required = true) @Autowired(required = true)
public ReadWriteNonCoreDataServiceImpl(final JdbcTemplate jdbcTemplate, final NamedParameterJdbcTemplate namedParameterJdbcTemplate, public ReadWriteNonCoreDataServiceImpl(final JdbcTemplate jdbcTemplate, final NamedParameterJdbcTemplate namedParameterJdbcTemplate,
final PlatformSecurityContext context, final FromJsonHelper fromJsonHelper, final GenericDataService genericDataService, final PlatformSecurityContext context, final FromJsonHelper fromJsonHelper, final GenericDataService genericDataService,
@@ -142,7 +139,6 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
this.configurationDomainService = configurationDomainService; this.configurationDomainService = configurationDomainService;
this.dataTableValidator = dataTableValidator; this.dataTableValidator = dataTableValidator;
this.columnValidator = columnValidator; this.columnValidator = columnValidator;
// this.configurationWriteService = configurationWriteService;
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate; this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
this.preventSqlInjectionService = sqlInjectionPreventerService; this.preventSqlInjectionService = sqlInjectionPreventerService;
} }
@@ -506,7 +502,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
private void assertDataTableExists(final String datatableName) { private void assertDataTableExists(final String datatableName) {
final String sql = "select (CASE WHEN exists (select 1 from information_schema.tables where table_schema = " final String sql = "select (CASE WHEN exists (select 1 from information_schema.tables where table_schema = "
+ sqlGenerator.currentSchema() + " and table_name = ?) THEN 'true' ELSE 'false' END)"; + sqlGenerator.currentSchema() + " and table_name = ?) THEN 'true' ELSE 'false' END)";
final String dataTableExistsString = this.jdbcTemplate.queryForObject(sql, String.class, new Object[] { datatableName }); final String dataTableExistsString = this.jdbcTemplate.queryForObject(sql, String.class, new Object[] { datatableName }); // NOSONAR
final boolean dataTableExists = Boolean.valueOf(dataTableExistsString); final boolean dataTableExists = Boolean.valueOf(dataTableExistsString);
if (!dataTableExists) { if (!dataTableExists) {
throw new PlatformDataIntegrityException("error.msg.invalid.datatable", "Invalid Data Table: " + datatableName, "name", throw new PlatformDataIntegrityException("error.msg.invalid.datatable", "Invalid Data Table: " + datatableName, "name",
@@ -967,9 +963,8 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
final boolean isConstraintApproach = this.configurationDomainService.isConstraintApproachEnabledForDatatables(); final boolean isConstraintApproach = this.configurationDomainService.isConstraintApproachEnabledForDatatables();
if (!StringUtils.isBlank(entitySubType)) { if (!StringUtils.isBlank(entitySubType)) {
String updateLegalFormSQL = "update x_registered_table SET entity_subtype='" + entitySubType jdbcTemplate.update("update x_registered_table SET entity_subtype=? WHERE registered_table_name = ?", // NOSONAR
+ "' WHERE registered_table_name = '" + datatableName + "'"; new Object[] { entitySubType, datatableName });
this.jdbcTemplate.execute(updateLegalFormSQL);
} }
if (!StringUtils.isBlank(apptableName)) { if (!StringUtils.isBlank(apptableName)) {
@@ -1183,7 +1178,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
private int getRowCount(final String datatableName) { private int getRowCount(final String datatableName) {
final String sql = "select count(*) from " + sqlGenerator.escape(datatableName); final String sql = "select count(*) from " + sqlGenerator.escape(datatableName);
return this.jdbcTemplate.queryForObject(sql, Integer.class); return this.jdbcTemplate.queryForObject(sql, Integer.class); // NOSONAR
} }
@Transactional @Transactional
@@ -1920,7 +1915,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
final String sqlString = "SELECT COUNT(" + sqlGenerator.escape(foreignKeyColumn) + ") FROM " + sqlGenerator.escape(datatableName) final String sqlString = "SELECT COUNT(" + sqlGenerator.escape(foreignKeyColumn) + ") FROM " + sqlGenerator.escape(datatableName)
+ " WHERE " + sqlGenerator.escape(foreignKeyColumn) + "=" + appTableId; + " WHERE " + sqlGenerator.escape(foreignKeyColumn) + "=" + appTableId;
final Long count = this.jdbcTemplate.queryForObject(sqlString, Long.class); final Long count = this.jdbcTemplate.queryForObject(sqlString, Long.class); // NOSONAR
return count; return count;
} }
@@ -21,6 +21,7 @@ package org.apache.fineract.infrastructure.documentmanagement.service;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Collection; import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepository; import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepository;
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryFactory; import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryFactory;
@@ -28,27 +29,19 @@ import org.apache.fineract.infrastructure.documentmanagement.data.DocumentData;
import org.apache.fineract.infrastructure.documentmanagement.data.FileData; import org.apache.fineract.infrastructure.documentmanagement.data.FileData;
import org.apache.fineract.infrastructure.documentmanagement.exception.DocumentNotFoundException; import org.apache.fineract.infrastructure.documentmanagement.exception.DocumentNotFoundException;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor
public class DocumentReadPlatformServiceImpl implements DocumentReadPlatformService { public class DocumentReadPlatformServiceImpl implements DocumentReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final ContentRepositoryFactory contentRepositoryFactory; private final ContentRepositoryFactory contentRepositoryFactory;
@Autowired
public DocumentReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate,
final ContentRepositoryFactory documentStoreFactory) {
this.context = context;
this.jdbcTemplate = jdbcTemplate;
this.contentRepositoryFactory = documentStoreFactory;
}
@Override @Override
public Collection<DocumentData> retrieveAllDocuments(final String entityType, final Long entityId) { public Collection<DocumentData> retrieveAllDocuments(final String entityType, final Long entityId) {
@@ -87,7 +80,7 @@ public class DocumentReadPlatformServiceImpl implements DocumentReadPlatformServ
private DocumentData fetchDocumentDetails(final String entityType, final Long entityId, final Long documentId, private DocumentData fetchDocumentDetails(final String entityType, final Long entityId, final Long documentId,
final DocumentMapper mapper) { final DocumentMapper mapper) {
final String sql = "select " + mapper.schema() + " and d.id=? "; final String sql = "select " + mapper.schema() + " and d.id=? ";
return this.jdbcTemplate.queryForObject(sql, mapper, new Object[] { entityType, entityId, documentId });// NOSOANR return this.jdbcTemplate.queryForObject(sql, mapper, new Object[] { entityType, entityId, documentId }); // NOSONAR
} }
private static final class DocumentMapper implements RowMapper<DocumentData> { private static final class DocumentMapper implements RowMapper<DocumentData> {
@@ -26,6 +26,7 @@ import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException; import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
@@ -52,7 +53,6 @@ import org.apache.fineract.organisation.teller.data.TellerTransactionData;
import org.apache.fineract.organisation.teller.domain.CashierTxnType; import org.apache.fineract.organisation.teller.domain.CashierTxnType;
import org.apache.fineract.organisation.teller.domain.TellerStatus; import org.apache.fineract.organisation.teller.domain.TellerStatus;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
@@ -61,6 +61,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@Service @Service
@RequiredArgsConstructor
public class TellerManagementReadPlatformServiceImpl implements TellerManagementReadPlatformService { public class TellerManagementReadPlatformServiceImpl implements TellerManagementReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
@@ -74,21 +75,6 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
private final PaginationHelper paginationHelper; private final PaginationHelper paginationHelper;
private final ColumnValidator columnValidator; private final ColumnValidator columnValidator;
@Autowired
public TellerManagementReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate,
final OfficeReadPlatformService officeReadPlatformService, StaffReadPlatformService staffReadPlatformService,
final CurrencyReadPlatformService currencyReadPlatformService, final ColumnValidator columnValidator,
DatabaseSpecificSQLGenerator sqlGenerator, PaginationHelper paginationHelper) {
this.context = context;
this.jdbcTemplate = jdbcTemplate;
this.officeReadPlatformService = officeReadPlatformService;
this.staffReadPlatformService = staffReadPlatformService;
this.currencyReadPlatformService = currencyReadPlatformService;
this.columnValidator = columnValidator;
this.sqlGenerator = sqlGenerator;
this.paginationHelper = paginationHelper;
}
private static final class TellerMapper implements RowMapper<TellerData> { private static final class TellerMapper implements RowMapper<TellerData> {
public String schema() { public String schema() {
@@ -459,9 +445,9 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final CashierTransactionSummaryMapper ctsm = new CashierTransactionSummaryMapper(); final CashierTransactionSummaryMapper ctsm = new CashierTransactionSummaryMapper();
final String sql = "select " + ctsm.cashierTxnSummarySchema() + " limit 1000"; final String sql = "select " + ctsm.cashierTxnSummarySchema() + " limit 1000";
Collection<CashierTransactionTypeTotalsData> cashierTxnTypeTotals = this.jdbcTemplate.query(sql, ctsm, Collection<CashierTransactionTypeTotalsData> cashierTxnTypeTotals = this.jdbcTemplate.query(sql, ctsm, // NOSONAR
new Object[] { cashierId, currencyCode, hierarchySearchString, cashierId, currencyCode, hierarchySearchString, cashierId, new Object[] { cashierId, currencyCode, hierarchySearchString, cashierId, currencyCode, hierarchySearchString, cashierId,
currencyCode, hierarchySearchString, cashierId, currencyCode, hierarchySearchString }); // NOSONAR currencyCode, hierarchySearchString, cashierId, currencyCode, hierarchySearchString });
Iterator<CashierTransactionTypeTotalsData> itr = cashierTxnTypeTotals.iterator(); Iterator<CashierTransactionTypeTotalsData> itr = cashierTxnTypeTotals.iterator();
BigDecimal allocAmount = new BigDecimal(0); BigDecimal allocAmount = new BigDecimal(0);
@@ -23,6 +23,7 @@ import java.sql.SQLException;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.portfolio.account.data.AccountAssociationsData; import org.apache.fineract.portfolio.account.data.AccountAssociationsData;
import org.apache.fineract.portfolio.account.data.PortfolioAccountData; import org.apache.fineract.portfolio.account.data.PortfolioAccountData;
@@ -31,31 +32,26 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountStatusType; import org.apache.fineract.portfolio.savings.domain.SavingsAccountStatusType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor
public class AccountAssociationsReadPlatformServiceImpl implements AccountAssociationsReadPlatformService { public class AccountAssociationsReadPlatformServiceImpl implements AccountAssociationsReadPlatformService {
private static final Logger LOG = LoggerFactory.getLogger(AccountAssociationsReadPlatformServiceImpl.class); private static final Logger LOG = LoggerFactory.getLogger(AccountAssociationsReadPlatformServiceImpl.class);
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
@Autowired
public AccountAssociationsReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
@Override @Override
public PortfolioAccountData retriveLoanLinkedAssociation(final Long loanId) { public PortfolioAccountData retriveLoanLinkedAssociation(final Long loanId) {
PortfolioAccountData linkedAccount = null; PortfolioAccountData linkedAccount = null;
final AccountAssociationsMapper mapper = new AccountAssociationsMapper(); final AccountAssociationsMapper mapper = new AccountAssociationsMapper();
final String sql = "select " + mapper.schema() + " where aa.loan_account_id = ? and aa.association_type_enum = ?"; final String sql = "select " + mapper.schema() + " where aa.loan_account_id = ? and aa.association_type_enum = ?";
try { try {
final AccountAssociationsData accountAssociationsData = this.jdbcTemplate.queryForObject(sql, mapper, loanId, final AccountAssociationsData accountAssociationsData = this.jdbcTemplate.queryForObject(sql, mapper, loanId, // NOSONAR
AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue()); // NOSONAR AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue());
if (accountAssociationsData != null) { if (accountAssociationsData != null) {
linkedAccount = accountAssociationsData.linkedAccount(); linkedAccount = accountAssociationsData.linkedAccount();
} }
@@ -83,8 +79,8 @@ public class AccountAssociationsReadPlatformServiceImpl implements AccountAssoci
final AccountAssociationsMapper mapper = new AccountAssociationsMapper(); final AccountAssociationsMapper mapper = new AccountAssociationsMapper();
final String sql = "select " + mapper.schema() + " where aa.savings_account_id = ? and aa.association_type_enum = ?"; final String sql = "select " + mapper.schema() + " where aa.savings_account_id = ? and aa.association_type_enum = ?";
try { try {
final AccountAssociationsData accountAssociationsData = this.jdbcTemplate.queryForObject(sql, mapper, final AccountAssociationsData accountAssociationsData = this.jdbcTemplate.queryForObject(sql, mapper, // NOSONAR
new Object[] { savingsId, AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue() }); // NOSONAR new Object[] { savingsId, AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue() });
if (accountAssociationsData != null) { if (accountAssociationsData != null) {
linkedAccount = accountAssociationsData.linkedAccount(); linkedAccount = accountAssociationsData.linkedAccount();
} }
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService; import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
@@ -36,7 +37,6 @@ import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
import org.apache.fineract.portfolio.calendar.domain.CalendarType; import org.apache.fineract.portfolio.calendar.domain.CalendarType;
import org.apache.fineract.portfolio.calendar.exception.CalendarNotFoundException; import org.apache.fineract.portfolio.calendar.exception.CalendarNotFoundException;
import org.apache.fineract.portfolio.meeting.data.MeetingData; import org.apache.fineract.portfolio.meeting.data.MeetingData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
@@ -44,17 +44,12 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@Service @Service
@RequiredArgsConstructor
public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformService { public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
private final ConfigurationDomainService configurationDomainService; private final ConfigurationDomainService configurationDomainService;
@Autowired
public CalendarReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate, final ConfigurationDomainService configurationDomainService) {
this.jdbcTemplate = jdbcTemplate;
this.configurationDomainService = configurationDomainService;
}
private static final class CalendarDataMapper implements RowMapper<CalendarData> { private static final class CalendarDataMapper implements RowMapper<CalendarData> {
public String schema() { public String schema() {
@@ -159,8 +154,8 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ
final String sql = rm.schema() final String sql = rm.schema()
+ " and ci.entity_id = ? and ci.entity_type_enum = ? and calendar_type_enum = ? order by c.start_date "; + " and ci.entity_id = ? and ci.entity_type_enum = ? and calendar_type_enum = ? order by c.start_date ";
final List<CalendarData> result = this.jdbcTemplate.query(sql, rm, final List<CalendarData> result = this.jdbcTemplate.query(sql, rm, // NOSONAR
new Object[] { entityId, entityTypeId, CalendarType.COLLECTION.getValue() }); // NOSONAR new Object[] { entityId, entityTypeId, CalendarType.COLLECTION.getValue() });
if (!result.isEmpty() && result.size() > 0) { if (!result.isEmpty() && result.size() > 0) {
return result.get(0); return result.get(0);
@@ -384,8 +379,8 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ
final String sql = rm.schema() + " and ci.entity_id = ? and ci.entity_type_enum = ? order by c.start_date "; final String sql = rm.schema() + " and ci.entity_id = ? and ci.entity_type_enum = ? order by c.start_date ";
CalendarData calendarData = null; CalendarData calendarData = null;
final Collection<CalendarData> calendars = this.jdbcTemplate.query(sql, rm, final Collection<CalendarData> calendars = this.jdbcTemplate.query(sql, rm, // NOSONAR
new Object[] { loanId, CalendarEntityType.LOANS.getValue() }); // NOSONAR new Object[] { loanId, CalendarEntityType.LOANS.getValue() });
if (!CollectionUtils.isEmpty(calendars)) { if (!CollectionUtils.isEmpty(calendars)) {
for (final CalendarData calendar : calendars) { for (final CalendarData calendar : calendars) {
@@ -431,8 +426,8 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ
final String sql = rm.schema() + " where c.calendar_id = ? and date(?) between c.start_date and c.end_date limit 1"; final String sql = rm.schema() + " where c.calendar_id = ? and date(?) between c.start_date and c.end_date limit 1";
return this.jdbcTemplate.queryForObject(sql, rm, return this.jdbcTemplate.queryForObject(sql, rm, // NOSONAR
new Object[] { calendarId, Date.from(compareDate.atStartOfDay(ZoneId.systemDefault()).toInstant()) }); // NOSONAR new Object[] { calendarId, Date.from(compareDate.atStartOfDay(ZoneId.systemDefault()).toInstant()) });
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
return null; return null;
} }
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.client.service;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Collection; import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.codes.data.CodeValueData; import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
@@ -28,24 +29,18 @@ import org.apache.fineract.portfolio.client.data.ClientIdentifierData;
import org.apache.fineract.portfolio.client.domain.ClientIdentifierStatus; import org.apache.fineract.portfolio.client.domain.ClientIdentifierStatus;
import org.apache.fineract.portfolio.client.exception.ClientIdentifierNotFoundException; import org.apache.fineract.portfolio.client.exception.ClientIdentifierNotFoundException;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor
public class ClientIdentifierReadPlatformServiceImpl implements ClientIdentifierReadPlatformService { public class ClientIdentifierReadPlatformServiceImpl implements ClientIdentifierReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
@Autowired
public ClientIdentifierReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate) {
this.context = context;
this.jdbcTemplate = jdbcTemplate;
}
@Override @Override
public Collection<ClientIdentifierData> retrieveClientIdentifiers(final Long clientId) { public Collection<ClientIdentifierData> retrieveClientIdentifiers(final Long clientId) {
@@ -75,8 +70,8 @@ public class ClientIdentifierReadPlatformServiceImpl implements ClientIdentifier
sql += " and ci.id = ?"; sql += " and ci.id = ?";
final ClientIdentifierData clientIdentifierData = this.jdbcTemplate.queryForObject(sql, rm, final ClientIdentifierData clientIdentifierData = this.jdbcTemplate.queryForObject(sql, rm, // NOSONAR
new Object[] { clientId, hierarchySearchString, clientIdentifierId }); // NOSONAR new Object[] { clientId, hierarchySearchString, clientIdentifierId });
return clientIdentifierData; return clientIdentifierData;
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
@@ -29,6 +29,7 @@ import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.codes.data.CodeValueData; import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService; import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService;
@@ -71,7 +72,6 @@ import org.apache.fineract.portfolio.group.data.GroupGeneralData;
import org.apache.fineract.portfolio.savings.data.SavingsProductData; import org.apache.fineract.portfolio.savings.data.SavingsProductData;
import org.apache.fineract.portfolio.savings.service.SavingsProductReadPlatformService; import org.apache.fineract.portfolio.savings.service.SavingsProductReadPlatformService;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
@@ -79,6 +79,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@Service @Service
@RequiredArgsConstructor
public class ClientReadPlatformServiceImpl implements ClientReadPlatformService { public class ClientReadPlatformServiceImpl implements ClientReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
@@ -102,33 +103,6 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
private final ColumnValidator columnValidator; private final ColumnValidator columnValidator;
private final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper; private final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper;
@Autowired
public ClientReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate,
final OfficeReadPlatformService officeReadPlatformService, final StaffReadPlatformService staffReadPlatformService,
final CodeValueReadPlatformService codeValueReadPlatformService,
final SavingsProductReadPlatformService savingsProductReadPlatformService,
final AddressReadPlatformService addressReadPlatformService,
final ClientFamilyMembersReadPlatformService clientFamilyMembersReadPlatformService,
final ConfigurationReadPlatformService configurationReadPlatformService,
final EntityDatatableChecksReadService entityDatatableChecksReadService, final ColumnValidator columnValidator,
final ClientCollateralManagementRepositoryWrapper clientCollateralManagementRepositoryWrapper,
DatabaseSpecificSQLGenerator sqlGenerator, PaginationHelper paginationHelper) {
this.context = context;
this.officeReadPlatformService = officeReadPlatformService;
this.jdbcTemplate = jdbcTemplate;
this.staffReadPlatformService = staffReadPlatformService;
this.codeValueReadPlatformService = codeValueReadPlatformService;
this.savingsProductReadPlatformService = savingsProductReadPlatformService;
this.addressReadPlatformService = addressReadPlatformService;
this.clientFamilyMembersReadPlatformService = clientFamilyMembersReadPlatformService;
this.configurationReadPlatformService = configurationReadPlatformService;
this.entityDatatableChecksReadService = entityDatatableChecksReadService;
this.columnValidator = columnValidator;
this.clientCollateralManagementRepositoryWrapper = clientCollateralManagementRepositoryWrapper;
this.paginationHelper = paginationHelper;
this.sqlGenerator = sqlGenerator;
}
@Override @Override
public ClientData retrieveTemplate(final Long officeId, final boolean staffInSelectedOfficeOnly) { public ClientData retrieveTemplate(final Long officeId, final boolean staffInSelectedOfficeOnly) {
this.context.authenticatedUser(); this.context.authenticatedUser();
@@ -323,8 +297,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
final String sql = "select " + this.clientMapper.schema() final String sql = "select " + this.clientMapper.schema()
+ " where ( o.hierarchy like ? or transferToOffice.hierarchy like ?) and c.id = ?"; + " where ( o.hierarchy like ? or transferToOffice.hierarchy like ?) and c.id = ?";
final ClientData clientData = this.jdbcTemplate.queryForObject(sql, this.clientMapper, final ClientData clientData = this.jdbcTemplate.queryForObject(sql, this.clientMapper, // NOSONAR
new Object[] { hierarchySearchString, hierarchySearchString, clientId }); // NOSONAR new Object[] { hierarchySearchString, hierarchySearchString, clientId });
// Get client collaterals // Get client collaterals
final Collection<ClientCollateralManagement> clientCollateralManagements = this.clientCollateralManagementRepositoryWrapper final Collection<ClientCollateralManagement> clientCollateralManagements = this.clientCollateralManagementRepositoryWrapper
@@ -341,8 +315,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
final String clientGroupsSql = "select " + this.clientGroupsMapper.parentGroupsSchema(); final String clientGroupsSql = "select " + this.clientGroupsMapper.parentGroupsSchema();
final Collection<GroupGeneralData> parentGroups = this.jdbcTemplate.query(clientGroupsSql, this.clientGroupsMapper, final Collection<GroupGeneralData> parentGroups = this.jdbcTemplate.query(clientGroupsSql, this.clientGroupsMapper, // NOSONAR
new Object[] { clientId }); // NOSONAR new Object[] { clientId });
return ClientData.setParentGroups(clientData, parentGroups, clientCollateralManagementDataSet); return ClientData.setParentGroups(clientData, parentGroups, clientCollateralManagementDataSet);
@@ -393,8 +367,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
final String sql = "select " + this.membersOfGroupMapper.schema() final String sql = "select " + this.membersOfGroupMapper.schema()
+ " where o.hierarchy like ? and pgc.group_id = ? and c.status_enum = ? "; + " where o.hierarchy like ? and pgc.group_id = ? and c.status_enum = ? ";
return this.jdbcTemplate.query(sql, this.membersOfGroupMapper, return this.jdbcTemplate.query(sql, this.membersOfGroupMapper, // NOSONAR
new Object[] { hierarchySearchString, groupId, ClientStatus.ACTIVE.getValue() }); // NOSONAR new Object[] { hierarchySearchString, groupId, ClientStatus.ACTIVE.getValue() });
} }
private static final class ClientMembersOfGroupMapper implements RowMapper<ClientData> { private static final class ClientMembersOfGroupMapper implements RowMapper<ClientData> {
@@ -582,8 +556,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
final String sql = "select " + this.membersOfGroupMapper.schema() final String sql = "select " + this.membersOfGroupMapper.schema()
+ " left join m_group g on pgc.group_id=g.id where o.hierarchy like ? and g.parent_id = ? and c.status_enum = ? group by c.id"; + " left join m_group g on pgc.group_id=g.id where o.hierarchy like ? and g.parent_id = ? and c.status_enum = ? group by c.id";
return this.jdbcTemplate.query(sql, this.membersOfGroupMapper, return this.jdbcTemplate.query(sql, this.membersOfGroupMapper, // NOSONAR
new Object[] { hierarchySearchString, centerId, ClientStatus.ACTIVE.getValue() }); // NOSONAR new Object[] { hierarchySearchString, centerId, ClientStatus.ACTIVE.getValue() });
} }
private static final class ClientMapper implements RowMapper<ClientData> { private static final class ClientMapper implements RowMapper<ClientData> {
@@ -31,6 +31,7 @@ import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.codes.data.CodeValueData; import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService; import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService; import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
@@ -69,7 +70,6 @@ import org.apache.fineract.portfolio.group.domain.GroupTypes;
import org.apache.fineract.portfolio.group.domain.GroupingTypeEnumerations; import org.apache.fineract.portfolio.group.domain.GroupingTypeEnumerations;
import org.apache.fineract.portfolio.group.exception.CenterNotFoundException; import org.apache.fineract.portfolio.group.exception.CenterNotFoundException;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
@@ -77,6 +77,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@Service @Service
@RequiredArgsConstructor
public class CenterReadPlatformServiceImpl implements CenterReadPlatformService { public class CenterReadPlatformServiceImpl implements CenterReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
@@ -99,27 +100,6 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
private final PaginationParametersDataValidator paginationParametersDataValidator; private final PaginationParametersDataValidator paginationParametersDataValidator;
private static final Set<String> SUPPORTED_ORDER_BY_VALUES = new HashSet<>(Arrays.asList("id", "name", "officeId", "officeName")); private static final Set<String> SUPPORTED_ORDER_BY_VALUES = new HashSet<>(Arrays.asList("id", "name", "officeId", "officeName"));
@Autowired
public CenterReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate,
final ClientReadPlatformService clientReadPlatformService, final OfficeReadPlatformService officeReadPlatformService,
final StaffReadPlatformService staffReadPlatformService, final CodeValueReadPlatformService codeValueReadPlatformService,
final PaginationParametersDataValidator paginationParametersDataValidator,
final ConfigurationDomainService configurationDomainService, final CalendarReadPlatformService calendarReadPlatformService,
final ColumnValidator columnValidator, DatabaseSpecificSQLGenerator sqlGenerator, PaginationHelper paginationHelper) {
this.context = context;
this.clientReadPlatformService = clientReadPlatformService;
this.jdbcTemplate = jdbcTemplate;
this.officeReadPlatformService = officeReadPlatformService;
this.staffReadPlatformService = staffReadPlatformService;
this.codeValueReadPlatformService = codeValueReadPlatformService;
this.paginationParametersDataValidator = paginationParametersDataValidator;
this.configurationDomainService = configurationDomainService;
this.calendarReadPlatformService = calendarReadPlatformService;
this.columnValidator = columnValidator;
this.paginationHelper = paginationHelper;
this.sqlGenerator = sqlGenerator;
}
// 'g.' preffix because of ERROR 1052 (23000): Column 'column_name' in where // 'g.' preffix because of ERROR 1052 (23000): Column 'column_name' in where
// clause is ambiguous // clause is ambiguous
// caused by the same name of columns in m_office and m_group tables // caused by the same name of columns in m_office and m_group tables
@@ -395,7 +375,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
} }
} }
return this.jdbcTemplate.query(sqlBuilder.toString(), this.centerMapper, extraCriteria.getArguments()); return this.jdbcTemplate.query(sqlBuilder.toString(), this.centerMapper, extraCriteria.getArguments()); // NOSONAR
} }
@Override @Override
@@ -526,11 +506,11 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
sql += " and g.staff_id=? "; sql += " and g.staff_id=? ";
sql += "and lrs.duedate<='" + passeddate + "' and l.loan_type_enum=3"; sql += "and lrs.duedate<='" + passeddate + "' and l.loan_type_enum=3";
sql += " group by c.id, ci.id, g.account_no, g.external_id, g.status_enum, g.activation_date, g.hierarchy"; sql += " group by c.id, ci.id, g.account_no, g.external_id, g.status_enum, g.activation_date, g.hierarchy";
centerDataArray = this.jdbcTemplate.query(sql, centerCalendarMapper, centerDataArray = this.jdbcTemplate.query(sql, centerCalendarMapper, // NOSONAR
new Object[] { passeddate, passeddate, passeddate, passeddate, passeddate, passeddate, officeId, staffId }); // NOSONAR new Object[] { passeddate, passeddate, passeddate, passeddate, passeddate, passeddate, officeId, staffId });
} else { } else {
centerDataArray = this.jdbcTemplate.query(sql, centerCalendarMapper, centerDataArray = this.jdbcTemplate.query(sql, centerCalendarMapper, // NOSONAR
new Object[] { passeddate, passeddate, passeddate, passeddate, passeddate, passeddate, officeId }); // NOSONAR new Object[] { passeddate, passeddate, passeddate, passeddate, passeddate, passeddate, officeId });
} }
Collection<StaffCenterData> staffCenterDataArray = new ArrayList<>(); Collection<StaffCenterData> staffCenterDataArray = new ArrayList<>();
@@ -80,8 +80,8 @@ public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRat
public InterestRateChartSlabData retrieveOne(Long chartId, Long chartSlabId) { public InterestRateChartSlabData retrieveOne(Long chartId, Long chartSlabId) {
this.context.authenticatedUser(); this.context.authenticatedUser();
final String sql = "select " + this.chartSlabExtractor.schema() + " where irc.id = ? order by ircd.id asc"; final String sql = "select " + this.chartSlabExtractor.schema() + " where irc.id = ? order by ircd.id asc";
Collection<InterestRateChartSlabData> chartDatas = this.jdbcTemplate.query(sql, this.chartSlabExtractor, Collection<InterestRateChartSlabData> chartDatas = this.jdbcTemplate.query(sql, this.chartSlabExtractor, // NOSONAR
new Object[] { chartSlabId, chartId }); // NOSONAR new Object[] { chartSlabId, chartId });
if (chartDatas == null || chartDatas.isEmpty()) { if (chartDatas == null || chartDatas.isEmpty()) {
throw new InterestRateChartSlabNotFoundException(chartSlabId, chartId); throw new InterestRateChartSlabNotFoundException(chartSlabId, chartId);
} }
@@ -22,6 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.staff.data.StaffAccountSummaryCollectionData; import org.apache.fineract.organisation.staff.data.StaffAccountSummaryCollectionData;
@@ -29,26 +30,18 @@ import org.apache.fineract.portfolio.accountdetails.data.LoanAccountSummaryData;
import org.apache.fineract.portfolio.accountdetails.service.AccountDetailsReadPlatformService; import org.apache.fineract.portfolio.accountdetails.service.AccountDetailsReadPlatformService;
import org.apache.fineract.portfolio.client.domain.ClientStatus; import org.apache.fineract.portfolio.client.domain.ClientStatus;
import org.apache.fineract.portfolio.group.domain.GroupingTypeStatus; import org.apache.fineract.portfolio.group.domain.GroupingTypeStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor
public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformService { public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final AccountDetailsReadPlatformService accountDetailsReadPlatformService; private final AccountDetailsReadPlatformService accountDetailsReadPlatformService;
@Autowired
public BulkLoansReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate,
final AccountDetailsReadPlatformService accountDetailsReadPlatformService) {
this.context = context;
this.jdbcTemplate = jdbcTemplate;
this.accountDetailsReadPlatformService = accountDetailsReadPlatformService;
}
@Override @Override
public StaffAccountSummaryCollectionData retrieveLoanOfficerAccountSummary(final Long loanOfficerId) { public StaffAccountSummaryCollectionData retrieveLoanOfficerAccountSummary(final Long loanOfficerId) {
@@ -60,8 +53,8 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
final StaffGroupMapper staffGroupMapper = new StaffGroupMapper(); final StaffGroupMapper staffGroupMapper = new StaffGroupMapper();
final String groupSql = "select distinct " + staffGroupMapper.schema() + " and g.status_enum=?"; final String groupSql = "select distinct " + staffGroupMapper.schema() + " and g.status_enum=?";
final List<StaffAccountSummaryCollectionData.LoanAccountSummary> clientSummaryList = this.jdbcTemplate.query(clientSql, final List<StaffAccountSummaryCollectionData.LoanAccountSummary> clientSummaryList = this.jdbcTemplate.query(clientSql, // NOSONAR
staffClientMapper, new Object[] { loanOfficerId, ClientStatus.ACTIVE.getValue() }); // NOSONAR staffClientMapper, new Object[] { loanOfficerId, ClientStatus.ACTIVE.getValue() });
for (final StaffAccountSummaryCollectionData.LoanAccountSummary clientSummary : clientSummaryList) { for (final StaffAccountSummaryCollectionData.LoanAccountSummary clientSummary : clientSummaryList) {
@@ -71,8 +64,8 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
clientSummary.setLoans(clientLoanAccounts); clientSummary.setLoans(clientLoanAccounts);
} }
final List<StaffAccountSummaryCollectionData.LoanAccountSummary> groupSummaryList = this.jdbcTemplate.query(groupSql, final List<StaffAccountSummaryCollectionData.LoanAccountSummary> groupSummaryList = this.jdbcTemplate.query(groupSql, // NOSONAR
staffGroupMapper, new Object[] { loanOfficerId, GroupingTypeStatus.ACTIVE.getValue() }); // NOSONAR staffGroupMapper, new Object[] { loanOfficerId, GroupingTypeStatus.ACTIVE.getValue() });
for (final StaffAccountSummaryCollectionData.LoanAccountSummary groupSummary : groupSummaryList) { for (final StaffAccountSummaryCollectionData.LoanAccountSummary groupSummary : groupSummaryList) {
@@ -27,6 +27,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.accounting.glaccount.data.GLAccountData; import org.apache.fineract.accounting.glaccount.data.GLAccountData;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
@@ -41,12 +42,12 @@ import org.apache.fineract.portfolio.loanaccount.data.LoanChargePaidByData;
import org.apache.fineract.portfolio.loanaccount.data.LoanInstallmentChargeData; import org.apache.fineract.portfolio.loanaccount.data.LoanInstallmentChargeData;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType; import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
import org.apache.fineract.portfolio.tax.data.TaxGroupData; import org.apache.fineract.portfolio.tax.data.TaxGroupData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor
public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatformService { public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
@@ -54,16 +55,6 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
private final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService; private final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService;
private final DropdownReadPlatformService dropdownReadPlatformService; private final DropdownReadPlatformService dropdownReadPlatformService;
@Autowired
public LoanChargeReadPlatformServiceImpl(final PlatformSecurityContext context,
final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService, final JdbcTemplate jdbcTemplate,
final DropdownReadPlatformService dropdownReadPlatformService) {
this.context = context;
this.chargeDropdownReadPlatformService = chargeDropdownReadPlatformService;
this.jdbcTemplate = jdbcTemplate;
this.dropdownReadPlatformService = dropdownReadPlatformService;
}
private static final class LoanChargeMapper implements RowMapper<LoanChargeData> { private static final class LoanChargeMapper implements RowMapper<LoanChargeData> {
public String schema() { public String schema() {
@@ -279,8 +270,8 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
final String sql = "select " + rm.schema() + " where lc.loan_id=? AND lc.is_active = true group by lc.id " final String sql = "select " + rm.schema() + " where lc.loan_id=? AND lc.is_active = true group by lc.id "
+ " order by lc.charge_time_enum ASC, lc.due_for_collection_as_of_date ASC, lc.is_penalty ASC"; + " order by lc.charge_time_enum ASC, lc.due_for_collection_as_of_date ASC, lc.is_penalty ASC";
Collection<LoanChargeData> charges = this.jdbcTemplate.query(sql, rm, Collection<LoanChargeData> charges = this.jdbcTemplate.query(sql, rm, // NOSONAR
new Object[] { LoanTransactionType.ACCRUAL.getValue(), loanId, loanId }); // NOSONAR new Object[] { LoanTransactionType.ACCRUAL.getValue(), loanId, loanId });
charges = updateLoanChargesWithUnrecognizedIncome(loanId, charges); charges = updateLoanChargesWithUnrecognizedIncome(loanId, charges);
Collection<LoanChargeData> removeCharges = new ArrayList<>(); Collection<LoanChargeData> removeCharges = new ArrayList<>();
@@ -404,8 +395,8 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
final LoanInstallmentChargeAccrualMapper rm = new LoanInstallmentChargeAccrualMapper(); final LoanInstallmentChargeAccrualMapper rm = new LoanInstallmentChargeAccrualMapper();
String sql = "select " + rm.schema() String sql = "select " + rm.schema()
+ " where lic.loan_charge_id= ? group by lsi.installment, lsi.duedate, lic.amount_outstanding_derived, lic.amount, lic.is_paid_derived, lic.amount_waived_derived, lic.waived"; + " where lic.loan_charge_id= ? group by lsi.installment, lsi.duedate, lic.amount_outstanding_derived, lic.amount, lic.is_paid_derived, lic.amount_waived_derived, lic.waived";
Collection<LoanInstallmentChargeData> chargeDatas = this.jdbcTemplate.query(sql, rm, Collection<LoanInstallmentChargeData> chargeDatas = this.jdbcTemplate.query(sql, rm, // NOSONAR
new Object[] { LoanTransactionType.ACCRUAL.getValue(), loanChargeId }); // NOSONAR new Object[] { LoanTransactionType.ACCRUAL.getValue(), loanChargeId });
final Map<Integer, LoanInstallmentChargeData> installmentChargeDatas = new HashMap<>(); final Map<Integer, LoanInstallmentChargeData> installmentChargeDatas = new HashMap<>();
for (LoanInstallmentChargeData installmentChargeData : chargeDatas) { for (LoanInstallmentChargeData installmentChargeData : chargeDatas) {
installmentChargeDatas.put(installmentChargeData.getInstallmentNumber(), installmentChargeData); installmentChargeDatas.put(installmentChargeData.getInstallmentNumber(), installmentChargeData);
@@ -438,8 +438,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
RepaymentTransactionTemplateMapper mapper = new RepaymentTransactionTemplateMapper(sqlGenerator); RepaymentTransactionTemplateMapper mapper = new RepaymentTransactionTemplateMapper(sqlGenerator);
String sql = "select " + mapper.schema(); String sql = "select " + mapper.schema();
LoanTransactionData loanTransactionData = this.jdbcTemplate.queryForObject(sql, mapper, LoanTransactionData loanTransactionData = this.jdbcTemplate.queryForObject(sql, mapper, // NOSONAR
new Object[] { LoanTransactionType.REPAYMENT.getValue(), loanId, loanId }); // NOSONAR new Object[] { LoanTransactionType.REPAYMENT.getValue(), loanId, loanId });
final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
return LoanTransactionData.templateOnTop(loanTransactionData, paymentOptions); return LoanTransactionData.templateOnTop(loanTransactionData, paymentOptions);
} }
@@ -2369,7 +2369,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
public CollectionData retrieveLoanCollectionData(Long loanId) { public CollectionData retrieveLoanCollectionData(Long loanId) {
final CollectionDataMapper mapper = new CollectionDataMapper(sqlGenerator); final CollectionDataMapper mapper = new CollectionDataMapper(sqlGenerator);
String sql = "select " + mapper.schema(); String sql = "select " + mapper.schema();
CollectionData collectionData = this.jdbcTemplate.queryForObject(sql, mapper, new Object[] { loanId }); CollectionData collectionData = this.jdbcTemplate.queryForObject(sql, mapper, new Object[] { loanId }); // NOSONAR
return collectionData; return collectionData;
} }
@@ -494,8 +494,8 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
try { try {
final String sql = "select " + this.rdTransactionTemplateMapper.schema() final String sql = "select " + this.rdTransactionTemplateMapper.schema()
+ " where sa.id = ? and sa.deposit_type_enum = ? order by mss.installment limit 1"; + " where sa.id = ? and sa.deposit_type_enum = ? order by mss.installment limit 1";
return this.jdbcTemplate.queryForObject(sql, this.rdTransactionTemplateMapper, return this.jdbcTemplate.queryForObject(sql, this.rdTransactionTemplateMapper, // NOSONAR
new Object[] { accountId, accountId, DepositAccountType.RECURRING_DEPOSIT.getValue() }); // NOSONAR new Object[] { accountId, accountId, DepositAccountType.RECURRING_DEPOSIT.getValue() });
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
throw new DepositAccountNotFoundException(DepositAccountType.RECURRING_DEPOSIT, accountId, e); throw new DepositAccountNotFoundException(DepositAccountType.RECURRING_DEPOSIT, accountId, e);
} }
@@ -251,8 +251,8 @@ public class SavingsAccountChargeReadPlatformServiceImpl implements SavingsAccou
+ " where sac.charge_due_date is not null and sac.charge_time_enum = ? " + " where sac.charge_due_date is not null and sac.charge_time_enum = ? "
+ " and sac.charge_due_date <= NOW() and sa.status_enum = ? "; + " and sac.charge_due_date <= NOW() and sa.status_enum = ? ";
return this.jdbcTemplate.query(sql, this.chargeDueMapper, return this.jdbcTemplate.query(sql, this.chargeDueMapper, // NOSONAR
new Object[] { ChargeTimeType.ANNUAL_FEE.getValue(), SavingsAccountStatusType.ACTIVE.getValue() }); // NOSONAR new Object[] { ChargeTimeType.ANNUAL_FEE.getValue(), SavingsAccountStatusType.ACTIVE.getValue() });
} }
@Override @Override
@@ -141,7 +141,6 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
this.transactionsMapper = new SavingsAccountTransactionsMapper(); this.transactionsMapper = new SavingsAccountTransactionsMapper();
this.savingsAccountTransactionsForBatchMapper = new SavingsAccountTransactionsForBatchMapper(); this.savingsAccountTransactionsForBatchMapper = new SavingsAccountTransactionsForBatchMapper();
this.savingAccountMapper = new SavingAccountMapper(); this.savingAccountMapper = new SavingAccountMapper();
// this.annualFeeMapper = new SavingsAccountAnnualFeeMapper();
this.chargeReadPlatformService = chargeReadPlatformService; this.chargeReadPlatformService = chargeReadPlatformService;
this.entityDatatableChecksReadService = entityDatatableChecksReadService; this.entityDatatableChecksReadService = entityDatatableChecksReadService;
this.columnValidator = columnValidator; this.columnValidator = columnValidator;
@@ -278,8 +277,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
sql = sql + "and apm.product_type=2 and sa.interest_posted_till_date < '" + java.sql.Date.valueOf(currentDate) + "'"; sql = sql + "and apm.product_type=2 and sa.interest_posted_till_date < '" + java.sql.Date.valueOf(currentDate) + "'";
sql = sql + " order by sa.id, tr.transaction_date, tr.created_date, tr.id"; sql = sql + " order by sa.id, tr.transaction_date, tr.created_date, tr.id";
List<SavingsAccountData> savingsAccountDataList = this.jdbcTemplate.query(sql, this.savingAccountMapperForInterestPosting, List<SavingsAccountData> savingsAccountDataList = this.jdbcTemplate.query(sql, this.savingAccountMapperForInterestPosting, // NOSONAR
new Object[] { maxSavingsId, status, pageSize }); // NOSONAR new Object[] { maxSavingsId, status, pageSize });
for (SavingsAccountData savingsAccountData : savingsAccountDataList) { for (SavingsAccountData savingsAccountData : savingsAccountDataList) {
this.savingAccountAssembler.assembleSavings(savingsAccountData); this.savingAccountAssembler.assembleSavings(savingsAccountData);
} }
@@ -1254,8 +1253,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
try { try {
final String sql = "select " + this.transactionTemplateMapper.schema() + " where sa.id = ? and sa.deposit_type_enum = ?"; final String sql = "select " + this.transactionTemplateMapper.schema() + " where sa.id = ? and sa.deposit_type_enum = ?";
return this.jdbcTemplate.queryForObject(sql, this.transactionTemplateMapper, return this.jdbcTemplate.queryForObject(sql, this.transactionTemplateMapper, // NOSONAR
new Object[] { savingsId, depositAccountType.getValue() }); // NOSONAR new Object[] { savingsId, depositAccountType.getValue() });
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
throw new SavingsAccountNotFoundException(savingsId, e); throw new SavingsAccountNotFoundException(savingsId, e);
} }
@@ -1276,8 +1275,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
final String sql = "select " + this.transactionsMapper.schema() + " where sa.id = ? and sa.deposit_type_enum = ? and tr.id= ?"; final String sql = "select " + this.transactionsMapper.schema() + " where sa.id = ? and sa.deposit_type_enum = ? and tr.id= ?";
return this.jdbcTemplate.queryForObject(sql, this.transactionsMapper, return this.jdbcTemplate.queryForObject(sql, this.transactionsMapper, // NOSONAR
new Object[] { savingsId, depositAccountType.getValue(), transactionId }); // NOSONAR new Object[] { savingsId, depositAccountType.getValue(), transactionId });
} }
private static final class SavingsAccountTransactionsForBatchMapper implements RowMapper<SavingsAccountTransactionData> { private static final class SavingsAccountTransactionsForBatchMapper implements RowMapper<SavingsAccountTransactionData> {
@@ -22,6 +22,7 @@ import java.math.BigDecimal;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Collection; import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.accounting.common.AccountingEnumerations; import org.apache.fineract.accounting.common.AccountingEnumerations;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
@@ -33,13 +34,13 @@ import org.apache.fineract.portfolio.savings.DepositAccountType;
import org.apache.fineract.portfolio.savings.data.SavingsProductData; import org.apache.fineract.portfolio.savings.data.SavingsProductData;
import org.apache.fineract.portfolio.savings.exception.SavingsProductNotFoundException; import org.apache.fineract.portfolio.savings.exception.SavingsProductNotFoundException;
import org.apache.fineract.portfolio.tax.data.TaxGroupData; import org.apache.fineract.portfolio.tax.data.TaxGroupData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor
public class SavingsProductReadPlatformServiceImpl implements SavingsProductReadPlatformService { public class SavingsProductReadPlatformServiceImpl implements SavingsProductReadPlatformService {
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
@@ -48,14 +49,6 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
private final SavingProductLookupMapper savingsProductLookupsRowMapper = new SavingProductLookupMapper(); private final SavingProductLookupMapper savingsProductLookupsRowMapper = new SavingProductLookupMapper();
private final FineractEntityAccessUtil fineractEntityAccessUtil; private final FineractEntityAccessUtil fineractEntityAccessUtil;
@Autowired
public SavingsProductReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate,
final FineractEntityAccessUtil fineractEntityAccessUtil) {
this.context = context;
this.jdbcTemplate = jdbcTemplate;
this.fineractEntityAccessUtil = fineractEntityAccessUtil;
}
@Override @Override
public Collection<SavingsProductData> retrieveAll() { public Collection<SavingsProductData> retrieveAll() {
@@ -87,8 +80,8 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
sql += " and id in ( " + inClause + " ) "; sql += " and id in ( " + inClause + " ) ";
} }
return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, // NOSONAR
new Object[] { DepositAccountType.SAVINGS_DEPOSIT.getValue() }); // NOSONAR new Object[] { DepositAccountType.SAVINGS_DEPOSIT.getValue() });
} }
@Override @Override
@@ -96,8 +89,8 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
try { try {
this.context.authenticatedUser(); this.context.authenticatedUser();
final String sql = "select " + this.savingsProductRowMapper.schema() + " where sp.id = ? and sp.deposit_type_enum = ?"; final String sql = "select " + this.savingsProductRowMapper.schema() + " where sp.id = ? and sp.deposit_type_enum = ?";
return this.jdbcTemplate.queryForObject(sql, this.savingsProductRowMapper, return this.jdbcTemplate.queryForObject(sql, this.savingsProductRowMapper, // NOSONAR
new Object[] { savingProductId, DepositAccountType.SAVINGS_DEPOSIT.getValue() }); // NOSONAR new Object[] { savingProductId, DepositAccountType.SAVINGS_DEPOSIT.getValue() });
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
throw new SavingsProductNotFoundException(savingProductId, e); throw new SavingsProductNotFoundException(savingProductId, e);
} }
@@ -268,8 +261,8 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
} else { } else {
sql += " where sp.allow_overdraft=? and sp.deposit_type_enum = ?"; sql += " where sp.allow_overdraft=? and sp.deposit_type_enum = ?";
} }
return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, // NOSONAR
new Object[] { isOverdraftType, DepositAccountType.SAVINGS_DEPOSIT.getValue() }); // NOSONAR new Object[] { isOverdraftType, DepositAccountType.SAVINGS_DEPOSIT.getValue() });
} }
if (inClauseAdded) { if (inClauseAdded) {
@@ -277,8 +270,8 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
} else { } else {
sql += " where sp.deposit_type_enum = ?"; sql += " where sp.deposit_type_enum = ?";
} }
return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, // NOSONAR
new Object[] { DepositAccountType.SAVINGS_DEPOSIT.getValue() }); // NOSONAR new Object[] { DepositAccountType.SAVINGS_DEPOSIT.getValue() });
} }
@Override @Override
@@ -26,6 +26,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService; import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService;
import org.apache.fineract.accounting.common.AccountingEnumerations; import org.apache.fineract.accounting.common.AccountingEnumerations;
import org.apache.fineract.accounting.glaccount.data.GLAccountData; import org.apache.fineract.accounting.glaccount.data.GLAccountData;
@@ -47,13 +48,13 @@ import org.apache.fineract.portfolio.products.service.ProductReadPlatformService
import org.apache.fineract.portfolio.shareaccounts.service.SharesEnumerations; import org.apache.fineract.portfolio.shareaccounts.service.SharesEnumerations;
import org.apache.fineract.portfolio.shareproducts.data.ShareProductData; import org.apache.fineract.portfolio.shareproducts.data.ShareProductData;
import org.apache.fineract.portfolio.shareproducts.data.ShareProductMarketPriceData; import org.apache.fineract.portfolio.shareproducts.data.ShareProductMarketPriceData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service(value = "shareReadPlatformService") @Service(value = "shareReadPlatformService")
@RequiredArgsConstructor
public class ShareProductReadPlatformServiceImpl implements ProductReadPlatformService { public class ShareProductReadPlatformServiceImpl implements ProductReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
@@ -65,23 +66,6 @@ public class ShareProductReadPlatformServiceImpl implements ProductReadPlatformS
private final PaginationHelper shareProductDataPaginationHelper; private final PaginationHelper shareProductDataPaginationHelper;
private final DatabaseSpecificSQLGenerator sqlGenerator; private final DatabaseSpecificSQLGenerator sqlGenerator;
@Autowired
public ShareProductReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate,
final CurrencyReadPlatformService currencyReadPlatformService, final ChargeReadPlatformService chargeReadPlatformService,
final ShareProductDropdownReadPlatformService shareProductDropdownReadPlatformService,
final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService,
final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService, DatabaseSpecificSQLGenerator sqlGenerator,
PaginationHelper paginationHelper) {
this.jdbcTemplate = jdbcTemplate;
this.currencyReadPlatformService = currencyReadPlatformService;
this.chargeReadPlatformService = chargeReadPlatformService;
this.shareProductDropdownReadPlatformService = shareProductDropdownReadPlatformService;
this.accountingDropdownReadPlatformService = accountingDropdownReadPlatformService;
this.accountMappingReadPlatformService = accountMappingReadPlatformService;
this.shareProductDataPaginationHelper = paginationHelper;
this.sqlGenerator = sqlGenerator;
}
@Override @Override
public Page<ProductData> retrieveAllProducts(Integer offSet, Integer limit) { public Page<ProductData> retrieveAllProducts(Integer offSet, Integer limit) {
final Collection<ShareProductMarketPriceData> shareMarketCollection = null; final Collection<ShareProductMarketPriceData> shareMarketCollection = null;
@@ -107,8 +91,8 @@ public class ShareProductReadPlatformServiceImpl implements ProductReadPlatformS
try { try {
final String sql1 = "select " + marketRowMapper.schema() + " where marketData.product_id = ?"; final String sql1 = "select " + marketRowMapper.schema() + " where marketData.product_id = ?";
final Collection<ShareProductMarketPriceData> shareMarketCollection = this.jdbcTemplate.query(sql1, marketRowMapper, final Collection<ShareProductMarketPriceData> shareMarketCollection = this.jdbcTemplate.query(sql1, marketRowMapper, // NOSONAR
new Object[] { productId }); // NOSONAR new Object[] { productId });
final Collection<ChargeData> charges = this.chargeReadPlatformService.retrieveShareProductCharges(productId); final Collection<ChargeData> charges = this.chargeReadPlatformService.retrieveShareProductCharges(productId);
ShareProductRowMapper mapper = new ShareProductRowMapper(shareMarketCollection, charges); ShareProductRowMapper mapper = new ShareProductRowMapper(shareMarketCollection, charges);
final String sql = "select " + mapper.schema() + " where shareproduct.id = ?"; final String sql = "select " + mapper.schema() + " where shareproduct.id = ?";