FINERACT-1932: Add starter Configuration class for portfolio.group module

This commit is contained in:
Mohamed Magdi-Abdelmonem
2023-10-28 02:11:50 +02:00
committed by Aleksandar Vidakovic
parent 937098c4ee
commit 0abb60c922
7 changed files with 149 additions and 64 deletions
@@ -70,10 +70,8 @@ import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@Service
@RequiredArgsConstructor
public class CenterReadPlatformServiceImpl implements CenterReadPlatformService {
@@ -21,26 +21,19 @@ package org.apache.fineract.portfolio.group.service;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.group.data.GroupLevelData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class GroupLevelReadPlatformServiceImpl implements GroupLevelReadPlatformService {
private final PlatformSecurityContext context;
private final JdbcTemplate jdbcTemplate;
@Autowired
public GroupLevelReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate) {
this.context = context;
this.jdbcTemplate = jdbcTemplate;
}
@Override
public Collection<GroupLevelData> retrieveAllLevels() {
this.context.authenticatedUser();
@@ -26,6 +26,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService;
import org.apache.fineract.infrastructure.core.data.PaginationParameters;
@@ -49,14 +50,12 @@ import org.apache.fineract.portfolio.group.data.GroupGeneralData;
import org.apache.fineract.portfolio.group.domain.GroupTypes;
import org.apache.fineract.portfolio.group.exception.GroupNotFoundException;
import org.apache.fineract.useradministration.domain.AppUser;
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;
import org.springframework.util.CollectionUtils;
@Service
@RequiredArgsConstructor
public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
public static final String ID = "id";
@@ -76,24 +75,6 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
private final PaginationParametersDataValidator paginationParametersDataValidator;
private final ColumnValidator columnValidator;
@Autowired
public GroupReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate,
final CenterReadPlatformService centerReadPlatformService, final OfficeReadPlatformService officeReadPlatformService,
final StaffReadPlatformService staffReadPlatformService, final CodeValueReadPlatformService codeValueReadPlatformService,
final PaginationParametersDataValidator paginationParametersDataValidator, final ColumnValidator columnValidator,
DatabaseSpecificSQLGenerator sqlGenerator, PaginationHelper paginationHelper) {
this.context = context;
this.jdbcTemplate = jdbcTemplate;
this.centerReadPlatformService = centerReadPlatformService;
this.officeReadPlatformService = officeReadPlatformService;
this.staffReadPlatformService = staffReadPlatformService;
this.codeValueReadPlatformService = codeValueReadPlatformService;
this.paginationParametersDataValidator = paginationParametersDataValidator;
this.columnValidator = columnValidator;
this.paginationHelper = paginationHelper;
this.sqlGenerator = sqlGenerator;
}
@Override
public GroupGeneralData retrieveTemplate(final Long officeId, final boolean isCenterGroup, final boolean staffInSelectedOfficeOnly) {
@@ -21,29 +21,22 @@ package org.apache.fineract.portfolio.group.service;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.group.data.GroupRoleData;
import org.apache.fineract.portfolio.group.exception.GroupRoleNotFoundException;
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 GroupRolesReadPlatformServiceImpl implements GroupRolesReadPlatformService {
private final JdbcTemplate jdbcTemplate;
private final PlatformSecurityContext context;
@Autowired
public GroupRolesReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate) {
this.context = context;
this.jdbcTemplate = jdbcTemplate;
}
@Override
public Collection<GroupRoleData> retrieveGroupRoles(final Long groupId) {
this.context.authenticatedUser();
@@ -19,6 +19,8 @@
package org.apache.fineract.portfolio.group.service;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.codes.domain.CodeValueRepositoryWrapper;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -35,19 +37,14 @@ import org.apache.fineract.portfolio.group.domain.GroupRole;
import org.apache.fineract.portfolio.group.domain.GroupRoleRepositoryWrapper;
import org.apache.fineract.portfolio.group.exception.ClientNotInGroupException;
import org.apache.fineract.portfolio.group.serialization.GroupRolesDataValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.NonTransientDataAccessException;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;
@Service
@Slf4j
@RequiredArgsConstructor
public class GroupRolesWritePlatformServiceJpaRepositoryImpl implements GroupRolesWritePlatformService {
private static final Logger LOG = LoggerFactory.getLogger(GroupRolesWritePlatformServiceJpaRepositoryImpl.class);
private final PlatformSecurityContext context;
private final GroupRepositoryWrapper groupRepository;
private final GroupRolesDataValidator fromApiJsonDeserializer;
@@ -55,19 +52,6 @@ public class GroupRolesWritePlatformServiceJpaRepositoryImpl implements GroupRol
private final ClientRepositoryWrapper clientRepository;
private final GroupRoleRepositoryWrapper groupRoleRepository;
@Autowired
public GroupRolesWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
final GroupRepositoryWrapper groupRepository, final GroupRolesDataValidator fromApiJsonDeserializer,
final CodeValueRepositoryWrapper codeValueRepository, final ClientRepositoryWrapper clientRepository,
final GroupRoleRepositoryWrapper groupRoleRepository) {
this.context = context;
this.groupRepository = groupRepository;
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
this.codeValueRepository = codeValueRepository;
this.clientRepository = clientRepository;
this.groupRoleRepository = groupRoleRepository;
}
@Override
public CommandProcessingResult createRole(final JsonCommand command) {
@@ -111,7 +95,7 @@ public class GroupRolesWritePlatformServiceJpaRepositoryImpl implements GroupRol
GroupingTypesApiConstants.clientIdParamName, roleId, clientId, command.getGroupId());
}
LOG.error("Error occured.", dve);
log.error("Error occured.", dve);
throw new PlatformDataIntegrityException("error.msg.group.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
}
@@ -88,12 +88,10 @@ import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepositoryWrap
import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
@Service
@Slf4j
@RequiredArgsConstructor
public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements GroupingTypesWritePlatformService {
@@ -0,0 +1,138 @@
/**
* 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.group.starter;
import org.apache.fineract.commands.service.CommandProcessingService;
import org.apache.fineract.infrastructure.accountnumberformat.domain.AccountNumberFormatRepositoryWrapper;
import org.apache.fineract.infrastructure.codes.domain.CodeValueRepositoryWrapper;
import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.core.data.PaginationParametersDataValidator;
import org.apache.fineract.infrastructure.core.service.PaginationHelper;
import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator;
import org.apache.fineract.infrastructure.dataqueries.service.EntityDatatableChecksWritePlatformService;
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.infrastructure.security.utils.ColumnValidator;
import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
import org.apache.fineract.organisation.office.service.OfficeReadPlatformService;
import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper;
import org.apache.fineract.organisation.staff.service.StaffReadPlatformService;
import org.apache.fineract.portfolio.calendar.domain.CalendarInstanceRepository;
import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.client.service.ClientReadPlatformService;
import org.apache.fineract.portfolio.group.domain.GroupLevelRepository;
import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper;
import org.apache.fineract.portfolio.group.domain.GroupRoleRepositoryWrapper;
import org.apache.fineract.portfolio.group.serialization.GroupRolesDataValidator;
import org.apache.fineract.portfolio.group.serialization.GroupingTypesDataValidator;
import org.apache.fineract.portfolio.group.service.CenterReadPlatformService;
import org.apache.fineract.portfolio.group.service.CenterReadPlatformServiceImpl;
import org.apache.fineract.portfolio.group.service.GroupLevelReadPlatformService;
import org.apache.fineract.portfolio.group.service.GroupLevelReadPlatformServiceImpl;
import org.apache.fineract.portfolio.group.service.GroupReadPlatformService;
import org.apache.fineract.portfolio.group.service.GroupReadPlatformServiceImpl;
import org.apache.fineract.portfolio.group.service.GroupRolesReadPlatformService;
import org.apache.fineract.portfolio.group.service.GroupRolesReadPlatformServiceImpl;
import org.apache.fineract.portfolio.group.service.GroupRolesWritePlatformService;
import org.apache.fineract.portfolio.group.service.GroupRolesWritePlatformServiceJpaRepositoryImpl;
import org.apache.fineract.portfolio.group.service.GroupingTypesWritePlatformService;
import org.apache.fineract.portfolio.group.service.GroupingTypesWritePlatformServiceJpaRepositoryImpl;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
import org.apache.fineract.portfolio.note.domain.NoteRepository;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepositoryWrapper;
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 GroupConfiguration {
@Bean
@ConditionalOnMissingBean(CenterReadPlatformService.class)
public CenterReadPlatformService centerReadPlatformService(JdbcTemplate jdbcTemplate, PlatformSecurityContext context,
ClientReadPlatformService clientReadPlatformService, OfficeReadPlatformService officeReadPlatformService,
StaffReadPlatformService staffReadPlatformService, CodeValueReadPlatformService codeValueReadPlatformService,
ConfigurationDomainService configurationDomainService, ColumnValidator columnValidator, PaginationHelper paginationHelper,
DatabaseSpecificSQLGenerator sqlGenerator, PaginationParametersDataValidator paginationParametersDataValidator) {
return new CenterReadPlatformServiceImpl(jdbcTemplate, context, clientReadPlatformService, officeReadPlatformService,
staffReadPlatformService, codeValueReadPlatformService, configurationDomainService, columnValidator, paginationHelper,
sqlGenerator, paginationParametersDataValidator);
}
@Bean
@ConditionalOnMissingBean(GroupingTypesWritePlatformService.class)
public GroupingTypesWritePlatformService groupingTypesWritePlatformService(PlatformSecurityContext context,
GroupRepositoryWrapper groupRepository, ClientRepositoryWrapper clientRepositoryWrapper,
OfficeRepositoryWrapper officeRepositoryWrapper, StaffRepositoryWrapper staffRepository, NoteRepository noteRepository,
GroupLevelRepository groupLevelRepository, GroupingTypesDataValidator fromApiJsonDeserializer,
LoanRepositoryWrapper loanRepositoryWrapper, CodeValueRepositoryWrapper codeValueRepository,
CommandProcessingService commandProcessingService, CalendarInstanceRepository calendarInstanceRepository,
ConfigurationDomainService configurationDomainService, SavingsAccountRepositoryWrapper savingsAccountRepositoryWrapper,
AccountNumberFormatRepositoryWrapper accountNumberFormatRepository, AccountNumberGenerator accountNumberGenerator,
EntityDatatableChecksWritePlatformService entityDatatableChecksWritePlatformService,
BusinessEventNotifierService businessEventNotifierService
) {
return new GroupingTypesWritePlatformServiceJpaRepositoryImpl(context, groupRepository, clientRepositoryWrapper,
officeRepositoryWrapper, staffRepository, noteRepository, groupLevelRepository, fromApiJsonDeserializer,
loanRepositoryWrapper, codeValueRepository, commandProcessingService, calendarInstanceRepository,
configurationDomainService, savingsAccountRepositoryWrapper, accountNumberFormatRepository, accountNumberGenerator,
entityDatatableChecksWritePlatformService, businessEventNotifierService
);
}
@Bean
@ConditionalOnMissingBean(GroupLevelReadPlatformService.class)
public GroupLevelReadPlatformService groupLevelReadPlatformService(PlatformSecurityContext context, JdbcTemplate jdbcTemplate) {
return new GroupLevelReadPlatformServiceImpl(context, jdbcTemplate);
}
@Bean
@ConditionalOnMissingBean(GroupReadPlatformService.class)
public GroupReadPlatformService groupReadPlatformService(JdbcTemplate jdbcTemplate, PlatformSecurityContext context,
OfficeReadPlatformService officeReadPlatformService, StaffReadPlatformService staffReadPlatformService,
CenterReadPlatformService centerReadPlatformService, CodeValueReadPlatformService codeValueReadPlatformService,
PaginationHelper paginationHelper, DatabaseSpecificSQLGenerator sqlGenerator,
PaginationParametersDataValidator paginationParametersDataValidator, ColumnValidator columnValidator) {
return new GroupReadPlatformServiceImpl(jdbcTemplate, context, officeReadPlatformService, staffReadPlatformService,
centerReadPlatformService, codeValueReadPlatformService, paginationHelper, sqlGenerator, paginationParametersDataValidator,
columnValidator);
}
@Bean
@ConditionalOnMissingBean(GroupRolesReadPlatformService.class)
public GroupRolesReadPlatformService groupRolesReadPlatformService(JdbcTemplate jdbcTemplate, PlatformSecurityContext context) {
return new GroupRolesReadPlatformServiceImpl(jdbcTemplate, context);
}
@Bean
@ConditionalOnMissingBean(GroupRolesWritePlatformService.class)
public GroupRolesWritePlatformService groupRolesWritePlatformService(PlatformSecurityContext context,
GroupRepositoryWrapper groupRepository, GroupRolesDataValidator fromApiJsonDeserializer,
CodeValueRepositoryWrapper codeValueRepository, ClientRepositoryWrapper clientRepository,
GroupRoleRepositoryWrapper groupRoleRepository) {
return new GroupRolesWritePlatformServiceJpaRepositoryImpl(context, groupRepository, fromApiJsonDeserializer, codeValueRepository,
clientRepository, groupRoleRepository);
}
}