|
@@ -1,8 +1,10 @@
|
|
|
package controllers;
|
|
package controllers;
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.util.AbstractMap.SimpleEntry;
|
|
import java.util.AbstractMap.SimpleEntry;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -80,8 +82,8 @@ public class MainController implements Initializable {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- matchTabController.getTable().getSelectionModel().selectedItemProperty().addListener(
|
|
|
|
|
- (obs, oldSelection, newSelection) -> showMatchStatsButton.setDisable(newSelection == null));
|
|
|
|
|
|
|
+ matchTabController.getTable().getSelectionModel().selectedItemProperty()
|
|
|
|
|
+ .addListener((obs, oldSelection, newSelection) -> showMatchStatsButton.setDisable(newSelection == null));
|
|
|
|
|
|
|
|
sportSelector.setItems(sports);
|
|
sportSelector.setItems(sports);
|
|
|
countrySelector.setItems(countries);
|
|
countrySelector.setItems(countries);
|
|
@@ -100,10 +102,8 @@ public class MainController implements Initializable {
|
|
|
homeTeams.add(soccerMatch.getHomeTeam().getTeamName());
|
|
homeTeams.add(soccerMatch.getHomeTeam().getTeamName());
|
|
|
awayTeams.add(soccerMatch.getAwayTeam().getTeamName());
|
|
awayTeams.add(soccerMatch.getAwayTeam().getTeamName());
|
|
|
|
|
|
|
|
- if (countriesList.stream()
|
|
|
|
|
- .noneMatch(p -> p != null && p.getValue().equals(soccerMatch.getHomeTeam().getCountryName()))) {
|
|
|
|
|
- countriesList.add(new SimpleEntry<>(soccerMatch.getHomeTeam().getCountryId(),
|
|
|
|
|
- soccerMatch.getHomeTeam().getCountryName()));
|
|
|
|
|
|
|
+ if (countriesList.stream().noneMatch(p -> p != null && p.getValue().equals(soccerMatch.getHomeTeam().getCountryName()))) {
|
|
|
|
|
+ countriesList.add(new SimpleEntry<>(soccerMatch.getHomeTeam().getCountryId(), soccerMatch.getHomeTeam().getCountryName()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -118,8 +118,8 @@ public class MainController implements Initializable {
|
|
|
if (countrySelector.getValue() != null && !countrySelector.getValue().equals("Country")) {
|
|
if (countrySelector.getValue() != null && !countrySelector.getValue().equals("Country")) {
|
|
|
leagueSelector.setDisable(false);
|
|
leagueSelector.setDisable(false);
|
|
|
final int countryId = getCountryIdFromSelector();
|
|
final int countryId = getCountryIdFromSelector();
|
|
|
- Optional<SimpleEntry<Integer, String>> selectedSport = sportsList.stream()
|
|
|
|
|
- .filter(p -> p.getValue().equals(sportSelector.getValue())).findFirst();
|
|
|
|
|
|
|
+ Optional<SimpleEntry<Integer, String>> selectedSport = sportsList.stream().filter(p -> p.getValue().equals(sportSelector.getValue()))
|
|
|
|
|
+ .findFirst();
|
|
|
if (selectedSport.isPresent()) {
|
|
if (selectedSport.isPresent()) {
|
|
|
final int sportId = selectedSport.get().getKey();
|
|
final int sportId = selectedSport.get().getKey();
|
|
|
matchTabController.filterCountryMatches(countrySelector.getValue());
|
|
matchTabController.filterCountryMatches(countrySelector.getValue());
|
|
@@ -140,14 +140,12 @@ public class MainController implements Initializable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private Integer getCountryIdFromSelector() {
|
|
private Integer getCountryIdFromSelector() {
|
|
|
- Optional<SimpleEntry<Integer, String>> o = countriesList.stream()
|
|
|
|
|
- .filter(p -> p.getValue().equals(countrySelector.getValue())).findFirst();
|
|
|
|
|
|
|
+ Optional<SimpleEntry<Integer, String>> o = countriesList.stream().filter(p -> p.getValue().equals(countrySelector.getValue())).findFirst();
|
|
|
return o.isPresent() ? o.get().getKey() : null;
|
|
return o.isPresent() ? o.get().getKey() : null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private Integer getLeagueIdFromSelector() {
|
|
private Integer getLeagueIdFromSelector() {
|
|
|
- Optional<SimpleEntry<Integer, String>> o = leaguesList.stream()
|
|
|
|
|
- .filter(p -> p.getValue().equals(leagueSelector.getValue())).findFirst();
|
|
|
|
|
|
|
+ Optional<SimpleEntry<Integer, String>> o = leaguesList.stream().filter(p -> p.getValue().equals(leagueSelector.getValue())).findFirst();
|
|
|
return o.isPresent() ? o.get().getKey() : null;
|
|
return o.isPresent() ? o.get().getKey() : null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -167,14 +165,13 @@ public class MainController implements Initializable {
|
|
|
}
|
|
}
|
|
|
matchTabController.filterLeagueMatches(leagueSelector.getValue(), getCountryIdFromSelector());
|
|
matchTabController.filterLeagueMatches(leagueSelector.getValue(), getCountryIdFromSelector());
|
|
|
updateStatsTableButton.setDisable(false);
|
|
updateStatsTableButton.setDisable(false);
|
|
|
- final List<Float> leagueAvareges = GuiMysql.getInstance().getLeagueAvarages(getLeagueIdFromSelector(),
|
|
|
|
|
- getCountryIdFromSelector());
|
|
|
|
|
|
|
+ final List<Float> leagueAvareges = GuiMysql.getInstance().getLeagueAvarages(getLeagueIdFromSelector(), getCountryIdFromSelector());
|
|
|
|
|
|
|
|
avgLeagueHomeScoreTxt.setText(leagueAvareges.get(0).toString());
|
|
avgLeagueHomeScoreTxt.setText(leagueAvareges.get(0).toString());
|
|
|
avgLeagueAwayScoreTxt.setText(leagueAvareges.get(1).toString());
|
|
avgLeagueAwayScoreTxt.setText(leagueAvareges.get(1).toString());
|
|
|
|
|
|
|
|
- Map<Integer, Integer> goalAvgTheSeason = GuiMysql.getInstance()
|
|
|
|
|
- .getGoalAvgThisSeason(getLeagueIdFromSelector(), getCountryIdFromSelector());
|
|
|
|
|
|
|
+ Map<Integer, Integer> goalAvgTheSeason = GuiMysql.getInstance().getGoalAvgThisSeason(getLeagueIdFromSelector(),
|
|
|
|
|
+ getCountryIdFromSelector());
|
|
|
|
|
|
|
|
league0Goals.setText(goalAvgTheSeason.getOrDefault(0, 0).toString());
|
|
league0Goals.setText(goalAvgTheSeason.getOrDefault(0, 0).toString());
|
|
|
league1Goals.setText(goalAvgTheSeason.getOrDefault(1, 0).toString());
|
|
league1Goals.setText(goalAvgTheSeason.getOrDefault(1, 0).toString());
|
|
@@ -222,8 +219,7 @@ public class MainController implements Initializable {
|
|
|
glass.setVisible(true);
|
|
glass.setVisible(true);
|
|
|
glass.setOpacity(0.8);
|
|
glass.setOpacity(0.8);
|
|
|
final OddsPortal op = new OddsPortal();
|
|
final OddsPortal op = new OddsPortal();
|
|
|
- op.getHistoricMatches(sportSelector.getValue().trim(), country, league,
|
|
|
|
|
- String.valueOf(LocalDate.now().getYear()));
|
|
|
|
|
|
|
+ op.getHistoricMatches(sportSelector.getValue().trim(), country, league, String.valueOf(LocalDate.now().getYear()));
|
|
|
glass.setOpacity(0.0);
|
|
glass.setOpacity(0.0);
|
|
|
glass.setVisible(false);
|
|
glass.setVisible(false);
|
|
|
glass.setDisable(true);
|
|
glass.setDisable(true);
|
|
@@ -234,8 +230,7 @@ public class MainController implements Initializable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@FXML private void getMoreLeagueInfo() {
|
|
@FXML private void getMoreLeagueInfo() {
|
|
|
- final String lastParsedYear = GuiMysql.getInstance().getLastParsedYear(leagueSelector.getValue().trim(),
|
|
|
|
|
- getCountryIdFromSelector());
|
|
|
|
|
|
|
+ final String lastParsedYear = GuiMysql.getInstance().getLastParsedYear(leagueSelector.getValue().trim(), getCountryIdFromSelector());
|
|
|
final String nextParseYear;
|
|
final String nextParseYear;
|
|
|
if (lastParsedYear.contains("-")) {
|
|
if (lastParsedYear.contains("-")) {
|
|
|
final String[] years = lastParsedYear.split("-");
|
|
final String[] years = lastParsedYear.split("-");
|
|
@@ -261,8 +256,8 @@ public class MainController implements Initializable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@FXML private void setMatchStatInfo() {
|
|
@FXML private void setMatchStatInfo() {
|
|
|
- final String season = GuiMysql.getInstance().getLastSeason(getCountryIdFromSelector(),
|
|
|
|
|
- getLeagueIdFromSelector());
|
|
|
|
|
- matchStatTabController.setLeagueStandingsTable(getLeagueIdFromSelector(), season, getCountryIdFromSelector());
|
|
|
|
|
|
|
+ final String season = GuiMysql.getInstance().getLastSeason(getCountryIdFromSelector(), getLeagueIdFromSelector());
|
|
|
|
|
+ matchStatTabController.setLeagueStandingsTable(getLeagueIdFromSelector(), season, getCountryIdFromSelector(),
|
|
|
|
|
+ new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|