use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class RolesPermissionsAction method getActivities.
private List<ActivityEntity> getActivities(List<ActivityEntity> activityList, Map<String, String> activities) {
List<ActivityEntity> newActivityList = new ArrayList<ActivityEntity>();
List<Short> ids = new ArrayList<Short>();
Set<String> keys = activities.keySet();
for (String string : keys) {
/*
* We need to collect the id's of all the checked activities when we
* created the ui. We have given unique name to leaf activities and
* "chekbox" to non leaf activities .Now we are trying to get the
* id's of checked leafs only
*/
if (!activities.get(string).equalsIgnoreCase("checkbox") && !activities.get(string).equalsIgnoreCase("")) {
Short activityId = Short.parseShort(activities.get(string));
ids.add(activityId);
}
}
for (ActivityEntity activityEntity : activityList) {
if (ids.contains(activityEntity.getId())) {
newActivityList.add(activityEntity);
}
}
return newActivityList;
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class ActivityTag method getActivities.
List<ActivityEntity> getActivities(List<ActivityEntity> activityList, Map<String, String> activities) {
List<ActivityEntity> newActivityList = new ArrayList<ActivityEntity>();
List<Short> ids = new ArrayList<Short>();
Set<String> keys = activities.keySet();
for (String string : keys) {
/*
* We need to collect the id's of all the checked activities when we
* created the ui. We have given unique name to leaf activities and
* "chekbox" to non leaf activities .Now we are trying to get the
* id's of checked leafs only
*/
if (!activities.get(string).equalsIgnoreCase("checkbox") && !activities.get(string).equalsIgnoreCase("")) {
Short activityId = Short.parseShort(activities.get(string));
ids.add(activityId);
}
}
for (ActivityEntity activityEntity : activityList) {
if (ids.contains(activityEntity.getId())) {
newActivityList.add(activityEntity);
}
}
return newActivityList;
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class ActivityTag method doEndTag.
@SuppressWarnings("unchecked")
@Override
public int doEndTag() throws JspException {
RoleTempleteBuilder builder = new RoleTempleteBuilder();
List<ActivityEntity> activities;
try {
activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, (HttpServletRequest) pageContext.getRequest());
activities = filterActivities(activities);
RoleBO role = (RoleBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, (HttpServletRequest) pageContext.getRequest());
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) pageContext.getSession().getAttribute("rolesPermissionsActionForm");
if (rolesPermissionsActionForm != null && rolesPermissionsActionForm.getActivities().size() > 0) {
List<ActivityEntity> flitered = filterActivities(getActivities(activities, rolesPermissionsActionForm.getActivities()));
Set<Short> activitySet = convertToIdSet(flitered);
builder.setCurrentActivites(activitySet);
} else if (role != null) {
List<ActivityEntity> flitered = filterActivities(new ArrayList<ActivityEntity>(role.getActivities()));
Set<Short> activitySet = convertToIdSet(flitered);
builder.setCurrentActivites(activitySet);
}
Map<Short, ActivityRestrictionDto> activityRestrictionDtoMap = rolesPermissionsActionForm.getActivityRestrictionDtoMap();
if (activityRestrictionDtoMap == null) {
activityRestrictionDtoMap = new HashMap<Short, ActivityRestrictionDto>();
}
builder.setActivityRestrictionDtoMap(activityRestrictionDtoMap);
SessionUtils.getAttribute(Constants.BUSINESS_KEY, (HttpServletRequest) pageContext.getRequest());
StringBuilder sb = builder.getRolesTemplete(activities);
pageContext.getOut().print(sb.toString());
} catch (IOException e) {
throw new JspException(e);
} catch (PageExpiredException e1) {
throw new JspException(e1);
}
return EVAL_PAGE;
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class LegacyRolesPermissionsDao method updateLookUpValue.
public void updateLookUpValue(Short activityId, String inputCategoryName) {
ActivityEntity activityEntity = null;
try {
activityEntity = getPersistentObject(ActivityEntity.class, activityId);
} catch (Exception ex) {
throw new RuntimeException(ex.getMessage());
}
if (activityEntity != null) {
LookUpValueEntity lookUpValueEntity = activityEntity.getDescriptionLookupValues();
ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValue(lookUpValueEntity, inputCategoryName);
}
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class LegacyRolesPermissionsDao method createActivityEntity.
private ActivityEntity createActivityEntity(short parentActivity, int lookUpId) throws ServiceException, ActivityGeneratorException, PersistenceException {
ActivityEntity parentActivityEntity;
if (parentActivity != 0) {
parentActivityEntity = getPersistentObject(ActivityEntity.class, parentActivity);
} else {
parentActivityEntity = null;
}
LookUpValueEntity lookupValueEntity = getPersistentObject(LookUpValueEntity.class, lookUpId);
ActivityEntity activityEntity = new ActivityEntity((short) calculateDynamicActivityId(), parentActivityEntity, lookupValueEntity);
createOrUpdate(activityEntity);
return activityEntity;
}
Aggregations