use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class RolesPermissionServiceFacadeWebTier method deleteRole.
@Override
public void deleteRole(Integer versionNo, Short roleId) throws Exception {
RolesPermissionsBusinessService rolesPermissionsBusinessService = new RolesPermissionsBusinessService();
RoleBO role = rolesPermissionsBusinessService.getRole(roleId);
role.setVersionNo(versionNo);
validateIfRoleAssignedToPersonnel(role);
try {
StaticHibernateUtil.startTransaction();
legacyRolesPermissionsDao.delete(role);
StaticHibernateUtil.flushSession();
for (ActivityEntity ae : legacyRolesPermissionsDao.getActivities()) {
StaticHibernateUtil.getSessionTL().refresh(ae);
}
StaticHibernateUtil.commitTransaction();
} catch (PersistenceException e) {
StaticHibernateUtil.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
StaticHibernateUtil.closeSession();
}
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class LegacyRolesPermissionsDao method retrieveOneActivityEntity.
public ActivityEntity retrieveOneActivityEntity(int lookUpId) throws PersistenceException {
Map<String, Object> queryParameters = new HashMap<String, Object>();
LookUpValueEntity aLookUpValueEntity = getPersistentObject(LookUpValueEntity.class, lookUpId);
queryParameters.put("aLookUpValueEntity", aLookUpValueEntity);
Object obj = execUniqueResultNamedQuery(NamedQueryConstants.GETACTIVITYENTITY, queryParameters);
if (null != obj) {
return (ActivityEntity) obj;
}
return null;
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class LegacyRolesPermissionsDao method createActivityForReports.
public int createActivityForReports(short parentActivity, String lookUpDescription) throws HibernateException, PersistenceException, ServiceException, ActivityGeneratorException {
StaticHibernateUtil.startTransaction();
int lookUpId = createLookUpValue(DynamicLookUpValueCreationTypes.BirtReport, lookUpDescription);
insertLookUpValueLocale(lookUpId, lookUpDescription);
ActivityEntity activityEntity = createActivityEntity(parentActivity, lookUpId);
RoleBO role = getPersistentObject(RoleBO.class, RolesAndPermissionConstants.ADMIN_ROLE);
role.getActivities().add(activityEntity);
StaticHibernateUtil.commitTransaction();
return lookUpId;
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity 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;
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class RolesPermissionsAction method update.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
List<ActivityEntity> activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, request);
rolesPermissionServiceFacade.updateRole(Short.parseShort(rolesPermissionsActionForm.getId()), userContext.getId(), rolesPermissionsActionForm.getName(), getActivityIds(getActivities(activities, rolesPermissionsActionForm.getActivities())), rolesPermissionsActionForm.getActivityRestrictionDtoToPersistList());
// MIFOS-3530: update all currently logged users
for (String loggedUser : getLoggedUsers(request)) {
this.authenticationAuthorizationServiceFacade.reloadUserDetailsForSecurityContext(loggedUser);
}
return mapping.findForward(ActionForwards.update_success.toString());
}
Aggregations