FINERACT-2238: New command processing - Business Date Management (org.apache.fineract.infrastructure.businessdate)
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
d5958f36c7
commit
bb46397daa
+6
-9
@@ -28,8 +28,6 @@ import static org.springframework.security.web.util.matcher.AntPathRequestMatche
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.apache.fineract.commands.domain.CommandSourceRepository;
|
||||
import org.apache.fineract.commands.service.CommandSourceService;
|
||||
import org.apache.fineract.infrastructure.businessdate.service.BusinessDateReadPlatformService;
|
||||
import org.apache.fineract.infrastructure.cache.service.CacheWritePlatformService;
|
||||
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||
@@ -48,7 +46,6 @@ import org.apache.fineract.infrastructure.security.filter.InsecureTwoFactorAuthe
|
||||
import org.apache.fineract.infrastructure.security.filter.TenantAwareBasicAuthenticationFilter;
|
||||
import org.apache.fineract.infrastructure.security.filter.TwoFactorAuthenticationFilter;
|
||||
import org.apache.fineract.infrastructure.security.service.BasicAuthTenantDetailsService;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.infrastructure.security.service.TenantAwareJpaPlatformUserDetailsService;
|
||||
import org.apache.fineract.infrastructure.security.service.TwoFactorService;
|
||||
import org.apache.fineract.notification.service.UserNotificationService;
|
||||
@@ -111,17 +108,11 @@ public class SecurityConfig {
|
||||
@Autowired
|
||||
private MDCWrapper mdcWrapper;
|
||||
@Autowired
|
||||
private CommandSourceRepository commandSourceRepository;
|
||||
@Autowired
|
||||
private CommandSourceService commandSourceService;
|
||||
@Autowired
|
||||
private FineractRequestContextHolder fineractRequestContextHolder;
|
||||
|
||||
@Autowired(required = false)
|
||||
private LoanCOBFilterHelper loanCOBFilterHelper;
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
@Autowired
|
||||
private IdempotencyStoreHelper idempotencyStoreHelper;
|
||||
|
||||
@Bean
|
||||
@@ -141,6 +132,12 @@ public class SecurityConfig {
|
||||
.requestMatchers(antMatcher(HttpMethod.POST, "/api/*/echo")).permitAll() //
|
||||
.requestMatchers(antMatcher(HttpMethod.POST, "/api/*/authentication")).permitAll() //
|
||||
.requestMatchers(antMatcher(HttpMethod.PUT, "/api/*/instance-mode")).permitAll() //
|
||||
// businessdate
|
||||
.requestMatchers(antMatcher(HttpMethod.GET, "/api/*/businessdate/*"))
|
||||
.hasAnyAuthority("ALL_FUNCTIONS", "ALL_FUNCTIONS_READ", "READ_BUSINESS_DATE") //
|
||||
.requestMatchers(antMatcher(HttpMethod.POST, "/api/*/businessdate"))
|
||||
.hasAnyAuthority("ALL_FUNCTIONS", "ALL_FUNCTIONS_WRITE", "UPDATE_BUSINESS_DATE") //
|
||||
//
|
||||
.requestMatchers(antMatcher(HttpMethod.POST, "/api/*/twofactor/validate")).fullyAuthenticated() //
|
||||
.requestMatchers(antMatcher("/api/*/twofactor")).fullyAuthenticated() //
|
||||
.requestMatchers(antMatcher("/api/**"))
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ public class JerseyConfig extends ResourceConfig {
|
||||
bind(PageableParamProvider.class).to(ValueParamProvider.class).in(Singleton.class);
|
||||
}
|
||||
});
|
||||
register(org.glassfish.jersey.server.validation.ValidationFeature.class);
|
||||
property(ServerProperties.WADL_FEATURE_DISABLE, true);
|
||||
}
|
||||
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.jobs.service.increasedateby1day;
|
||||
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
|
||||
public interface IncreaseDateBy1DayService {
|
||||
|
||||
void increaseDateByTypeByOneDay(BusinessDateType businessDateType);
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.jobs.service.increasedateby1day;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.infrastructure.businessdate.data.BusinessDateData;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDate;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateRepository;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.businessdate.service.BusinessDateWritePlatformService;
|
||||
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class IncreaseDateBy1DayServiceImpl implements IncreaseDateBy1DayService {
|
||||
|
||||
private final BusinessDateRepository businessDateRepository;
|
||||
private final BusinessDateWritePlatformService businessDateWritePlatformService;
|
||||
|
||||
@Override
|
||||
public void increaseDateByTypeByOneDay(BusinessDateType businessDateType) {
|
||||
Map<String, Object> changes = new HashMap<>();
|
||||
Optional<BusinessDate> businessDateEntity = businessDateRepository.findByType(businessDateType);
|
||||
LocalDate businessDate = businessDateEntity.map(BusinessDate::getDate).orElse(DateUtils.getLocalDateOfTenant());
|
||||
businessDate = businessDate.plusDays(1);
|
||||
try {
|
||||
BusinessDateData businessDateData = BusinessDateData.instance(businessDateType, businessDate);
|
||||
businessDateWritePlatformService.adjustDate(businessDateData, changes);
|
||||
} catch (final PlatformApiDataValidationException e) {
|
||||
final List<ApiParameterError> errors = e.getErrors();
|
||||
for (final ApiParameterError error : errors) {
|
||||
log.error("Increasing {} by 1 day failed due to: {}", businessDateType.getDescription(), error.getDeveloperMessage());
|
||||
}
|
||||
} catch (final AbstractPlatformDomainRuleException e) {
|
||||
log.error("Increasing {} by 1 day failed due to: {}", businessDateType.getDescription(), e.getDefaultUserMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("Increasing {} by 1 day failed due to: {}", businessDateType.getDescription(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-22
@@ -18,16 +18,14 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.increasebusinessdateby1day;
|
||||
|
||||
import org.apache.fineract.infrastructure.businessdate.service.BusinessDateWritePlatformService;
|
||||
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||
import org.apache.fineract.infrastructure.jobs.service.JobName;
|
||||
import org.apache.fineract.infrastructure.jobs.service.increasedateby1day.IncreaseDateBy1DayService;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.job.builder.JobBuilder;
|
||||
import org.springframework.batch.core.launch.support.RunIdIncrementer;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.step.builder.StepBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
@@ -35,29 +33,17 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
@Configuration
|
||||
public class IncreaseBusinessDateBy1DayConfig {
|
||||
|
||||
@Autowired
|
||||
private JobRepository jobRepository;
|
||||
@Autowired
|
||||
private PlatformTransactionManager transactionManager;
|
||||
@Autowired
|
||||
private IncreaseDateBy1DayService increaseDateBy1DayService;
|
||||
@Autowired
|
||||
private ConfigurationDomainService configurationDomainService;
|
||||
|
||||
@Bean
|
||||
protected Step increaseBusinessDateBy1DayStep() {
|
||||
return new StepBuilder(JobName.INCREASE_BUSINESS_DATE_BY_1_DAY.name(), jobRepository)
|
||||
.tasklet(increaseBusinessDateBy1DayTasklet(), transactionManager).build();
|
||||
public IncreaseBusinessDateBy1DayTasklet increaseBusinessDateBy1DayTasklet(
|
||||
BusinessDateWritePlatformService businessDateWritePlatformService, ConfigurationDomainService configurationDomainService) {
|
||||
return new IncreaseBusinessDateBy1DayTasklet(businessDateWritePlatformService, configurationDomainService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Job increaseBusinessDateBy1DayJob() {
|
||||
return new JobBuilder(JobName.INCREASE_BUSINESS_DATE_BY_1_DAY.name(), jobRepository).start(increaseBusinessDateBy1DayStep())
|
||||
public Job increaseBusinessDateBy1DayJob(PlatformTransactionManager transactionManager, JobRepository jobRepository,
|
||||
IncreaseBusinessDateBy1DayTasklet tasklet) {
|
||||
return new JobBuilder(JobName.INCREASE_BUSINESS_DATE_BY_1_DAY.name(), jobRepository).start(
|
||||
new StepBuilder(JobName.INCREASE_BUSINESS_DATE_BY_1_DAY.name(), jobRepository).tasklet(tasklet, transactionManager).build())
|
||||
.incrementer(new RunIdIncrementer()).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IncreaseBusinessDateBy1DayTasklet increaseBusinessDateBy1DayTasklet() {
|
||||
return new IncreaseBusinessDateBy1DayTasklet(increaseDateBy1DayService, configurationDomainService);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,8 +21,8 @@ package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.incre
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.businessdate.service.BusinessDateWritePlatformService;
|
||||
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||
import org.apache.fineract.infrastructure.jobs.service.increasedateby1day.IncreaseDateBy1DayService;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
@@ -33,13 +33,13 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
@RequiredArgsConstructor
|
||||
public class IncreaseBusinessDateBy1DayTasklet implements Tasklet {
|
||||
|
||||
private final IncreaseDateBy1DayService increaseDateBy1DayService;
|
||||
private final BusinessDateWritePlatformService businessDateWritePlatformService;
|
||||
private final ConfigurationDomainService configurationDomainService;
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
if (configurationDomainService.isBusinessDateEnabled()) {
|
||||
increaseDateBy1DayService.increaseDateByTypeByOneDay(BusinessDateType.BUSINESS_DATE);
|
||||
businessDateWritePlatformService.increaseDateByTypeByOneDay(BusinessDateType.BUSINESS_DATE);
|
||||
} else {
|
||||
contribution.setExitStatus(ExitStatus.NOOP);
|
||||
}
|
||||
|
||||
+8
-11
@@ -18,31 +18,28 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.increasecobdateby1day;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.businessdate.service.BusinessDateWritePlatformService;
|
||||
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||
import org.apache.fineract.infrastructure.jobs.service.JobName;
|
||||
import org.apache.fineract.infrastructure.jobs.service.increasedateby1day.IncreaseDateBy1DayService;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.job.builder.JobBuilder;
|
||||
import org.springframework.batch.core.launch.support.RunIdIncrementer;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.step.builder.StepBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class IncreaseCobDateBy1DayConfig {
|
||||
|
||||
@Autowired
|
||||
private JobRepository jobRepository;
|
||||
@Autowired
|
||||
private PlatformTransactionManager transactionManager;
|
||||
@Autowired
|
||||
private IncreaseDateBy1DayService increaseDateBy1DayService;
|
||||
@Autowired
|
||||
private ConfigurationDomainService configurationDomainService;
|
||||
private final JobRepository jobRepository;
|
||||
private final PlatformTransactionManager transactionManager;
|
||||
private final BusinessDateWritePlatformService businessDateWritePlatformService;
|
||||
private final ConfigurationDomainService configurationDomainService;
|
||||
|
||||
@Bean
|
||||
protected Step increaseCobDateBy1DayStep() {
|
||||
@@ -58,6 +55,6 @@ public class IncreaseCobDateBy1DayConfig {
|
||||
|
||||
@Bean
|
||||
public IncreaseCobDateBy1DayTasklet increaseCobDateBy1DayTasklet() {
|
||||
return new IncreaseCobDateBy1DayTasklet(increaseDateBy1DayService, configurationDomainService);
|
||||
return new IncreaseCobDateBy1DayTasklet(businessDateWritePlatformService, configurationDomainService);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,8 +21,8 @@ package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.incre
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.businessdate.service.BusinessDateWritePlatformService;
|
||||
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||
import org.apache.fineract.infrastructure.jobs.service.increasedateby1day.IncreaseDateBy1DayService;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
@@ -33,13 +33,13 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
@RequiredArgsConstructor
|
||||
public class IncreaseCobDateBy1DayTasklet implements Tasklet {
|
||||
|
||||
private final IncreaseDateBy1DayService increaseDateBy1DayService;
|
||||
private final BusinessDateWritePlatformService businessDateWritePlatformService;
|
||||
private final ConfigurationDomainService configurationDomainService;
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
if (configurationDomainService.isBusinessDateEnabled()) {
|
||||
increaseDateBy1DayService.increaseDateByTypeByOneDay(BusinessDateType.COB_DATE);
|
||||
businessDateWritePlatformService.increaseDateByTypeByOneDay(BusinessDateType.COB_DATE);
|
||||
} else {
|
||||
contribution.setExitStatus(ExitStatus.NOOP);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user