Skip to content

Commit

Permalink
Add custom Configuration class for meeting service (FINERACT-1932)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav7sinha committed Aug 22, 2023
1 parent 477b2fd commit 5e03af4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,20 @@
import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.portfolio.calendar.service.CalendarUtils;
import org.apache.fineract.portfolio.meeting.data.MeetingData;
import org.apache.fineract.portfolio.meeting.exception.MeetingNotFoundException;
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 MeetingReadPlatformServiceImpl implements MeetingReadPlatformService {

private final JdbcTemplate jdbcTemplate;

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

private static final class MeetingDataMapper implements RowMapper<MeetingData> {

public String schema() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
Expand All @@ -56,12 +57,10 @@
import org.apache.fineract.portfolio.meeting.domain.Meeting;
import org.apache.fineract.portfolio.meeting.domain.MeetingRepository;
import org.apache.fineract.portfolio.meeting.domain.MeetingRepositoryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class MeetingWritePlatformServiceJpaRepositoryImpl implements MeetingWritePlatformService {

private final MeetingRepositoryWrapper meetingRepositoryWrapper;
Expand All @@ -74,23 +73,6 @@ public class MeetingWritePlatformServiceJpaRepositoryImpl implements MeetingWrit
private final FromJsonHelper fromApiJsonHelper;
private final ConfigurationDomainService configurationDomainService;

@Autowired
public MeetingWritePlatformServiceJpaRepositoryImpl(final MeetingRepositoryWrapper meetingRepositoryWrapper,
final MeetingRepository meetingRepository, final MeetingDataValidator meetingDataValidator,
final CalendarInstanceRepository calendarInstanceRepository, final CalendarRepository calendarRepository,
final ClientRepositoryWrapper clientRepositoryWrapper, final GroupRepository groupRepository,
final FromJsonHelper fromApiJsonHelper, final ConfigurationDomainService configurationDomainService) {
this.meetingRepositoryWrapper = meetingRepositoryWrapper;
this.meetingRepository = meetingRepository;
this.meetingDataValidator = meetingDataValidator;
this.calendarInstanceRepository = calendarInstanceRepository;
this.calendarRepository = calendarRepository;
this.clientRepositoryWrapper = clientRepositoryWrapper;
this.groupRepository = groupRepository;
this.fromApiJsonHelper = fromApiJsonHelper;
this.configurationDomainService = configurationDomainService;
}

@Override
public CommandProcessingResult createMeeting(final JsonCommand command) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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.portfolio.meeting.starter;

import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.calendar.domain.CalendarInstanceRepository;
import org.apache.fineract.portfolio.calendar.domain.CalendarRepository;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.group.domain.GroupRepository;
import org.apache.fineract.portfolio.meeting.data.MeetingDataValidator;
import org.apache.fineract.portfolio.meeting.domain.MeetingRepository;
import org.apache.fineract.portfolio.meeting.domain.MeetingRepositoryWrapper;
import org.apache.fineract.portfolio.meeting.service.MeetingReadPlatformService;
import org.apache.fineract.portfolio.meeting.service.MeetingReadPlatformServiceImpl;
import org.apache.fineract.portfolio.meeting.service.MeetingWritePlatformService;
import org.apache.fineract.portfolio.meeting.service.MeetingWritePlatformServiceJpaRepositoryImpl;
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 MeetingConfiguration {

@Bean
@ConditionalOnMissingBean(MeetingReadPlatformService.class)
public MeetingReadPlatformService meetingReadPlatformService(JdbcTemplate jdbcTemplate) {
return new MeetingReadPlatformServiceImpl(jdbcTemplate);
}

@Bean
@ConditionalOnMissingBean(MeetingWritePlatformService.class)
public MeetingWritePlatformService meetingWritePlatformService(MeetingRepositoryWrapper meetingRepositoryWrapper,
MeetingRepository meetingRepository, MeetingDataValidator meetingDataValidator,
CalendarInstanceRepository calendarInstanceRepository, CalendarRepository calendarRepository,
ClientRepositoryWrapper clientRepositoryWrapper, GroupRepository groupRepository, FromJsonHelper fromApiJsonHelper,
ConfigurationDomainService configurationDomainService) {
return new MeetingWritePlatformServiceJpaRepositoryImpl(meetingRepositoryWrapper, meetingRepository, meetingDataValidator,
calendarInstanceRepository, calendarRepository, clientRepositoryWrapper, groupRepository, fromApiJsonHelper,
configurationDomainService);
}
}

0 comments on commit 5e03af4

Please sign in to comment.