diff --git a/README.md b/README.md index a9301f5f..6add0cc9 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![GitHub commit activity](https://img.shields.io/github/commit-activity/y/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager) [![GitHub last commit](https://img.shields.io/github/last-commit/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager) [![CircleCI](https://circleci.com/gh/softwaremagico/KendoTournamentManager.svg?style=shield)](https://circleci.com/gh/softwaremagico/KendoTournamentManager) -[![Time](https://img.shields.io/badge/development-622.5h-blueviolet.svg)]() +[![Time](https://img.shields.io/badge/development-623h-blueviolet.svg)]() [![Powered by](https://img.shields.io/badge/powered%20by%20java-orange.svg?logo=OpenJDK&logoColor=white)]() [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=kendo-tournament-backend&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=kendo-tournament-backend) diff --git a/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/html/lists/BlogExporter.java b/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/html/lists/BlogExporter.java index 46399218..67faef5d 100644 --- a/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/html/lists/BlogExporter.java +++ b/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/html/lists/BlogExporter.java @@ -161,13 +161,13 @@ private void addScoreTables(StringBuilder stringBuilder, TournamentDTO tournamen String name; name = NameUtils.getLastnameName(competitor); columns.add(name); - columns.add(getFaults(fight, teamMember, true)); - columns.add(getScore(fight, teamMember, 1, true)); - columns.add(getScore(fight, teamMember, 0, true)); + columns.add(getFaultsDiv(fight, teamMember, true)); + columns.add(getScoreDiv(fight, teamMember, 1, true)); + columns.add(getScoreDiv(fight, teamMember, 0, true)); columns.add(getDrawFight(fight, teamMember)); - columns.add(getScore(fight, teamMember, 0, false)); - columns.add(getScore(fight, teamMember, 1, false)); - columns.add(getFaults(fight, teamMember, false)); + columns.add(getScoreDiv(fight, teamMember, 0, false)); + columns.add(getScoreDiv(fight, teamMember, 1, false)); + columns.add(getFaultsDiv(fight, teamMember, false)); // Team 2 competitor = fight.getTeam2().getMembers().get(teamMember); @@ -257,38 +257,67 @@ private String getDrawFight(FightDTO fightDTO, int duel) { // Draw Fights final String draw; if (fightDTO.getDuels().get(duel).getWinner() == 0 && fightDTO.isOver()) { - draw = String.valueOf(Score.DRAW.getPdfAbbreviation()); + return "
" + + Score.DRAW.getPdfAbbreviation() + + "
"; } else { - draw = String.valueOf(Score.EMPTY.getPdfAbbreviation()); + return String.valueOf(Score.EMPTY.getPdfAbbreviation()); } - return draw; } - private String getFaults(FightDTO fightDTO, int duel, boolean leftTeam) { - final String faultSymbol; + private String getFaultsDiv(FightDTO fightDTO, int duel, boolean leftTeam) { + final boolean fault = getFaults(fightDTO, duel, leftTeam); + if (!fault) { + return ""; + } + return "
" + + "
"; + } + + private boolean getFaults(FightDTO fightDTO, int duel, boolean leftTeam) { final boolean faults; if (leftTeam) { - faults = fightDTO.getDuels().get(duel).getCompetitor1Fault(); + return fightDTO.getDuels().get(duel).getCompetitor1Fault(); } else { - faults = fightDTO.getDuels().get(duel).getCompetitor2Fault(); + return fightDTO.getDuels().get(duel).getCompetitor2Fault(); } - if (faults) { - faultSymbol = String.valueOf(Score.FAULT.getPdfAbbreviation()); - } else { - faultSymbol = String.valueOf(Score.EMPTY.getPdfAbbreviation()); + } + + private String getScoreDiv(FightDTO fightDTO, int duel, int score, boolean leftTeam) { + final Score scoreText = getScore(fightDTO, duel, score, leftTeam); + if (scoreText == null || scoreText == Score.EMPTY) { + return ""; } - return faultSymbol; + final int scoreTime = getScoreTime(fightDTO, duel, score, leftTeam); + return "
0 ? " title=\"" + scoreTime + ""\">" : ">") + + String.valueOf(scoreText.getPdfAbbreviation()).replace(" ", " ") + + "
"; } - private String getScore(FightDTO fightDTO, int duel, int score, boolean leftTeam) { + private int getScoreTime(FightDTO fightDTO, int duel, int score, boolean leftTeam) { + final int time; try { if (leftTeam) { - return String.valueOf(fightDTO.getDuels().get(duel).getCompetitor1Score().get(score).getPdfAbbreviation()); + time = fightDTO.getDuels().get(duel).getCompetitor1ScoreTime().get(score); } else { - return String.valueOf(fightDTO.getDuels().get(duel).getCompetitor2Score().get(score).getPdfAbbreviation()); + time = fightDTO.getDuels().get(duel).getCompetitor2ScoreTime().get(score); + } + return time; + } catch (Exception ignored) { + } + return -1; + } + + private Score getScore(FightDTO fightDTO, int duel, int score, boolean leftTeam) { + try { + if (leftTeam) { + return fightDTO.getDuels().get(duel).getCompetitor1Score().get(score); + } else { + return fightDTO.getDuels().get(duel).getCompetitor2Score().get(score); } } catch (IndexOutOfBoundsException | NullPointerException e) { - return ""; + return null; } } }