Search in sources :

Example 11 with ReportsCategoryBO

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

the class BirtReportsUploadAction method editprevious.

public ActionForward editprevious(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);
    return mapping.findForward(ActionForwards.editprevious_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)

Example 12 with ReportsCategoryBO

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

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

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

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

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