|
|
@@ -19,6 +19,7 @@ import com.google.common.base.Strings;
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import mysql.Mysql;
|
|
|
+import objects.Constants;
|
|
|
import objects.League;
|
|
|
import objects.OverUnder;
|
|
|
import objects.SoccerMatch;
|
|
|
@@ -28,6 +29,9 @@ import objects.TeamStanding;
|
|
|
|
|
|
public class GuiMysql extends Mysql {
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
private static final BigDecimal INCREMENT = BigDecimal.valueOf(0.2);
|
|
|
private static final GuiMysql instance = new GuiMysql();
|
|
|
private final Connection conn;
|
|
|
@@ -50,7 +54,7 @@ public class GuiMysql extends Mysql {
|
|
|
final ResultSet rs = stat.executeQuery();
|
|
|
|
|
|
while (rs.next()) {
|
|
|
- final SimpleEntry<Integer, String> entry = new SimpleEntry<>(rs.getInt("id"), rs.getString("name"));
|
|
|
+ final SimpleEntry<Integer, String> entry = new SimpleEntry<>(rs.getInt(Constants.ID), rs.getString("name"));
|
|
|
sports.add(entry);
|
|
|
}
|
|
|
} catch (final SQLException e) {
|
|
|
@@ -69,7 +73,7 @@ public class GuiMysql extends Mysql {
|
|
|
final ResultSet rs = stat.executeQuery();
|
|
|
|
|
|
while (rs.next()) {
|
|
|
- final SimpleEntry<Integer, String> entry = new SimpleEntry<>(rs.getInt("id"), rs.getString("name"));
|
|
|
+ final SimpleEntry<Integer, String> entry = new SimpleEntry<>(rs.getInt(Constants.ID), rs.getString("name"));
|
|
|
countries.add(entry);
|
|
|
}
|
|
|
} catch (final SQLException e) {
|
|
|
@@ -89,7 +93,7 @@ public class GuiMysql extends Mysql {
|
|
|
final ResultSet rs = stat.executeQuery();
|
|
|
|
|
|
while (rs.next()) {
|
|
|
- final SimpleEntry<Integer, String> entry = new SimpleEntry<>(rs.getInt("id"), rs.getString("name"));
|
|
|
+ final SimpleEntry<Integer, String> entry = new SimpleEntry<>(rs.getInt(Constants.ID), rs.getString("name"));
|
|
|
leagues.add(entry);
|
|
|
}
|
|
|
} catch (final SQLException e) {
|
|
|
@@ -121,28 +125,28 @@ public class GuiMysql extends Mysql {
|
|
|
final Team homeTeam = new Team();
|
|
|
final Team awayTeam = new Team();
|
|
|
|
|
|
- homeTeam.setTeamId(rs.getInt("homeTeamId"));
|
|
|
- awayTeam.setTeamId(rs.getInt("awayTeamId"));
|
|
|
- homeTeam.setTeamName(rs.getString("homeTeamName"));
|
|
|
- awayTeam.setTeamName(rs.getString("awayTeamName"));
|
|
|
- homeTeam.setTeamLeagueId(rs.getInt("leagueId"));
|
|
|
- awayTeam.setTeamLeagueId(rs.getInt("leagueId"));
|
|
|
- homeTeam.setTeamLeague(rs.getString("leagueName"));
|
|
|
- awayTeam.setTeamLeague(rs.getString("leagueName"));
|
|
|
- homeTeam.setCountryId(rs.getInt("countryId"));
|
|
|
- awayTeam.setCountryId(rs.getInt("countryId"));
|
|
|
- homeTeam.setCountryName(rs.getString("countryName"));
|
|
|
- awayTeam.setCountryName(rs.getString("countryName"));
|
|
|
-
|
|
|
- sm.setAwayScore(rs.getInt("awayScore"));
|
|
|
- sm.setHomeScore(rs.getInt("homeScore"));
|
|
|
+ homeTeam.setTeamId(rs.getInt(Constants.HOME_TEAM_ID));
|
|
|
+ awayTeam.setTeamId(rs.getInt(Constants.AWAY_TEAM_ID));
|
|
|
+ homeTeam.setTeamName(rs.getString(Constants.HOME_TEAM_NAME));
|
|
|
+ awayTeam.setTeamName(rs.getString(Constants.AWAY_TEAM_NAME));
|
|
|
+ homeTeam.setTeamLeagueId(rs.getInt(Constants.LEAGUE_ID));
|
|
|
+ awayTeam.setTeamLeagueId(rs.getInt(Constants.LEAGUE_ID));
|
|
|
+ homeTeam.setTeamLeague(rs.getString(Constants.LEAGUE_NAME));
|
|
|
+ awayTeam.setTeamLeague(rs.getString(Constants.LEAGUE_NAME));
|
|
|
+ homeTeam.setCountryId(rs.getInt(Constants.COUNTRY_ID));
|
|
|
+ awayTeam.setCountryId(rs.getInt(Constants.COUNTRY_ID));
|
|
|
+ homeTeam.setCountryName(rs.getString(Constants.COUNTRY_NAME));
|
|
|
+ awayTeam.setCountryName(rs.getString(Constants.COUNTRY_NAME));
|
|
|
+
|
|
|
+ sm.setAwayScore(rs.getInt(Constants.AWAY_SCORE));
|
|
|
+ sm.setHomeScore(rs.getInt(Constants.HOME_SCORE));
|
|
|
sm.setHomeTeam(homeTeam);
|
|
|
sm.setAwayTeam(awayTeam);
|
|
|
- sm.setMatchId(rs.getInt("id"));
|
|
|
- sm.setOdds1(rs.getFloat("odds1"));
|
|
|
- sm.setOddsX(rs.getFloat("oddsX"));
|
|
|
- sm.setOdds2(rs.getFloat("odds2"));
|
|
|
- sm.setGameDate(LocalDateTime.parse(rs.getString("gameDate")));
|
|
|
+ sm.setMatchId(rs.getInt(Constants.ID));
|
|
|
+ sm.setOdds1(rs.getFloat(Constants.ODDS_1));
|
|
|
+ sm.setOddsX(rs.getFloat(Constants.ODDS_X));
|
|
|
+ sm.setOdds2(rs.getFloat(Constants.ODDS_2));
|
|
|
+ sm.setGameDate(LocalDateTime.parse(rs.getString(Constants.GAME_DATE)));
|
|
|
sm.setCountryPrio(rs.getBoolean("prio"));
|
|
|
|
|
|
matches.add(sm);
|
|
|
@@ -201,7 +205,7 @@ public class GuiMysql extends Mysql {
|
|
|
+ " FROM SoccerResults WHERE leagueId = ? AND countryId = ?";
|
|
|
|
|
|
final String goalsSql = "SELECT (homeScore + awayScore) as totalGoals, count(*) as count FROM SoccerResults WHERE leagueId = ? AND countryId = ? AND season = ? GROUP BY totalGoals ORDER BY totalGoals asc";
|
|
|
- try (PreparedStatement stat = conn.prepareStatement(sql)) {
|
|
|
+ try (PreparedStatement stat = conn.prepareStatement(sql); PreparedStatement goalStmt = conn.prepareStatement(goalsSql)) {
|
|
|
stat.setInt(1, leagueId);
|
|
|
stat.setInt(2, countryId);
|
|
|
|
|
|
@@ -211,14 +215,13 @@ public class GuiMysql extends Mysql {
|
|
|
returnValue.add(rs.getFloat("avgAwayScore"));
|
|
|
}
|
|
|
|
|
|
- final PreparedStatement goalStmt = conn.prepareStatement(goalsSql);
|
|
|
goalStmt.setInt(1, leagueId);
|
|
|
goalStmt.setInt(2, countryId);
|
|
|
goalStmt.setString(3, getLastSeason(countryId, leagueId));
|
|
|
|
|
|
final ResultSet goalRs = goalStmt.executeQuery();
|
|
|
while (goalRs.next()) {
|
|
|
-
|
|
|
+ // TODO Not done!
|
|
|
}
|
|
|
|
|
|
} catch (final SQLException e) {
|
|
|
@@ -297,7 +300,7 @@ public class GuiMysql extends Mysql {
|
|
|
final ResultSet rs = stat.executeQuery();
|
|
|
while (rs.next()) {
|
|
|
final TeamStanding ts = new TeamStanding(rs.getString("teamName"), rs.getInt("wins"), rs.getInt("lost"),
|
|
|
- rs.getInt("draws"), rs.getInt("score"), rs.getFloat("homeScore"), rs.getFloat("awayScore"),
|
|
|
+ rs.getInt("draws"), rs.getInt("score"), rs.getFloat(Constants.HOME_SCORE), rs.getFloat(Constants.AWAY_SCORE),
|
|
|
rs.getFloat("goal_diff"));
|
|
|
result.add(ts);
|
|
|
}
|
|
|
@@ -340,7 +343,7 @@ public class GuiMysql extends Mysql {
|
|
|
|
|
|
final ResultSet rs = stmt.executeQuery();
|
|
|
while (rs.next()) {
|
|
|
- season = rs.getString("season");
|
|
|
+ season = rs.getString(Constants.SEASON);
|
|
|
}
|
|
|
} catch (final SQLException e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -440,7 +443,7 @@ public class GuiMysql extends Mysql {
|
|
|
final ResultSet rs = stat.executeQuery();
|
|
|
|
|
|
while (rs.next()) {
|
|
|
- result.add(new SimpleEntry<>(rs.getInt("id"), rs.getString("name")));
|
|
|
+ result.add(new SimpleEntry<>(rs.getInt(Constants.ID), rs.getString("name")));
|
|
|
}
|
|
|
} catch (final SQLException e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -460,7 +463,7 @@ public class GuiMysql extends Mysql {
|
|
|
final ResultSet rs = stat.executeQuery();
|
|
|
|
|
|
while (rs.next()) {
|
|
|
- final SimpleEntry<Integer, String> entry = new SimpleEntry<>(rs.getInt("id"), rs.getString("name"));
|
|
|
+ final SimpleEntry<Integer, String> entry = new SimpleEntry<>(rs.getInt(Constants.ID), rs.getString("name"));
|
|
|
leagues.add(entry);
|
|
|
}
|
|
|
} catch (final SQLException e) {
|
|
|
@@ -493,25 +496,25 @@ public class GuiMysql extends Mysql {
|
|
|
final Team homeTeam = new Team();
|
|
|
final Team awayTeam = new Team();
|
|
|
|
|
|
- homeTeam.setTeamId(rs.getInt("homeTeamId"));
|
|
|
- awayTeam.setTeamId(rs.getInt("awayTeamId"));
|
|
|
- homeTeam.setTeamName(rs.getString("homeTeamName"));
|
|
|
- awayTeam.setTeamName(rs.getString("awayTeamName"));
|
|
|
- homeTeam.setTeamLeagueId(rs.getInt("leagueId"));
|
|
|
- awayTeam.setTeamLeagueId(rs.getInt("leagueId"));
|
|
|
- homeTeam.setCountryId(rs.getInt("countryId"));
|
|
|
- awayTeam.setCountryId(rs.getInt("countryId"));
|
|
|
-
|
|
|
- sm.setAwayScore(rs.getInt("awayScore"));
|
|
|
- sm.setHomeScore(rs.getInt("homeScore"));
|
|
|
+ homeTeam.setTeamId(rs.getInt(Constants.HOME_TEAM_ID));
|
|
|
+ awayTeam.setTeamId(rs.getInt(Constants.AWAY_TEAM_ID));
|
|
|
+ homeTeam.setTeamName(rs.getString(Constants.HOME_TEAM_NAME));
|
|
|
+ awayTeam.setTeamName(rs.getString(Constants.AWAY_TEAM_NAME));
|
|
|
+ homeTeam.setTeamLeagueId(rs.getInt(Constants.LEAGUE_ID));
|
|
|
+ awayTeam.setTeamLeagueId(rs.getInt(Constants.LEAGUE_ID));
|
|
|
+ homeTeam.setCountryId(rs.getInt(Constants.COUNTRY_ID));
|
|
|
+ awayTeam.setCountryId(rs.getInt(Constants.COUNTRY_ID));
|
|
|
+
|
|
|
+ sm.setAwayScore(rs.getInt(Constants.AWAY_SCORE));
|
|
|
+ sm.setHomeScore(rs.getInt(Constants.HOME_SCORE));
|
|
|
sm.setHomeTeam(homeTeam);
|
|
|
sm.setAwayTeam(awayTeam);
|
|
|
- sm.setMatchId(rs.getInt("id"));
|
|
|
- sm.setOdds1(rs.getFloat("odds1"));
|
|
|
- sm.setOddsX(rs.getFloat("oddsX"));
|
|
|
- sm.setOdds2(rs.getFloat("odds2"));
|
|
|
- sm.setGameDate(LocalDateTime.parse(rs.getString("gameDate")));
|
|
|
- sm.setSeason(rs.getString("season"));
|
|
|
+ sm.setMatchId(rs.getInt(Constants.ID));
|
|
|
+ sm.setOdds1(rs.getFloat(Constants.ODDS_1));
|
|
|
+ sm.setOddsX(rs.getFloat(Constants.ODDS_X));
|
|
|
+ sm.setOdds2(rs.getFloat(Constants.ODDS_2));
|
|
|
+ sm.setGameDate(LocalDateTime.parse(rs.getString(Constants.GAME_DATE)));
|
|
|
+ sm.setSeason(rs.getString(Constants.SEASON));
|
|
|
|
|
|
matches.add(sm);
|
|
|
}
|
|
|
@@ -531,7 +534,7 @@ public class GuiMysql extends Mysql {
|
|
|
final ResultSet rs = stat.executeQuery();
|
|
|
|
|
|
while (rs.next()) {
|
|
|
- result = new League(rs.getInt("id"), rs.getString("name"), rs.getInt("lookback"),
|
|
|
+ result = new League(rs.getInt(Constants.ID), rs.getString("name"), rs.getInt("lookback"),
|
|
|
rs.getInt("betMargin"), rs.getInt("lookbackHome"), rs.getInt("lookbackDraw"),
|
|
|
rs.getInt("lookbackAway"), rs.getInt("betMarginHome"), rs.getInt("betMarginDraw"),
|
|
|
rs.getInt("betMarginAway"));
|
|
|
@@ -551,7 +554,7 @@ public class GuiMysql extends Mysql {
|
|
|
final ResultSet rs = stat.executeQuery();
|
|
|
|
|
|
while (rs.next()) {
|
|
|
- result = new League(rs.getInt("id"), rs.getString("name"), rs.getInt("lookback"),
|
|
|
+ result = new League(rs.getInt(Constants.ID), rs.getString("name"), rs.getInt("lookback"),
|
|
|
rs.getInt("betMargin"), rs.getInt("lookbackHome"), rs.getInt("lookbackDraw"),
|
|
|
rs.getInt("lookbackAway"), rs.getInt("betMarginHome"), rs.getInt("betMarginDraw"),
|
|
|
rs.getInt("betMarginAway"));
|