Search in sources :

Example 1 with ActivityGeneratorException

use of org.mifos.security.activity.ActivityGeneratorException in project head by mifos.

the class LegacyRolesPermissionsDao method calculateDynamicActivityId.

public int calculateDynamicActivityId() throws ServiceException, ActivityGeneratorException {
    int activityId = 0;
    for (ActivityEntity activity : new RolesPermissionsBusinessService().getActivities()) {
        if (activity.getId().intValue() < activityId) {
            activityId = activity.getId();
        }
    }
    if (activityId <= Short.MIN_VALUE) {
        throw new ActivityGeneratorException();
    }
    int newActivityId = activityId - 1;
    return newActivityId;
}
Also used : RolesPermissionsBusinessService(org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService) ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) ActivityGeneratorException(org.mifos.security.activity.ActivityGeneratorException)

Example 2 with ActivityGeneratorException

use of org.mifos.security.activity.ActivityGeneratorException in project head by mifos.

the class BirtReportsUploadAction method upload.

public ActionForward upload(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()));
    if (isReportAlreadyExist(request, uploadForm.getReportTitle(), category)) {
        return mapping.findForward(ActionForwards.preview_failure.toString());
    }
    short parentActivity = category.getActivityId();
    int newActivityId;
    String activityNameHead = "Can view ";
    try {
        newActivityId = legacyRolesPermissionsDao.calculateDynamicActivityId();
        legacyRolesPermissionsDao.createActivityForReports(parentActivity, activityNameHead + uploadForm.getReportTitle());
    } catch (ActivityGeneratorException ex) {
        ActionErrors errors = new ActionErrors();
        errors.add(ex.getKey(), new ActionMessage(ex.getKey()));
        request.setAttribute(Globals.ERROR_KEY, errors);
        return mapping.findForward(ActionForwards.preview_failure.toString());
    }
    FormFile formFile = uploadForm.getFile();
    uploadFile(formFile);
    ReportsBO reportBO = createOrUpdateReport(category, newActivityId, uploadForm.getReportTitle(), Short.valueOf(uploadForm.getIsActive()), formFile.getFileName(), uploadForm.getIsDW());
    allowActivityPermission(reportBO, newActivityId);
    request.setAttribute("report", reportBO);
    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) ActionMessage(org.apache.struts.action.ActionMessage) ActivityGeneratorException(org.mifos.security.activity.ActivityGeneratorException) ActionErrors(org.apache.struts.action.ActionErrors) FormFile(org.apache.struts.upload.FormFile) ReportsBO(org.mifos.reports.business.ReportsBO)

Example 3 with ActivityGeneratorException

use of org.mifos.security.activity.ActivityGeneratorException 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)

Aggregations

ActivityGeneratorException (org.mifos.security.activity.ActivityGeneratorException)3 ActionErrors (org.apache.struts.action.ActionErrors)2 ActionMessage (org.apache.struts.action.ActionMessage)2 ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)2 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)2 FormFile (org.apache.struts.upload.FormFile)1 ReportsBO (org.mifos.reports.business.ReportsBO)1 BirtReportsUploadActionForm (org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)1 ReportsCategoryActionForm (org.mifos.reports.struts.actionforms.ReportsCategoryActionForm)1 ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)1 RolesPermissionsBusinessService (org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService)1