use of org.mifos.reports.business.ReportsBO in project head by mifos.
the class PentahoReportsServiceImpl method checkAccessToReport.
@Override
public boolean checkAccessToReport(Integer reportId) {
ReportsBO report = this.reportsPersistence.getReport(reportId.shortValue());
boolean result = false;
if (report != null) {
Short activityID = report.getActivityId();
try {
result = this.rolesPermissionService.hasUserAccessForActivity(activityID);
} catch (Exception ex) {
result = false;
}
}
return result;
}
use of org.mifos.reports.business.ReportsBO in project head by mifos.
the class ReportTemplateDownloadServlet method doGet.
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String realPath = request.getParameter("realPath");
boolean isReportAnAdminDocument = false;
if (StringUtils.isBlank(realPath)) {
realPath = "report";
} else {
isReportAnAdminDocument = true;
}
File dir = new File(ApplicationContextProvider.getBean(ViewOrganizationSettingsServiceFacade.class).getUploadStorageDirectory(), realPath);
String reportFileName = "";
if (isReportAnAdminDocument) {
reportFileName = ((AdminDocumentBO) request.getSession().getAttribute("reportsBO")).getAdminDocumentIdentifier();
} else {
reportFileName = ((ReportsBO) request.getSession().getAttribute("reportsBO")).getReportsJasperMap().getReportJasper();
}
File file = new File(dir, reportFileName);
if (!file.exists()) {
file = new File(new File(getServletContext().getRealPath("/") + realPath), reportFileName);
}
try {
BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
response.setContentType("application/x-msdownload;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=" + reportFileName);
OutputStream os = response.getOutputStream();
byte[] buffer = new byte[4096];
int bytesRead = 0;
while ((bytesRead = is.read(buffer, 0, 4096)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
is.close();
} catch (FileNotFoundException e) {
response.sendRedirect("birtAdminDocumentUploadAction.do?method=getFileNotFoundPage");
}
request.getSession().setAttribute("reportsBO", null);
}
use of org.mifos.reports.business.ReportsBO in project head by mifos.
the class BirtReportsUploadAction method createOrUpdateReport.
private ReportsBO createOrUpdateReport(ReportsCategoryBO category, int newActivityId, String reportTitle, Short isActive, String fileName, Boolean isDW) throws PersistenceException {
ReportsBO reportBO = new ReportsBO();
reportBO.setReportName(reportTitle);
reportBO.setReportsCategoryBO(category);
reportBO.setActivityId((short) newActivityId);
reportBO.setIsActive(isActive);
reportBO.setIsDW(isDW);
ReportsJasperMap reportsJasperMap = reportBO.getReportsJasperMap();
reportsJasperMap.setReportJasper(fileName);
reportBO.setReportsJasperMap(reportsJasperMap);
new ReportsPersistence().createOrUpdate(reportBO);
return reportBO;
}
use of org.mifos.reports.business.ReportsBO 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.business.ReportsBO 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;
}
Aggregations