use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class ReportsCategoryAction method addNewCategory.
public ActionForward addNewCategory(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In ReportsCategoryAction:addNewCategory Method: ");
ReportsCategoryActionForm defineNewCategoryForm = (ReportsCategoryActionForm) form;
String categoryName = defineNewCategoryForm.getCategoryName();
ReportsCategoryBO reportsCategoryBO = new ReportsCategoryBO();
int newActivityId;
try {
newActivityId = legacyRolesPermissionsDao.calculateDynamicActivityId();
} catch (ActivityGeneratorException agex) {
ActionErrors errors = new ActionErrors();
errors.add(agex.getKey(), new ActionMessage(agex.getKey()));
request.setAttribute(Globals.ERROR_KEY, errors);
return mapping.findForward(ActionForwards.preview_failure.toString());
}
Short parentActivityId = SecurityConstants.REPORTS_MANAGEMENT;
legacyRolesPermissionsDao.createActivityForReports(parentActivityId, categoryName);
reportsCategoryBO.setActivityId((short) newActivityId);
reportsCategoryBO.setReportCategoryName(categoryName);
new ReportsPersistence().createOrUpdate(reportsCategoryBO);
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class ReportsCategoryAction method confirmDeleteReportsCategory.
public ActionForward confirmDeleteReportsCategory(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) {
logger.debug("In ReportsCategoryAction:confirmDeleteReportsCategory Method: ");
ReportsCategoryActionForm reportsCategoryActionForm = (ReportsCategoryActionForm) form;
ReportsCategoryBO reportsCategoryBO = new ReportsPersistence().getReportCategoryByCategoryId(Short.valueOf(reportsCategoryActionForm.getCategoryId()));
reportsCategoryActionForm.setCategoryName(reportsCategoryBO.getReportCategoryName());
if (!isValidToDelete(request, reportsCategoryBO)) {
return mapping.findForward(ActionForwards.confirm_delete.toString());
}
return mapping.findForward(ActionForwards.confirm_delete.toString());
}
use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class ReportsCategoryAction method editThenSubmit.
public ActionForward editThenSubmit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In ReportsCategoryAction:editThenSubmit Method: ");
ReportsCategoryActionForm reportsCategoryActionForm = (ReportsCategoryActionForm) form;
short reportCategoryId = reportsCategoryActionForm.getCategoryId();
String inputCategoryName = reportsCategoryActionForm.getCategoryName();
ReportsCategoryBO reportsCategoryBO = new ReportsPersistence().getReportCategoryByCategoryId(reportCategoryId);
if (isReportCategoryNameAlreadyExist(request, inputCategoryName)) {
return mapping.findForward(ActionForwards.editPreview_failure.toString());
}
reportsCategoryBO.setReportCategoryName(inputCategoryName);
ReportsPersistence rPersistence = new ReportsPersistence();
rPersistence.createOrUpdate(reportsCategoryBO);
// update cache
Short activityId = reportsCategoryBO.getActivityId();
rPersistence.updateLookUpValue(activityId, inputCategoryName);
legacyRolesPermissionsDao.changeActivityMessage(reportsCategoryBO.getActivityId(), Localization.ENGLISH_LOCALE_ID, reportsCategoryBO.getReportCategoryName());
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class ReportsCategoryAction method preview.
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In ReportsCategoryAction:preview Method: ");
ReportsCategoryActionForm defineCategoryForm = (ReportsCategoryActionForm) form;
String categoryName = defineCategoryForm.getCategoryName();
request.setAttribute("categoryName", categoryName);
for (ReportsCategoryBO category : new ReportsPersistence().getAllReportCategories()) {
if (categoryName.equals(category.getReportCategoryName())) {
ActionErrors errors = new ActionErrors();
errors.add(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST, new ActionMessage(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST));
request.setAttribute(Globals.ERROR_KEY, errors);
return mapping.findForward(ActionForwards.preview_failure.toString());
}
}
return mapping.findForward(ActionForwards.preview_success.toString());
}
use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class ReportsCategoryAction method edit.
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In ReportsCategoryAction:edit Method: ");
ReportsCategoryActionForm reportsCategoryActionForm = (ReportsCategoryActionForm) form;
String reportCategoryId = request.getParameter("categoryId");
ReportsCategoryBO reportCategory = new ReportsPersistence().getReportCategoryByCategoryId(Short.valueOf(reportCategoryId));
reportsCategoryActionForm.setCategoryName(reportCategory.getReportCategoryName());
return mapping.findForward(ActionForwards.edit_success.toString());
}
Aggregations