Ejemplo n.º 1
0
 private Integer getLastCorrectCompetitionId() {
   Integer id = 0;
   for (Competition competition : this.competitions) {
     if (competition.getId() > id) {
       id = competition.getId();
     }
   }
   id++;
   return id;
 }
Ejemplo n.º 2
0
 public void addCompetition(Competition competition) {
   if (competition.getId() == null) {
     Integer id = this.getLastCorrectCompetitionId();
     competition.setId(id);
   }
   if (competition.getMatchs() != null) {
     this.setIdsToMatchs(competition);
   }
   boolean insertCorrectly = this.competitions.add(competition);
   if (insertCorrectly == false) {
     throw new CompetitionInsertException("La competition no se ha insertado porque ya exisitia");
   }
 }