Search in sources :

Example 1 with ReportsCategoryBO

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

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

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

the class BirtReportsUploadAction method editThenUpload.

public ActionForward editThenUpload(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()));
    ReportsBO reportBO = rp.getReport(Short.valueOf(uploadForm.getReportId()));
    ReportsJasperMap reportJasperMap = reportBO.getReportsJasperMap();
    if (!isReportItsSelf(uploadForm, reportBO) && isReportAlreadyExist(request, uploadForm.getReportTitle(), category)) {
        return mapping.findForward(ActionForwards.editpreview_failure.toString());
    } else if (isReportActivityIdNull(request, reportBO)) {
        return mapping.findForward(ActionForwards.create_failure.toString());
    }
    reportBO.setReportName(uploadForm.getReportTitle());
    reportBO.setIsActive(Short.valueOf(uploadForm.getIsActive()));
    reportBO.setReportsCategoryBO(category);
    rp.createOrUpdate(reportBO);
    // kim
    String activityNameHead = "Can view ";
    rp.updateLookUpValue(reportBO.getActivityId(), activityNameHead + uploadForm.getReportTitle());
    legacyRolesPermissionsDao.reparentActivityUsingHibernate(reportBO.getActivityId(), category.getActivityId());
    legacyRolesPermissionsDao.changeActivityMessage(reportBO.getActivityId(), Localization.ENGLISH_LOCALE_ID, "Can view " + reportBO.getReportName());
    FormFile formFile = uploadForm.getFile();
    if (StringUtils.isEmpty(formFile.getFileName())) {
        formFile.destroy();
    } else {
        reportJasperMap.setReportJasper(formFile.getFileName());
        rp.createOrUpdate(reportJasperMap);
        uploadFile(formFile);
    }
    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) ReportsJasperMap(org.mifos.reports.business.ReportsJasperMap) ReportsBO(org.mifos.reports.business.ReportsBO) FormFile(org.apache.struts.upload.FormFile)

Example 4 with ReportsCategoryBO

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

the class ReportsCategoryAction method editPreview.

public ActionForward editPreview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsCategoryAction:editPreview Method: ");
    ReportsCategoryActionForm defineCategoryForm = (ReportsCategoryActionForm) form;
    String inputCategoryName = defineCategoryForm.getCategoryName();
    short reportCategoryId = defineCategoryForm.getCategoryId();
    ReportsCategoryBO reportCategory = new ReportsPersistence().getReportCategoryByCategoryId(reportCategoryId);
    if (isReportCategoryNameNotEdit(request, inputCategoryName, reportCategory)) {
        return mapping.findForward(ActionForwards.editPreview_failure.toString());
    } else if (isReportCategoryNameAlreadyExist(request, inputCategoryName)) {
        return mapping.findForward(ActionForwards.editPreview_failure.toString());
    }
    return mapping.findForward(ActionForwards.editpreview_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

Example 5 with ReportsCategoryBO

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

the class ReportsCategoryAction method isReportCategoryNameAlreadyExist.

private boolean isReportCategoryNameAlreadyExist(HttpServletRequest request, String inputCategoryName) {
    for (ReportsCategoryBO category : new ReportsPersistence().getAllReportCategories()) {
        if (category.getReportCategoryName().equals(inputCategoryName)) {
            ActionErrors errors = new ActionErrors();
            errors.add(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST, new ActionMessage(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST));
            request.setAttribute(Globals.ERROR_KEY, errors);
            return true;
        }
    }
    return false;
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Aggregations

ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)20 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)15 ReportsCategoryActionForm (org.mifos.reports.struts.actionforms.ReportsCategoryActionForm)7 ReportsBO (org.mifos.reports.business.ReportsBO)5 BirtReportsUploadActionForm (org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)5 ActionErrors (org.apache.struts.action.ActionErrors)4 ActionMessage (org.apache.struts.action.ActionMessage)4 Test (org.junit.Test)4 FormFile (org.apache.struts.upload.FormFile)2 ActivityGeneratorException (org.mifos.security.activity.ActivityGeneratorException)2 ArrayList (java.util.ArrayList)1 Query (org.hibernate.Query)1 Session (org.hibernate.Session)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 ReportCategoryDto (org.mifos.dto.domain.ReportCategoryDto)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 ReportsJasperMap (org.mifos.reports.business.ReportsJasperMap)1