예제 #1
0
  public Team save(Team team) {
    Team result;
    User principal;

    principal = userService.findByPrincipal();

    result = teamRepository.save(team);

    if (team.getId() == 0) {
      principal.getTeamsCreated().add(result);
      principal.getTeams().add(result);
    }

    userService.save(principal);

    return result;
  }
예제 #2
0
  public void delete(Team team) {

    User captain;

    captain = team.getCaptain();

    for (Tournament t : team.getTournaments()) {
      Assert.isTrue(t.getFinishMoment().before(new Date()));
    }

    captain.getTeams().remove(team);
    captain.getTeamsCreated().remove(team);

    Assert.notNull(team);
    checkPrincipal(team);
    teamRepository.delete(team);

    userService.save(captain);
  }