Search in sources :

Example 6 with BirtReportsUploadActionForm

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

the class BirtReportsUploadActionStrutsTest method testShouldPreviewFailureWithOutReportTemplate.

@Test
public void testShouldPreviewFailureWithOutReportTemplate() throws Exception {
    setRequestPathInfo("/birtReportsUploadAction.do");
    BirtReportsUploadActionForm form = new BirtReportsUploadActionForm();
    form.setIsActive("1");
    form.setReportCategoryId("1");
    form.setReportTitle("testReportTitle2");
    setActionForm(form);
    addRequestParameter("method", "preview");
    actionPerform();
    String[] errors = { ReportsConstants.ERROR_FILE };
    verifyActionErrors(errors);
}
Also used : BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm) Test(org.junit.Test)

Example 7 with BirtReportsUploadActionForm

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

the class BirtReportsUploadAction method preview.

public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    BirtReportsUploadActionForm uploadForm = (BirtReportsUploadActionForm) form;
    ReportsPersistence rp = new ReportsPersistence();
    ReportsCategoryBO category = rp.getPersistentObject(ReportsCategoryBO.class, Short.valueOf(uploadForm.getReportCategoryId()));
    request.setAttribute("category", category);
    if (isReportAlreadyExist(request, uploadForm.getReportTitle(), category)) {
        return mapping.findForward(ActionForwards.preview_failure.toString());
    }
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)

Example 8 with BirtReportsUploadActionForm

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

the class BirtReportsUploadAction method getBirtReportsUploadPage.

public ActionForward getBirtReportsUploadPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsAction:getBirtReportPage Method: ");
    StaticHibernateUtil.flushAndCloseSession();
    BirtReportsUploadActionForm uploadForm = (BirtReportsUploadActionForm) form;
    uploadForm.clear();
    request.getSession().setAttribute(ReportsConstants.LISTOFREPORTS, new ReportsPersistence().getAllReportCategories());
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)

Example 9 with BirtReportsUploadActionForm

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

the class BirtReportsUploadAction method upload.

public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    BirtReportsUploadActionForm uploadForm = (BirtReportsUploadActionForm) form;
    ReportsPersistence rp = new ReportsPersistence();
    ReportsCategoryBO category = rp.getPersistentObject(ReportsCategoryBO.class, Short.valueOf(uploadForm.getReportCategoryId()));
    if (isReportAlreadyExist(request, uploadForm.getReportTitle(), category)) {
        return mapping.findForward(ActionForwards.preview_failure.toString());
    }
    short parentActivity = category.getActivityId();
    int newActivityId;
    String activityNameHead = "Can view ";
    try {
        newActivityId = legacyRolesPermissionsDao.calculateDynamicActivityId();
        legacyRolesPermissionsDao.createActivityForReports(parentActivity, activityNameHead + uploadForm.getReportTitle());
    } catch (ActivityGeneratorException ex) {
        ActionErrors errors = new ActionErrors();
        errors.add(ex.getKey(), new ActionMessage(ex.getKey()));
        request.setAttribute(Globals.ERROR_KEY, errors);
        return mapping.findForward(ActionForwards.preview_failure.toString());
    }
    FormFile formFile = uploadForm.getFile();
    uploadFile(formFile);
    ReportsBO reportBO = createOrUpdateReport(category, newActivityId, uploadForm.getReportTitle(), Short.valueOf(uploadForm.getIsActive()), formFile.getFileName(), uploadForm.getIsDW());
    allowActivityPermission(reportBO, newActivityId);
    request.setAttribute("report", reportBO);
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm) ActionMessage(org.apache.struts.action.ActionMessage) ActivityGeneratorException(org.mifos.security.activity.ActivityGeneratorException) ActionErrors(org.apache.struts.action.ActionErrors) FormFile(org.apache.struts.upload.FormFile) ReportsBO(org.mifos.reports.business.ReportsBO)

Example 10 with BirtReportsUploadActionForm

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

the class BirtReportsUploadAction method editprevious.

public ActionForward editprevious(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    BirtReportsUploadActionForm uploadForm = (BirtReportsUploadActionForm) form;
    ReportsPersistence rp = new ReportsPersistence();
    ReportsCategoryBO category = rp.getPersistentObject(ReportsCategoryBO.class, Short.valueOf(uploadForm.getReportCategoryId()));
    request.setAttribute("category", category);
    return mapping.findForward(ActionForwards.editprevious_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)

Aggregations

BirtReportsUploadActionForm (org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)13 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)9 ReportsBO (org.mifos.reports.business.ReportsBO)7 Test (org.junit.Test)6 ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)6 MockFormFile (org.mifos.reports.business.MockFormFile)5 FormFile (org.apache.struts.upload.FormFile)4 ReportsJasperMap (org.mifos.reports.business.ReportsJasperMap)3 ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)2 IOException (java.io.IOException)1 ActionErrors (org.apache.struts.action.ActionErrors)1 ActionMessage (org.apache.struts.action.ActionMessage)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 AddActivity (org.mifos.security.AddActivity)1 ActivityGeneratorException (org.mifos.security.activity.ActivityGeneratorException)1 RolesPermissionsBusinessService (org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService)1