Upgrade to Spring Boot 2.6.0

This commit is contained in:
Petri
2021-11-24 16:26:51 +01:00
committed by Aleksandar Vidakovic
parent aacb28b131
commit d82560d7b3
43 changed files with 128 additions and 164 deletions
+3 -3
View File
@@ -59,7 +59,7 @@ plugins {
id 'com.github.hierynomus.license' version '0.16.1' apply false
id 'org.openapi.generator' version '4.3.1' apply false
id 'org.zeroturnaround.gradle.jrebel' version '1.1.11' apply false
id 'org.springframework.boot' version '2.3.5.RELEASE' apply false
id 'org.springframework.boot' version '2.6.0' apply false
id 'net.ltgt.errorprone' version '2.0.2' apply false
id 'io.swagger.core.v3.swagger-gradle-plugin' version '2.1.11' apply false
id 'com.gorylenko.gradle-git-properties' version '2.3.1' apply false
@@ -99,7 +99,7 @@ allprojects {
dependencyManagement {
imports {
mavenBom 'org.springframework:spring-framework-bom:5.3.12'
mavenBom 'org.springframework.boot:spring-boot-dependencies:2.5.4'
mavenBom 'org.springframework.boot:spring-boot-dependencies:2.6.0'
mavenBom 'org.junit:junit-bom:5.8.1'
}
@@ -141,7 +141,7 @@ allprojects {
dependency 'org.mock-server:mockserver-junit-jupiter:5.11.2'
dependency 'org.webjars.npm:swagger-ui-dist:4.0.1'
dependency 'org.webjars:webjars-locator-core:0.48'
dependency 'org.springframework.boot:spring-boot-starter-mail:2.5.4'
dependency 'org.springframework.boot:spring-boot-starter-mail:2.6.0'
// fineract client dependencies
dependency "com.squareup.retrofit2:retrofit:$retrofitVersion"
+3 -1
View File
@@ -175,6 +175,7 @@ war {
into "WEB-INF/" // no leading slash
}
enabled = true
classifier = ''
}
// If we are running Gradle within Eclipse to enhance classes with OpenJPA,
@@ -261,7 +262,7 @@ bootRun {
}
springBoot {
mainClassName = 'org.apache.fineract.ServerApplication'
mainClass = 'org.apache.fineract.ServerApplication'
}
bootJar {
@@ -270,6 +271,7 @@ bootJar {
attributes 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher'
}
dependsOn resolve
classifier = ''
}
bootWar {
@@ -27,6 +27,7 @@ management.health.readinessState.enabled=true
# FINERACT-883
management.info.git.mode=FULL
management.endpoints.web.exposure.include=health,info
# FINERACT-914
server.forward-headers-strategy=framework
@@ -28,6 +28,7 @@ management.health.readinessState.enabled=true
# FINERACT-883
management.info.git.mode=FULL
management.endpoints.web.exposure.include=health,info
# FINERACT-914
server.forward-headers-strategy=framework
@@ -28,6 +28,7 @@ management.health.readinessState.enabled=true
# FINERACT-883
management.info.git.mode=FULL
management.endpoints.web.exposure.include=health,info
# FINERACT-914
server.forward-headers-strategy=framework
@@ -28,6 +28,7 @@ management.health.readinessState.enabled=true
# FINERACT-883
management.info.git.mode=FULL
management.endpoints.web.exposure.include=health,info
# FINERACT-914
server.forward-headers-strategy=framework
@@ -232,7 +232,7 @@ public class ProductToGLAccountMappingHelper {
// If input map is empty, delete all existing mappings
if (inputChargeToIncomeAccountMap.size() == 0) {
this.accountMappingRepository.deleteInBatch(existingChargeToIncomeAccountMappings);
this.accountMappingRepository.deleteAllInBatch(existingChargeToIncomeAccountMappings);
} /**
* Else, <br/>
* update existing mappings OR <br/>
@@ -315,7 +315,7 @@ public class ProductToGLAccountMappingHelper {
// If input map is empty, delete all existing mappings
if (inputPaymentChannelFundSourceMap.size() == 0) {
this.accountMappingRepository.deleteInBatch(existingPaymentChannelToFundSourceMappings);
this.accountMappingRepository.deleteAllInBatch(existingPaymentChannelToFundSourceMappings);
} /**
* Else, <br/>
* update existing mappings OR <br/>
@@ -448,7 +448,7 @@ public class ProductToGLAccountMappingHelper {
final List<ProductToGLAccountMapping> productToGLAccountMappings = this.accountMappingRepository
.findByProductIdAndProductType(loanProductId, portfolioProductType.getValue());
if (productToGLAccountMappings != null && productToGLAccountMappings.size() > 0) {
this.accountMappingRepository.deleteInBatch(productToGLAccountMappings);
this.accountMappingRepository.deleteAllInBatch(productToGLAccountMappings);
}
}
}
@@ -33,7 +33,6 @@ import org.springframework.security.authentication.dao.DaoAuthenticationProvider
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
@@ -50,21 +49,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private TenantAwareJpaPlatformUserDetailsService userDetailsService;
@Autowired
private TenantAwareBasicAuthenticationFilter tenantAwareBasicAuthenticationFilter;
@Autowired
private TwoFactorAuthenticationFilter twoFactorAuthenticationFilter;
/**
* The purpose of this method is to exclude the URL's specific to Login, Swagger UI and static files. Any URL that
* should be excluded from the Spring security chain should be added to the ignore list in this method only
*/
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/swagger-ui/**", "/actuator/**", "/api-docs/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
@@ -86,12 +73,17 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.sessionManagement() //
.sessionCreationPolicy(SessionCreationPolicy.STATELESS) //
.and() //
.addFilterAfter(tenantAwareBasicAuthenticationFilter, SecurityContextPersistenceFilter.class) //
.addFilterAfter(tenantAwareBasicAuthenticationFilter(), SecurityContextPersistenceFilter.class) //
.addFilterAfter(twoFactorAuthenticationFilter, BasicAuthenticationFilter.class) //
.requiresChannel(channel -> channel.antMatchers("/api/**").requiresSecure());
}
@Bean
public TenantAwareBasicAuthenticationFilter tenantAwareBasicAuthenticationFilter() throws Exception {
return new TenantAwareBasicAuthenticationFilter(authenticationManagerBean(), basicAuthenticationEntryPoint());
}
@Bean
public BasicAuthenticationEntryPoint basicAuthenticationEntryPoint() {
BasicAuthenticationEntryPoint basicAuthenticationEntryPoint = new BasicAuthenticationEntryPoint();
@@ -125,9 +117,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
}
@Bean
public FilterRegistrationBean<TenantAwareBasicAuthenticationFilter> tenantAwareBasicAuthenticationFilterRegistration() {
public FilterRegistrationBean<TenantAwareBasicAuthenticationFilter> tenantAwareBasicAuthenticationFilterRegistration()
throws Exception {
FilterRegistrationBean<TenantAwareBasicAuthenticationFilter> registration = new FilterRegistrationBean<TenantAwareBasicAuthenticationFilter>(
tenantAwareBasicAuthenticationFilter);
tenantAwareBasicAuthenticationFilter());
registration.setEnabled(false);
return registration;
}
@@ -28,7 +28,7 @@ public class PaginationHelper<E> {
public Page<E> fetchPage(final JdbcTemplate jt, final String sqlCountRows, final String sqlFetchRows, final Object[] args,
final RowMapper<E> rowMapper) {
final List<E> items = jt.query(sqlFetchRows, args, rowMapper);
final List<E> items = jt.query(sqlFetchRows, rowMapper, args);
// determine how many rows are available
final int totalFilteredRecords = jt.queryForObject(sqlCountRows, Integer.class);
@@ -65,7 +65,7 @@ public class CreditBureauConfigurationWritePlatformServiceImpl implements Credit
this.fromApiJsonDeserializer.validateForCreate(command.json(), creditBureauId);
final OrganisationCreditBureau orgcb = this.organisationCreditBureauRepository.getOne(creditBureauId);
final OrganisationCreditBureau orgcb = this.organisationCreditBureauRepository.getById(creditBureauId);
final CreditBureauConfiguration cb_config = CreditBureauConfiguration.fromJson(command, orgcb);
@@ -68,9 +68,9 @@ public class CreditBureauLoanProductMappingWritePlatformServiceImpl implements C
final long lpid = command.longValueOfParameterNamed("loanProductId");
final OrganisationCreditBureau orgcb = this.organisationCreditBureauRepository.getOne(organisationCreditBureauId);
final OrganisationCreditBureau orgcb = this.organisationCreditBureauRepository.getById(organisationCreditBureauId);
final LoanProduct lp = this.loanProductRepository.getOne(lpid);
final LoanProduct lp = this.loanProductRepository.getById(lpid);
final CreditBureauLoanProductMapping cb_lp = CreditBureauLoanProductMapping.fromJson(command, orgcb, lp);
@@ -88,7 +88,7 @@ public class CreditBureauLoanProductMappingWritePlatformServiceImpl implements C
final Long mappingid = command.longValueOfParameterNamed("creditbureauLoanProductMappingId");
final boolean isActive = command.booleanPrimitiveValueOfParameterNamed("isActive");
final CreditBureauLoanProductMapping cblpmapping = this.creditBureauLoanProductMappingRepository.getOne(mappingid);
final CreditBureauLoanProductMapping cblpmapping = this.creditBureauLoanProductMappingRepository.getById(mappingid);
cblpmapping.setIs_active(isActive);
this.creditBureauLoanProductMappingRepository.saveAndFlush(cblpmapping);
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(cblpmapping.getId()).build();
@@ -58,7 +58,7 @@ public class OrganisationCreditBureauWritePlatflormServiceImpl implements Organi
this.context.authenticatedUser();
this.fromApiJsonDeserializer.validateForCreate(command.json(), creditBureauId);
final CreditBureau creditBureau = this.creditBureauRepository.getOne(creditBureauId);
final CreditBureau creditBureau = this.creditBureauRepository.getById(creditBureauId);
final OrganisationCreditBureau organisationCreditBureau = OrganisationCreditBureau.fromJson(command, creditBureau);
@@ -78,7 +78,7 @@ public class OrganisationCreditBureauWritePlatflormServiceImpl implements Organi
final boolean isActive = command.booleanPrimitiveValueOfParameterNamed("isActive");
final OrganisationCreditBureau orgcb = organisationCreditBureauRepository.getOne(creditbureauID);
final OrganisationCreditBureau orgcb = organisationCreditBureauRepository.getById(creditbureauID);
orgcb.setIsActive(isActive);
@@ -69,56 +69,28 @@ public class JobRegisterServiceImpl implements JobRegisterService, ApplicationLi
private static final Logger LOG = LoggerFactory.getLogger(JobRegisterServiceImpl.class);
// MIFOSX-1184: This class cannot use constructor injection, because one of
// its dependencies (SchedulerStopListener) has a circular dependency to
// itself. So, slightly differently from how it's done elsewhere in this
// code base, the following fields are not final, and there is no
// constructor, but setters.
@Autowired
private ApplicationContext applicationContext;
@Autowired
private SchedularWritePlatformService schedularWritePlatformService;
@Autowired
private TenantDetailsService tenantDetailsService;
@Autowired
private SchedulerJobListener schedulerJobListener;
private SchedulerStopListener schedulerStopListener;
@Autowired
private SchedulerTriggerListener globalSchedulerTriggerListener;
@Autowired
private JobParameterRepository jobParameterRepository;
private final HashMap<String, Scheduler> schedulers = new HashMap<>(4);
@Autowired
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@Autowired
public void setSchedularWritePlatformService(SchedularWritePlatformService schedularWritePlatformService) {
this.schedularWritePlatformService = schedularWritePlatformService;
}
@Autowired
public void setTenantDetailsService(TenantDetailsService tenantDetailsService) {
this.tenantDetailsService = tenantDetailsService;
}
@Autowired
public void setSchedulerJobListener(SchedulerJobListener schedulerJobListener) {
this.schedulerJobListener = schedulerJobListener;
}
@Autowired
public void setSchedulerStopListener(SchedulerStopListener schedulerStopListener) {
this.schedulerStopListener = schedulerStopListener;
}
@Autowired
public void setGlobalTriggerListener(SchedulerTriggerListener globalTriggerListener) {
this.globalSchedulerTriggerListener = globalTriggerListener;
}
@Autowired
public void setJobParameterRepository(JobParameterRepository jobParameterRepository) {
this.jobParameterRepository = jobParameterRepository;
}
// This cannot be injected as Autowired due to circular dependency
private SchedulerStopListener schedulerStopListener = new SchedulerStopListener(this);
@Value("${node_id:1}")
private String nodeId;
@@ -21,13 +21,10 @@ package org.apache.fineract.infrastructure.jobs.service;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Global job Listener class to Stop the temporary scheduler once job execution completes
*/
@Component
public class SchedulerStopListener implements JobListener {
private static final String name = "Singlr Trigger Global Listener";
@@ -40,8 +37,7 @@ public class SchedulerStopListener implements JobListener {
private JobRegisterService jobRegisterService;
@Autowired
public void setJobRegisterService(JobRegisterService jobRegisterService) {
public SchedulerStopListener(JobRegisterService jobRegisterService) {
this.jobRegisterService = jobRegisterService;
}
@@ -45,7 +45,6 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.stereotype.Service;
/**
* A customised version of spring security's {@link BasicAuthenticationFilter}.
@@ -59,33 +58,34 @@ import org.springframework.stereotype.Service;
*
* If multi-tenant and basic auth credentials are invalid, a http error response is returned.
*/
@Service
@Profile("basicauth")
public class TenantAwareBasicAuthenticationFilter extends BasicAuthenticationFilter {
private static boolean firstRequestProcessed = false;
private static final Logger LOG = LoggerFactory.getLogger(TenantAwareBasicAuthenticationFilter.class);
private final BasicAuthTenantDetailsService basicAuthTenantDetailsService;
private final ToApiJsonSerializer<PlatformRequestLog> toApiJsonSerializer;
private final ConfigurationDomainService configurationDomainService;
private final CacheWritePlatformService cacheWritePlatformService;
private final NotificationReadPlatformService notificationReadPlatformService;
@Autowired
private ToApiJsonSerializer<PlatformRequestLog> toApiJsonSerializer;
@Autowired
private ConfigurationDomainService configurationDomainService;
@Autowired
private CacheWritePlatformService cacheWritePlatformService;
@Autowired
private NotificationReadPlatformService notificationReadPlatformService;
@Autowired
private BasicAuthTenantDetailsService basicAuthTenantDetailsService;
private final String tenantRequestHeader = "Fineract-Platform-TenantId";
private final boolean exceptionIfHeaderMissing = true;
@Autowired
public TenantAwareBasicAuthenticationFilter(final AuthenticationManager authenticationManager,
final AuthenticationEntryPoint authenticationEntryPoint, final BasicAuthTenantDetailsService basicAuthTenantDetailsService,
final ToApiJsonSerializer<PlatformRequestLog> toApiJsonSerializer, final ConfigurationDomainService configurationDomainService,
final CacheWritePlatformService cacheWritePlatformService,
final NotificationReadPlatformService notificationReadPlatformService) {
final AuthenticationEntryPoint authenticationEntryPoint) {
super(authenticationManager, authenticationEntryPoint);
this.basicAuthTenantDetailsService = basicAuthTenantDetailsService;
this.toApiJsonSerializer = toApiJsonSerializer;
this.configurationDomainService = configurationDomainService;
this.cacheWritePlatformService = cacheWritePlatformService;
this.notificationReadPlatformService = notificationReadPlatformService;
}
@Override
@@ -550,8 +550,8 @@ public class AccountTransfersReadPlatformServiceImpl implements AccountTransfers
sqlBuilder.append(" and trans.transaction_date = ? ");
sqlBuilder.append(" and IF(1=?, det.from_loan_account_id = ?, det.from_savings_account_id = ?) ");
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(),
new Object[] { this.formatter.format(transactionDate), accountType, accountId, accountId }, BigDecimal.class);
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), BigDecimal.class, this.formatter.format(transactionDate),
accountType, accountId, accountId);
}
}
@@ -79,22 +79,22 @@ public class AddressWritePlatformServiceImpl implements AddressWritePlatformServ
if (command.longValueOfParameterNamed("stateProvinceId") != null) {
stateId = command.longValueOfParameterNamed("stateProvinceId");
stateIdobj = this.codeValueRepository.getOne(stateId);
stateIdobj = this.codeValueRepository.getById(stateId);
}
if (command.longValueOfParameterNamed("countryId") != null) {
countryId = command.longValueOfParameterNamed("countryId");
countryIdObj = this.codeValueRepository.getOne(countryId);
countryIdObj = this.codeValueRepository.getById(countryId);
}
final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
final CodeValue addressTypeIdObj = this.codeValueRepository.getById(addressTypeId);
final Address add = Address.fromJson(command, stateIdobj, countryIdObj);
add.setCreatedOn(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
add.setUpdatedOn(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
this.addressRepository.save(add);
final Long addressid = add.getId();
final Address addobj = this.addressRepository.getOne(addressid);
final Address addobj = this.addressRepository.getById(addressid);
final Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId);
final boolean isActive = command.booleanPrimitiveValueOfParameterNamed("isActive");
@@ -126,23 +126,23 @@ public class AddressWritePlatformServiceImpl implements AddressWritePlatformServ
if (jsonObject.get("stateProvinceId") != null) {
stateId = jsonObject.get("stateProvinceId").getAsLong();
stateIdobj = this.codeValueRepository.getOne(stateId);
stateIdobj = this.codeValueRepository.getById(stateId);
}
if (jsonObject.get("countryId") != null) {
countryId = jsonObject.get("countryId").getAsLong();
countryIdObj = this.codeValueRepository.getOne(countryId);
countryIdObj = this.codeValueRepository.getById(countryId);
}
final long addressTypeId = jsonObject.get("addressTypeId").getAsLong();
final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
final CodeValue addressTypeIdObj = this.codeValueRepository.getById(addressTypeId);
final Address add = Address.fromJsonObject(jsonObject, stateIdobj, countryIdObj);
add.setCreatedOn(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
add.setUpdatedOn(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
this.addressRepository.save(add);
final Long addressid = add.getId();
final Address addobj = this.addressRepository.getOne(addressid);
final Address addobj = this.addressRepository.getById(addressid);
// final boolean isActive =
// jsonObject.get("isActive").getAsBoolean();
@@ -184,7 +184,7 @@ public class AddressWritePlatformServiceImpl implements AddressWritePlatformServ
throw new AddressNotFoundException(clientId);
}
final Address addobj = this.addressRepository.getOne(addressId);
final Address addobj = this.addressRepository.getById(addressId);
if (!command.stringValueOfParameterNamed("addressLine1").isEmpty()) {
@@ -232,7 +232,7 @@ public class AddressWritePlatformServiceImpl implements AddressWritePlatformServ
if (command.longValueOfParameterNamed("stateProvinceId") != 0) {
is_address_update = true;
stateId = command.longValueOfParameterNamed("stateProvinceId");
stateIdobj = this.codeValueRepository.getOne(stateId);
stateIdobj = this.codeValueRepository.getById(stateId);
addobj.setStateProvince(stateIdobj);
}
@@ -241,7 +241,7 @@ public class AddressWritePlatformServiceImpl implements AddressWritePlatformServ
if (command.longValueOfParameterNamed("countryId") != 0) {
is_address_update = true;
countryId = command.longValueOfParameterNamed("countryId");
countryIdObj = this.codeValueRepository.getOne(countryId);
countryIdObj = this.codeValueRepository.getById(countryId);
addobj.setCountry(countryIdObj);
}
@@ -82,7 +82,7 @@ public class FieldConfigurationReadPlatformServiceImpl implements FieldConfigura
final FieldMapper rm = new FieldMapper();
final String sql = "select " + rm.schema() + " where fld.entity=?";
return this.jdbcTemplate.query(sql, new Object[] { entity }, rm);
return this.jdbcTemplate.query(sql, rm, entity);
}
}
@@ -62,7 +62,7 @@ public enum CalendarFrequencyType {
public static CalendarFrequencyType fromString(final String frequencyString) {
CalendarFrequencyType frequency = CalendarFrequencyType.INVALID;
if (StringUtils.isEmpty(frequencyString)) {
if (!StringUtils.hasText(frequencyString)) {
return frequency;
}
@@ -79,7 +79,7 @@ public enum CalendarWeekDaysType {
public static CalendarWeekDaysType fromString(final String weekDayString) {
CalendarWeekDaysType weekDay = CalendarWeekDaysType.INVALID;
if (StringUtils.isEmpty(weekDayString)) {
if (!StringUtils.hasText(weekDayString)) {
return weekDay;
}
@@ -268,8 +268,7 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ
String query = "Select COUNT(*) from m_calendar_instance ci where ci.entity_id = ? and ci.calendar_id = ? and "
+ " ci.entity_type_enum = ?";
try {
int calendarInstaneId = this.jdbcTemplate.queryForObject(query, new Object[] { entityId, calendarId, entityTypeId },
Integer.class);
int calendarInstaneId = this.jdbcTemplate.queryForObject(query, Integer.class, entityId, calendarId, entityTypeId);
if (calendarInstaneId > 0) {
return true;
}
@@ -69,7 +69,7 @@ public enum ClientStatus {
ClientStatus clientStatus = ClientStatus.INVALID;
if (StringUtils.isEmpty(clientString)) {
if (!StringUtils.hasLength(clientString)) {
return clientStatus;
}
@@ -119,22 +119,22 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
if (command.longValueOfParameterNamed("relationshipId") != null) {
relationshipId = command.longValueOfParameterNamed("relationshipId");
relationship = this.codeValueRepository.getOne(relationshipId);
relationship = this.codeValueRepository.getById(relationshipId);
}
if (command.longValueOfParameterNamed("maritalStatusId") != null) {
maritalStatusId = command.longValueOfParameterNamed("maritalStatusId");
maritalStatus = this.codeValueRepository.getOne(maritalStatusId);
maritalStatus = this.codeValueRepository.getById(maritalStatusId);
}
if (command.longValueOfParameterNamed("genderId") != null) {
genderId = command.longValueOfParameterNamed("genderId");
gender = this.codeValueRepository.getOne(genderId);
gender = this.codeValueRepository.getById(genderId);
}
if (command.longValueOfParameterNamed("professionId") != null) {
professionId = command.longValueOfParameterNamed("professionId");
profession = this.codeValueRepository.getOne(professionId);
profession = this.codeValueRepository.getById(professionId);
}
if (command.dateValueOfParameterNamed("dateOfBirth") != null) {
@@ -218,22 +218,22 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
if (member.get("relationshipId") != null) {
relationshipId = member.get("relationshipId").getAsLong();
relationship = this.codeValueRepository.getOne(relationshipId);
relationship = this.codeValueRepository.getById(relationshipId);
}
if (member.get("maritalStatusId") != null) {
maritalStatusId = member.get("maritalStatusId").getAsLong();
maritalStatus = this.codeValueRepository.getOne(maritalStatusId);
maritalStatus = this.codeValueRepository.getById(maritalStatusId);
}
if (member.get("genderId") != null) {
genderId = member.get("genderId").getAsLong();
gender = this.codeValueRepository.getOne(genderId);
gender = this.codeValueRepository.getById(genderId);
}
if (member.get("professionId") != null) {
professionId = member.get("professionId").getAsLong();
profession = this.codeValueRepository.getOne(professionId);
profession = this.codeValueRepository.getById(professionId);
}
if (member.get("dateOfBirth") != null) {
@@ -295,7 +295,7 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
* command.longValueOfParameterNamed("clientFamilyMemberId"); }
*/
ClientFamilyMembers clientFamilyMember = clientFamilyRepository.getOne(familyMemberId);
ClientFamilyMembers clientFamilyMember = clientFamilyRepository.getById(familyMemberId);
// Client
// client=clientRepositoryWrapper.findOneWithNotFoundDetection(clientId);
@@ -337,25 +337,25 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
if (command.longValueOfParameterNamed("relationShipId") != null) {
relationshipId = command.longValueOfParameterNamed("relationShipId");
relationship = this.codeValueRepository.getOne(relationshipId);
relationship = this.codeValueRepository.getById(relationshipId);
clientFamilyMember.setRelationship(relationship);
}
if (command.longValueOfParameterNamed("maritalStatusId") != 0) {
maritalStatusId = command.longValueOfParameterNamed("maritalStatusId");
maritalStatus = this.codeValueRepository.getOne(maritalStatusId);
maritalStatus = this.codeValueRepository.getById(maritalStatusId);
clientFamilyMember.setMaritalStatus(maritalStatus);
}
if (command.longValueOfParameterNamed("genderId") != 0) {
genderId = command.longValueOfParameterNamed("genderId");
gender = this.codeValueRepository.getOne(genderId);
gender = this.codeValueRepository.getById(genderId);
clientFamilyMember.setGender(gender);
}
if (command.longValueOfParameterNamed("professionId") != 0) {
professionId = command.longValueOfParameterNamed("professionId");
profession = this.codeValueRepository.getOne(professionId);
profession = this.codeValueRepository.getById(professionId);
clientFamilyMember.setProfession(profession);
}
@@ -386,7 +386,7 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
ClientFamilyMembers clientFamilyMember = null;
if (clientFamilyMemberId != null) {
clientFamilyMember = clientFamilyRepository.getOne(clientFamilyMemberId);
clientFamilyMember = clientFamilyRepository.getById(clientFamilyMemberId);
clientFamilyRepository.delete(clientFamilyMember);
}
@@ -175,7 +175,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new ClientMustBePendingToBeDeletedException(clientId);
}
final List<Note> relatedNotes = this.noteRepository.findByClient(client);
this.noteRepository.deleteInBatch(relatedNotes);
this.noteRepository.deleteAllInBatch(relatedNotes);
final ClientNonPerson clientNonPerson = this.clientNonPersonRepository.findOneByClientId(clientId);
if (clientNonPerson != null) {
@@ -595,7 +595,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
}
final List<Note> relatedNotes = this.noteRepository.findByGroup(groupForDelete);
this.noteRepository.deleteInBatch(relatedNotes);
this.noteRepository.deleteAllInBatch(relatedNotes);
this.groupRepository.delete(groupForDelete);
this.groupRepository.flush();
@@ -1286,7 +1286,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
}
final List<Note> relatedNotes = this.noteRepository.findByLoanId(loan.getId());
this.noteRepository.deleteInBatch(relatedNotes);
this.noteRepository.deleteAllInBatch(relatedNotes);
final AccountAssociations accountAssociations = this.accountAssociationsRepository.findByLoanIdAndType(loanId,
AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue());
@@ -2059,8 +2059,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
public Date retrieveMinimumDateOfRepaymentTransaction(Long loanId) {
// TODO Auto-generated method stub
Date date = this.jdbcTemplate.queryForObject(
"select min(transaction_date) from m_loan_transaction where loan_id=? and transaction_type_enum=2", new Object[] { loanId },
Date.class);
"select min(transaction_date) from m_loan_transaction where loan_id=? and transaction_type_enum=2", Date.class, loanId);
return date;
}
@@ -2290,8 +2289,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
@Override
public Long retrieveLoanIdByAccountNumber(String loanAccountNumber) {
try {
return this.jdbcTemplate.queryForObject("select l.id from m_loan l where l.account_no = ?", new Object[] { loanAccountNumber },
Long.class);
return this.jdbcTemplate.queryForObject("select l.id from m_loan l where l.account_no = ?", Long.class, loanAccountNumber);
} catch (final EmptyResultDataAccessException e) {
return null;
@@ -2302,7 +2300,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
public String retrieveAccountNumberByAccountId(Long accountId) {
try {
final String sql = "select loan.account_no from m_loan loan where loan.id = ?";
return this.jdbcTemplate.queryForObject(sql, new Object[] { accountId }, String.class);
return this.jdbcTemplate.queryForObject(sql, String.class, accountId);
} catch (final EmptyResultDataAccessException e) {
throw new LoanNotFoundException(accountId, e);
}
@@ -1857,7 +1857,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WAIVE_CHARGE_UNDO,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
LoanTransaction loanTransactionData = this.loanTransactionRepository.getOne(command.entityId());
LoanTransaction loanTransactionData = this.loanTransactionRepository.getById(command.entityId());
changes.put("principalPortion", loanTransactionData.getPrincipalPortion());
changes.put("interestPortion", loanTransactionData.getInterestPortion(loan.getCurrency()));
changes.put("feeChargesPortion", loanTransactionData.getFeeChargesPortion(loan.getCurrency()));
@@ -623,7 +623,7 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
}
final List<Note> relatedNotes = this.noteRepository.findBySavingsAccount(account);
this.noteRepository.deleteInBatch(relatedNotes);
this.noteRepository.deleteAllInBatch(relatedNotes);
this.savingAccountRepository.delete(account);
@@ -1202,8 +1202,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
final StringBuilder buff = new StringBuilder("select count(*) from m_savings_account sa ");
buff.append(
" where sa.id = ? and sa.client_id = ? and sa.deposit_type_enum = ? and sa.currency_code = ? and sa.status_enum = 300");
return this.jdbcTemplate.queryForObject(buff.toString(),
new Object[] { accountId, clientId, depositAccountType.getValue(), currencyCode }, Integer.class) > 0;
return this.jdbcTemplate.queryForObject(buff.toString(), Integer.class, accountId, clientId, depositAccountType.getValue(),
currencyCode) > 0;
} catch (final EmptyResultDataAccessException e) {
throw new SavingsAccountNotFoundException(accountId, e);
}
@@ -1235,7 +1235,7 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
public String retrieveAccountNumberByAccountId(Long accountId) {
try {
final String sql = "select s.account_no from m_savings_account s where s.id = ?";
return this.jdbcTemplate.queryForObject(sql, new Object[] { accountId }, String.class);
return this.jdbcTemplate.queryForObject(sql, String.class, accountId);
} catch (final EmptyResultDataAccessException e) {
throw new SavingsAccountNotFoundException(accountId, e);
}
@@ -468,7 +468,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
}
final List<Note> relatedNotes = this.noteRepository.findBySavingsAccount(account);
this.noteRepository.deleteInBatch(relatedNotes);
this.noteRepository.deleteAllInBatch(relatedNotes);
this.savingAccountRepository.delete(account);
@@ -186,6 +186,6 @@ public class SelfBeneficiariesTPTReadPlatformServiceImpl implements SelfBenefici
sqlBuilder.append(" and b.account_type = ? ");
sqlBuilder.append(" and b.is_active = 1; ");
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), new Object[] { appUserId, accountId, accountType }, Long.class);
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class, appUserId, accountId, accountType);
}
}
@@ -43,7 +43,7 @@ public class AppuserClientMapperReadServiceImpl implements AppuserClientMapperRe
return this.jdbcTemplate.queryForObject(
"select case when (count(*) > 0) then true else false end "
+ " from m_selfservice_user_client_mapping where client_id = ? and appuser_id = ?",
new Object[] { clientId, appUserId }, Boolean.class);
Boolean.class, clientId, appUserId);
}
@Override
@@ -38,7 +38,7 @@ public class AppuserLoansMapperReadServiceImpl implements AppuserLoansMapperRead
return this.jdbcTemplate.queryForObject(
"select case when (count(*) > 0) then true else false end " + " from m_selfservice_user_client_mapping as m "
+ " left join m_loan as l on l.client_id = m.client_id " + " where l.id = ? and m.appuser_id = ? ",
new Object[] { loanId, appUserId }, Boolean.class);
Boolean.class, loanId, appUserId);
}
}
@@ -79,7 +79,7 @@ public class PocketAccountMappingReadPlatformServiceImpl implements PocketAccoun
public boolean validatePocketAndAccountMapping(Long pocketId, Long accountId, Integer accountType) {
final String sql = "select count(id) from m_pocket_accounts_mapping mapping where pocket_id = ? and account_id = ? and account_type = ?";
try {
return this.jdbcTemplate.queryForObject(sql, new Object[] { pocketId, accountId, accountType }, Boolean.class);
return this.jdbcTemplate.queryForObject(sql, Boolean.class, pocketId, accountId, accountType);
} catch (EmptyResultDataAccessException e) {
return false;
}
@@ -42,7 +42,7 @@ public class SelfServiceRegistrationReadPlatformServiceImpl implements SelfServi
sql = sql + " and mobile_no = ?";
params = new Object[] { accountNumber, firstName, lastName, mobileNumber };
}
Integer count = this.jdbcTemplate.queryForObject(sql, params, Integer.class);
Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class, params);
if (count == 0) {
return false;
}
@@ -38,6 +38,6 @@ public class AppuserSavingsMapperReadServiceImpl implements AppuserSavingsMapper
return this.jdbcTemplate.queryForObject(
"select case when (count(*) > 0) then true else false end " + " from m_selfservice_user_client_mapping as m "
+ " left join m_savings_account as s on s.client_id = m.client_id " + " where s.id = ? and m.appuser_id = ? ",
new Object[] { savingsId, appUserId }, Boolean.class);
Boolean.class, savingsId, appUserId);
}
}
@@ -39,7 +39,7 @@ public class AppUserShareAccountsMapperReadPlatformServiceImpl implements AppUse
return this.jdbcTemplate.queryForObject("select case when (count(*) > 0) then true else false end "
+ " from m_selfservice_user_client_mapping as m "
+ " left join m_share_account as shares on shares.client_id = m.client_id " + " where shares.id = ? and m.appuser_id = ? ",
new Object[] { accountId, appUserId }, Boolean.class);
Boolean.class, accountId, appUserId);
}
}
@@ -232,7 +232,7 @@ public class ShareAccountReadPlatformServiceImpl implements ShareAccountReadPlat
sb.append(" and saps.status_enum = ?");
params.add(PurchasedSharesStatusType.APPROVED.getValue());
Object[] whereClauseItems = params.toArray();
return this.jdbcTemplate.query(sb.toString(), whereClauseItems, mapper);
return this.jdbcTemplate.query(sb.toString(), mapper, whereClauseItems);
}
public Collection<ShareAccountChargeData> convertChargesToShareAccountCharges(Collection<ChargeData> productCharges) {
@@ -510,7 +510,7 @@ public class ShareAccountReadPlatformServiceImpl implements ShareAccountReadPlat
public String retrieveAccountNumberByAccountId(Long accountId) {
try {
final String sql = "select s.account_no from m_share_account s where s.id = ?";
return this.jdbcTemplate.queryForObject(sql, new Object[] { accountId }, String.class);
return this.jdbcTemplate.queryForObject(sql, String.class, accountId);
} catch (final EmptyResultDataAccessException e) {
throw new ShareAccountNotFoundException(accountId, e);
}
@@ -57,6 +57,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -92,7 +93,7 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService
final DepositAccountWritePlatformService depositAccountWritePlatformService,
final ShareAccountDividendReadPlatformService shareAccountDividendReadPlatformService,
final ShareAccountSchedularService shareAccountSchedularService,
final TrialBalanceRepositoryWrapper trialBalanceRepositoryWrapper, final JobRegisterService jobRegisterService,
final TrialBalanceRepositoryWrapper trialBalanceRepositoryWrapper, @Lazy final JobRegisterService jobRegisterService,
final ScheduledJobDetailRepository scheduledJobDetailsRepository) {
this.dataSourceServiceFactory = dataSourceServiceFactory;
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
@@ -461,16 +462,15 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService
// Updating closing balance
String distinctOfficeQuery = "select distinct(office_id) from m_trial_balance where closing_balance is null group by office_id";
final List<Long> officeIds = jdbcTemplate.queryForList(distinctOfficeQuery, new Object[] {}, Long.class);
final List<Long> officeIds = jdbcTemplate.queryForList(distinctOfficeQuery, Long.class);
for (Long officeId : officeIds) {
String distinctAccountQuery = "select distinct(account_id) from m_trial_balance where office_id=? and closing_balance is null group by account_id";
final List<Long> accountIds = jdbcTemplate.queryForList(distinctAccountQuery, new Object[] { officeId }, Long.class);
final List<Long> accountIds = jdbcTemplate.queryForList(distinctAccountQuery, Long.class, officeId);
for (Long accountId : accountIds) {
final String closingBalanceQuery = "select closing_balance from m_trial_balance where office_id=? and account_id=? and closing_balance "
+ "is not null order by created_date desc, entry_date desc limit 1";
List<BigDecimal> closingBalanceData = jdbcTemplate.queryForList(closingBalanceQuery, new Object[] { officeId, accountId },
BigDecimal.class);
List<BigDecimal> closingBalanceData = jdbcTemplate.queryForList(closingBalanceQuery, BigDecimal.class, officeId, accountId);
List<TrialBalance> tbRows = this.trialBalanceRepositoryWrapper.findNewByOfficeAndAccount(officeId, accountId);
BigDecimal closingBalance = null;
if (!CollectionUtils.isEmpty(closingBalanceData)) {
@@ -219,7 +219,7 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
public boolean isUsernameExist(String username) {
String sql = "select count(*) from m_appuser where username = ?";
Object[] params = new Object[] { username };
Integer count = this.jdbcTemplate.queryForObject(sql, params, Integer.class);
Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class, params);
if (count == 0) {
return false;
}
@@ -63,7 +63,7 @@ public class RoleReadPlatformServiceImpl implements RoleReadPlatformService {
final String role = SelfServiceApiConstants.SELF_SERVICE_USER_ROLE;
final String sql = "select " + this.roleRowMapper.schema() + " where r.name = ? order by r.id";
return this.jdbcTemplate.query(sql, new Object[] { role }, this.roleRowMapper);
return this.jdbcTemplate.query(sql, this.roleRowMapper, role);
}
@Override
@@ -65,12 +65,12 @@ public class TopicTest {
@Test
public void testTopicStorage() {
Office office = officeRepository.getOne(1L);
Office office = officeRepository.getById(1L);
Role role = new Role("New Member_Type", "Testing topic creation");
Topic topic = topicRepository.getOne(1L);
Topic topic = topicRepository.getById(1L);
lenient().when(this.officeRepository.getOne(1L)).thenReturn(office);
lenient().when(this.topicRepository.getOne(1L)).thenReturn(topic);
lenient().when(this.officeRepository.getById(1L)).thenReturn(office);
lenient().when(this.topicRepository.getById(1L)).thenReturn(topic);
when(this.roleRepository.save(role)).thenReturn(role);
when(this.topicWritePltfService.create(refEq(topic))).thenReturn(1L);
@@ -85,13 +85,13 @@ public class TopicTest {
@Test
public void testTopicSubscriberStorage() {
AppUser user = appUserRepository.getOne(1L);
Topic topic = topicRepository.getOne(1L);
AppUser user = appUserRepository.getById(1L);
Topic topic = topicRepository.getById(1L);
TopicSubscriber topicSubscriber = new TopicSubscriber(topic, user, new Date());
lenient().when(this.appUserRepository.getOne(1L)).thenReturn(user);
lenient().when(this.topicRepository.getOne(1L)).thenReturn(topic);
lenient().when(this.appUserRepository.getById(1L)).thenReturn(user);
lenient().when(this.topicRepository.getById(1L)).thenReturn(topic);
when(this.topicSubscriberWritePltfService.create(refEq(topicSubscriber))).thenReturn(1L);
Long subscriberId = this.topicSubscriberWritePltfService.create(topicSubscriber);