use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class LegacyRolesPermissionsDao method isActivityAllowed.
public boolean isActivityAllowed(UserContext userContext, ActivityContext activityContext) {
try {
ActivityEntity activity = getActivityById(activityContext.getActivityId());
if (activity == null) {
return false;
}
Set<Short> activityAllowedRoles = activity.getRoleIds();
if (activityAllowedRoles == null) {
return false;
}
Set<Short> userRoles = userContext.getRoles();
activityAllowedRoles.retainAll(userRoles);
if (activityAllowedRoles.isEmpty()) {
return false;
}
HierarchyManager.BranchLocation where = HierarchyManager.getInstance().compareOfficeInHierarchy(userContext, activityContext.getRecordOfficeId());
return checkAccessByHierarchy(activityContext.getRecordLoanOfficer(), where, userContext.getLevel(), userContext.getId());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class LegacyRolesPermissionsDao method getActivitieIds.
public List<Short> getActivitieIds() throws PersistenceException {
try {
Query query = getSession().getNamedQuery(NamedQueryConstants.GET_ALL_ACTIVITIES);
List<ActivityEntity> activities = query.list();
List<Short> activityIds = new ArrayList();
for (ActivityEntity activity : activities) {
activityIds.add(activity.getId());
}
return activityIds;
} catch (Exception e) {
throw new PersistenceException(e);
}
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class LegacyRolesPermissionsDao method changeActivityMessage.
public void changeActivityMessage(short activityId, short localeId, String newMessage) throws PersistenceException {
ActivityEntity activityEntity = getPersistentObject(ActivityEntity.class, Short.valueOf(activityId));
Integer lookUpId = activityEntity.getActivityNameLookupValues().getLookUpId();
LookUpValueLocaleEntity lookUpValueLocaleEntity = legacyMasterDao.retrieveOneLookUpValueLocaleEntity(localeId, lookUpId);
lookUpValueLocaleEntity.setLookUpValue(newMessage);
createOrUpdate(lookUpValueLocaleEntity);
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class LegacyRolesPermissionsDao method createActivityForQuestionGroup.
public int createActivityForQuestionGroup(short parentActivity, String lookUpDescription) throws HibernateException, PersistenceException, ServiceException, ActivityGeneratorException {
StaticHibernateUtil.startTransaction();
int lookUpId = createLookUpValue(DynamicLookUpValueCreationTypes.QuestionGroup, 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 reparentActivityUsingHibernate.
public void reparentActivityUsingHibernate(short activityId, Short newParent) throws PersistenceException {
ActivityEntity parent = getPersistentObject(ActivityEntity.class, newParent);
ActivityEntity activity = getPersistentObject(ActivityEntity.class, activityId);
activity.setParent(parent);
createOrUpdate(activity);
}
Aggregations