Пример #1
0
  public Team reconstruct(TeamForm teamForm) {
    Team result;

    if (teamForm.getId() != 0) {
      result = findOne(teamForm.getId());

      checkPrincipal(result);
    } else {
      result = this.create();
    }

    result.setId(teamForm.getId());
    result.setMaxNumber(teamForm.getMaxNumber());
    result.setName(teamForm.getName());
    result.setCaptain(teamForm.getCaptain());

    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);
  }