Skip to content

Commit

Permalink
Add custom Configuration class for organisation/workingdays module (F…
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav7sinha authored and vidakovic committed Oct 26, 2023
1 parent 8710b1c commit 9f3ebfb
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,22 @@
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.organisation.workingdays.data.WorkingDaysData;
import org.apache.fineract.organisation.workingdays.domain.RepaymentRescheduleType;
import org.apache.fineract.organisation.workingdays.domain.WorkingDaysEnumerations;
import org.apache.fineract.organisation.workingdays.exception.WorkingDaysNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class WorkingDaysReadPlatformServiceImpl implements WorkingDaysReadPlatformService {

private final JdbcTemplate jdbcTemplate;

@Autowired
public WorkingDaysReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}

private static final class WorkingDaysMapper implements RowMapper<WorkingDaysData> {

private final String schema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.text.ParseException;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import net.fortuna.ical4j.model.property.RRule;
import net.fortuna.ical4j.validate.ValidationException;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
Expand All @@ -30,23 +31,14 @@
import org.apache.fineract.organisation.workingdays.data.WorkingDayValidator;
import org.apache.fineract.organisation.workingdays.domain.WorkingDays;
import org.apache.fineract.organisation.workingdays.domain.WorkingDaysRepositoryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class WorkingDaysWritePlatformServiceJpaRepositoryImpl implements WorkingDaysWritePlatformService {

private final WorkingDaysRepositoryWrapper daysRepositoryWrapper;
private final WorkingDayValidator fromApiJsonDeserializer;

@Autowired
public WorkingDaysWritePlatformServiceJpaRepositoryImpl(final WorkingDaysRepositoryWrapper daysRepositoryWrapper,
final WorkingDayValidator fromApiJsonDeserializer) {
this.daysRepositoryWrapper = daysRepositoryWrapper;
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
}

@Transactional
@Override
public CommandProcessingResult updateWorkingDays(JsonCommand command) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* 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.workingdays.starter;

import org.apache.fineract.organisation.workingdays.data.WorkingDayValidator;
import org.apache.fineract.organisation.workingdays.domain.WorkingDaysRepositoryWrapper;
import org.apache.fineract.organisation.workingdays.service.WorkingDaysReadPlatformService;
import org.apache.fineract.organisation.workingdays.service.WorkingDaysReadPlatformServiceImpl;
import org.apache.fineract.organisation.workingdays.service.WorkingDaysWritePlatformService;
import org.apache.fineract.organisation.workingdays.service.WorkingDaysWritePlatformServiceJpaRepositoryImpl;
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 OrganisationWorkingDaysConfiguration {

@Bean
@ConditionalOnMissingBean(WorkingDaysReadPlatformService.class)
public WorkingDaysReadPlatformService workingDaysReadPlatformService(JdbcTemplate jdbcTemplate) {
return new WorkingDaysReadPlatformServiceImpl(jdbcTemplate);
}

@Bean
@ConditionalOnMissingBean(WorkingDaysWritePlatformService.class)
public WorkingDaysWritePlatformService workingDaysWritePlatformService(WorkingDaysRepositoryWrapper daysRepositoryWrapper,
WorkingDayValidator fromApiJsonDeserializer) {
return new WorkingDaysWritePlatformServiceJpaRepositoryImpl(daysRepositoryWrapper, fromApiJsonDeserializer);
}
}

0 comments on commit 9f3ebfb

Please sign in to comment.