Add custom Configuration class for organisation/holiday module (FINERACT-1932)
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
1ef600ed73
commit
54ca135c3f
+2
-9
@@ -25,6 +25,7 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
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.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;
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
@@ -32,24 +33,16 @@ import org.apache.fineract.infrastructure.security.service.PlatformSecurityConte
|
|||||||
import org.apache.fineract.organisation.holiday.data.HolidayData;
|
import org.apache.fineract.organisation.holiday.data.HolidayData;
|
||||||
import org.apache.fineract.organisation.holiday.domain.RescheduleType;
|
import org.apache.fineract.organisation.holiday.domain.RescheduleType;
|
||||||
import org.apache.fineract.organisation.holiday.exception.HolidayNotFoundException;
|
import org.apache.fineract.organisation.holiday.exception.HolidayNotFoundException;
|
||||||
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;
|
|
||||||
|
|
||||||
@Service
|
@RequiredArgsConstructor
|
||||||
public class HolidayReadPlatformServiceImpl implements HolidayReadPlatformService {
|
public class HolidayReadPlatformServiceImpl implements HolidayReadPlatformService {
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public HolidayReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate) {
|
|
||||||
this.context = context;
|
|
||||||
this.jdbcTemplate = jdbcTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class HolidayMapper implements RowMapper<HolidayData> {
|
private static final class HolidayMapper implements RowMapper<HolidayData> {
|
||||||
|
|
||||||
private final String schema;
|
private final String schema;
|
||||||
|
|||||||
+5
-21
@@ -27,6 +27,8 @@ import java.time.LocalDate;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||||
@@ -45,19 +47,14 @@ import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
|
|||||||
import org.apache.fineract.organisation.workingdays.domain.WorkingDays;
|
import org.apache.fineract.organisation.workingdays.domain.WorkingDays;
|
||||||
import org.apache.fineract.organisation.workingdays.domain.WorkingDaysRepositoryWrapper;
|
import org.apache.fineract.organisation.workingdays.domain.WorkingDaysRepositoryWrapper;
|
||||||
import org.apache.fineract.organisation.workingdays.service.WorkingDaysUtil;
|
import org.apache.fineract.organisation.workingdays.service.WorkingDaysUtil;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@Service
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWritePlatformService {
|
public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWritePlatformService {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(HolidayWritePlatformServiceJpaRepositoryImpl.class);
|
|
||||||
|
|
||||||
private final HolidayDataValidator fromApiJsonDeserializer;
|
private final HolidayDataValidator fromApiJsonDeserializer;
|
||||||
private final HolidayRepositoryWrapper holidayRepository;
|
private final HolidayRepositoryWrapper holidayRepository;
|
||||||
private final WorkingDaysRepositoryWrapper daysRepositoryWrapper;
|
private final WorkingDaysRepositoryWrapper daysRepositoryWrapper;
|
||||||
@@ -65,19 +62,6 @@ public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWrit
|
|||||||
private final OfficeRepositoryWrapper officeRepositoryWrapper;
|
private final OfficeRepositoryWrapper officeRepositoryWrapper;
|
||||||
private final FromJsonHelper fromApiJsonHelper;
|
private final FromJsonHelper fromApiJsonHelper;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public HolidayWritePlatformServiceJpaRepositoryImpl(final HolidayDataValidator fromApiJsonDeserializer,
|
|
||||||
final HolidayRepositoryWrapper holidayRepository, final PlatformSecurityContext context,
|
|
||||||
final OfficeRepositoryWrapper officeRepositoryWrapper, final FromJsonHelper fromApiJsonHelper,
|
|
||||||
final WorkingDaysRepositoryWrapper daysRepositoryWrapper) {
|
|
||||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
|
||||||
this.holidayRepository = holidayRepository;
|
|
||||||
this.context = context;
|
|
||||||
this.officeRepositoryWrapper = officeRepositoryWrapper;
|
|
||||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
|
||||||
this.daysRepositoryWrapper = daysRepositoryWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult createHoliday(final JsonCommand command) {
|
public CommandProcessingResult createHoliday(final JsonCommand command) {
|
||||||
@@ -185,7 +169,7 @@ public class HolidayWritePlatformServiceJpaRepositoryImpl implements HolidayWrit
|
|||||||
"name", name);
|
"name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.error("Error occured.", dve);
|
log.error("Error occured.", dve);
|
||||||
throw new PlatformDataIntegrityException("error.msg.office.unknown.data.integrity.issue",
|
throw new PlatformDataIntegrityException("error.msg.office.unknown.data.integrity.issue",
|
||||||
"Unknown data integrity issue with resource.");
|
"Unknown data integrity issue with resource.");
|
||||||
}
|
}
|
||||||
|
|||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* 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.organisation.holiday.starter;
|
||||||
|
|
||||||
|
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
||||||
|
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||||
|
import org.apache.fineract.organisation.holiday.data.HolidayDataValidator;
|
||||||
|
import org.apache.fineract.organisation.holiday.domain.HolidayRepositoryWrapper;
|
||||||
|
import org.apache.fineract.organisation.holiday.service.HolidayReadPlatformService;
|
||||||
|
import org.apache.fineract.organisation.holiday.service.HolidayReadPlatformServiceImpl;
|
||||||
|
import org.apache.fineract.organisation.holiday.service.HolidayWritePlatformService;
|
||||||
|
import org.apache.fineract.organisation.holiday.service.HolidayWritePlatformServiceJpaRepositoryImpl;
|
||||||
|
import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
|
||||||
|
import org.apache.fineract.organisation.workingdays.domain.WorkingDaysRepositoryWrapper;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class OrganisationHolidayConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean(HolidayReadPlatformService.class)
|
||||||
|
public HolidayReadPlatformService holidayReadPlatformService(PlatformSecurityContext context, JdbcTemplate jdbcTemplate) {
|
||||||
|
return new HolidayReadPlatformServiceImpl(context, jdbcTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean(HolidayWritePlatformService.class)
|
||||||
|
public HolidayWritePlatformService holidayWritePlatformService(HolidayDataValidator fromApiJsonDeserializer,
|
||||||
|
HolidayRepositoryWrapper holidayRepository, PlatformSecurityContext context, OfficeRepositoryWrapper officeRepositoryWrapper,
|
||||||
|
FromJsonHelper fromApiJsonHelper, WorkingDaysRepositoryWrapper daysRepositoryWrapper) {
|
||||||
|
return new HolidayWritePlatformServiceJpaRepositoryImpl(fromApiJsonDeserializer, holidayRepository, daysRepositoryWrapper, context,
|
||||||
|
officeRepositoryWrapper, fromApiJsonHelper);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user