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);
}
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());
}
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());
}
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());
}
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());
}
Aggregations