use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class GroupServiceFacadeWebTier method updateCustomerHistoricalData.
@Override
public void updateCustomerHistoricalData(String globalCustNum, CustomerHistoricalDataUpdateRequest historicalData) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
customerBO.updateDetails(userContext);
try {
CustomerHistoricalDataEntity customerHistoricalDataEntity = customerBO.getHistoricalData();
if (customerBO.getPersonnel() != null) {
checkPermissionForAddingHistoricalData(customerBO.getLevel(), userContext, customerBO.getOffice().getOfficeId(), customerBO.getPersonnel().getPersonnelId());
} else {
checkPermissionForAddingHistoricalData(customerBO.getLevel(), userContext, customerBO.getOffice().getOfficeId(), userContext.getId());
}
// Integer oldLoanCycleNo = 0;
if (customerHistoricalDataEntity == null) {
customerHistoricalDataEntity = new CustomerHistoricalDataEntity(customerBO);
customerHistoricalDataEntity.setCreatedBy(customerBO.getUserContext().getId());
customerHistoricalDataEntity.setCreatedDate(new DateTimeService().getCurrentJavaDateTime());
} else {
// oldLoanCycleNo =
// customerHistoricalDataEntity.getLoanCycleNumber();
customerHistoricalDataEntity.setUpdatedDate(new DateTimeService().getCurrentJavaDateTime());
customerHistoricalDataEntity.setUpdatedBy(customerBO.getUserContext().getId());
}
customerHistoricalDataEntity.setInterestPaid(StringUtils.isBlank(historicalData.getInterestPaid()) ? null : new Money(Money.getDefaultCurrency(), historicalData.getInterestPaid()));
customerHistoricalDataEntity.setLoanAmount(StringUtils.isBlank(historicalData.getLoanAmount()) ? null : new Money(Money.getDefaultCurrency(), historicalData.getLoanAmount()));
customerHistoricalDataEntity.setLoanCycleNumber(historicalData.getLoanCycleNumber());
customerHistoricalDataEntity.setMissedPaymentsCount(historicalData.getMissedPaymentsCount());
customerHistoricalDataEntity.setNotes(historicalData.getNotes());
customerHistoricalDataEntity.setProductName(historicalData.getProductName());
customerHistoricalDataEntity.setTotalAmountPaid(StringUtils.isBlank(historicalData.getTotalAmountPaid()) ? null : new Money(Money.getDefaultCurrency(), historicalData.getTotalAmountPaid()));
customerHistoricalDataEntity.setTotalPaymentsCount(historicalData.getTotalPaymentsCount());
customerHistoricalDataEntity.setMfiJoiningDate(historicalData.getMfiJoiningDate());
this.transactionHelper.startTransaction();
this.transactionHelper.beginAuditLoggingFor(customerBO);
customerBO.updateHistoricalData(customerHistoricalDataEntity);
this.customerDao.save(customerBO);
this.transactionHelper.commitTransaction();
} catch (ApplicationException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class CenterCustAction method update.
// NOTE - manage->preview->update
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CenterBO centerFromSession = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
CenterCustActionForm actionForm = (CenterCustActionForm) form;
AddressDto dto = null;
if (actionForm.getAddress() != null) {
dto = Address.toDto(actionForm.getAddress());
}
CenterUpdate centerUpdate = new CenterUpdate(centerFromSession.getCustomerId(), actionForm.getDisplayName(), centerFromSession.getVersionNo(), actionForm.getLoanOfficerIdValue(), actionForm.getExternalId(), actionForm.getMfiJoiningDate(), dto, actionForm.getCustomFields(), actionForm.getCustomerPositions());
try {
this.centerServiceFacade.updateCenter(centerUpdate);
} catch (BusinessRuleException e) {
throw new ApplicationException(e.getMessageKey(), e);
}
return mapping.findForward(ActionForwards.update_success.toString());
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class CenterCustAction method get.
@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CenterInformationDto centerInformationDto;
try {
centerInformationDto = this.centerServiceFacade.getCenterInformationDto(((CenterCustActionForm) form).getGlobalCustNum());
} catch (MifosRuntimeException e) {
if (e.getCause() instanceof ApplicationException) {
throw (ApplicationException) e.getCause();
}
throw e;
}
SessionUtils.removeThenSetAttribute("centerInformationDto", centerInformationDto, request);
// John W - 'BusinessKey' attribute used by breadcrumb but is not in associated jsp
CenterBO centerBO = (CenterBO) this.customerDao.findCustomerById(centerInformationDto.getCenterDisplay().getCustomerId());
SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, centerBO, request);
setCurrentPageUrl(request, centerBO);
setQuestionGroupInstances(request, centerBO);
return mapping.findForward(ActionForwards.get_success.toString());
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class BulkEntryTag method doStartTag.
@SuppressWarnings("unchecked")
@Override
public int doStartTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
JspWriter out = pageContext.getOut();
StringBuilder builder = new StringBuilder();
CollectionSheetEntryGridDto bulkEntry = null;
try {
bulkEntry = (CollectionSheetEntryGridDto) SessionUtils.getAttribute(CollectionSheetEntryConstants.BULKENTRY, request);
} catch (PageExpiredException e) {
logger.error("Page expired getting BulkEntryBO.");
}
if (null != bulkEntry) {
List<ProductDto> loanProducts = bulkEntry.getLoanProducts();
List<ProductDto> savingsProducts = bulkEntry.getSavingProducts();
try {
final List<CustomValueListElementDto> custAttTypes = (List<CustomValueListElementDto>) SessionUtils.getAttribute(CollectionSheetEntryConstants.CUSTOMERATTENDANCETYPES, request);
String method = request.getParameter(CollectionSheetEntryConstants.METHOD);
generateTagData(bulkEntry, loanProducts, savingsProducts, custAttTypes, method, builder);
} catch (ApplicationException ae) {
throw new JspException(ae);
} catch (SystemException se) {
throw new JspException(se);
}
}
try {
out.write(builder.toString());
} catch (IOException ioe) {
throw new JspException(ioe);
}
return SKIP_BODY;
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class MeetingActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter("method");
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
ActionErrors errors = new ActionErrors();
try {
errors = validateFields(request, method);
} catch (ApplicationException ae) {
errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
}
if (null != errors && !errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
return errors;
}
Aggregations