Search in sources :

Example 16 with ReportsPersistence

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());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm) ActionMessage(org.apache.struts.action.ActionMessage) ActivityGeneratorException(org.mifos.security.activity.ActivityGeneratorException) ActionErrors(org.apache.struts.action.ActionErrors) FormFile(org.apache.struts.upload.FormFile) ReportsBO(org.mifos.reports.business.ReportsBO)

Example 17 with ReportsPersistence

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);
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsParamsMapActionForm(org.mifos.reports.struts.actionforms.ReportsParamsMapActionForm)

Example 18 with ReportsPersistence

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");
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsJasperMap(org.mifos.reports.business.ReportsJasperMap) File(java.io.File)

Example 19 with ReportsPersistence

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;
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors) ReportsBO(org.mifos.reports.business.ReportsBO)

Example 20 with ReportsPersistence

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());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)

Aggregations

ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)29 ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)16 ReportsBO (org.mifos.reports.business.ReportsBO)10 BirtReportsUploadActionForm (org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)9 ReportsJasperMap (org.mifos.reports.business.ReportsJasperMap)7 ReportsCategoryActionForm (org.mifos.reports.struts.actionforms.ReportsCategoryActionForm)7 ActionErrors (org.apache.struts.action.ActionErrors)5 ActionMessage (org.apache.struts.action.ActionMessage)5 File (java.io.File)3 Test (org.junit.Test)3 MockFormFile (org.mifos.reports.business.MockFormFile)3 FormFile (org.apache.struts.upload.FormFile)2 ActivityGeneratorException (org.mifos.security.activity.ActivityGeneratorException)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 ReportCategoryDto (org.mifos.dto.domain.ReportCategoryDto)1 AbstractBusinessObject (org.mifos.framework.business.AbstractBusinessObject)1 ApplicationException (org.mifos.framework.exceptions.ApplicationException)1