use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class HolidayDaoHibernate method validateNoExtraFutureHolidaysApplicableOnParentOffice.
@Override
public void validateNoExtraFutureHolidaysApplicableOnParentOffice(Short oldParentOfficeId, Short newParentOfficeId) throws ApplicationException {
List<Holiday> previousApplicableHolidays = retrieveCurrentAndFutureHolidaysForOfficeHierarchyInAscendingOrder(oldParentOfficeId);
List<Holiday> possibleApplicableHolidays = retrieveCurrentAndFutureHolidaysForOfficeHierarchyInAscendingOrder(newParentOfficeId);
if (previousApplicableHolidays.size() != possibleApplicableHolidays.size()) {
throw new ApplicationException(OfficeConstants.ERROR_REPARENT_NOT_ALLOWED_AS_FUTURE_APPLICABLE_HOLIDAYS_ARE_DIFFERENT_ON_PREVIOUS_AND_NEW_PARENT);
}
for (Holiday holiday : previousApplicableHolidays) {
HolidayBO applicableHoliday = (HolidayBO) holiday;
if (!possibleApplicableHolidays.contains(applicableHoliday)) {
throw new ApplicationException(OfficeConstants.ERROR_REPARENT_NOT_ALLOWED_AS_FUTURE_APPLICABLE_HOLIDAYS_ARE_DIFFERENT_ON_PREVIOUS_AND_NEW_PARENT);
}
}
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class GroupCustAction method get.
@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In GroupCustAction get method ");
// John W - UserContext object passed because some status' need to be looked up for internationalisation based
// on UserContext info
String groupSystemId = ((GroupCustActionForm) form).getGlobalCustNum();
GroupInformationDto groupInformationDto;
try {
groupInformationDto = this.groupServiceFacade.getGroupInformationDto(groupSystemId);
} catch (MifosRuntimeException e) {
if (e.getCause() instanceof ApplicationException) {
throw (ApplicationException) e.getCause();
}
throw e;
}
SessionUtils.removeThenSetAttribute("groupInformationDto", groupInformationDto, request);
// John W - - not sure whether to leave these rules as is or do something else like bake the logic into the main
// dto and out of the jsp
SessionUtils.setAttribute(GroupConstants.IS_GROUP_LOAN_ALLOWED, ClientRules.getGroupCanApplyLoans(), request);
SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, ClientRules.getCenterHierarchyExists(), request);
// John W - 'BusinessKey' attribute linked to GroupBo is still used by other actions (e.g. meeting related)
// further on and also breadcrumb.
GroupBO groupBO = (GroupBO) this.customerDao.findCustomerById(groupInformationDto.getGroupDisplay().getCustomerId());
SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, groupBO, request);
setCurrentPageUrl(request, groupBO);
setQuestionGroupInstances(request, groupBO);
logger.debug("Exiting GroupCustAction get method ");
return mapping.findForward(ActionForwards.get_success.toString());
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class GroupCustAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
GroupCustActionForm actionForm = (GroupCustActionForm) form;
MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
UserContext userContext = getUserContext(request);
String groupName = actionForm.getDisplayName();
String externalId = actionForm.getExternalId();
boolean trained = actionForm.isCustomerTrained();
DateTime trainedOn = new DateTime(actionForm.getTrainedDateValue(userContext.getPreferredLocale()));
AddressDto addressDto = null;
if (actionForm.getAddress() != null) {
addressDto = Address.toDto(actionForm.getAddress());
}
Short customerStatusId = actionForm.getStatusValue().getValue();
String centerSystemId = "";
boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
if (isCenterHierarchyExists) {
centerSystemId = actionForm.getParentCustomer().getGlobalCustNum();
}
Short officeId = actionForm.getOfficeIdValue();
MeetingDto meetingDto = null;
if (meeting != null) {
meetingDto = meeting.toDto();
}
DateTime mfiJoiningDate = new DateTime().toDateMidnight().toDateTime();
DateTime activationDate = new DateTime().toDateMidnight().toDateTime();
try {
GroupCreationDetail groupCreationDetail = new GroupCreationDetail(groupName, externalId, addressDto, actionForm.getFormedByPersonnelValue(), actionForm.getFeesToApply(), customerStatusId, trained, trainedOn, centerSystemId, officeId, mfiJoiningDate, activationDate);
CustomerDetailsDto centerDetails = this.groupServiceFacade.createNewGroup(groupCreationDetail, meetingDto);
createGroupQuestionnaire.saveResponses(request, actionForm, centerDetails.getId());
actionForm.setCustomerId(centerDetails.getId().toString());
actionForm.setGlobalCustNum(centerDetails.getGlobalCustNum());
} catch (BusinessRuleException e) {
throw new ApplicationException(e.getMessageKey(), e);
}
SessionUtils.setAttribute(GroupConstants.IS_GROUP_LOAN_ALLOWED, ClientRules.getGroupCanApplyLoans(), request);
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class GroupCustActionForm method validateFields.
@Override
protected ActionErrors validateFields(HttpServletRequest request, String method) throws ApplicationException {
ActionErrors errors = new ActionErrors();
try {
if (method.equals(Methods.previewManage.toString())) {
validateName(errors);
validateTrained(request, errors);
validateConfigurableMandatoryFields(request, errors, EntityType.GROUP);
validateCustomFieldsForCustomers(request, errors);
} else if (method.equals(Methods.preview.toString()) || method.equals(Methods.previewOnly.toString())) {
validateName(errors);
validateLO(errors);
validateFormedByPersonnel(errors);
validateTrained(request, errors);
validateConfigurableMandatoryFields(request, errors, EntityType.GROUP);
validateCustomFieldsForCustomers(request, errors);
validateFees(request, errors);
}
} catch (ApplicationException ae) {
// Discard other errors (is that right?)
ae.printStackTrace();
errors = new ActionErrors();
errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
}
if (!errors.isEmpty()) {
request.setAttribute(GroupConstants.METHODCALLED, method);
}
return errors;
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class CustomerApplyAdjustmentAction method previewAdjustment.
@TransactionDemarcate(joinToken = true)
public ActionForward previewAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_PREVIEW_ADJUSTMENT);
CustomerApplyAdjustmentActionForm applyAdjustmentActionForm = (CustomerApplyAdjustmentActionForm) form;
String globalCustNum = applyAdjustmentActionForm.getGlobalCustNum();
CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request);
if (null == customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate()) {
request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_LOAD_ADJUSTMENT);
request.setAttribute("isDisabled", "true");
throw new ApplicationException(AccountExceptionConstants.ZEROAMNTADJUSTMENT);
}
return mapping.findForward(CustomerConstants.METHOD_PREVIEW_ADJUSTMENT_SUCCESS);
}
Aggregations