Esempio n. 1
0
  public static void storeresults() {
    if (ValidationUtils.verifyAuthenticity()) {
      checkAuthenticity();
    }

    final Map<String, String> map = params.allSimple();
    final Set<String> keys = new HashSet<String>();
    for (final Entry<String, String> entry : map.entrySet()) {
      String key = entry.getKey();
      if (StringUtils.isNotBlank(key)
          && key.contains("game_")
          && (key.contains("_homeScore") || key.contains("_awayScore"))) {
        key =
            key.replace("game_", "")
                .replace("_homeScore", "")
                .replace("_awayScore", "")
                .replace("_homeScore_et", "")
                .replace("_awayScore_et", "")
                .trim();
        keys.add(key);
      }
    }

    String gamekey = null;
    for (final String key : keys) {
      gamekey = key;
      final String homeScore = map.get("game_" + key + "_homeScore");
      final String awayScore = map.get("game_" + key + "_awayScore");
      final String extratime = map.get("extratime_" + key);
      final String homeScoreExtratime = map.get("game_" + key + "_homeScore_et");
      final String awayScoreExtratime = map.get("game_" + key + "_awayScore_et");
      AppUtils.setGameScore(
          key, homeScore, awayScore, extratime, homeScoreExtratime, awayScoreExtratime);
    }

    AppUtils.calculations();

    flash.put("infomessage", Messages.get("controller.games.tippsstored"));
    flash.keep();

    int playday = 1;
    if ((keys != null) && (keys.size() >= 1)) {
      if (StringUtils.isNotBlank(gamekey)) {
        gamekey = gamekey.replace("_et", "");
        final Game game = Game.findById(new Long(gamekey));
        if ((game != null) && (game.getPlayday() != null)) {
          playday = game.getPlayday().getNumber();
        }
      }
    }

    redirect("/admin/results/" + playday);
  }