use of org.mifos.security.rolesandpermission.util.helpers.RoleTempleteBuilder in project head by mifos.
the class RoleTempleteBuilderIntegrationTest method testGetRolesTemplete.
@Test
public void testGetRolesTemplete() throws Exception {
List<ActivityEntity> activities = new RolesPermissionsBusinessService().getActivities();
StringBuilder stringBuilder = new RoleTempleteBuilder().getRolesTemplete(activities);
Assert.assertNotNull(stringBuilder);
Assert.assertTrue(stringBuilder.toString().contains("Can create new role"));
Assert.assertTrue(stringBuilder.toString().contains("Can modify a role"));
Assert.assertTrue(stringBuilder.toString().contains("Can delete a role"));
}
use of org.mifos.security.rolesandpermission.util.helpers.RoleTempleteBuilder in project head by mifos.
the class RoleTempleteBuilderIntegrationTest method testSetCurrentActivites.
@Test
public void testSetCurrentActivites() {
Set<Short> activities = new HashSet<Short>();
activities.add(Short.valueOf("1"));
RoleTempleteBuilder roleTempleteBuilder = new RoleTempleteBuilder();
roleTempleteBuilder.setCurrentActivites(activities);
activities = roleTempleteBuilder.getCurrentActivites();
Assert.assertEquals(1, activities.size());
}
use of org.mifos.security.rolesandpermission.util.helpers.RoleTempleteBuilder in project head by mifos.
the class RoleTempleteBuilderIntegrationTest method testLocaleId.
@Test
public void testLocaleId() {
RoleTempleteBuilder roleTempleteBuilder = new RoleTempleteBuilder();
roleTempleteBuilder.setLocaleId(Short.valueOf("1"));
Assert.assertEquals(Short.valueOf("1"), roleTempleteBuilder.getLocaleId());
}
use of org.mifos.security.rolesandpermission.util.helpers.RoleTempleteBuilder 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;
}
Aggregations