use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class BirtReportsUploadAction method editThenUpload.
public ActionForward editThenUpload(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()));
ReportsBO reportBO = rp.getReport(Short.valueOf(uploadForm.getReportId()));
ReportsJasperMap reportJasperMap = reportBO.getReportsJasperMap();
if (!isReportItsSelf(uploadForm, reportBO) && isReportAlreadyExist(request, uploadForm.getReportTitle(), category)) {
return mapping.findForward(ActionForwards.editpreview_failure.toString());
} else if (isReportActivityIdNull(request, reportBO)) {
return mapping.findForward(ActionForwards.create_failure.toString());
}
reportBO.setReportName(uploadForm.getReportTitle());
reportBO.setIsActive(Short.valueOf(uploadForm.getIsActive()));
reportBO.setReportsCategoryBO(category);
rp.createOrUpdate(reportBO);
// kim
String activityNameHead = "Can view ";
rp.updateLookUpValue(reportBO.getActivityId(), activityNameHead + uploadForm.getReportTitle());
legacyRolesPermissionsDao.reparentActivityUsingHibernate(reportBO.getActivityId(), category.getActivityId());
legacyRolesPermissionsDao.changeActivityMessage(reportBO.getActivityId(), Localization.ENGLISH_LOCALE_ID, "Can view " + reportBO.getReportName());
FormFile formFile = uploadForm.getFile();
if (StringUtils.isEmpty(formFile.getFileName())) {
formFile.destroy();
} else {
reportJasperMap.setReportJasper(formFile.getFileName());
rp.createOrUpdate(reportJasperMap);
uploadFile(formFile);
}
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.reports.persistence.ReportsPersistence 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());
}
use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class ReportsCategoryAction method isReportCategoryNameAlreadyExist.
private boolean isReportCategoryNameAlreadyExist(HttpServletRequest request, String inputCategoryName) {
for (ReportsCategoryBO category : new ReportsPersistence().getAllReportCategories()) {
if (category.getReportCategoryName().equals(inputCategoryName)) {
ActionErrors errors = new ActionErrors();
errors.add(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST, new ActionMessage(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST));
request.setAttribute(Globals.ERROR_KEY, errors);
return true;
}
}
return false;
}
use of org.mifos.reports.persistence.ReportsPersistence 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());
}
use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class BirtReportsUploadActionStrutsTest method testShouldSubmitSuccessAfterEdit.
@Test
public void testShouldSubmitSuccessAfterEdit() throws Exception {
setRequestPathInfo("/birtReportsUploadAction.do");
ReportsPersistence persistence = new ReportsPersistence();
ReportsBO report = new ReportsBO();
report.setReportName("testShouldSubmitSuccessAfterEdit");
report.setReportsCategoryBO(persistence.getPersistentObject(ReportsCategoryBO.class, (short) 1));
report.setIsActive((short) 1);
short newActivityId = (short) legacyRolesPermissionsDao.calculateDynamicActivityId();
legacyRolesPermissionsDao.createActivityForReports((short) 1, "test" + "testShouldSubmitSuccessAfterEdit");
report.setActivityId(newActivityId);
ReportsJasperMap reportJasperMap = report.getReportsJasperMap();
reportJasperMap.setReportJasper("testFileName_EDIT.rptdesign");
report.setReportsJasperMap(reportJasperMap);
persistence.createOrUpdate(report);
BirtReportsUploadActionForm editForm = new BirtReportsUploadActionForm();
editForm.setReportId(report.getReportId().toString());
editForm.setReportTitle("newTestShouldSubmitSuccessAfterEdit");
editForm.setReportCategoryId("2");
editForm.setIsActive("0");
editForm.setFile(new MockFormFile("newTestShouldSubmitSuccessAfterEdit.rptdesign"));
setActionForm(editForm);
addRequestParameter("method", "editThenUpload");
actionPerform();
ReportsBO newReport = persistence.getReport(report.getReportId());
Assert.assertEquals("newTestShouldSubmitSuccessAfterEdit", newReport.getReportName());
Assert.assertEquals(2, newReport.getReportsCategoryBO().getReportCategoryId().shortValue());
Assert.assertEquals(0, newReport.getIsActive().shortValue());
Assert.assertEquals("newTestShouldSubmitSuccessAfterEdit.rptdesign", newReport.getReportsJasperMap().getReportJasper());
ReportsJasperMap jasper = persistence.getPersistentObject(ReportsJasperMap.class, report.getReportsJasperMap().getReportId());
Assert.assertEquals("newTestShouldSubmitSuccessAfterEdit.rptdesign", jasper.getReportJasper());
removeReport(newReport.getReportId());
}
Aggregations