Add show table update, add matches list creator
This commit is contained in:
@@ -21,6 +21,7 @@ dependencies {
|
|||||||
implementation 'mysql:mysql-connector-java:8.0.17'
|
implementation 'mysql:mysql-connector-java:8.0.17'
|
||||||
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
|
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
|
||||||
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
|
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
|
||||||
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
testImplementation 'junit:junit:4.11'
|
testImplementation 'junit:junit:4.11'
|
||||||
compile 'com.google.api-client:google-api-client:1.23.0'
|
compile 'com.google.api-client:google-api-client:1.23.0'
|
||||||
compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
|
compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class App {
|
|||||||
}
|
}
|
||||||
if(!StatusHolder.getError() && !sql.equals("")) {
|
if(!StatusHolder.getError() && !sql.equals("")) {
|
||||||
TippligaSQLConnector con = new TippligaSQLConnector();
|
TippligaSQLConnector con = new TippligaSQLConnector();
|
||||||
// con.executeUpdate(sql);
|
con.executeUpdate(sql);
|
||||||
logger.info(beautifulInfo);
|
logger.info(beautifulInfo);
|
||||||
}
|
}
|
||||||
if(StatusHolder.getError()) {
|
if(StatusHolder.getError()) {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public class APIFootballConnector {
|
|||||||
private static APIFootballConnector conn = null;
|
private static APIFootballConnector conn = null;
|
||||||
private final int season;
|
private final int season;
|
||||||
private final String gistId;
|
private final String gistId;
|
||||||
private HashMap<String, JSONObject> rounds = new HashMap<>();
|
private final HashMap<String, JSONObject> rounds = new HashMap<>();
|
||||||
private HashMap<String, JSONObject> matches = new HashMap<>();
|
private final HashMap<String, JSONObject> matches = new HashMap<>();
|
||||||
|
|
||||||
private APIFootballConnector(int season) {
|
private APIFootballConnector(int season) {
|
||||||
this.season = season;
|
this.season = season;
|
||||||
@@ -94,7 +94,7 @@ public class APIFootballConnector {
|
|||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
|
|
||||||
GistProvider prov = GistProvider.getInstance();
|
GistProvider prov = GistProvider.getInstance();
|
||||||
String jsonConfig = prov.getFileFromGist(this.gistId, filename);
|
String jsonConfig = prov.getFileFromGist(filename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
object = (JSONObject) jsonParser.parse(jsonConfig);
|
object = (JSONObject) jsonParser.parse(jsonConfig);
|
||||||
@@ -111,7 +111,7 @@ public class APIFootballConnector {
|
|||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
|
|
||||||
GistProvider prov = GistProvider.getInstance();
|
GistProvider prov = GistProvider.getInstance();
|
||||||
String jsonConfig = prov.getFileFromGist(this.gistId, filename);
|
String jsonConfig = prov.getFileFromGist(filename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
object = (JSONArray) jsonParser.parse(jsonConfig);
|
object = (JSONArray) jsonParser.parse(jsonConfig);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class APIFootballMatch extends BaseMatch {
|
|||||||
private String matchStatus;
|
private String matchStatus;
|
||||||
private final String teamNameHome;
|
private final String teamNameHome;
|
||||||
private final String teamNameGuest;
|
private final String teamNameGuest;
|
||||||
|
private Boolean showTable = null;
|
||||||
|
|
||||||
public APIFootballMatch(JSONObject json, int season) {
|
public APIFootballMatch(JSONObject json, int season) {
|
||||||
this.season = season;
|
this.season = season;
|
||||||
@@ -67,4 +68,12 @@ public class APIFootballMatch extends BaseMatch {
|
|||||||
public String getTeamNameGuest() {
|
public String getTeamNameGuest() {
|
||||||
return this.teamNameGuest;
|
return this.teamNameGuest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowTable(boolean showTable) {
|
||||||
|
this.showTable = showTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getShowTable() {
|
||||||
|
return this.showTable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,16 +17,28 @@ public class APIFootballMatchesProvider {
|
|||||||
for (Object singleConfigObject : config) {
|
for (Object singleConfigObject : config) {
|
||||||
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
||||||
String type = (String) singleConfig.get("type");
|
String type = (String) singleConfig.get("type");
|
||||||
|
boolean showTable = false;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "AllMatchesOfMatchday":
|
case "AllMatchesOfMatchday":
|
||||||
int matchesLeague = ((Long) singleConfig.get("matchesLeague")).intValue();
|
int matchesLeague = ((Long) singleConfig.get("matchesLeague")).intValue();
|
||||||
int leagueMatchday = ((Long) singleConfig.get("leagueMatchday")).intValue();
|
int leagueMatchday = ((Long) singleConfig.get("leagueMatchday")).intValue();
|
||||||
apiFootballMatches.addAll(conn.getMatchDataByLeagueAndMatchday(matchesLeague, leagueMatchday));
|
ArrayList<APIFootballMatch> matches = conn.getMatchDataByLeagueAndMatchday(matchesLeague, leagueMatchday);
|
||||||
|
try {
|
||||||
|
showTable = (boolean) singleConfig.get("showTable");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
boolean finalShowTable = showTable;
|
||||||
|
matches.forEach(apiFootballMatch -> apiFootballMatch.setShowTable(finalShowTable));
|
||||||
|
apiFootballMatches.addAll(matches);
|
||||||
break;
|
break;
|
||||||
case "SingleMatch":
|
case "SingleMatch":
|
||||||
int matchLeague = ((Long) singleConfig.get("matchLeague")).intValue();
|
int matchLeague = ((Long) singleConfig.get("matchLeague")).intValue();
|
||||||
int matchId = ((Long) singleConfig.get("matchId")).intValue();
|
int matchId = ((Long) singleConfig.get("matchId")).intValue();
|
||||||
apiFootballMatches.add(conn.getMatchDataByLeagueAndMatchID(matchLeague, matchId));
|
APIFootballMatch match = conn.getMatchDataByLeagueAndMatchID(matchLeague, matchId);
|
||||||
|
showTable = (boolean) singleConfig.get("showTable");
|
||||||
|
match.setShowTable(showTable);
|
||||||
|
apiFootballMatches.add(match);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class APIFootballUpdater {
|
|||||||
|
|
||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
GistProvider prov = GistProvider.getInstance();
|
GistProvider prov = GistProvider.getInstance();
|
||||||
String jsonConfig = prov.getTippligaConfig(this.season, config);
|
String jsonConfig = prov.getTippligaConfig(config);
|
||||||
JSONObject configObject = null;
|
JSONObject configObject = null;
|
||||||
try {
|
try {
|
||||||
configObject = (JSONObject) jsonParser.parse(jsonConfig);
|
configObject = (JSONObject) jsonParser.parse(jsonConfig);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import java.util.Set;
|
|||||||
public class GistProvider {
|
public class GistProvider {
|
||||||
|
|
||||||
private static GistProvider prov = null;
|
private static GistProvider prov = null;
|
||||||
private JSONArray gistList;
|
private final JSONArray gistList;
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@@ -153,11 +153,10 @@ public class GistProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JSONArray getTeamIdMatcher() {
|
public JSONArray getTeamIdMatcher() {
|
||||||
String id = getGistID("Team_ID_Matcher");
|
return stringToJSONArray(getFileFromGist("Team_ID_Matcher.json"));
|
||||||
return stringToJSONArray(getFileFromGist(id, "Team_ID_Matcher.json"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileFromGist(String id, String filename) {
|
public String getFileFromGist(String filename) {
|
||||||
String fileurl = null;
|
String fileurl = null;
|
||||||
for (Object o : this.gistList) {
|
for (Object o : this.gistList) {
|
||||||
JSONObject gist = (JSONObject) o;
|
JSONObject gist = (JSONObject) o;
|
||||||
@@ -237,13 +236,30 @@ public class GistProvider {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTippligaConfig(int season, String filename) {
|
private JSONObject stringToJSONObject(String rawData) {
|
||||||
String id = getGistID("Tippliga_Config_" + season);
|
|
||||||
return getFileFromGist(id, filename);
|
JSONParser parser = new JSONParser();
|
||||||
|
JSONObject data = null;
|
||||||
|
try {
|
||||||
|
data = (JSONObject) parser.parse(rawData);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
/* TODO */
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTippligaConfig(String filename) {
|
||||||
|
return getFileFromGist(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTippligaBaseConfig(String filename) {
|
public String getTippligaBaseConfig(String filename) {
|
||||||
String id = getGistID("Tippliga_Config_Base");
|
return getFileFromGist(filename);
|
||||||
return getFileFromGist(id, filename);
|
}
|
||||||
|
|
||||||
|
public JSONObject getAPIFootballLeagueConfig(int league) {
|
||||||
|
String filename = "matches_league_" + league + ".json";
|
||||||
|
String file = getFileFromGist(filename);
|
||||||
|
return stringToJSONObject(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
58
src/main/java/de/jeyp91/gists/MatchesListCreator.java
Normal file
58
src/main/java/de/jeyp91/gists/MatchesListCreator.java
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
package de.jeyp91.gists;
|
||||||
|
|
||||||
|
import com.google.gson.*;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
public class MatchesListCreator {
|
||||||
|
|
||||||
|
private final JSONObject matches = new JSONObject();
|
||||||
|
|
||||||
|
public MatchesListCreator(int league) {
|
||||||
|
GistProvider provider = GistProvider.getInstance();
|
||||||
|
JSONObject leagueConfig = provider.getAPIFootballLeagueConfig(league);
|
||||||
|
JSONObject api = (JSONObject) leagueConfig.get("api");
|
||||||
|
JSONArray matchesAPIFootball = (JSONArray) api.get("fixtures");
|
||||||
|
JSONObject firstMatchAPIFootball = (JSONObject) matchesAPIFootball.get(0);
|
||||||
|
JSONObject leagueObject = (JSONObject) firstMatchAPIFootball.get("league");
|
||||||
|
String country = leagueObject.get("country").toString();
|
||||||
|
String leagueName = leagueObject.get("name").toString();
|
||||||
|
matches.put("country", country);
|
||||||
|
matches.put("leagueName", leagueName);
|
||||||
|
matches.put("leagueId", league);
|
||||||
|
populateMatches(matchesAPIFootball);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateMatches(JSONArray matchesAPIFootball) {
|
||||||
|
JSONArray matches = new JSONArray();
|
||||||
|
for(Object matchAPIFootballObject : matchesAPIFootball) {
|
||||||
|
JSONObject matchAPIFootball = (JSONObject) matchAPIFootballObject;
|
||||||
|
JSONObject match = new JSONObject();
|
||||||
|
|
||||||
|
String matchday = matchAPIFootball.get("round").toString();
|
||||||
|
match.put("matchday", matchday);
|
||||||
|
|
||||||
|
JSONObject teamHome = (JSONObject) matchAPIFootball.get("homeTeam");
|
||||||
|
String teamNameHome = teamHome.get("team_name").toString();
|
||||||
|
JSONObject teamGuest = (JSONObject) matchAPIFootball.get("awayTeam");
|
||||||
|
String teamNameGuest = teamGuest.get("team_name").toString();
|
||||||
|
match.put("match", teamNameHome + " - " + teamNameGuest);
|
||||||
|
|
||||||
|
Long fixtureId = (Long) matchAPIFootball.get("fixture_id");
|
||||||
|
match.put("matchId", fixtureId);
|
||||||
|
|
||||||
|
matches.add(match);
|
||||||
|
}
|
||||||
|
this.matches.put("matches", matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getMatches() {
|
||||||
|
return this.matches;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMatchesBeautful() {
|
||||||
|
JsonElement jelement = JsonParser.parseString(this.matches.toString());
|
||||||
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
return gson.toJson(jelement);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -199,6 +199,10 @@ public class TLWMatch extends BaseMatch{
|
|||||||
return this.groupId;
|
return this.groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getShowTable() {
|
||||||
|
return this.showTable;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFormulaHome() {
|
public String getFormulaHome() {
|
||||||
String formula = "'D'";
|
String formula = "'D'";
|
||||||
if(this.teamIdHome != null) {
|
if(this.teamIdHome != null) {
|
||||||
@@ -270,9 +274,15 @@ public class TLWMatch extends BaseMatch{
|
|||||||
this.matchDatetime = matchDateTime;
|
this.matchDatetime = matchDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowTable(Boolean showTable) {
|
||||||
|
this.showTable = showTable ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateMatch(APIFootballMatch apiFootballMatch) {
|
public void updateMatch(APIFootballMatch apiFootballMatch) {
|
||||||
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch.getTeamIdHome());
|
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch.getTeamIdHome());
|
||||||
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch.getTeamIdGuest());
|
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch.getTeamIdGuest());
|
||||||
|
this.teamNameHome = apiFootballMatch.getTeamNameHome();
|
||||||
|
this.teamNameGuest = apiFootballMatch.getTeamNameGuest();
|
||||||
this.goalsHome = apiFootballMatch.getGoalsHome();
|
this.goalsHome = apiFootballMatch.getGoalsHome();
|
||||||
this.goalsGuest = apiFootballMatch.getGoalsGuest();
|
this.goalsGuest = apiFootballMatch.getGoalsGuest();
|
||||||
this.matchDatetime = apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19);
|
this.matchDatetime = apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class TLWMatchdaysCreator {
|
|||||||
this.matches = matchesCreator.getMatches();
|
this.matches = matchesCreator.getMatches();
|
||||||
|
|
||||||
GistProvider prov = GistProvider.getInstance();
|
GistProvider prov = GistProvider.getInstance();
|
||||||
String jsonConfig = prov.getTippligaConfig(season, configPath);
|
String jsonConfig = prov.getTippligaConfig(configPath);
|
||||||
|
|
||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
|
|||||||
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
|
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
|
||||||
|
|
||||||
GistProvider prov = GistProvider.getInstance();
|
GistProvider prov = GistProvider.getInstance();
|
||||||
String jsonConfig = prov.getTippligaConfig(2021, configFileName);
|
String jsonConfig = prov.getTippligaConfig(configFileName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
|
|||||||
String matchPairingConfigString = prov.getTippligaBaseConfig("Tipper_Match_Pair_Config.json");
|
String matchPairingConfigString = prov.getTippligaBaseConfig("Tipper_Match_Pair_Config.json");
|
||||||
this.matchPairingConfig = (JSONArray) jsonParser.parse(matchPairingConfigString);
|
this.matchPairingConfig = (JSONArray) jsonParser.parse(matchPairingConfigString);
|
||||||
|
|
||||||
String tipperListString = prov.getTippligaConfig(season, configFileName);
|
String tipperListString = prov.getTippligaConfig(configFileName);
|
||||||
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
|
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
|
||||||
|
|
||||||
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
|
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
|
|||||||
try {
|
try {
|
||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
|
|
||||||
String tipperListString = prov.getTippligaConfig(season, configFileName);
|
String tipperListString = prov.getTippligaConfig(configFileName);
|
||||||
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
|
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
|
||||||
|
|
||||||
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
|
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class TLWMatchesManagerBase {
|
|||||||
protected void initConfigParamsFromFile(String configFileName) {
|
protected void initConfigParamsFromFile(String configFileName) {
|
||||||
|
|
||||||
GistProvider prov = GistProvider.getInstance();
|
GistProvider prov = GistProvider.getInstance();
|
||||||
String jsonConfig = prov.getTippligaConfig(season, configFileName);
|
String jsonConfig = prov.getTippligaConfig(configFileName);
|
||||||
try {
|
try {
|
||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
//Read JSON file
|
//Read JSON file
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package de.jeyp91.tippliga;
|
package de.jeyp91.tippliga;
|
||||||
|
|
||||||
import com.google.api.client.util.DateTime;
|
|
||||||
import de.jeyp91.App;
|
import de.jeyp91.App;
|
||||||
import de.jeyp91.TeamIDMatcher;
|
import de.jeyp91.TeamIDMatcher;
|
||||||
import de.jeyp91.apifootball.APIFootballMatch;
|
import de.jeyp91.apifootball.APIFootballMatch;
|
||||||
@@ -10,14 +9,11 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
import javax.sound.midi.SysexMessage;
|
|
||||||
import java.time.*;
|
import java.time.*;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
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> tlwMatchesOriginal;
|
||||||
ArrayList<TLWMatch> tlwMatchesUpdated;
|
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> tlwMatchesOriginalMatchday = tippligaSQLConnector.getMatches(String.valueOf(this.season), String.valueOf(this.league), String.valueOf(tlwMatchday));
|
||||||
ArrayList<TLWMatch> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
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()) {
|
if (apiFootballMatches.size() > tlwMatchesUpdatedMatchday.size()) {
|
||||||
logger.error("Not matching config!");
|
logger.error("Not matching config!");
|
||||||
@@ -55,6 +53,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
|
|
||||||
addMissingMatches(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
addMissingMatches(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||||
updateMatchDateTimes(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
updateMatchDateTimes(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||||
|
updateShowTable(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||||
updateStatus(tlwMatchesUpdatedMatchday);
|
updateStatus(tlwMatchesUpdatedMatchday);
|
||||||
|
|
||||||
this.tlwMatchesOriginal.addAll(tlwMatchesOriginalMatchday);
|
this.tlwMatchesOriginal.addAll(tlwMatchesOriginalMatchday);
|
||||||
@@ -87,7 +86,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
"Spielnummer " + matchOriginal.getMatchNo() + ", " +
|
"Spielnummer " + matchOriginal.getMatchNo() + ", " +
|
||||||
"Spiel '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdHome()) + "' - '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdGuest()) + "', ";
|
"Spiel '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdHome()) + "' - '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdGuest()) + "', ";
|
||||||
|
|
||||||
if(matchOriginal.getTeamIdHome() != matchUpdated.getTeamIdHome()) {
|
if(!matchOriginal.getTeamIdHome().equals(matchUpdated.getTeamIdHome())) {
|
||||||
updateString += updateStart +
|
updateString += updateStart +
|
||||||
"team_id_home = " + matchUpdated.getTeamIdHome() + " " +
|
"team_id_home = " + matchUpdated.getTeamIdHome() + " " +
|
||||||
condition;
|
condition;
|
||||||
@@ -95,7 +94,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
"Heimteam zu '" + matchUpdated.getTeamNameHome() + "'.\n";
|
"Heimteam zu '" + matchUpdated.getTeamNameHome() + "'.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(matchOriginal.getTeamIdGuest() != matchUpdated.getTeamIdGuest()) {
|
if(!matchOriginal.getTeamIdGuest().equals(matchUpdated.getTeamIdGuest())) {
|
||||||
updateString += updateStart +
|
updateString += updateStart +
|
||||||
"team_id_guest = " + matchUpdated.getTeamIdGuest() + " " +
|
"team_id_guest = " + matchUpdated.getTeamIdGuest() + " " +
|
||||||
condition;
|
condition;
|
||||||
@@ -119,6 +118,14 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
"Status zu '" + matchUpdated.getStatus() + "'.\n";
|
"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;
|
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) {
|
private TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) {
|
||||||
int foundMatches = 0;
|
int foundMatches = 0;
|
||||||
TLWMatch matchingMatch = null;
|
TLWMatch matchingMatch = null;
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ public class GistProviderTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getFileTest() {
|
public void getFileTest() {
|
||||||
GistProvider prov = GistProvider.getInstance();
|
GistProvider prov = GistProvider.getInstance();
|
||||||
String id = prov.getGistID("Team_ID_Matcher");
|
String file = prov.getFileFromGist("Team_ID_Matcher.json");
|
||||||
String file = prov.getFileFromGist(id,"Team_ID_Matcher.json");
|
|
||||||
System.out.println(file);
|
System.out.println(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
41
src/test/java/de/jeyp91/gists/MatchesListCreatorTest.java
Normal file
41
src/test/java/de/jeyp91/gists/MatchesListCreatorTest.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package de.jeyp91.gists;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class MatchesListCreatorTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchesTest2664() {
|
||||||
|
MatchesListCreator creator = new MatchesListCreator(2664);
|
||||||
|
String matches = creator.getMatchesBeautful();
|
||||||
|
System.out.println(matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchesTest2743() {
|
||||||
|
MatchesListCreator creator = new MatchesListCreator(2743);
|
||||||
|
String matches = creator.getMatchesBeautful();
|
||||||
|
System.out.println(matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchesTest2755() {
|
||||||
|
MatchesListCreator creator = new MatchesListCreator(2755);
|
||||||
|
String matches = creator.getMatchesBeautful();
|
||||||
|
System.out.println(matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchesTest2790() {
|
||||||
|
MatchesListCreator creator = new MatchesListCreator(2790);
|
||||||
|
String matches = creator.getMatchesBeautful();
|
||||||
|
System.out.println(matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchesTest2795() {
|
||||||
|
MatchesListCreator creator = new MatchesListCreator(2795);
|
||||||
|
String matches = creator.getMatchesBeautful();
|
||||||
|
System.out.println(matches);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user