Add custom Configuration class for organisation/staff module (FINERACT-1932)
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
66341db853
commit
9535bc0ec5
+4
-10
@@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
|
||||
import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
@@ -34,26 +35,19 @@ import org.apache.fineract.organisation.staff.exception.StaffNotFoundException;
|
||||
import org.apache.fineract.portfolio.client.domain.ClientStatus;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
|
||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccountStatusType;
|
||||
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 StaffReadPlatformServiceImpl implements StaffReadPlatformService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final PlatformSecurityContext context;
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
private static final StaffLookupMapper LOOKUP_MAPPER = new StaffLookupMapper();
|
||||
private static final StaffInOfficeHierarchyMapper STAFF_IN_OFFICE_HIERARCHY_MAPPER = new StaffInOfficeHierarchyMapper();
|
||||
|
||||
@Autowired
|
||||
public StaffReadPlatformServiceImpl(final PlatformSecurityContext context, final JdbcTemplate jdbcTemplate) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
private static final class StaffMapper implements RowMapper<StaffData> {
|
||||
|
||||
public String schema() {
|
||||
|
||||
+5
-16
@@ -20,6 +20,8 @@ package org.apache.fineract.organisation.staff.service;
|
||||
|
||||
import jakarta.persistence.PersistenceException;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
@@ -32,31 +34,18 @@ import org.apache.fineract.organisation.staff.domain.Staff;
|
||||
import org.apache.fineract.organisation.staff.domain.StaffRepository;
|
||||
import org.apache.fineract.organisation.staff.exception.StaffNotFoundException;
|
||||
import org.apache.fineract.organisation.staff.serialization.StaffCommandFromApiJsonDeserializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePlatformService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(StaffWritePlatformServiceJpaRepositoryImpl.class);
|
||||
|
||||
private final StaffCommandFromApiJsonDeserializer fromApiJsonDeserializer;
|
||||
private final StaffRepository staffRepository;
|
||||
private final OfficeRepositoryWrapper officeRepositoryWrapper;
|
||||
|
||||
@Autowired
|
||||
public StaffWritePlatformServiceJpaRepositoryImpl(final StaffCommandFromApiJsonDeserializer fromApiJsonDeserializer,
|
||||
final StaffRepository staffRepository, final OfficeRepositoryWrapper officeRepositoryWrapper) {
|
||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||
this.staffRepository = staffRepository;
|
||||
this.officeRepositoryWrapper = officeRepositoryWrapper;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult createStaff(final JsonCommand command) {
|
||||
@@ -138,7 +127,7 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla
|
||||
"A staff with the given display name '" + displayName + "' already exists", "displayName", displayName);
|
||||
}
|
||||
|
||||
LOG.error("Error occured.", dve);
|
||||
log.error("Error occured.", dve);
|
||||
throw new PlatformDataIntegrityException("error.msg.staff.unknown.data.integrity.issue",
|
||||
"Unknown data integrity issue with resource: " + realCause.getMessage());
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 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.staff.starter;
|
||||
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
|
||||
import org.apache.fineract.organisation.staff.domain.StaffRepository;
|
||||
import org.apache.fineract.organisation.staff.serialization.StaffCommandFromApiJsonDeserializer;
|
||||
import org.apache.fineract.organisation.staff.service.StaffReadPlatformService;
|
||||
import org.apache.fineract.organisation.staff.service.StaffReadPlatformServiceImpl;
|
||||
import org.apache.fineract.organisation.staff.service.StaffWritePlatformService;
|
||||
import org.apache.fineract.organisation.staff.service.StaffWritePlatformServiceJpaRepositoryImpl;
|
||||
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 OrganisationStaffConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(StaffReadPlatformService.class)
|
||||
public StaffReadPlatformService staffReadPlatformService(PlatformSecurityContext context, JdbcTemplate jdbcTemplate) {
|
||||
return new StaffReadPlatformServiceImpl(context, jdbcTemplate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(StaffWritePlatformService.class)
|
||||
public StaffWritePlatformService staffWritePlatformService(StaffCommandFromApiJsonDeserializer fromApiJsonDeserializer,
|
||||
StaffRepository staffRepository, OfficeRepositoryWrapper officeRepositoryWrapper) {
|
||||
return new StaffWritePlatformServiceJpaRepositoryImpl(fromApiJsonDeserializer, staffRepository, officeRepositoryWrapper);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user