Exemplo n.º 1
0
  public Group addGroup(GroupDTO groupDto) {
    Group group = new Group();
    group.setName(groupDto.getName());

    if (groupDto.getPermissionArray() != null) {
      for (String permission : groupDto.getPermissionArray()) {
        group.addPermission(new GroupPermission(permission));
      }
    }

    return groupRepo.save(group);
  }
Exemplo n.º 2
0
  public void updateGroup(GroupDTO groupDto) throws DataIntegrityViolationException {

    Group group = groupRepo.findOne(groupDto.getId());

    // remove all existing permission (orphanRemoval=true in OneToMany relationship)
    group.getPermissionList().clear();

    group.setName(groupDto.getName());

    if (groupDto.getPermissionArray() != null) {
      for (String permission : groupDto.getPermissionArray()) {
        group.addPermission(new GroupPermission(permission));
      }
    }

    groupRepo.save(group);
  }
Exemplo n.º 3
0
 public Group addGroup(Group group) {
   return groupRepo.save(group);
 }