use of org.mifos.framework.components.batchjobs.exceptions.BatchJobException in project head by mifos.
the class BranchReportHelper method execute.
@Override
public void execute(long timeInMillis) throws BatchJobException {
Session session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
Date runDate = new Date(timeInMillis);
try {
removeExistingBranchReportsForGivenRunDate(runDate);
populateBranchReportBatch(session, runDate);
StaticHibernateUtil.commitTransaction();
} catch (HibernateException e) {
StaticHibernateUtil.rollbackTransaction();
throw new BatchJobException(e);
} catch (ServiceException e) {
throw new BatchJobException(e);
}
}
use of org.mifos.framework.components.batchjobs.exceptions.BatchJobException in project head by mifos.
the class MifosBatchJob method launchJob.
/**
* A method responsible for the actual launch of the Spring Batch job.
* @param job Job class
* @param jobParameters Job parameters
* @return Batch computation status
* @throws BatchJobException when something goes wrong
*/
private BatchStatus launchJob(Job job, JobParameters jobParameters) throws BatchJobException {
BatchStatus exitStatus = BatchStatus.UNKNOWN;
JobExecution jobExecution = null;
try {
batchJobStarted();
requiresExclusiveAccess();
jobExecution = jobLauncher.run(job, jobParameters);
exitStatus = jobExecution.getStatus();
} catch (JobInstanceAlreadyCompleteException jiace) {
exitStatus = BatchStatus.COMPLETED;
return exitStatus;
} catch (Exception ex) {
throw new BatchJobException(ex);
} finally {
batchJobFinished();
}
return exitStatus;
}
use of org.mifos.framework.components.batchjobs.exceptions.BatchJobException in project head by mifos.
the class ApplyCustomerFeeChangesHelper method execute.
@Override
public void execute(@SuppressWarnings("unused") long timeInMillis) throws BatchJobException {
List<String> errorList = new ArrayList<String>();
List<Short> updatedFeeIds = new ArrayList<Short>();
try {
updatedFeeIds = getFeeDao().getUpdatedFeesForCustomer();
} catch (Exception e) {
errorList.add(e.getMessage());
throw new BatchJobException(SchedulerConstants.FAILURE, errorList);
}
for (Short feeId : updatedFeeIds) {
try {
FeeBO hydratedFee = getFeeDao().findById(feeId);
if (!hydratedFee.getFeeChangeType().equals(FeeChangeType.NOT_UPDATED)) {
List<AccountBO> accounts = new CustomerPersistence().getCustomerAccountsForFee(hydratedFee.getFeeId());
if (accounts != null && accounts.size() > 0) {
for (AccountBO account : accounts) {
updateAccountFee(account, hydratedFee);
}
}
}
hydratedFee.updateFeeChangeType(FeeChangeType.NOT_UPDATED);
UserContext userContext = new UserContext();
userContext.setId(PersonnelConstants.SYSTEM_USER);
hydratedFee.setUserContext(userContext);
hydratedFee.save();
StaticHibernateUtil.commitTransaction();
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
errorList.add("feeId: " + feeId);
}
}
if (errorList.size() > 0) {
throw new BatchJobException(SchedulerConstants.FAILURE, errorList);
}
}
use of org.mifos.framework.components.batchjobs.exceptions.BatchJobException in project head by mifos.
the class BranchReportLoanArrearsAgingHelper method populateLoanArrearsAging.
public void populateLoanArrearsAging() throws BatchJobException {
LoanArrearsAgingPeriod[] values = LoanArrearsAgingPeriod.values();
for (LoanArrearsAgingPeriod period : values) {
try {
BranchReportLoanArrearsAgingBO loanArrears = branchReportService.extractLoanArrearsAgingInfoInPeriod(branchReport.getBranchId(), period, branchReportConfigService.getCurrency());
branchReport.addLoanArrearsAging(loanArrears);
} catch (ServiceException e) {
throw new BatchJobException(e);
}
}
}
use of org.mifos.framework.components.batchjobs.exceptions.BatchJobException in project head by mifos.
the class CustomerAccountBO method updateFee.
public void updateFee(final AccountFeesEntity fee, final FeeBO feeBO) throws BatchJobException {
boolean feeApplied = isFeeAlreadyApplied(fee, feeBO);
if (!feeApplied) {
// update this account fee
try {
if (feeBO.getFeeChangeType().equals(FeeChangeType.AMOUNT_AND_STATUS_UPDATED)) {
if (!feeBO.isActive()) {
removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(feeBO.getFeeId(), Short.valueOf("1"));
fee.changeFeesStatus(FeeStatus.INACTIVE, new DateTimeService().getCurrentJavaDateTime());
updateAccountFee(fee, (AmountFeeBO) feeBO);
} else {
// generate repayment schedule and enable fee
fee.changeFeesStatus(FeeStatus.ACTIVE, new DateTimeService().getCurrentJavaDateTime());
updateAccountFee(fee, (AmountFeeBO) feeBO);
associateFeeWithAllKnownFutureInstallments(fee);
}
} else if (feeBO.getFeeChangeType().equals(FeeChangeType.STATUS_UPDATED)) {
if (!feeBO.isActive()) {
removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(feeBO.getFeeId(), Short.valueOf("1"));
} else {
fee.changeFeesStatus(FeeStatus.ACTIVE, new DateTimeService().getCurrentJavaDateTime());
associateFeeWithAllKnownFutureInstallments(fee);
}
} else if (feeBO.getFeeChangeType().equals(FeeChangeType.AMOUNT_UPDATED)) {
updateAccountFee(fee, (AmountFeeBO) feeBO);
updateUpcomingAndFutureInstallments(fee);
}
} catch (PropertyNotFoundException e) {
throw new BatchJobException(e);
} catch (AccountException e) {
throw new BatchJobException(e);
}
}
}
Aggregations