use of org.mifos.framework.components.batchjobs.exceptions.BatchJobException in project head by mifos.
the class ProductStatusHelper method execute.
@Override
public void execute(long timeInMillis) throws BatchJobException {
Session session;
String hqlUpdate;
Query query;
try {
session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
hqlUpdate = "update PrdOfferingBO p set p.prdStatus=:activeLoanStatus " + "where p.prdType.productTypeID=:loan and p.startDate=:currentDate";
query = session.createQuery(hqlUpdate);
query.setShort("activeLoanStatus", PrdStatus.LOAN_ACTIVE.getValue());
query.setShort("loan", ProductType.LOAN.getValue());
query.setDate("currentDate", new Date(timeInMillis));
query.executeUpdate();
hqlUpdate = "update PrdOfferingBO p set p.prdStatus=:inActiveLoanStatus " + "where p.prdType.productTypeID=:loan and p.endDate=:currentDate";
query = session.createQuery(hqlUpdate);
query.setShort("inActiveLoanStatus", PrdStatus.LOAN_INACTIVE.getValue());
query.setShort("loan", ProductType.LOAN.getValue());
query.setDate("currentDate", new Date(timeInMillis));
query.executeUpdate();
hqlUpdate = "update PrdOfferingBO p set p.prdStatus=:activeSavingStatus " + "where p.prdType.productTypeID=:saving and p.startDate=:currentDate";
query = session.createQuery(hqlUpdate);
query.setShort("activeSavingStatus", PrdStatus.SAVINGS_ACTIVE.getValue());
query.setShort("saving", ProductType.SAVINGS.getValue());
query.setDate("currentDate", new Date(timeInMillis));
query.executeUpdate();
hqlUpdate = "update PrdOfferingBO p set p.prdStatus=:inActiveSavingStatus " + "where p.prdType.productTypeID=:saving and p.endDate=:currentDate";
query = session.createQuery(hqlUpdate);
query.setShort("inActiveSavingStatus", PrdStatus.SAVINGS_INACTIVE.getValue());
query.setShort("saving", ProductType.SAVINGS.getValue());
query.setDate("currentDate", new Date(timeInMillis));
query.executeUpdate();
StaticHibernateUtil.commitTransaction();
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new BatchJobException(e);
}
}
use of org.mifos.framework.components.batchjobs.exceptions.BatchJobException in project head by mifos.
the class SavingsIntPostingHelper method execute.
@Override
public void execute(final long scheduledFireTime) throws BatchJobException {
MifosUser principal = createMifosAdminUser();
SecurityContext securityContext = SecurityContextHolder.getContext();
if (securityContext == null) {
securityContext = new SecurityContextImpl();
SecurityContextHolder.setContext(securityContext);
}
if (securityContext.getAuthentication() == null || !securityContext.getAuthentication().isAuthenticated()) {
Authentication authentication = new UsernamePasswordAuthenticationToken(principal, principal, principal.getAuthorities());
securityContext.setAuthentication(authentication);
}
LocalDate dateOfBatchJob = new LocalDate(scheduledFireTime);
List<String> errorList = new ArrayList<String>();
try {
this.savingsServiceFacade.postInterestForLastPostingPeriod(dateOfBatchJob);
} catch (BusinessRuleException e) {
errorList.add(e.getMessageKey());
}
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 BranchReportStaffSummaryHelper method populateStaffSummary.
public void populateStaffSummary() throws BatchJobException {
try {
List<BranchReportStaffSummaryBO> staffSummaries = branchReportService.extractBranchReportStaffSummary(branchReport.getBranchId(), branchReportConfigService.getGracePeriodDays(), branchReportConfigService.getCurrency());
branchReport.addStaffSummaries(staffSummaries);
} catch (ServiceException e) {
throw new BatchJobException(e);
}
}
Aggregations