Search in sources :

Example 1 with ReportsParamQueryDAO

use of org.mifos.reports.business.dao.ReportsParamQueryDAO 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)

Aggregations

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 ReportsUserParamsActionForm (org.mifos.reports.struts.actionforms.ReportsUserParamsActionForm)1