Refactor and clean up code
This commit is contained in:
@@ -127,8 +127,6 @@ public class TLWMatch extends BaseMatch {
|
||||
this.matchday = matchday;
|
||||
this.league = league;
|
||||
this.matchNo = matchNo;
|
||||
this.formulaHome = "D";
|
||||
this.formulaGuest = "D";
|
||||
this.status = status;
|
||||
this.koMatch = koMatch;
|
||||
this.matchDatetime = matchDatetime;
|
||||
@@ -169,35 +167,42 @@ public class TLWMatch extends BaseMatch {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public Integer isSameMatch(OpenLigaDBMatch compareMatch) {
|
||||
if(this.getSeason() != compareMatch.getSeason()) {
|
||||
return COMPARISON_DIFFERENT;
|
||||
public String getFormulaHome() {
|
||||
String formula = "'D'";
|
||||
if(this.teamIdHome != null) {
|
||||
return "''";
|
||||
}
|
||||
if(this.getMatchday() != compareMatch.getMatchday()) {
|
||||
return COMPARISON_DIFFERENT;
|
||||
else if (this.formulaHome != null) {
|
||||
formula = this.formulaHome;
|
||||
}
|
||||
if(this.getTeamIdHome() != compareMatch.getTeamIdHome()) {
|
||||
return COMPARISON_DIFFERENT;
|
||||
return formula;
|
||||
}
|
||||
|
||||
public String getFormulaGuest() {
|
||||
String formula = "'D'";
|
||||
if(this.teamIdGuest != null) {
|
||||
return "''";
|
||||
}
|
||||
if(this.getTeamIdGuest() != compareMatch.getTeamIdGuest()) {
|
||||
return COMPARISON_DIFFERENT;
|
||||
else if (this.formulaGuest != null) {
|
||||
formula = this.formulaGuest;
|
||||
}
|
||||
String thisDateTime = this.getMatchDateTime().replace("T", " ");
|
||||
String tempDateTime = compareMatch.getMatchDateTime().replace("T", " ");
|
||||
if(!tempDateTime.equals(thisDateTime)) {
|
||||
return COMPARISON_DIFFERENT_DATETIME;
|
||||
}
|
||||
if(this.goalsHome != compareMatch.getGoalsHome() ||
|
||||
this.goalsGuest != compareMatch.getGoalsGuest()) {
|
||||
return COMPARISON_DIFFERENT_RESULT;
|
||||
}
|
||||
return COMPARISON_IDENTICAL;
|
||||
return formula;
|
||||
}
|
||||
|
||||
public String getSQLQueryInsert() {
|
||||
return "INSERT INTO phpbb_footb_matches VALUES (" +
|
||||
getSQLQueryValues()
|
||||
+ ");";
|
||||
}
|
||||
|
||||
public String getSQLQueryReplace() {
|
||||
return "REPLACE INTO phpbb_footb_matches VALUES (" +
|
||||
getSQLQueryValues()
|
||||
+ ");";
|
||||
}
|
||||
|
||||
String query = "REPLACE INTO phpbb_footb_matches VALUES (" +
|
||||
this.season + ", " +
|
||||
public String getSQLQueryValues() {
|
||||
return this.season + ", " +
|
||||
this.league + ", " +
|
||||
this.matchNo + ", " +
|
||||
nullToSqlEmptyString(this.teamIdHome) + ", " +
|
||||
@@ -206,20 +211,22 @@ public class TLWMatch extends BaseMatch {
|
||||
nullToSqlEmptyString(this.goalsGuest) + ", " +
|
||||
this.matchday + ", " +
|
||||
this.status + ", " +
|
||||
"'" + this.matchDatetime + "', " +
|
||||
"'" + this.groupId + "', " +
|
||||
"'" + this.formulaHome + "', " +
|
||||
"'" + this.formulaGuest + "', " +
|
||||
nullToSqlEmptyString(this.matchDatetime) + ", " +
|
||||
nullToSqlEmptyString(this.groupId) + ", " +
|
||||
getFormulaHome() + ", " +
|
||||
getFormulaGuest() + ", " +
|
||||
nullToSqlEmptyString(this.koMatch) + ", " +
|
||||
nullToSqlEmptyString(this.goalsOvertimeHome) + ", " +
|
||||
nullToSqlEmptyString(this.goalsOvertimeGuest) + ", " +
|
||||
nullToSqlEmptyString(this.showTable) + ", " +
|
||||
"'0.00','0.00','0.00','0.00');";
|
||||
|
||||
return query;
|
||||
"'0.00','0.00','0.00','0.00'";
|
||||
}
|
||||
|
||||
private String nullToSqlEmptyString(Integer number) {
|
||||
return number != null ? number.toString() : "''";
|
||||
}
|
||||
|
||||
private String nullToSqlEmptyString(String string) {
|
||||
return string != null ? "'"+string+"'" : "''";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user