Search in sources :

Example 1 with ReportsUserParamsActionForm

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

the class ReportsUserParamsAction method loadAddList.

/**
     * Loads the Parameter Add page
     */
@SuppressWarnings("unchecked")
public ActionForward loadAddList(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsUserParamsAction:load Method: ");
    request.getSession().setAttribute("listOfAllParameters", new ReportsPersistence().getAllReportParams());
    ReportsParamQueryDAO paramDAO = new ReportsParamQueryDAO();
    ReportsUserParamsActionForm actionForm = (ReportsUserParamsActionForm) form;
    String strReportId = request.getParameter("reportId");
    if (strReportId == null) {
        strReportId = actionForm.getReportId() + "";
    }
    if (strReportId.equals("")) {
        strReportId = "0";
    }
    int reportId = Integer.parseInt(strReportId);
    String reportName = reportsPersistence.getReport((short) reportId).getReportName();
    List<ReportsJasperMap> reports = reportsPersistence.findJasperOfReportId(reportId);
    if (reports.size() > 0) {
        ReportsJasperMap reportFile = reports.get(0);
        String filename = reportFile.getReportJasper();
        File file = new File(BirtReportsUploadAction.getCustomReportStorageDirectory(), filename);
        if (file.exists()) {
            filename = file.getAbsolutePath();
        } else {
            filename = "report/" + filename;
        }
        if (filename.endsWith(".rptdesign")) {
            request.setAttribute("reportFile", filename);
            request.setAttribute("reportName", reportName);
            return mapping.findForward(ReportsConstants.BIRTREPORTPATH);
        }
    }
    actionForm.setReportId(reportId);
    request.getSession().setAttribute("listOfAllParametersForReportId", reportsPersistence.findParamsOfReportId(reportId));
    request.getSession().setAttribute("listOfReportJasper", reportsPersistence.findJasperOfReportId(reportId));
    List<ReportsParamsMap> reportParams = (List) request.getSession().getAttribute("listOfAllParametersForReportId");
    Object[] obj = reportParams.toArray();
    if (obj != null && obj.length > 0) {
        for (int i = 0; i < obj.length; i++) {
            ReportsParamsMap rp = (ReportsParamsMap) obj[i];
            if (rp.getReportsParams().getType().equalsIgnoreCase("Query")) {
                request.getSession().setAttribute("para" + (i + 1), paramDAO.listValuesOfParameters(rp.getReportsParams()));
            }
        }
    }
    return mapping.findForward(ReportsConstants.ADDLISTREPORTSUSERPARAMS);
}
Also used : ReportsParamsMap(org.mifos.reports.business.ReportsParamsMap) ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsParamQueryDAO(org.mifos.reports.business.dao.ReportsParamQueryDAO) ReportsUserParamsActionForm(org.mifos.reports.struts.actionforms.ReportsUserParamsActionForm) ReportsJasperMap(org.mifos.reports.business.ReportsJasperMap) List(java.util.List) File(java.io.File)

Example 2 with ReportsUserParamsActionForm

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

the class ReportsUserParamsAction method processReport.

/**
     * Generate report in given export format
     */
public ActionForward processReport(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsUserParamsAction:processReport Method: ");
    ReportsUserParamsActionForm actionForm = (ReportsUserParamsActionForm) form;
    int reportId = actionForm.getReportId();
    String applPath = actionForm.getApplPath();
    String expType = actionForm.getExpFormat();
    String expFilename = reportsBusinessService.runReport(reportId, request, applPath, expType);
    request.getSession().setAttribute("expFileName", expFilename);
    actionForm.setExpFileName(expFilename);
    String forward = "";
    String error = (String) request.getSession().getAttribute("paramerror");
    if (error == null || error.equals("")) {
        forward = ReportsConstants.PROCESSREPORTSUSERPARAMS;
    } else {
        forward = ReportsConstants.ADDLISTREPORTSUSERPARAMS;
    }
    return mapping.findForward(forward);
}
Also used : ReportsUserParamsActionForm(org.mifos.reports.struts.actionforms.ReportsUserParamsActionForm)

Aggregations

ReportsUserParamsActionForm (org.mifos.reports.struts.actionforms.ReportsUserParamsActionForm)2 File (java.io.File)1 List (java.util.List)1 ReportsJasperMap (org.mifos.reports.business.ReportsJasperMap)1 ReportsParamsMap (org.mifos.reports.business.ReportsParamsMap)1 ReportsParamQueryDAO (org.mifos.reports.business.dao.ReportsParamQueryDAO)1 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)1