FINERACT-717 Lazy load child collections for Interest posting batch job

This commit is contained in:
Vishwas Babu A J
2019-02-27 20:36:28 -08:00
parent 576c8ccf9f
commit fd8121fe64
3 changed files with 20 additions and 4 deletions
@@ -108,7 +108,7 @@ public class SchedulerJobsTest {
Thread.sleep(15000);
schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
Assert.assertNotNull(schedulerJob);
System.out.println("Job is Still Running");
System.out.println("Job " +jobId.toString() +" is Still Running");
}
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
jobId.toString());
@@ -23,6 +23,8 @@ import java.util.List;
import org.apache.fineract.portfolio.savings.DepositAccountType;
import org.apache.fineract.portfolio.savings.exception.SavingsAccountNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -79,8 +81,15 @@ public class SavingsAccountRepositoryWrapper {
loadLazyCollections(accounts);
return accounts ;
}
@Transactional(readOnly=true)
public Page<SavingsAccount> findByStatus(Integer status, Pageable pageable) {
Page<SavingsAccount> accounts = this.repository.findByStatus(status, pageable);
loadLazyCollections(accounts);
return accounts;
}
//Root Entities are enough
//Root Entities are enough
public List<SavingsAccount> findByClientIdAndGroupId(@Param("clientId") Long clientId, @Param("groupId") Long groupId) {
return this.repository.findByClientIdAndGroupId(clientId, groupId) ;
}
@@ -118,4 +127,10 @@ public class SavingsAccountRepositoryWrapper {
}
}
}
private void loadLazyCollections(Page<SavingsAccount> accounts) {
for (SavingsAccount account : accounts) {
account.loadLazyCollections();
}
}
}
@@ -27,6 +27,7 @@ import org.apache.fineract.infrastructure.jobs.service.JobName;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountAssembler;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepository;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepositoryWrapper;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountStatusType;
import org.joda.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,12 +41,12 @@ public class SavingsSchedularServiceImpl implements SavingsSchedularService {
private final SavingsAccountAssembler savingAccountAssembler;
private final SavingsAccountWritePlatformService savingsAccountWritePlatformService;
private final SavingsAccountReadPlatformService savingAccountReadPlatformService;
private final SavingsAccountRepository savingsAccountRepository;
private final SavingsAccountRepositoryWrapper savingsAccountRepository;
@Autowired
public SavingsSchedularServiceImpl(final SavingsAccountAssembler savingAccountAssembler,
final SavingsAccountWritePlatformService savingsAccountWritePlatformService,
final SavingsAccountReadPlatformService savingAccountReadPlatformService, final SavingsAccountRepository savingsAccountRepository) {
final SavingsAccountReadPlatformService savingAccountReadPlatformService, final SavingsAccountRepositoryWrapper savingsAccountRepository) {
this.savingAccountAssembler = savingAccountAssembler;
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
this.savingAccountReadPlatformService = savingAccountReadPlatformService;