Merge pull request #1468 from pramodn02/performanceissues

MIFOSX-2163 : added transaction scope at loan level
This commit is contained in:
Vishwas Babu A J
2015-08-25 14:20:35 +05:30
5 changed files with 14 additions and 14 deletions
@@ -38,7 +38,6 @@ import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntryRunningBalanceUpdateService { public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntryRunningBalanceUpdateService {
@@ -123,7 +122,6 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
return commandProcessingResultBuilder.build(); return commandProcessingResultBuilder.build();
} }
@Transactional
private void updateOrganizationRunningBalance(Date entityDate) { private void updateOrganizationRunningBalance(Date entityDate) {
Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5); Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5);
Map<Long, Map<Long, BigDecimal>> officesRunningBalance = new HashMap<>(); Map<Long, Map<Long, BigDecimal>> officesRunningBalance = new HashMap<>();
@@ -188,7 +186,6 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
} }
@Transactional
private void updateRunningBalance(Long officeId, Date entityDate) { private void updateRunningBalance(Long officeId, Date entityDate) {
Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5); Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5);
@@ -12,4 +12,6 @@ public interface LoanSchedularService {
void applyChargeForOverdueLoans() throws JobExecutionException; void applyChargeForOverdueLoans() throws JobExecutionException;
void recalculateInterest();
} }
@@ -92,5 +92,14 @@ public class LoanSchedularServiceImpl implements LoanSchedularService {
if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); } if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); }
} }
} }
@Override
@CronTarget(jobName = JobName.RECALCULATE_INTEREST_FOR_LOAN)
public void recalculateInterest() {
Collection<Long> loanIds = this.loanReadPlatformService.fetchArrearLoans();
for (Long loanId : loanIds) {
this.loanWritePlatformService.recalculateInterest(loanId);
}
}
} }
@@ -79,8 +79,6 @@ public interface LoanWritePlatformService {
CommandProcessingResult updateDisbursementDateAndAmountForTranche(Long loanId, Long disbursementId, JsonCommand command); CommandProcessingResult updateDisbursementDateAndAmountForTranche(Long loanId, Long disbursementId, JsonCommand command);
void recalculateInterest();
CommandProcessingResult recoverFromGuarantor(Long loanId); CommandProcessingResult recoverFromGuarantor(Long loanId);
void applyMeetingDateChanges(Calendar calendar, Collection<CalendarInstance> loanCalendarInstances); void applyMeetingDateChanges(Calendar calendar, Collection<CalendarInstance> loanCalendarInstances);
@@ -91,4 +89,6 @@ public interface LoanWritePlatformService {
void applyOverdueChargesForLoan(Long loanId, Collection<OverdueLoanScheduleData> overdueLoanScheduleDatas); void applyOverdueChargesForLoan(Long loanId, Collection<OverdueLoanScheduleData> overdueLoanScheduleDatas);
void recalculateInterest(long loanId);
} }
@@ -2774,16 +2774,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
return transaction; return transaction;
} }
@Override
@CronTarget(jobName = JobName.RECALCULATE_INTEREST_FOR_LOAN)
public void recalculateInterest() {
Collection<Long> loanIds = this.loanReadPlatformService.fetchArrearLoans();
for (Long loanId : loanIds) {
recalculateInterest(loanId);
}
}
@Transactional @Transactional
@Override
public void recalculateInterest(final long loanId) { public void recalculateInterest(final long loanId) {
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
Loan loan = this.loanAssembler.assembleFrom(loanId); Loan loan = this.loanAssembler.assembleFrom(loanId);