Search in sources :

Example 1 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm in project head by mifos.

the class ReportsCategoryAction method editPreview.

public ActionForward editPreview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsCategoryAction:editPreview Method: ");
    ReportsCategoryActionForm defineCategoryForm = (ReportsCategoryActionForm) form;
    String inputCategoryName = defineCategoryForm.getCategoryName();
    short reportCategoryId = defineCategoryForm.getCategoryId();
    ReportsCategoryBO reportCategory = new ReportsPersistence().getReportCategoryByCategoryId(reportCategoryId);
    if (isReportCategoryNameNotEdit(request, inputCategoryName, reportCategory)) {
        return mapping.findForward(ActionForwards.editPreview_failure.toString());
    } else if (isReportCategoryNameAlreadyExist(request, inputCategoryName)) {
        return mapping.findForward(ActionForwards.editPreview_failure.toString());
    }
    return mapping.findForward(ActionForwards.editpreview_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

Example 2 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm in project head by mifos.

the class ReportsCategoryAction method deleteReportsCategory.

public ActionForward deleteReportsCategory(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsCategoryAction:deleteReportsCategory Method: ");
    ReportsCategoryActionForm reportsCategoryActionForm = (ReportsCategoryActionForm) form;
    ReportsCategoryBO reportsCategoryBO = new ReportsPersistence().getReportCategoryByCategoryId(Short.valueOf(reportsCategoryActionForm.getCategoryId()));
    if (!isValidToDelete(request, reportsCategoryBO)) {
        return mapping.findForward(ActionForwards.confirm_delete.toString());
    }
    new ReportsPersistence().delete(reportsCategoryBO);
    request.getSession().setAttribute(ReportsConstants.LISTOFREPORTCATEGORIES, new ReportsPersistence().getAllReportCategories());
    return mapping.findForward(ActionForwards.delete_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

Example 3 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm in project head by mifos.

the class ReportsCategoryActionStrutsTest method testCategoryNameShouldBeNullBeforeDefineNewCategory.

@Test
public void testCategoryNameShouldBeNullBeforeDefineNewCategory() throws Exception {
    setRequestPathInfo("/reportsCategoryAction.do");
    ReportsCategoryActionForm form = new ReportsCategoryActionForm();
    String categoryName = "Not Null";
    form.setCategoryName(categoryName);
    setActionForm(form);
    addRequestParameter("method", "loadDefineNewCategoryPage");
    actionPerform();
    Assert.assertNull(((ReportsCategoryActionForm) getActionForm()).getCategoryName());
}
Also used : ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) Test(org.junit.Test)

Example 4 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm in project head by mifos.

the class ReportsCategoryActionStrutsTest method testShouldSubmitSuccessAfterEdit.

@Test
public void testShouldSubmitSuccessAfterEdit() throws Exception {
    setRequestPathInfo("/reportsCategoryAction.do");
    addRequestParameter("method", "editThenSubmit");
    ReportsCategoryActionForm form = new ReportsCategoryActionForm();
    String categoryName = "neverExist";
    form.setCategoryName(categoryName);
    form.setCategoryId((short) 1);
    setActionForm(form);
    actionPerform();
    verifyForward("create_success");
    verifyForwardPath("/reportsCategoryAction.do?method=viewReportsCategory");
    verifyNoActionErrors();
}
Also used : ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) Test(org.junit.Test)

Example 5 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm in project head by mifos.

the class ReportsCategoryActionStrutsTest method testShouldPreviewSuccessAfterEdit.

@Test
public void testShouldPreviewSuccessAfterEdit() throws Exception {
    setRequestPathInfo("/reportsCategoryAction.do");
    ReportsCategoryActionForm form = new ReportsCategoryActionForm();
    String categoryName = "Not Null";
    form.setCategoryName(categoryName);
    form.setCategoryId((short) 1);
    setActionForm(form);
    addRequestParameter("method", "editPreview");
    actionPerform();
    verifyForwardPath("/pages/application/reports/jsp/edit_preview_reports_category.jsp");
    verifyNoActionErrors();
}
Also used : ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) Test(org.junit.Test)

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