Package org.opentides.bean.user

Examples of org.opentides.bean.user.UserGroup


  @Override
  protected ModelAndView handleRequestInternal(HttpServletRequest request,
      HttpServletResponse response) throws Exception {   
    Map<String, Object> model = new HashMap<String, Object>();
    Map<String, String> roles = userGroupService.getRoles();
    List<UserGroup> userGroups = userGroupService.findByExample(new UserGroup())
    model.put("roles", roles);
    for (UserGroup userGroup:userGroups)
      userGroup.mapRoleMatrix(roles);
    model.put("userGroups", userGroups);
        return new ModelAndView(viewName, model);
View Full Code Here


   */
  @Override
  protected ModelAndView handleRequestInternal(HttpServletRequest req,
      HttpServletResponse res) throws Exception {
    String userGroupId = req.getParameter("userGroupId");
    UserGroup userGroup = userGroupService.load(userGroupId);
    List<String> roleNames = userGroup.getRoleNames();
    return new ModelAndView(roleListView, "roleNames", roleNames);
  }
View Full Code Here

public class UserGroupDAOTest extends BaseTidesTest {

  private UserGroupDAO userGroupDAO;

  public void testAdd() {
    UserGroup group = new UserGroup();
    group.setName("test");
    group.setDescription("test");
    UserRole role1 = new UserRole(group, "role1");
    group.addRole(role1);

    userGroupDAO.saveEntityModel(group);

    assertNotNull(group.getId());
    UserGroup testGroup = userGroupDAO.loadEntityModel(group.getId());
    Set<UserRole> roles = testGroup.getRoles();
    assertNotNull(roles);
    assertTrue(roles.size() == 1);
    assertTrue(roles.iterator().next().getRole().equals(role1.getRole()));

    testGroup.removeRole(role1);
    userGroupDAO.saveEntityModel(testGroup);

    assertEquals(testGroup.getId(), group.getId());
    UserGroup testGroup2 = userGroupDAO.loadEntityModel(testGroup.getId());
    assertTrue(testGroup2.getRoles().size() == 0);

  }
View Full Code Here

    @Override
    @Before
    protected void onSetUpInTransaction() throws Exception {
        super.onSetUpInTransaction();
        group1 = new UserGroup();
        group1.setId(981L);
        group1.setName("group1");
        group1.setDescription("Group 1");

        group2 = new UserGroup();
        group2.setId(982L);
        group2.setName("group2");
        group2.setDescription("Group 2");
       
        userGroupDAO.saveEntityModel(group1);
View Full Code Here

  public boolean supports(Class clazz) {
    return UserGroup.class.isAssignableFrom(clazz);
  }

  public void validate(Object object, Errors errors) {
    UserGroup userGroup = (UserGroup) object;
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.usergroup.name.required", "User Group Name is required");
    ValidationUtils.rejectIfEmpty(errors, "description", "error.usergroup.description.required", "User Group Description is required");
    if (userGroup.getRoles() == null || userGroup.getRoles().size() < 1){
      errors.reject("error.usergroup.must.have.role", "User Group must have a role");
    }
  }
View Full Code Here

  }

  @Override
  public String getAsText() {
    if (getValue() != null) {
      UserGroup editor = (UserGroup) getValue();
      return editor.getId().toString();
    }
    return "";
  }
View Full Code Here

  }

  @Override
  public void setAsText(String text) throws IllegalArgumentException {
    if (!StringUtil.isEmpty(text)) {
      UserGroup group = userGroupService.load(text);
      setValue(group);
    }
  }
View Full Code Here

      user.setEmailAddress("admin@ideyatech.com");
      user.setFirstName("SuperAdmin");
      user.setLastName("User");

      // create usergroup for user
      UserGroup userGroup = new UserGroup();
      userGroup.setName("Super User");
      userGroup.setDescription("With all roles");

      // Let's super user role
      List<String> roleNames = new ArrayList<String>();
      roleNames.add("SUPER_USER");
      roleNames.add("ACCESS_ALL");
      userGroup.setRoleNames(roleNames);
      userGroupDAO.saveEntityModel(userGroup);

      user.addGroup(userGroup);
      userDAO.saveEntityModel(user);
      _log.info("New installation detected, inserted admin/ideyatech user to database.");
View Full Code Here

  }*/
 
  public void testSetAuthoritiesFromCsvFile() throws Exception {
    String file = this.getClass().getClassLoader().getResource("resources/UserGroup.csv").getPath();
    userGroupService.setAuthoritiesFromCsvFile(file);
    UserGroup userGroup = userGroupService.loadUserGroupByName("MIS");
    Set<UserRole> roles = userGroup.getRoles();
    assertEquals(4, roles.size());
  }
View Full Code Here

  @SuppressWarnings("rawtypes")
  private static final class UserGroupsExtractor implements ResultSetExtractor{
    public Object extractData(ResultSet rs) throws SQLException,
        DataAccessException {
      rs.next();
      UserGroup ug = new UserGroup();
      ug.setDescription(rs.getString("description"));
      ug.setName(rs.getString("name"));
      return ug;
    }
View Full Code Here

TOP

Related Classes of org.opentides.bean.user.UserGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.