Add show table update, add matches list creator
This commit is contained in:
@@ -199,6 +199,10 @@ public class TLWMatch extends BaseMatch{
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public Integer getShowTable() {
|
||||
return this.showTable;
|
||||
}
|
||||
|
||||
public String getFormulaHome() {
|
||||
String formula = "'D'";
|
||||
if(this.teamIdHome != null) {
|
||||
@@ -270,9 +274,15 @@ public class TLWMatch extends BaseMatch{
|
||||
this.matchDatetime = matchDateTime;
|
||||
}
|
||||
|
||||
public void setShowTable(Boolean showTable) {
|
||||
this.showTable = showTable ? 0 : 1;
|
||||
}
|
||||
|
||||
public void updateMatch(APIFootballMatch apiFootballMatch) {
|
||||
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch.getTeamIdHome());
|
||||
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch.getTeamIdGuest());
|
||||
this.teamNameHome = apiFootballMatch.getTeamNameHome();
|
||||
this.teamNameGuest = apiFootballMatch.getTeamNameGuest();
|
||||
this.goalsHome = apiFootballMatch.getGoalsHome();
|
||||
this.goalsGuest = apiFootballMatch.getGoalsGuest();
|
||||
this.matchDatetime = apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class TLWMatchdaysCreator {
|
||||
this.matches = matchesCreator.getMatches();
|
||||
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getTippligaConfig(season, configPath);
|
||||
String jsonConfig = prov.getTippligaConfig(configPath);
|
||||
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
try {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
|
||||
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
|
||||
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getTippligaConfig(2021, configFileName);
|
||||
String jsonConfig = prov.getTippligaConfig(configFileName);
|
||||
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
|
||||
String matchPairingConfigString = prov.getTippligaBaseConfig("Tipper_Match_Pair_Config.json");
|
||||
this.matchPairingConfig = (JSONArray) jsonParser.parse(matchPairingConfigString);
|
||||
|
||||
String tipperListString = prov.getTippligaConfig(season, configFileName);
|
||||
String tipperListString = prov.getTippligaConfig(configFileName);
|
||||
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
|
||||
|
||||
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
|
||||
String tipperListString = prov.getTippligaConfig(season, configFileName);
|
||||
String tipperListString = prov.getTippligaConfig(configFileName);
|
||||
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
|
||||
|
||||
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
|
||||
|
||||
@@ -28,7 +28,7 @@ public class TLWMatchesManagerBase {
|
||||
protected void initConfigParamsFromFile(String configFileName) {
|
||||
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getTippligaConfig(season, configFileName);
|
||||
String jsonConfig = prov.getTippligaConfig(configFileName);
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
//Read JSON file
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import com.google.api.client.util.DateTime;
|
||||
import de.jeyp91.App;
|
||||
import de.jeyp91.TeamIDMatcher;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
@@ -10,14 +9,11 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import javax.sound.midi.SysexMessage;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
private static Logger logger = LogManager.getLogger(App.class);
|
||||
private static final Logger logger = LogManager.getLogger(App.class);
|
||||
|
||||
ArrayList<TLWMatch> tlwMatchesOriginal;
|
||||
ArrayList<TLWMatch> tlwMatchesUpdated;
|
||||
@@ -47,7 +43,9 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
|
||||
ArrayList<TLWMatch> tlwMatchesOriginalMatchday = tippligaSQLConnector.getMatches(String.valueOf(this.season), String.valueOf(this.league), String.valueOf(tlwMatchday));
|
||||
ArrayList<TLWMatch> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
||||
for (TLWMatch match : tlwMatchesOriginalMatchday) tlwMatchesUpdatedMatchday.add(new TLWMatch(match));
|
||||
for (TLWMatch match : tlwMatchesOriginalMatchday) {
|
||||
tlwMatchesUpdatedMatchday.add(new TLWMatch(match));
|
||||
}
|
||||
|
||||
if (apiFootballMatches.size() > tlwMatchesUpdatedMatchday.size()) {
|
||||
logger.error("Not matching config!");
|
||||
@@ -55,6 +53,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
|
||||
addMissingMatches(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||
updateMatchDateTimes(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||
updateShowTable(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||
updateStatus(tlwMatchesUpdatedMatchday);
|
||||
|
||||
this.tlwMatchesOriginal.addAll(tlwMatchesOriginalMatchday);
|
||||
@@ -87,7 +86,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
"Spielnummer " + matchOriginal.getMatchNo() + ", " +
|
||||
"Spiel '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdHome()) + "' - '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdGuest()) + "', ";
|
||||
|
||||
if(matchOriginal.getTeamIdHome() != matchUpdated.getTeamIdHome()) {
|
||||
if(!matchOriginal.getTeamIdHome().equals(matchUpdated.getTeamIdHome())) {
|
||||
updateString += updateStart +
|
||||
"team_id_home = " + matchUpdated.getTeamIdHome() + " " +
|
||||
condition;
|
||||
@@ -95,7 +94,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
"Heimteam zu '" + matchUpdated.getTeamNameHome() + "'.\n";
|
||||
}
|
||||
|
||||
if(matchOriginal.getTeamIdGuest() != matchUpdated.getTeamIdGuest()) {
|
||||
if(!matchOriginal.getTeamIdGuest().equals(matchUpdated.getTeamIdGuest())) {
|
||||
updateString += updateStart +
|
||||
"team_id_guest = " + matchUpdated.getTeamIdGuest() + " " +
|
||||
condition;
|
||||
@@ -119,6 +118,14 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
"Status zu '" + matchUpdated.getStatus() + "'.\n";
|
||||
}
|
||||
|
||||
if (!matchOriginal.getShowTable().equals(matchUpdated.getShowTable())) {
|
||||
updateString += updateStart +
|
||||
"show_table = '" + matchUpdated.getShowTable() + "' " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Spiel in Tabelle einberechnen zu '" + (matchUpdated.getShowTable() == 1 ? "falsch" : "wahr") + "'.\n";
|
||||
}
|
||||
|
||||
|
||||
return updateString;
|
||||
}
|
||||
@@ -174,6 +181,16 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateShowTable(
|
||||
ArrayList<TLWMatch> tlwMatches,
|
||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||
{
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
|
||||
tlwMatch.setShowTable(apiFootballMatch.getShowTable());
|
||||
}
|
||||
}
|
||||
|
||||
private TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) {
|
||||
int foundMatches = 0;
|
||||
TLWMatch matchingMatch = null;
|
||||
|
||||
Reference in New Issue
Block a user