Add show table update, add matches list creator
This commit is contained in:
@@ -17,8 +17,8 @@ public class APIFootballConnector {
|
||||
private static APIFootballConnector conn = null;
|
||||
private final int season;
|
||||
private final String gistId;
|
||||
private HashMap<String, JSONObject> rounds = new HashMap<>();
|
||||
private HashMap<String, JSONObject> matches = new HashMap<>();
|
||||
private final HashMap<String, JSONObject> rounds = new HashMap<>();
|
||||
private final HashMap<String, JSONObject> matches = new HashMap<>();
|
||||
|
||||
private APIFootballConnector(int season) {
|
||||
this.season = season;
|
||||
@@ -94,7 +94,7 @@ public class APIFootballConnector {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getFileFromGist(this.gistId, filename);
|
||||
String jsonConfig = prov.getFileFromGist(filename);
|
||||
|
||||
try {
|
||||
object = (JSONObject) jsonParser.parse(jsonConfig);
|
||||
@@ -111,7 +111,7 @@ public class APIFootballConnector {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getFileFromGist(this.gistId, filename);
|
||||
String jsonConfig = prov.getFileFromGist(filename);
|
||||
|
||||
try {
|
||||
object = (JSONArray) jsonParser.parse(jsonConfig);
|
||||
|
||||
@@ -20,6 +20,7 @@ public class APIFootballMatch extends BaseMatch {
|
||||
private String matchStatus;
|
||||
private final String teamNameHome;
|
||||
private final String teamNameGuest;
|
||||
private Boolean showTable = null;
|
||||
|
||||
public APIFootballMatch(JSONObject json, int season) {
|
||||
this.season = season;
|
||||
@@ -67,4 +68,12 @@ public class APIFootballMatch extends BaseMatch {
|
||||
public String getTeamNameGuest() {
|
||||
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) {
|
||||
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
||||
String type = (String) singleConfig.get("type");
|
||||
boolean showTable = false;
|
||||
switch (type) {
|
||||
case "AllMatchesOfMatchday":
|
||||
int matchesLeague = ((Long) singleConfig.get("matchesLeague")).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;
|
||||
case "SingleMatch":
|
||||
int matchLeague = ((Long) singleConfig.get("matchLeague")).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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class APIFootballUpdater {
|
||||
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getTippligaConfig(this.season, config);
|
||||
String jsonConfig = prov.getTippligaConfig(config);
|
||||
JSONObject configObject = null;
|
||||
try {
|
||||
configObject = (JSONObject) jsonParser.parse(jsonConfig);
|
||||
|
||||
Reference in New Issue
Block a user