Search in sources :

Example 6 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm 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());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) ActionMessage(org.apache.struts.action.ActionMessage) ActivityGeneratorException(org.mifos.security.activity.ActivityGeneratorException) ActionErrors(org.apache.struts.action.ActionErrors)

Example 7 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm 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());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

Example 8 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm 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());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

Example 9 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm 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());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 10 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm 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());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

Aggregations

ReportsCategoryActionForm (org.mifos.reports.struts.actionforms.ReportsCategoryActionForm)12 ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)7 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)7 Test (org.junit.Test)5 ActionErrors (org.apache.struts.action.ActionErrors)2 ActionMessage (org.apache.struts.action.ActionMessage)2 ActivityGeneratorException (org.mifos.security.activity.ActivityGeneratorException)1