Search in sources :

Example 6 with ReportsJasperMap

use of org.mifos.reports.business.ReportsJasperMap in project head by mifos.

the class AddReportIntegrationTest method testStartFromStandardStore.

@Test
public void testStartFromStandardStore() throws Exception {
    short newId = 17032;
    AddReport upgrade = new AddReport(ReportsCategoryBO.ANALYSIS, "Detailed Aging of Portfolio at Risk", "DetailedAgingPortfolioAtRisk.rptdesign");
    upgrade.upgrade(session.connection());
    ReportsBO fetched = (ReportsBO) session.get(ReportsBO.class, newId);
    Assert.assertEquals(newId, (int) fetched.getReportId());
    Assert.assertEquals(ReportsBO.ACTIVE, fetched.getIsActive());
    Assert.assertEquals(null, fetched.getActivityId());
    Assert.assertEquals("Detailed Aging of Portfolio at Risk", fetched.getReportName());
    Assert.assertEquals("aging_portfolio_at_risk", fetched.getReportIdentifier());
    Assert.assertEquals(ReportsCategoryBO.ANALYSIS, (int) fetched.getReportsCategoryBO().getReportCategoryId());
    ReportsJasperMap map = fetched.getReportsJasperMap();
    Assert.assertEquals("DetailedAgingPortfolioAtRisk.rptdesign", map.getReportJasper());
}
Also used : ReportsJasperMap(org.mifos.reports.business.ReportsJasperMap) ReportsBO(org.mifos.reports.business.ReportsBO) Test(org.junit.Test)

Example 7 with ReportsJasperMap

use of org.mifos.reports.business.ReportsJasperMap in project head by mifos.

the class ReportsPersistenceIntegrationTest method testCreateJasper.

@Test
public void testCreateJasper() throws Exception {
    ReportsJasperMap jasperMap = new ReportsJasperMap(null, "report.jrxml");
    new ReportsPersistence().createJasperMap(session, jasperMap);
    short reportId = jasperMap.getReportId();
    ReportsJasperMap reRead = new ReportsPersistence().oneJasperOfReportId(session, reportId);
    Assert.assertEquals("report.jrxml", reRead.getReportJasper());
}
Also used : ReportsJasperMap(org.mifos.reports.business.ReportsJasperMap) Test(org.junit.Test)

Example 8 with ReportsJasperMap

use of org.mifos.reports.business.ReportsJasperMap in project head by mifos.

the class BirtAdminDocumentUploadActionStrutsTest method testShouldSubmitSucessWhenUploadNewAdminDocument.

@Test
public void testShouldSubmitSucessWhenUploadNewAdminDocument() throws Exception {
    setRequestPathInfo("/birtAdminDocumentUploadAction.do");
    BirtAdminDocumentUploadActionForm form = new BirtAdminDocumentUploadActionForm();
    form.setAdminiDocumentTitle("testShouldSubmitSucessWhenUploadNewAdminDocumentWithAVeryLongNameThatExceedsOneHundredCharactersInLength");
    form.setIsActive("1");
    form.setFile(new MockFormFile("testFileName1.rptdesign"));
    setActionForm(form);
    addRequestParameter("method", "upload");
    actionPerform();
    AdminDocumentBO adminDocument = (AdminDocumentBO) request.getAttribute(Constants.BUSINESS_KEY);
    Assert.assertNotNull(adminDocument);
    ReportsPersistence rp = new ReportsPersistence();
    ReportsJasperMap jasper = rp.getPersistentObject(ReportsJasperMap.class, adminDocument.getAdmindocId());
    Assert.assertNotNull(jasper);
    verifyNoActionErrors();
    verifyForward("create_success");
    removeReport(adminDocument.getAdmindocId());
}
Also used : MockFormFile(org.mifos.reports.business.MockFormFile) ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) BirtAdminDocumentUploadActionForm(org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm) ReportsJasperMap(org.mifos.reports.business.ReportsJasperMap) Test(org.junit.Test)

Example 9 with ReportsJasperMap

use of org.mifos.reports.business.ReportsJasperMap 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;
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsJasperMap(org.mifos.reports.business.ReportsJasperMap) ReportsBO(org.mifos.reports.business.ReportsBO)

Example 10 with ReportsJasperMap

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

Aggregations

ReportsJasperMap (org.mifos.reports.business.ReportsJasperMap)10 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)7 Test (org.junit.Test)5 ReportsBO (org.mifos.reports.business.ReportsBO)5 MockFormFile (org.mifos.reports.business.MockFormFile)3 BirtReportsUploadActionForm (org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)3 File (java.io.File)2 List (java.util.List)2 ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)2 ReportsParamsMap (org.mifos.reports.business.ReportsParamsMap)2 Connection (java.sql.Connection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 FormFile (org.apache.struts.upload.FormFile)1 AbstractBusinessObject (org.mifos.framework.business.AbstractBusinessObject)1 ApplicationException (org.mifos.framework.exceptions.ApplicationException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 SystemException (org.mifos.framework.exceptions.SystemException)1 AdminDocumentBO (org.mifos.reports.admindocuments.business.AdminDocumentBO)1