예제 #1
0
  @Override
  public Mandant copy(String oid) {
    Mandant in = this.read(oid);

    // map
    Mandant out = new Mandant(in);
    out.setOid(IdService.next());

    // in DB speichern
    this.save(out);

    return out;
  }
예제 #2
0
 @Override
 public Mandant create() {
   Mandant mandant = new Mandant();
   mandant.setOid(IdService.next());
   return mandant;
 }
  public void init() {
    User user = new User();
    user.setEmail("*****@*****.**");
    user.setPassword("test");
    user.setUsername("hans");
    user.setOid(IdService.next());
    user.setEnabled(TRUE);
    Mandant mandant = new Mandant();
    mandant.setOid("1");
    mandantRepo.save(mandant);
    user.setMandant(mandant);
    usersRepo.save(user);

    Authority auth = new Authority();
    auth.setAuthority("ADMIN");
    auth.setOid(IdService.next());
    authRepo.save(auth);

    List<String> permissions = new ArrayList();
    for (Method method : BuergerController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }

    for (Method method : AdresseController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : StaatsangehoerigkeitController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : WohnungController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : AuthorityController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : UserController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : CompanyBaseInfoController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : PermissionController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : UserAuthorityController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : SecurityRestClientController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : AuthorityPermissionController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : AccountController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    //        for (Method method : SachbearbeiterController.class.getDeclaredMethods()) {
    //            String name = method.getName();
    //            permissions.add("PERM_" + name);
    //        }
    for (Method method : PassController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    for (Method method : MandantController.class.getDeclaredMethods()) {
      String name = method.getName();
      permissions.add("PERM_" + name);
    }
    permissions
        .stream()
        .map(
            (permision1) -> {
              Permission permission = new Permission();
              permission.setPermision(permision1);
              return permission;
            })
        .map(
            (permission) -> {
              permission.setOid(IdService.next());
              return permission;
            })
        .map(
            (permission) -> {
              permRepo.save(permission);
              return permission;
            })
        .map(
            (permission) -> {
              AuthorityPermission authPerm = new AuthorityPermission();
              AuthPermId idA = new AuthPermId(permission, auth);
              authPerm.setId(idA);
              return authPerm;
            })
        .forEach(
            (authPerm) -> {
              authPermRepo.save(authPerm);
            });
    UserAuthority userAuth = new UserAuthority();
    UserAuthId id = new UserAuthId(user, auth);

    userAuth.setId(id);

    userAuthRepo.save(userAuth);
  }