Improve error output and add team id matcher template creator

This commit is contained in:
2020-11-04 21:22:27 +01:00
parent 2f411aae67
commit d42edcf01c
15 changed files with 158 additions and 154 deletions

View File

@@ -94,29 +94,13 @@ public class TLWMatch extends BaseMatch{
}
}
public TLWMatch(OpenLigaDBMatch oldbmatch, int season, int league, int matchday, int matchNo) {
this.season = season;
this.league = league;
this.matchday = matchday;
this.matchNo = matchNo;
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(oldbmatch.getTeamIdHome());
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(oldbmatch.getTeamIdGuest());
this.goalsHome = oldbmatch.getGoalsHome();
this.goalsGuest = oldbmatch.getGoalsGuest();
this.matchDatetime = oldbmatch.getMatchDateTime().replace("T", " ");
this.groupId = "";
this.formulaHome = "";
this.formulaGuest = "";
this.status = 0;
}
public TLWMatch(APIFootballMatch apiFootballMatch, int season, int league, int matchday, int matchNo, int status, int koMatch) {
this.season = season;
this.league = league;
this.matchday = matchday;
this.matchNo = matchNo;
this.teamIdHome = this.getTeamIdHomeFromApiFootballMatch(apiFootballMatch);
this.teamIdGuest = this.getTeamIdGuestFromApiFootballMatch(apiFootballMatch);
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST);
this.goalsHome = apiFootballMatch.getGoalsHome();
this.goalsGuest = apiFootballMatch.getGoalsGuest();
this.matchDatetime = apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19);
@@ -279,30 +263,12 @@ public class TLWMatch extends BaseMatch{
}
public void updateMatch(APIFootballMatch apiFootballMatch) {
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch.getTeamIdHome());
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch.getTeamIdGuest());
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST);
this.teamNameHome = apiFootballMatch.getTeamNameHome();
this.teamNameGuest = apiFootballMatch.getTeamNameGuest();
this.goalsHome = apiFootballMatch.getGoalsHome();
this.goalsGuest = apiFootballMatch.getGoalsGuest();
this.matchDatetime = apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19);
}
private Integer getTeamIdHomeFromApiFootballMatch(APIFootballMatch match) {
Integer id = TeamIDMatcher.getTippligaIdFromApiFootballId(match.getTeamIdHome());
if(id == null) {
logger.error("Could not find id " + match.getTeamIdHome() + " for " + match.getTeamNameHome());
StatusHolder.setError();
}
return id;
}
private Integer getTeamIdGuestFromApiFootballMatch(APIFootballMatch match) {
Integer id = TeamIDMatcher.getTippligaIdFromApiFootballId(match.getTeamIdGuest());
if(id == null) {
logger.error("Could not find id " + match.getTeamIdGuest() + " for " + match.getTeamNameGuest());
StatusHolder.setError();
}
return id;
}
}