Search in sources :

Example 1 with ReportsPersistence

use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveReportCategories.

@Override
public List<ReportCategoryDto> retrieveReportCategories() {
    List<ReportCategoryDto> reportCategories = new ArrayList<ReportCategoryDto>();
    List<ReportsCategoryBO> allCategories = new ReportsPersistence().getAllReportCategories();
    for (ReportsCategoryBO category : allCategories) {
        reportCategories.add(category.toDto());
    }
    return reportCategories;
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportCategoryDto(org.mifos.dto.domain.ReportCategoryDto) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) ArrayList(java.util.ArrayList)

Example 2 with ReportsPersistence

use of org.mifos.reports.persistence.ReportsPersistence 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 3 with ReportsPersistence

use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.

the class ReportsUserParamsAction method loadAdminReport.

/**
     * To allow loading Administrative documents
     */
public ActionForward loadAdminReport(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    request.getSession().setAttribute("listOfAllParameters", new ReportsPersistence().getAllReportParams());
    String strReportId = request.getParameter("admindocId");
    String account_id = request.getParameter("globalAccountNum");
    if (strReportId == null || strReportId.equals("")) {
        strReportId = "0";
    }
    int reportId = Integer.parseInt(strReportId);
    String reportName = legacyAdminDocumentDao.getAdminDocumentById((short) reportId).getAdminDocumentName();
    String filename = legacyAdminDocumentDao.getAdminDocumentById((short) reportId).getAdminDocumentIdentifier();
    File file = new File(viewOrganizationSettingsServiceFacade.getAdminDocumentStorageDirectory(), filename);
    if (file.exists()) {
        filename = file.getAbsolutePath();
    } else {
        filename = "adminReport/" + filename;
    }
    if (filename.endsWith(".rptdesign")) {
        request.setAttribute("reportFile", filename);
        request.setAttribute("reportName", reportName);
        request.setAttribute("account_id", account_id);
        return mapping.findForward(ReportsConstants.ADMINDOCBIRTREPORTPATH);
    }
    return mapping.findForward(ReportsConstants.ADMINDOCBIRTREPORTPATH);
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) File(java.io.File)

Example 4 with ReportsPersistence

use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.

the class BirtReportsUploadAction method editpreview.

public ActionForward editpreview(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);
    ReportsBO report = new ReportsPersistence().getReport(Short.valueOf(uploadForm.getReportId()));
    if (isReportInfoNotEdit(request, uploadForm, report)) {
        return mapping.findForward(ActionForwards.editpreview_failure.toString());
    } else if (!isReportItsSelf(uploadForm, report) && isReportAlreadyExist(request, uploadForm.getReportTitle(), category)) {
        return mapping.findForward(ActionForwards.editpreview_failure.toString());
    }
    return mapping.findForward(ActionForwards.editpreview_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm) ReportsBO(org.mifos.reports.business.ReportsBO)

Example 5 with ReportsPersistence

use of org.mifos.reports.persistence.ReportsPersistence in project head by mifos.

the class BirtReportsUploadAction method edit.

public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    BirtReportsUploadActionForm birtReportsUploadActionForm = (BirtReportsUploadActionForm) form;
    ReportsBO report = new ReportsPersistence().getReport(Short.valueOf(request.getParameter("reportId")));
    request.setAttribute(Constants.BUSINESS_KEY, report);
    birtReportsUploadActionForm.setReportTitle(report.getReportName());
    birtReportsUploadActionForm.setReportCategoryId(report.getReportsCategoryBO().getReportCategoryId().toString());
    birtReportsUploadActionForm.setIsActive(report.getIsActive().toString());
    request.getSession().setAttribute(ReportsConstants.LISTOFREPORTS, new ReportsPersistence().getAllReportCategories());
    return mapping.findForward(ActionForwards.edit_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm) ReportsBO(org.mifos.reports.business.ReportsBO)

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