Beispiel #1
0
  public CompetitionRankingVO getCompetitionRanking(Long competitionid) {
    Competition competition = em.find(Competition.class, competitionid);
    if (competition == null) {
      return null;
    }

    List<Athlete> list = getAthletesWithCompetionResults(competitionid);

    CompetitionRankingVO ranking = new CompetitionRankingVO();
    ranking.setCompetition(competition);

    Map<Category, List<Athlete>> map = new HashMap<>();
    for (Athlete a : list) {
      List<Athlete> as = map.get(a.getCategory());
      if (as == null) {
        as = new ArrayList<>();
      }
      as.add(a);
      map.put(a.getCategory(), as);
    }
    for (Map.Entry<Category, List<Athlete>> entry : map.entrySet()) {
      CompetitionRankingCategoryVO rc = new CompetitionRankingCategoryVO();
      Category c = entry.getKey();
      c.setEvents(null);
      rc.setCategory(c);
      rc.setAthletes(filterAndSortByTotalPoints(competition, entry.getValue()));
      ranking.getCategories().add(rc);
    }
    Collections.sort(ranking.getCategories());
    return ranking;
  }
Beispiel #2
0
  public byte[] createEmptySheets(Long categoryid, Locale locale) {
    Category category = em.find(Category.class, categoryid);
    if (category == null) {
      throw new IllegalArgumentException();
    }
    Series series = em.find(Series.class, category.getSeries_id());
    if (series == null) {
      throw new IllegalArgumentException();
    }
    Athlete template = new Athlete();
    template.setCategory(category);

    Sheets sheet = new Sheets(template, series.getLogo(), locale);
    return sheet.create();
  }