Пример #1
0
  @SuppressWarnings("unchecked")
  public void reOrderCfTeams() {
    List<CfbTeamBo> teamBos = getAllCfbTeams();
    Collections.sort(teamBos);

    Criteria criteria = session.createCriteria(CfbTeam.class);
    criteria.addOrder(Order.asc("name").ignoreCase());
    List<CfbTeam> teams = criteria.list();
    Transaction tx = session.beginTransaction();
    for (CfbTeam team : teams) {
      session.delete(team);
    }
    tx.commit();
    session.flush();

    Transaction saveTx = session.beginTransaction();
    for (CfbTeamBo teamBo : teamBos) {
      CfbTeam team = new CfbTeam();
      team.setName(teamBo.getName());
      team.setLogo(teamBo.getLogoRaw());
      team.setColorAHex(teamBo.getColorAHex());
      team.setColorBHex(teamBo.getColorBHex());
      team.setLastEditTimestamp(new Date());
      team.setCreateTimestamp(new Date());
      session.save(team);
    }
    saveTx.commit();
    session.flush();
  }
Пример #2
0
  public String getUserBowlPickTotalScore(User user) {
    Integer pointsPossible = 0;
    for (BowlMatchup matchup : this.getAllBowlMatchups()) {
      if (matchup.getWinningTeam() != null) {
        pointsPossible++;
      }
    }

    Integer points = 0;
    for (BowlPick pick : user.getBowlPicks()) {
      CfbTeam pickedTeam = pick.getSelectedTeam();
      CfbTeam winningTeam = pick.getBowlMatchup().getWinningTeam();
      if (pickedTeam != null && winningTeam != null) {
        if (pickedTeam.getCfbTeamId() == winningTeam.getCfbTeamId()) {
          points++;
        }
      }
    }

    return points + " / " + pointsPossible;
  }