97 lines
4.0 KiB
Java
97 lines
4.0 KiB
Java
package de.jeyp91;
|
|
|
|
import org.json.simple.JSONArray;
|
|
import org.json.simple.JSONObject;
|
|
|
|
public class MatchUtils {
|
|
|
|
/*
|
|
|
|
public void updateDataFromOpenLigaDb(JSONArray openLigaDbData) throws Exception {
|
|
loopOverAllMatchdays:
|
|
for(int i = 0; i < openLigaDbData.size(); i++) {
|
|
for(int j = 0; j < ((JSONArray)(openLigaDbData.get(i))).size(); j++) {
|
|
Match tempMatch = new Match(this.season, this.league, this.matchday, this.matchNo, (JSONObject)(((JSONArray)openLigaDbData.get(i)).get(j)));
|
|
if(isSameMatch(tempMatch)) {
|
|
break loopOverAllMatchdays;
|
|
}
|
|
updateDateTime(tempMatch);
|
|
updateResult(tempMatch);
|
|
}
|
|
}
|
|
}
|
|
|
|
public boolean updateDateTime(Match compareMatch) {
|
|
if(!this.getSeason().equals(compareMatch.getSeason())) {
|
|
return false;
|
|
}
|
|
if(!this.getLeague().equals(compareMatch.getLeague())) {
|
|
return false;
|
|
}
|
|
if(!this.getMatchday().equals(compareMatch.getMatchday())) {
|
|
return false;
|
|
}
|
|
if(this.getTeamIdHome() == null || compareMatch.getTeamIdHome() == null
|
|
|| (this.getTeamIdHome() != compareMatch.getTeamIdHome())) {
|
|
return false;
|
|
}
|
|
if(this.getTeamIdGuest() == null || compareMatch.getTeamIdGuest() == null
|
|
|| (this.getTeamIdGuest() != compareMatch.getTeamIdGuest())) {
|
|
return false;
|
|
}
|
|
|
|
String thisDateTime = this.getMatchDateTime().replace("T", " ");
|
|
String tempDateTime = compareMatch.getMatchDateTime().replace("T", " ");
|
|
if(!tempDateTime.equals(thisDateTime)) {
|
|
// System.out.println(String.valueOf(this.matchNo) + ":");
|
|
// System.out.println("Old date: " + thisDateTime + "; New date: " + tempDateTime);
|
|
// System.out.println();
|
|
|
|
// String updateQuery = "UPDATE phpbb_footb_matches SET match_datetime = '" + tempDateTime + "' WHERE season = " + this.season + " AND league = " + this.league + " AND match_no = " + this.matchNo + " AND team_id_home = " + this.teamIdHome + " AND team_id_guest = " + this.teamIdGuest + " AND match_datetime = '" + this.matchDatetime + "';";
|
|
// System.out.println(updateQuery);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public boolean updateResult(Match compareMatch) {
|
|
if(!this.getSeason().equals(compareMatch.getSeason())) {
|
|
return false;
|
|
}
|
|
if(!this.getLeague().equals(compareMatch.getLeague())) {
|
|
return false;
|
|
}
|
|
if(!this.getMatchday().equals(compareMatch.getMatchday())) {
|
|
return false;
|
|
}
|
|
if(this.getTeamIdHome() == null || compareMatch.getTeamIdHome() == null
|
|
|| (this.getTeamIdHome() != compareMatch.getTeamIdHome())) {
|
|
return false;
|
|
}
|
|
if(this.getTeamIdGuest() == null || compareMatch.getTeamIdGuest() == null
|
|
|| (this.getTeamIdGuest() != compareMatch.getTeamIdGuest())) {
|
|
return false;
|
|
}
|
|
String thisDateTime = this.getMatchDateTime().replace("T", " ");
|
|
String tempDateTime = compareMatch.getMatchDateTime().replace("T", " ");
|
|
if(!tempDateTime.equals(thisDateTime)) {
|
|
return false;
|
|
}
|
|
|
|
if(this.goalsHome != compareMatch.goalsHome ||
|
|
this.goalsGuest != compareMatch.goalsGuest &&
|
|
this.goalsHome != null && this.goalsGuest != null && compareMatch.goalsHome != null && compareMatch.goalsGuest != null) {
|
|
String oldResult = String.valueOf(this.goalsHome) + " : " + String.valueOf(this.goalsGuest);
|
|
String newResult = String.valueOf(compareMatch.goalsHome) + " : " + String.valueOf(compareMatch.goalsGuest);
|
|
|
|
System.out.println(String.valueOf(this.matchNo) + ":");
|
|
System.out.println(this.matchDatetime + " Old result: " + oldResult + "; New result: " + newResult);
|
|
System.out.println();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
*/
|
|
}
|