Prepare WM Tippspiel

This commit is contained in:
2026-05-27 23:36:18 +02:00
parent 91f2f3171c
commit 3da3d02cb1
10 changed files with 292 additions and 236 deletions
+14 -10
View File
@@ -4,13 +4,13 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Objects;
import de.jeyp91.App;
import de.jeyp91.BaseMatch;
import de.jeyp91.teamidmatcher.TeamIDMatcher;
import de.jeyp91.apifootball.APIFootballMatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.jeyp91.BaseMatch;
import de.jeyp91.apifootball.APIFootballMatch;
import de.jeyp91.teamidmatcher.TeamIDMatcher;
/**
*
*/
@@ -179,19 +179,19 @@ public class TLWMatch extends BaseMatch{
}
public String getFormulaHome() {
String formula = "'D'";
String formula = "D";
if (this.formulaHome != null) {
formula = this.formulaHome;
}
return formula;
return "'" + formula + "'";
}
public String getFormulaGuest() {
String formula = "'D'";
String formula = "D";
if (this.formulaGuest != null) {
formula = this.formulaGuest;
}
return formula;
return "'" + formula + "'";
}
public String getSQLQueryInsert() {
@@ -210,8 +210,8 @@ public class TLWMatch extends BaseMatch{
return this.season + ", " +
this.league + ", " +
this.matchNo + ", " +
nullToSqlEmptyString(this.teamIdHome) + ", " +
nullToSqlEmptyString(this.teamIdGuest) + ", " +
nullToSqlNullString(this.teamIdHome) + ", " +
nullToSqlNullString(this.teamIdGuest) + ", " +
nullToSqlEmptyString(this.goalsHome) + ", " +
nullToSqlEmptyString(this.goalsGuest) + ", " +
this.matchday + ", " +
@@ -231,6 +231,10 @@ public class TLWMatch extends BaseMatch{
return number != null ? number.toString() : "''";
}
private String nullToSqlNullString(Integer number) {
return number != null ? number.toString() : "0";
}
private String nullToSqlEmptyString(String string) {
return string != null ? "'"+string+"'" : "''";
}
@@ -157,6 +157,9 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
ArrayList<APIFootballMatch> apiFootballMatches) {
ArrayList<APIFootballMatch> missingMatches = new ArrayList<>();
if(!validateApiFootballTeamIds(apiFootballMatches)) {
return;
}
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) {
@@ -316,4 +319,20 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
public String getBeautifulInfo() {
return this.beautifulInfo;
}
private boolean validateApiFootballTeamIds(ArrayList<APIFootballMatch> apiFootballMatches) {
int missing = 0;
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
if(TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME) == null) {
missing++;
}
if(TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST) == null) {
missing++;
}
}
return missing == 0;
}
}