This is an automated email from the ASF dual-hosted git repository. vorburger pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/fineract.git
commit e2f5c950349d713663c101e67345a9734f40d6d3 Author: Angel Cajas <[email protected]> AuthorDate: Mon Jan 13 15:04:25 2020 -0600 Fixing some code to be compatible with Spring update --- .../portfolio/rate/domain/RateRepositoryWrapper.java | 9 ++------- .../portfolio/rate/service/RateWriteServiceImpl.java | 14 ++++++-------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/rate/domain/RateRepositoryWrapper.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/rate/domain/RateRepositoryWrapper.java index 7604a11..679c2d7 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/rate/domain/RateRepositoryWrapper.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/rate/domain/RateRepositoryWrapper.java @@ -36,19 +36,14 @@ public class RateRepositoryWrapper { } public Rate findOneWithNotFoundDetection(final Long rateId) { - - final Rate rate = this.repository.findOne(rateId); - if (rate == null) { - throw new RateNotFoundException(rateId); - } - + final Rate rate = this.repository.findById(rateId).orElseThrow(() -> new RateNotFoundException(rateId)); return rate; } public List<Rate> findMultipleWithNotFoundDetection(final List<Long> rateIds) { List<Rate> rates = new ArrayList<>(); if (rateIds != null && !rateIds.isEmpty()) { - final List<Rate> foundRates = this.repository.findAll(rateIds); + final List<Rate> foundRates = this.repository.findAllById(rateIds); for (Long rateId : rateIds) { Boolean found = false; for (Rate foundRate : foundRates) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/rate/service/RateWriteServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/rate/service/RateWriteServiceImpl.java index 51f97b4..b7f7c3d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/rate/service/RateWriteServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/rate/service/RateWriteServiceImpl.java @@ -34,6 +34,7 @@ import org.apache.fineract.portfolio.rate.exception.RateNotFoundException; import org.apache.fineract.portfolio.rate.serialization.RateDefinitionCommandFromApiJsonDeserializer; import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUserRepository; +import org.apache.fineract.useradministration.exception.UserNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -73,7 +74,7 @@ public class RateWriteServiceImpl implements RateWriteService { final Long approveUserId = command.longValueOfParameterNamed(approveUserIdParamName); AppUser approveUser = null; if (approveUserId != null) { - approveUser = this.appUserRepository.findOne(approveUserId); + approveUser = this.appUserRepository.findById(approveUserId).orElseThrow(() -> new UserNotFoundException(approveUserId)); } final Rate rate = Rate.fromJson(command, approveUser); @@ -98,20 +99,17 @@ public class RateWriteServiceImpl implements RateWriteService { try { this.context.authenticatedUser(); - final Rate rateToUpdate = this.rateRepository.findOne(rateId); - if (rateToUpdate == null) { - throw new RateNotFoundException(rateId); - } + final Rate rateToUpdate = this.rateRepository.findById(rateId).orElseThrow(() -> new RateNotFoundException(rateId)); final Map<String, Object> changes = rateToUpdate.update(command); this.fromApiJsonDeserializer.validateForUpdate(command.json()); if (changes.containsKey(approveUserIdParamName)) { - final Long newValue = (Long) changes.get(approveUserIdParamName); + final Long newApproveUserId = (Long) changes.get(approveUserIdParamName); AppUser newApproveUser = null; - if (newValue != null) { - newApproveUser = this.appUserRepository.findOne(newValue); + if (newApproveUserId != null) { + newApproveUser = this.appUserRepository.findById(newApproveUserId).orElseThrow(() -> new UserNotFoundException(newApproveUserId)); } rateToUpdate.setApproveUser(newApproveUser); }
