Search in sources :

Example 11 with ReportsPersistence

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

the class BirtReportsUploadActionStrutsTest method testShouldSubmitSucessWhenUploadNewReport.

@Test
public void testShouldSubmitSucessWhenUploadNewReport() throws Exception {
    setRequestPathInfo("/birtReportsUploadAction.do");
    BirtReportsUploadActionForm form = new BirtReportsUploadActionForm();
    form.setReportTitle("testShouldSubmitSucessWhenUploadNewReport");
    form.setReportCategoryId("1");
    form.setIsActive("1");
    form.setFile(new MockFormFile("testFileName1.rptdesign"));
    setActionForm(form);
    addRequestParameter("method", "upload");
    actionPerform();
    ReportsBO report = (ReportsBO) request.getAttribute("report");
    Assert.assertNotNull(report);
    ReportsPersistence rp = new ReportsPersistence();
    ReportsJasperMap jasper = rp.getPersistentObject(ReportsJasperMap.class, report.getReportsJasperMap().getReportId());
    Assert.assertNotNull(jasper);
    verifyNoActionErrors();
    verifyForward("create_success");
    removeReport(report.getReportId());
}
Also used : MockFormFile(org.mifos.reports.business.MockFormFile) ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm) ReportsJasperMap(org.mifos.reports.business.ReportsJasperMap) ReportsBO(org.mifos.reports.business.ReportsBO) Test(org.junit.Test)

Example 12 with ReportsPersistence

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

the class AdminServiceFacadeWebTier method createReportsCategory.

@Override
public void createReportsCategory(ReportCategoryDto reportCategory) {
    ReportsCategoryBO newReportCategory = new ReportsCategoryBO();
    newReportCategory.setReportCategoryName(reportCategory.getName());
    try {
        new ReportsPersistence().createOrUpdate(newReportCategory);
        StaticHibernateUtil.commitTransaction();
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) BusinessRuleException(org.mifos.service.BusinessRuleException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ServiceException(org.mifos.framework.exceptions.ServiceException)

Example 13 with ReportsPersistence

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

the class BirtReportsUploadAction method preview.

public ActionForward preview(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);
    if (isReportAlreadyExist(request, uploadForm.getReportTitle(), category)) {
        return mapping.findForward(ActionForwards.preview_failure.toString());
    }
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)

Example 14 with ReportsPersistence

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

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

the class BirtReportsUploadAction method getBirtReportsUploadPage.

public ActionForward getBirtReportsUploadPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsAction:getBirtReportPage Method: ");
    StaticHibernateUtil.flushAndCloseSession();
    BirtReportsUploadActionForm uploadForm = (BirtReportsUploadActionForm) form;
    uploadForm.clear();
    request.getSession().setAttribute(ReportsConstants.LISTOFREPORTS, new ReportsPersistence().getAllReportCategories());
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) 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