Package org.vosao.entity

Examples of org.vosao.entity.GroupEntity


  }

  private void initGroups() {
    guests = getDao().getGroupDao().getByName("guests");
    if (guests == null) {
      guests = new GroupEntity("guests");
      getDao().getGroupDao().save(guests);
    }
  }
View Full Code Here


        groupTool = new GroupTool(getDao());
        userTool = new UserTool(getDao());
  }   
 
  public void testSelectByGroup() {
    GroupEntity group1 = groupTool.addGroup("group1");
    GroupEntity group2 = groupTool.addGroup("group2");
    groupTool.addUserGroup(group1.getId(),
        userTool.addUser("roma", UserRole.USER).getId());
    groupTool.addUserGroup(group1.getId(),
        userTool.addUser("sasha", UserRole.USER).getId());
    groupTool.addUserGroup(group2.getId(),
        userTool.addUser("alex1", UserRole.USER).getId());
    groupTool.addUserGroup(group2.getId(),
        userTool.addUser("alex2", UserRole.USER).getId());
    groupTool.addUserGroup(group2.getId(),
        userTool.addUser("alex3", UserRole.USER).getId());
  }
View Full Code Here

    for (Iterator<Element> i = permissionsElement.elementIterator();
        i.hasNext(); ) {
            Element element = i.next();
            if (element.getName().equals("permission")) {
              String groupName = element.elementText("group");
              GroupEntity group = getDao().getGroupDao().getByName(groupName);
              if (group == null) {
                logger.error("Group " + groupName + " was not found.");
                continue;
              }
              FolderPermissionType permType = FolderPermissionType.valueOf(
View Full Code Here

  public GroupTool(Dao aDao) {
    dao = aDao;
  }
 
  public GroupEntity addGroup(String name) {
    return dao.getGroupDao().save(new GroupEntity(name));
  }
View Full Code Here

    return doc.asXML();
  }

  private void createFolderPermissionXML(Element permissionsElement,
      final FolderPermissionEntity permission) {
    GroupEntity group = getDao().getGroupDao().getById(
        permission.getGroupId());
    Element permissionElement = permissionsElement.addElement("permission");
    permissionElement.addElement("group").setText(group.getName());
    permissionElement.addElement("permissionType").setText(
        permission.getPermission().name());
  }
View Full Code Here

    readFolderPermissions(root.element("permissions"), folder);
  }

  private void readFolderPermissions(Element element, FolderEntity folder) {
    for (Element permElement : (List<Element>)element.elements("permission")) {
      GroupEntity group = getDao().getGroupDao().getByName(
        permElement.elementText("group"));
      FolderPermissionType permission = FolderPermissionType.valueOf(
        permElement.elementText("permissionType"));
      getBusiness().getFolderPermissionBusiness().setPermission(
          folder, group, permission);
View Full Code Here

    List<UserEntity> users2 = getDao().getUserDao().getByRole(UserRole.USER);
    assertEquals(1, users2.size());
 
 
  public void testSelectByGroup() {
    GroupEntity group1 = groupTool.addGroup("group1");
    GroupEntity group2 = groupTool.addGroup("group2");
    UserEntity user1 = userTool.addUser("roma", UserRole.USER);
    groupTool.addUserGroup(group1.getId(), user1.getId());
    groupTool.addUserGroup(group1.getId(),
        userTool.addUser("sasha", UserRole.USER).getId());
    groupTool.addUserGroup(group2.getId(),
        userTool.addUser("alex1", UserRole.USER).getId());
    groupTool.addUserGroup(group2.getId(),
        userTool.addUser("alex2", UserRole.USER).getId());
    groupTool.addUserGroup(group2.getId(),
        userTool.addUser("alex3", UserRole.USER).getId());
    List<UserEntity> list = getDao().getUserDao().selectByGroup(
        group1.getId());
    assertEquals(2, list.size());
    assertEquals(2, getDao().getUserGroupDao().selectByGroup(group1.getId())
        .size());
    assertEquals(user1.getId(), getDao().getUserGroupDao().getByUserGroup(
        group1.getId(), user1.getId()).getUserId());
    List<Long> ids = new ArrayList<Long>();
    ids.add(group2.getId());
    getDao().getUserGroupDao().removeByGroup(ids);
    assertEquals(0, getDao().getUserGroupDao().selectByGroup(group2.getId())
        .size());
    ids.clear();
    ids.add(user1.getId());
    getDao().getUserGroupDao().removeByUser(ids);
    assertEquals(1, getDao().getUserGroupDao().selectByGroup(group1.getId())
View Full Code Here

    for (Iterator<Element> i = groupsElement.elementIterator();
        i.hasNext(); ) {
            Element element = i.next();
            if (element.getName().equals("group")) {
              String name = element.elementText("name");
              GroupEntity group = getDao().getGroupDao().getByName(name);
              if (group == null) {
                group = new GroupEntity(name);
              }
              else {
                group.setName(name);
              }
              getDaoTaskAdapter().groupSave(group);
              for (Iterator<Element> j = element.element("users").elementIterator();
                j.hasNext(); ) {
                    Element userElement = j.next();
                    UserEntity user = getDao().getUserDao().getByEmail(
                        userElement.getText());
                    if (user != null) {
                      UserGroupEntity userGroup = getDao().getUserGroupDao()
                          .getByUserGroup(group.getId(), user.getId());
                  if (userGroup == null) {
                    userGroup = new UserGroupEntity(group.getId(),
                        user.getId());
                  }
                      getDaoTaskAdapter().userGroupSave(userGroup);
                    }
            }
View Full Code Here

    }
  }

  private void createPagePermissionXML(Element permissionsElement,
      final ContentPermissionEntity permission) {
    GroupEntity group = getDao().getGroupDao().getById(permission.getGroupId());
    Element permissionElement = permissionsElement.addElement("permission");
    permissionElement.addElement("group").setText(group.getName());
    permissionElement.addElement("permissionType").setText(
        permission.getPermission().name());
    permissionElement.addElement("allLanguages").setText(
        String.valueOf(permission.isAllLanguages()));
    permissionElement.addElement("languages").setText(notNull(
View Full Code Here

    for (Iterator<Element> i = permissionsElement.elementIterator();
        i.hasNext(); ) {
            Element element = i.next();
            if (element.getName().equals("permission")) {
              String groupName = element.elementText("group");
              GroupEntity group = getDao().getGroupDao().getByName(groupName);
              if (group == null) {
                logger.error("Group " + groupName + " was not found.");
                continue;
              }
              ContentPermissionType permType = ContentPermissionType.valueOf(
View Full Code Here

TOP

Related Classes of org.vosao.entity.GroupEntity

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.