fineract-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100126 <...@git.apache.org>
Subject [GitHub] incubator-fineract pull request: 293_post_interest_job
Date Thu, 12 May 2016 11:27:34 GMT
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/103#discussion_r63004091
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularServiceImpl.java
---
    @@ -37,42 +41,73 @@
     
         private final SavingsAccountAssembler savingAccountAssembler;
         private final SavingsAccountWritePlatformService savingsAccountWritePlatformService;
    -    private final SavingsAccountRepository savingAccountRepository;
         private final SavingsAccountReadPlatformService savingAccountReadPlatformService;
     
         @Autowired
         public SavingsSchedularServiceImpl(final SavingsAccountAssembler savingAccountAssembler,
                 final SavingsAccountWritePlatformService savingsAccountWritePlatformService,
    -            final SavingsAccountRepository savingAccountRepository,
                 final SavingsAccountReadPlatformService savingAccountReadPlatformService)
{
             this.savingAccountAssembler = savingAccountAssembler;
             this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
    -        this.savingAccountRepository = savingAccountRepository;
             this.savingAccountReadPlatformService = savingAccountReadPlatformService;
         }
     
    -    @CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
    -    @Override
    -    public void postInterestForAccounts() throws JobExecutionException {
    -        final List<SavingsAccount> savingsAccounts = this.savingAccountRepository.findSavingAccountByStatus(SavingsAccountStatusType.ACTIVE
    -                .getValue());
    -        StringBuffer sb = new StringBuffer();
    -        for (final SavingsAccount savingsAccount : savingsAccounts) {
    -            try {
    -                this.savingAccountAssembler.assignSavingAccountHelpers(savingsAccount);
    -                this.savingsAccountWritePlatformService.postInterest(savingsAccount);
    -            } catch (Exception e) {
    -                Throwable realCause = e;
    -                if (e.getCause() != null) {
    -                    realCause = e.getCause();
    -                }
    -                sb.append("failed to post interest for Savings with id " + savingsAccount.getId()
+ " with message "
    -                        + realCause.getMessage());
    -            }
    -        }
    -        
    -        if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); }
    -    }
    +	@Transactional
    +	@CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
    +	@Override
    +	public void postInterestForAccounts() throws JobExecutionException {
    +		final int maxPazeSize = 10;
    +		boolean hasErrorOccurred = false;
    +		boolean tempHasErrorOccured = false;
    +		int offSet = 0;
    +		final Integer status = SavingsAccountStatusType.ACTIVE.getValue();
    +		List<SavingsAccount> savings = new ArrayList<>();
    +
    +		Page<SavingsAccountData> savingsAccounts = this.savingAccountReadPlatformService
    +				.retrieveActiveSavingsAccount(maxPazeSize, offSet, status);
    +
    +		while (savingsAccounts.getPageItems().size() < savingsAccounts.getTotalFilteredRecords())
{
    +			offSet += savingsAccounts.getPageItems().size();
    +			savingsAccounts = this.savingAccountReadPlatformService.retrieveActiveSavingsAccount(maxPazeSize,
offSet,
    +					status);
    +			for (SavingsAccountData savingsAccountData : savingsAccounts.getPageItems()) {
    +				SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(savingsAccountData.id());
    +				savings.add(savingsAccount);
    +			}
    +			postInterestInBatch(savings);
    --- End diff --
    
    Why do we need to call postInterestInBatch() method two times?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message