Search in sources :

Example 21 with ReportsPersistence

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

the class ReportsCategoryAction method addNewCategory.

public ActionForward addNewCategory(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsCategoryAction:addNewCategory Method: ");
    ReportsCategoryActionForm defineNewCategoryForm = (ReportsCategoryActionForm) form;
    String categoryName = defineNewCategoryForm.getCategoryName();
    ReportsCategoryBO reportsCategoryBO = new ReportsCategoryBO();
    int newActivityId;
    try {
        newActivityId = legacyRolesPermissionsDao.calculateDynamicActivityId();
    } catch (ActivityGeneratorException agex) {
        ActionErrors errors = new ActionErrors();
        errors.add(agex.getKey(), new ActionMessage(agex.getKey()));
        request.setAttribute(Globals.ERROR_KEY, errors);
        return mapping.findForward(ActionForwards.preview_failure.toString());
    }
    Short parentActivityId = SecurityConstants.REPORTS_MANAGEMENT;
    legacyRolesPermissionsDao.createActivityForReports(parentActivityId, categoryName);
    reportsCategoryBO.setActivityId((short) newActivityId);
    reportsCategoryBO.setReportCategoryName(categoryName);
    new ReportsPersistence().createOrUpdate(reportsCategoryBO);
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) ActionMessage(org.apache.struts.action.ActionMessage) ActivityGeneratorException(org.mifos.security.activity.ActivityGeneratorException) ActionErrors(org.apache.struts.action.ActionErrors)

Example 22 with ReportsPersistence

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

the class ReportsCategoryAction method confirmDeleteReportsCategory.

public ActionForward confirmDeleteReportsCategory(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) {
    logger.debug("In ReportsCategoryAction:confirmDeleteReportsCategory Method: ");
    ReportsCategoryActionForm reportsCategoryActionForm = (ReportsCategoryActionForm) form;
    ReportsCategoryBO reportsCategoryBO = new ReportsPersistence().getReportCategoryByCategoryId(Short.valueOf(reportsCategoryActionForm.getCategoryId()));
    reportsCategoryActionForm.setCategoryName(reportsCategoryBO.getReportCategoryName());
    if (!isValidToDelete(request, reportsCategoryBO)) {
        return mapping.findForward(ActionForwards.confirm_delete.toString());
    }
    return mapping.findForward(ActionForwards.confirm_delete.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

Example 23 with ReportsPersistence

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

the class ReportsCategoryAction method editThenSubmit.

public ActionForward editThenSubmit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsCategoryAction:editThenSubmit Method: ");
    ReportsCategoryActionForm reportsCategoryActionForm = (ReportsCategoryActionForm) form;
    short reportCategoryId = reportsCategoryActionForm.getCategoryId();
    String inputCategoryName = reportsCategoryActionForm.getCategoryName();
    ReportsCategoryBO reportsCategoryBO = new ReportsPersistence().getReportCategoryByCategoryId(reportCategoryId);
    if (isReportCategoryNameAlreadyExist(request, inputCategoryName)) {
        return mapping.findForward(ActionForwards.editPreview_failure.toString());
    }
    reportsCategoryBO.setReportCategoryName(inputCategoryName);
    ReportsPersistence rPersistence = new ReportsPersistence();
    rPersistence.createOrUpdate(reportsCategoryBO);
    // update cache
    Short activityId = reportsCategoryBO.getActivityId();
    rPersistence.updateLookUpValue(activityId, inputCategoryName);
    legacyRolesPermissionsDao.changeActivityMessage(reportsCategoryBO.getActivityId(), Localization.ENGLISH_LOCALE_ID, reportsCategoryBO.getReportCategoryName());
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

Example 24 with ReportsPersistence

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

the class ReportsCategoryAction method preview.

public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsCategoryAction:preview Method: ");
    ReportsCategoryActionForm defineCategoryForm = (ReportsCategoryActionForm) form;
    String categoryName = defineCategoryForm.getCategoryName();
    request.setAttribute("categoryName", categoryName);
    for (ReportsCategoryBO category : new ReportsPersistence().getAllReportCategories()) {
        if (categoryName.equals(category.getReportCategoryName())) {
            ActionErrors errors = new ActionErrors();
            errors.add(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST, new ActionMessage(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST));
            request.setAttribute(Globals.ERROR_KEY, errors);
            return mapping.findForward(ActionForwards.preview_failure.toString());
        }
    }
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 25 with ReportsPersistence

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

the class ReportsCategoryAction method edit.

public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsCategoryAction:edit Method: ");
    ReportsCategoryActionForm reportsCategoryActionForm = (ReportsCategoryActionForm) form;
    String reportCategoryId = request.getParameter("categoryId");
    ReportsCategoryBO reportCategory = new ReportsPersistence().getReportCategoryByCategoryId(Short.valueOf(reportCategoryId));
    reportsCategoryActionForm.setCategoryName(reportCategory.getReportCategoryName());
    return mapping.findForward(ActionForwards.edit_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

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