Fixing some code to be compatible with Spring update
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
c342f5b43d
commit
e2f5c95034
+2
-7
@@ -36,19 +36,14 @@ public class RateRepositoryWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Rate findOneWithNotFoundDetection(final Long rateId) {
|
public Rate findOneWithNotFoundDetection(final Long rateId) {
|
||||||
|
final Rate rate = this.repository.findById(rateId).orElseThrow(() -> new RateNotFoundException(rateId));
|
||||||
final Rate rate = this.repository.findOne(rateId);
|
|
||||||
if (rate == null) {
|
|
||||||
throw new RateNotFoundException(rateId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rate;
|
return rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Rate> findMultipleWithNotFoundDetection(final List<Long> rateIds) {
|
public List<Rate> findMultipleWithNotFoundDetection(final List<Long> rateIds) {
|
||||||
List<Rate> rates = new ArrayList<>();
|
List<Rate> rates = new ArrayList<>();
|
||||||
if (rateIds != null && !rateIds.isEmpty()) {
|
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) {
|
for (Long rateId : rateIds) {
|
||||||
Boolean found = false;
|
Boolean found = false;
|
||||||
for (Rate foundRate : foundRates) {
|
for (Rate foundRate : foundRates) {
|
||||||
|
|||||||
+6
-8
@@ -34,6 +34,7 @@ import org.apache.fineract.portfolio.rate.exception.RateNotFoundException;
|
|||||||
import org.apache.fineract.portfolio.rate.serialization.RateDefinitionCommandFromApiJsonDeserializer;
|
import org.apache.fineract.portfolio.rate.serialization.RateDefinitionCommandFromApiJsonDeserializer;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.apache.fineract.useradministration.domain.AppUserRepository;
|
import org.apache.fineract.useradministration.domain.AppUserRepository;
|
||||||
|
import org.apache.fineract.useradministration.exception.UserNotFoundException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -73,7 +74,7 @@ public class RateWriteServiceImpl implements RateWriteService {
|
|||||||
final Long approveUserId = command.longValueOfParameterNamed(approveUserIdParamName);
|
final Long approveUserId = command.longValueOfParameterNamed(approveUserIdParamName);
|
||||||
AppUser approveUser = null;
|
AppUser approveUser = null;
|
||||||
if (approveUserId != 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);
|
final Rate rate = Rate.fromJson(command, approveUser);
|
||||||
|
|
||||||
@@ -98,20 +99,17 @@ public class RateWriteServiceImpl implements RateWriteService {
|
|||||||
try {
|
try {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final Rate rateToUpdate = this.rateRepository.findOne(rateId);
|
final Rate rateToUpdate = this.rateRepository.findById(rateId).orElseThrow(() -> new RateNotFoundException(rateId));
|
||||||
if (rateToUpdate == null) {
|
|
||||||
throw new RateNotFoundException(rateId);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Map<String, Object> changes = rateToUpdate.update(command);
|
final Map<String, Object> changes = rateToUpdate.update(command);
|
||||||
|
|
||||||
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
||||||
|
|
||||||
if (changes.containsKey(approveUserIdParamName)) {
|
if (changes.containsKey(approveUserIdParamName)) {
|
||||||
final Long newValue = (Long) changes.get(approveUserIdParamName);
|
final Long newApproveUserId = (Long) changes.get(approveUserIdParamName);
|
||||||
AppUser newApproveUser = null;
|
AppUser newApproveUser = null;
|
||||||
if (newValue != null) {
|
if (newApproveUserId != null) {
|
||||||
newApproveUser = this.appUserRepository.findOne(newValue);
|
newApproveUser = this.appUserRepository.findById(newApproveUserId).orElseThrow(() -> new UserNotFoundException(newApproveUserId));
|
||||||
}
|
}
|
||||||
rateToUpdate.setApproveUser(newApproveUser);
|
rateToUpdate.setApproveUser(newApproveUser);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user