use of org.mifos.reports.persistence.ReportsPersistence 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.persistence.ReportsPersistence in project head by mifos.
the class ReportsParamsMapAction method loadAddList.
/**
* Loads the Parameter Map AddList page
*/
public ActionForward loadAddList(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In ReportsParamsMapAction:load Method: ");
request.getSession().setAttribute("listOfAllParameters", new ReportsPersistence().getAllReportParams());
ReportsParamsMapActionForm actionForm = (ReportsParamsMapActionForm) form;
String strReportId = request.getParameter("reportId");
if (strReportId == null) {
strReportId = actionForm.getReportId() + "";
}
if (strReportId.equals("")) {
strReportId = "0";
}
int reportId = Integer.parseInt(strReportId);
actionForm.setReportId(reportId);
request.getSession().setAttribute("listOfAllParametersForReportId", reportsPersistence.findParamsOfReportId(reportId));
return mapping.findForward(ReportsConstants.ADDLISTREPORTSPARAMSMAP);
}
use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class ReportsUploadAction method uploadReport.
/**
* Uploads the Report
*/
public ActionForward uploadReport(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In ReportsUploadAction:uploadReport Method: ");
String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
String strreportId = request.getParameter("reportId") == null || request.getParameter("reportId").equals("") ? "0" : request.getParameter("reportId");
int reportId = Integer.parseInt(strreportId);
File reportUploadFile = new File(filename);
String fname = reportUploadFile.getName();
if (fname != null) {
fname = fname.replaceAll(".jrxml", ".jasper");
}
ReportsJasperMap objmap = new ReportsJasperMap();
objmap.setReportId((short) reportId);
objmap.setReportJasper(fname);
reportsPersistence.updateReportsJasperMap(objmap);
request.getSession().setAttribute(ReportsConstants.LISTOFREPORTS, new ReportsPersistence().getAllReportCategories());
return mapping.findForward("administerreports_path");
}
use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.
the class BirtReportsUploadAction method isReportAlreadyExist.
private boolean isReportAlreadyExist(HttpServletRequest request, String reportName, ReportsCategoryBO categoryBO) throws Exception {
for (ReportsBO report : new ReportsPersistence().getAllReports()) {
if (reportName.equals(report.getReportName()) && categoryBO.getReportCategoryId().equals(report.getReportsCategoryBO().getReportCategoryId())) {
ActionErrors errors = new ActionErrors();
errors.add(ReportsConstants.ERROR_REPORTALREADYEXIST, new ActionMessage(ReportsConstants.ERROR_REPORTALREADYEXIST));
request.setAttribute(Globals.ERROR_KEY, errors);
return true;
}
}
return false;
}
use of org.mifos.reports.persistence.ReportsPersistence 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