use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class BaseAction method postExecute.
protected void postExecute(HttpServletRequest request, TransactionDemarcate annotation, boolean closeSession) throws ApplicationException, SystemException {
// do cleanup here
if (startSession()) {
try {
StaticHibernateUtil.commitTransaction();
postHandleTransaction(request, annotation);
} catch (HibernateException he) {
he.printStackTrace();
StaticHibernateUtil.rollbackTransaction();
throw new ApplicationException(he);
}
} else {
postHandleTransaction(request, annotation);
}
if (closeSession) {
// StaticHibernateUtil.flushAndCloseSession();
StaticHibernateUtil.closeSession();
}
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class WebTierPenaltyServiceFacade method updatePenalty.
@Override
public void updatePenalty(PenaltyFormDto dto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
PenaltyBO penaltyBO = this.penaltyDao.findPenaltyById(dto.getId());
penaltyBO.updateDetails(userContext);
try {
PenaltyFrequency penaltyFrequency = dto.getPenaltyFrequency() != null ? PenaltyFrequency.getPenaltyFrequencyType(dto.getPenaltyFrequency()) : null;
PenaltyPeriod penaltyPeriod = dto.getPenaltyPeriod() != null ? PenaltyPeriod.getPenaltyPeriod(dto.getPenaltyPeriod()) : null;
PenaltyFormula penaltyFormula = dto.getPenaltyFormula() != null ? PenaltyFormula.getPenaltyFormula(dto.getPenaltyFormula()) : null;
PenaltyStatus penaltyStatus = dto.getPenaltyStatus() != null ? PenaltyStatus.getPenaltyStatus(dto.getPenaltyStatus()) : null;
penaltyBO.setPeriodType(this.penaltyDao.findPenaltyPeriodEntityByType(penaltyPeriod));
penaltyBO.setPenaltyFrequency(this.penaltyDao.findPenaltyFrequencyEntityByType(penaltyFrequency));
penaltyBO.setPenaltyName(dto.getPenaltyName());
penaltyBO.setPeriodDuration(dto.getDuration());
penaltyBO.setMinimumLimit(dto.getMin());
penaltyBO.setMaximumLimit(dto.getMax());
penaltyBO.setStatus(this.penaltyDao.findPenaltyStatusEntityByType(penaltyStatus));
penaltyBO.setGlCode(this.generalLedgerDao.findGlCodeById(dto.getGlCode()));
if (dto.isRatePenalty()) {
RatePenaltyBO ratePenaltyBO = (RatePenaltyBO) penaltyBO;
ratePenaltyBO.setRate(dto.getRate());
ratePenaltyBO.setFormula(this.penaltyDao.findPenaltyFormulaEntityByType(penaltyFormula));
} else {
AmountPenaltyBO amountPenaltyBO = (AmountPenaltyBO) penaltyBO;
amountPenaltyBO.setAmount(new Money(getCurrency(dto.getCurrencyId()), dto.getAmount()));
}
try {
StaticHibernateUtil.startTransaction();
this.penaltyDao.save(penaltyBO);
StaticHibernateUtil.commitTransaction();
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
StaticHibernateUtil.closeSession();
}
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class ReportsPersistence method deleteReportsDataSource.
public void deleteReportsDataSource(ReportsDataSource reportsDataSource) throws ApplicationException, SystemException {
Session session = null;
try {
session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
session.delete(reportsDataSource);
session.flush();
StaticHibernateUtil.commitTransaction();
} catch (HibernateProcessException hpe) {
StaticHibernateUtil.rollbackTransaction();
throw new ApplicationException(hpe);
} catch (HibernateException e) {
StaticHibernateUtil.rollbackTransaction();
throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
} finally {
StaticHibernateUtil.closeSession();
}
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class ReportsPersistence method createReportsParamsMap.
/**
* Creates a link between a report and a parameter
*/
public void createReportsParamsMap(ReportsParamsMapValue reportsParamsMapValue) throws ApplicationException, SystemException {
Session session = null;
try {
session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
session.save(reportsParamsMapValue);
session.flush();
StaticHibernateUtil.commitTransaction();
} catch (HibernateProcessException hpe) {
StaticHibernateUtil.rollbackTransaction();
throw new ApplicationException(hpe);
} catch (HibernateException e) {
StaticHibernateUtil.rollbackTransaction();
throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
} finally {
StaticHibernateUtil.closeSession();
}
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class ReportsPersistence method createReportParams.
public void createReportParams(ReportsParamsValue reportsParams) throws ApplicationException, SystemException {
Session session = null;
Transaction trxn = null;
try {
session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
session.save(reportsParams);
session.flush();
StaticHibernateUtil.commitTransaction();
} catch (HibernateProcessException hpe) {
StaticHibernateUtil.rollbackTransaction();
throw new ApplicationException(hpe);
} catch (HibernateException hpe) {
trxn.rollback();
throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION);
} catch (Exception e) {
trxn.rollback();
throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
} finally {
StaticHibernateUtil.closeSession();
}
}
Aggregations