diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/FightStatisticsController.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/FightStatisticsController.java index ea2b2d2a5..1354b4d4e 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/FightStatisticsController.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/FightStatisticsController.java @@ -23,7 +23,7 @@ import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.controller.models.TournamentFightStatisticsDTO; import com.softwaremagico.kt.core.converters.TeamConverter; @@ -78,7 +78,7 @@ public TournamentFightStatisticsDTO estimateByMembers(TournamentDTO tournamentDT return convert(getProvider().estimateByMembers(tournamentConverter.reverse(tournamentDTO))); } - public TournamentFightStatisticsDTO estimate(TournamentDTO tournamentDTO, Collection teams) { + public TournamentFightStatisticsDTO estimate(TournamentDTO tournamentDTO, Collection teams) { return estimate(tournamentDTO, tournamentDTO.getTeamSize(), teams); } @@ -86,7 +86,7 @@ public TournamentFightStatisticsDTO estimateByRoles(TournamentDTO tournamentDTO, return estimate(tournamentDTO, emulateTeams(tournamentDTO, roles.stream().map(RoleDTO::getParticipant).toList())); } - public TournamentFightStatisticsDTO estimate(TournamentDTO tournamentDTO, int teamSize, Collection teams) { + public TournamentFightStatisticsDTO estimate(TournamentDTO tournamentDTO, int teamSize, Collection teams) { if (tournamentDTO == null || teams == null || teams.size() < 2) { return null; } @@ -102,15 +102,15 @@ public TournamentFightStatisticsDTO estimate(TournamentDTO tournamentDTO, int te } } - private TournamentFightStatisticsDTO estimateLeagueStatistics(int teamSize, Collection teams) { + private TournamentFightStatisticsDTO estimateLeagueStatistics(int teamSize, Collection teams) { return convert(getProvider().estimateLeagueStatistics(teamSize, teamConverter.reverseAll(teams))); } - private TournamentFightStatisticsDTO estimateLoopStatistics(TournamentDTO tournamentDTO, int teamSize, Collection teams) { + private TournamentFightStatisticsDTO estimateLoopStatistics(TournamentDTO tournamentDTO, int teamSize, Collection teams) { return convert(getProvider().estimateLoopStatistics(tournamentConverter.reverse(tournamentDTO), teamSize, teamConverter.reverseAll(teams))); } - private int getDuels(int fightByTeam, int teamSize, Collection teams) { + private int getDuels(int fightByTeam, int teamSize, Collection teams) { final AtomicInteger counter = new AtomicInteger(); final AtomicInteger missingMembers = new AtomicInteger(); @@ -130,10 +130,10 @@ private int getDuels(int fightByTeam, int teamSize, Collection teams) { * @param participants the list of members that will participate on the tournament. * @return a list of transient teams. */ - private List emulateTeams(TournamentDTO tournamentDTO, Collection participants) { + private List emulateTeams(TournamentDTO tournamentDTO, Collection participants) { int teamIndex = 0; - final List teams = new ArrayList<>(); - DTO team = null; + final List teams = new ArrayList<>(); + TeamDTO team = null; int teamMember = 0; @@ -141,7 +141,7 @@ private List emulateTeams(TournamentDTO tournamentDTO, Collection teams, String username) { + public GroupDTO addTeams(Integer groupId, List teams, String username) { return convert(getProvider().addTeams(groupId, teamConverter.reverseAll(teams), username)); } - public GroupDTO deleteTeams(Integer groupId, List teams, String username) { + public GroupDTO deleteTeams(Integer groupId, List teams, String username) { return convert(getProvider().deleteTeams(groupId, teamConverter.reverseAll(teams), username)); } @@ -161,13 +161,13 @@ public List deleteTeamsFromTournament(Integer tournamentId, String use username)); } - public List deleteTeamsFromTournament(Integer tournamentId, List teams, String username) { + public List deleteTeamsFromTournament(Integer tournamentId, List teams, String username) { return convertAll(getProvider().deleteTeams(tournamentProvider.get(tournamentId).orElseThrow(() -> new TournamentNotFoundException(this.getClass(), "Tournament with id" + tournamentId + " not found!")), teamConverter.reverseAll(teams), username)); } - public GroupDTO setTeams(Integer groupId, List teams, String username) { + public GroupDTO setTeams(Integer groupId, List teams, String username) { GroupDTO groupDTO = get(groupId); final List fights = new ArrayList<>(groupDTO.getFights()); @@ -185,7 +185,7 @@ public GroupDTO setTeams(Integer groupId, List teams, String username) { return convert(getProvider().save(reverse(groupDTO))); } - public GroupDTO setTeams(List teams, String username) { + public GroupDTO setTeams(List teams, String username) { if (teams.isEmpty()) { throw new TeamNotFoundException(this.getClass(), "No teams found!"); } diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/RankingController.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/RankingController.java index de13c6a07..30ec90291 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/RankingController.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/RankingController.java @@ -27,7 +27,7 @@ import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.ScoreOfCompetitorDTO; import com.softwaremagico.kt.core.controller.models.ScoreOfTeamDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.converters.DuelConverter; import com.softwaremagico.kt.core.converters.FightConverter; @@ -105,9 +105,9 @@ public RankingController(GroupProvider groupProvider, GroupConverter groupConver this.scoreOfTeamConverter = scoreOfTeamConverter; } - private static Set getParticipants(List teams) { + private static Set getParticipants(List teams) { final Set allCompetitors = new HashSet<>(); - for (final DTO team : teams) { + for (final TeamDTO team : teams) { allCompetitors.addAll(team.getMembers()); } return allCompetitors; @@ -117,7 +117,7 @@ private boolean checkLevel(TournamentDTO tournament) { return tournament == null || tournament.getType() != TournamentType.KING_OF_THE_MOUNTAIN; } - public List getTeamsRanking(GroupDTO groupDTO) { + public List getTeamsRanking(GroupDTO groupDTO) { return teamConverter.convertAll(rankingProvider.getTeamsRanking(groupConverter.reverse(groupDTO)) .stream().map(TeamConverterRequest::new).toList()); } @@ -143,7 +143,7 @@ public List getTeamsScoreRanking(GroupDTO groupDTO) { groupDTO.getTeams(), groupDTO.getFights(), groupDTO.getUnties(), checkLevel(groupDTO.getTournament())); } - public List getTeamsScoreRanking(ScoreType type, List teams, List fights, List unties, + public List getTeamsScoreRanking(ScoreType type, List teams, List fights, List unties, boolean checkLevel) { return scoreOfTeamConverter.convertAll(rankingProvider.getTeamsScoreRanking( type, @@ -165,18 +165,18 @@ public List getTeamsScoreRanking(TournamentDTO tournamentDTO) { * * @return classification of the teams */ - public Map> getTeamsByPosition(GroupDTO groupDTO) { + public Map> getTeamsByPosition(GroupDTO groupDTO) { final Map> teamsByPosition = rankingProvider.getTeamsByPosition(groupConverter.reverse(groupDTO)); - final Map> teamsByPositionDTO = new HashMap<>(); + final Map> teamsByPositionDTO = new HashMap<>(); teamsByPosition.keySet().forEach(key -> teamsByPositionDTO.put(key, teamConverter.convertAll(teamsByPosition.get(key) .stream().map(TeamConverterRequest::new).toList()))); return teamsByPositionDTO; } - public List getFirstTeamsWithDrawScore(GroupDTO groupDTO, Integer maxWinners) { - final Map> teamsByPosition = getTeamsByPosition(groupDTO); + public List getFirstTeamsWithDrawScore(GroupDTO groupDTO, Integer maxWinners) { + final Map> teamsByPosition = getTeamsByPosition(groupDTO); for (int i = 0; i < maxWinners; i++) { - final List teamsInDraw = teamsByPosition.get(i); + final List teamsInDraw = teamsByPosition.get(i); if (teamsInDraw.size() > 1) { return teamsInDraw; } @@ -184,8 +184,8 @@ public List getFirstTeamsWithDrawScore(GroupDTO groupDTO, Integer maxWinner return new ArrayList<>(); } - public DTO getTeam(GroupDTO groupDTO, Integer order) { - final List teamsOrder = getTeamsRanking(groupDTO); + public TeamDTO getTeam(GroupDTO groupDTO, Integer order) { + final List teamsOrder = getTeamsRanking(groupDTO); if (order >= 0 && order < teamsOrder.size()) { return teamsOrder.get(order); } @@ -262,7 +262,7 @@ public ScoreOfCompetitorDTO getScoreOfCompetitor(GroupDTO groupDTO, Integer orde .getScoreOfCompetitor(groupConverter.reverse(groupDTO), order))); } - public Integer getOrder(GroupDTO groupDTO, DTO teamDTO) { + public Integer getOrder(GroupDTO groupDTO, TeamDTO teamDTO) { return rankingProvider.getOrder(groupConverter.reverse(groupDTO), teamConverter.reverse(teamDTO)); } diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/TeamController.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/TeamController.java index d14dc0bb3..9072e3dfa 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/TeamController.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/TeamController.java @@ -21,8 +21,8 @@ * #L% */ -import com.softwaremagico.kt.core.controller.models.DTO; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.converters.ParticipantConverter; import com.softwaremagico.kt.core.converters.TeamConverter; @@ -45,7 +45,7 @@ import java.util.List; @Controller -public class TeamController extends BasicInsertableController { private final TournamentProvider tournamentProvider; private final TournamentConverter tournamentConverter; @@ -68,18 +68,18 @@ protected TeamConverterRequest createConverterRequest(Team entity) { return new TeamConverterRequest(entity); } - public List getAllByTournament(TournamentDTO tournamentDTO, String createdBy) { - final List teams = convertAll(getProvider().getAll(tournamentConverter.reverse(tournamentDTO))); + public List getAllByTournament(TournamentDTO tournamentDTO, String createdBy) { + final List teams = convertAll(getProvider().getAll(tournamentConverter.reverse(tournamentDTO))); if (teams.isEmpty()) { return convertAll(getProvider().createDefaultTeams(tournamentConverter.reverse(tournamentDTO), createdBy)); } return teams; } - public List getAllByTournament(Integer tournamentId, String createdBy) { + public List getAllByTournament(Integer tournamentId, String createdBy) { final Tournament tournament = tournamentProvider.get(tournamentId) .orElseThrow(() -> new TournamentNotFoundException(getClass(), "No tournament found with id '" + tournamentId + "'.")); - final List teams = convertAll(getProvider().getAll(tournament)); + final List teams = convertAll(getProvider().getAll(tournament)); if (teams.isEmpty()) { return convertAll(getProvider().createDefaultTeams(tournament, createdBy)); } @@ -92,21 +92,21 @@ public long countByTournament(Integer tournamentId) { } @Override - public DTO create(DTO teamDTO, String username) { + public TeamDTO create(TeamDTO teamDTO, String username) { if (teamDTO.getName() == null) { teamDTO.setName(getProvider().getNextDefaultName(tournamentConverter.reverse(teamDTO.getTournament()))); } - final DTO storedTeamDTO = super.create(teamDTO, username); + final TeamDTO storedTeamDTO = super.create(teamDTO, username); storedTeamDTO.setTournament(teamDTO.getTournament()); return storedTeamDTO; } - public List create(TournamentDTO tournamentDTO, String createdBy) { + public List create(TournamentDTO tournamentDTO, String createdBy) { return convertAll(getProvider().createDefaultTeams(tournamentConverter.reverse(tournamentDTO), createdBy)); } @Override - public List create(Collection teamsDTOs, String username) { + public List create(Collection teamsDTOs, String username) { teamsDTOs.forEach(teamDTO -> { if (teamDTO.getName() == null) { teamDTO.setName(getProvider().getNextDefaultName(tournamentConverter.reverse(teamDTO.getTournament()))); @@ -115,7 +115,7 @@ public List create(Collection teamsDTOs, String username) { return super.create(teamsDTOs, username); } - public DTO delete(TournamentDTO tournamentDTO, ParticipantDTO member) { + public TeamDTO delete(TournamentDTO tournamentDTO, ParticipantDTO member) { final Team team = getProvider().delete(tournamentConverter.reverse(tournamentDTO), participantConverter.reverse(member)).orElse(null); if (team != null) { return convert(team); @@ -133,7 +133,7 @@ public void delete(TournamentDTO tournamentDTO) { } @Override - public DTO update(DTO teamDTO, String username) { + public TeamDTO update(TeamDTO teamDTO, String username) { teamDTO.setUpdatedBy(username); validate(teamDTO); final Team dbTeam = super.getProvider().save(reverse(teamDTO)); @@ -146,7 +146,7 @@ public long count(TournamentDTO tournament) { } @Override - public void validate(DTO teamDTO) throws ValidateBadRequestException { + public void validate(TeamDTO teamDTO) throws ValidateBadRequestException { if (teamDTO == null || teamDTO.getTournament() == null) { throw new ValidateBadRequestException(getClass(), "Team data is missing"); } diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/FightDTO.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/FightDTO.java index 1268ac95c..a6298cf75 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/FightDTO.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/FightDTO.java @@ -27,8 +27,8 @@ import java.util.Objects; public class FightDTO extends ElementDTO { - private DTO team1; - private DTO team2; + private TeamDTO team1; + private TeamDTO team2; private TournamentDTO tournament; private Integer shiaijo; private List duels = new ArrayList<>(); @@ -39,7 +39,7 @@ public FightDTO() { super(); } - public FightDTO(TournamentDTO tournament, DTO team1, DTO team2, Integer shiaijo, Integer level) { + public FightDTO(TournamentDTO tournament, TeamDTO team1, TeamDTO team2, Integer shiaijo, Integer level) { this(); setTournament(tournament); setTeam1(team1); @@ -49,19 +49,19 @@ public FightDTO(TournamentDTO tournament, DTO team1, DTO team2, Integer shiaijo, } - public DTO getTeam1() { + public TeamDTO getTeam1() { return team1; } - public void setTeam1(DTO team1) { + public void setTeam1(TeamDTO team1) { this.team1 = team1; } - public DTO getTeam2() { + public TeamDTO getTeam2() { return team2; } - public void setTeam2(DTO team2) { + public void setTeam2(TeamDTO team2) { this.team2 = team2; } @@ -109,7 +109,7 @@ public boolean isOver() { return duels.stream().anyMatch(DuelDTO::isOver); } - public DTO getWinner() { + public TeamDTO getWinner() { int points = 0; for (int i = 0; i < getDuels().size(); i++) { points += getDuels().get(i).getWinner(); @@ -145,7 +145,7 @@ public boolean isDrawFight() { return getWinner() == null; } - public int getWonDuels(DTO team) { + public int getWonDuels(TeamDTO team) { if (Objects.equals(team1, team)) { return (int) getDuels().stream().filter(duel -> duel.getWinner() == -1).count(); } @@ -155,7 +155,7 @@ public int getWonDuels(DTO team) { return 0; } - public Integer getDrawDuels(DTO team) { + public Integer getDrawDuels(TeamDTO team) { int drawDuels = 0; if ((getTeam1().equals(team) || getTeam2().equals(team))) { drawDuels = (int) getDuels().stream().filter(duel -> duel.getWinner() == 0).count(); @@ -178,7 +178,7 @@ public Integer getScore(ParticipantDTO competitor) { return score; } - public Integer getScore(DTO team) { + public Integer getScore(TeamDTO team) { if (Objects.equals(team1, team)) { return getScoreTeam1(); } diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/GroupDTO.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/GroupDTO.java index 612bf8d25..cde63580f 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/GroupDTO.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/GroupDTO.java @@ -28,7 +28,7 @@ public class GroupDTO extends ElementDTO { private TournamentDTO tournament; - private List teams; + private List teams; private Integer shiaijo; @@ -50,11 +50,11 @@ public void setTournament(TournamentDTO tournamentDTO) { this.tournament = tournamentDTO; } - public List getTeams() { + public List getTeams() { return teams; } - public void setTeams(List teams) { + public void setTeams(List teams) { this.teams = teams; } diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/ScoreOfTeamDTO.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/ScoreOfTeamDTO.java index fa0cd9f4b..4c50b3488 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/ScoreOfTeamDTO.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/ScoreOfTeamDTO.java @@ -29,7 +29,7 @@ public class ScoreOfTeamDTO { - private DTO team; + private TeamDTO team; @JsonIgnore private List fights; @JsonIgnore @@ -48,18 +48,18 @@ public ScoreOfTeamDTO() { } - public ScoreOfTeamDTO(DTO team, List fights, List unties) { + public ScoreOfTeamDTO(TeamDTO team, List fights, List unties) { this.team = team; this.fights = fights; this.unties = unties; update(); } - public DTO getTeam() { + public TeamDTO getTeam() { return team; } - public void setTeam(DTO team) { + public void setTeam(TeamDTO team) { this.team = team; } @@ -97,7 +97,7 @@ public void setLevel() { public void setWonFights() { wonFights = 0; for (final FightDTO fight : fights) { - final DTO winner = fight.getWinner(); + final TeamDTO winner = fight.getWinner(); if (winner != null && winner.equals(team)) { wonFights++; } diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/DTO.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/TeamDTO.java similarity index 93% rename from backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/DTO.java rename to backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/TeamDTO.java index c2086fa12..6ad6786a8 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/DTO.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/controller/models/TeamDTO.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Objects; -public class DTO extends ElementDTO implements IName { +public class TeamDTO extends ElementDTO implements IName { private String name; @@ -37,12 +37,12 @@ public class DTO extends ElementDTO implements IName { private Integer group; - public DTO() { + public TeamDTO() { super(); members = new ArrayList<>(); } - public DTO(String name, TournamentDTO tournament) { + public TeamDTO(String name, TournamentDTO tournament) { this(); setName(name); setTournament(tournament); @@ -93,7 +93,7 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof DTO teamDTO)) { + if (!(o instanceof TeamDTO teamDTO)) { return false; } if (!super.equals(o)) { diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/converters/TeamConverter.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/converters/TeamConverter.java index 615b9ee67..13f011dbe 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/converters/TeamConverter.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/converters/TeamConverter.java @@ -21,7 +21,7 @@ * #L% */ -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.converters.models.ParticipantConverterRequest; import com.softwaremagico.kt.core.converters.models.TeamConverterRequest; import com.softwaremagico.kt.core.converters.models.TournamentConverterRequest; @@ -36,7 +36,7 @@ import java.util.ArrayList; @Component -public class TeamConverter extends ElementConverter { +public class TeamConverter extends ElementConverter { private final TournamentConverter tournamentConverter; private final ParticipantConverter participantConverter; private final TournamentProvider tournamentProvider; @@ -50,8 +50,8 @@ public TeamConverter(TournamentConverter tournamentConverter, ParticipantConvert @Override - protected DTO convertElement(TeamConverterRequest from) { - final DTO teamDTO = new DTO(); + protected TeamDTO convertElement(TeamConverterRequest from) { + final TeamDTO teamDTO = new TeamDTO(); BeanUtils.copyProperties(from.getEntity(), teamDTO, ConverterUtils.getNullPropertyNames(from.getEntity())); teamDTO.setMembers(new ArrayList<>()); @@ -75,7 +75,7 @@ protected DTO convertElement(TeamConverterRequest from) { } @Override - public Team reverse(DTO to) { + public Team reverse(TeamDTO to) { if (to == null) { return null; } diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/tournaments/KingOfTheMountainHandler.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/tournaments/KingOfTheMountainHandler.java index 35b77c39b..ef6cb0e14 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/tournaments/KingOfTheMountainHandler.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/tournaments/KingOfTheMountainHandler.java @@ -22,7 +22,7 @@ */ import com.softwaremagico.kt.core.controller.RankingController; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.converters.GroupConverter; import com.softwaremagico.kt.core.converters.TeamConverter; import com.softwaremagico.kt.core.converters.models.GroupConverterRequest; @@ -118,7 +118,7 @@ private List getGroupTeams(Tournament tournament, int level) { //Repository OrderByIndex not working well... groups.sort(Comparator.comparing(Group::getLevel).thenComparing(Group::getIndex)); final Group lastGroup = !groups.isEmpty() ? groups.get(groups.size() - 1) : null; - final Map> ranking = rankingController.getTeamsByPosition(groupConverter.convert(new GroupConverterRequest(lastGroup))); + final Map> ranking = rankingController.getTeamsByPosition(groupConverter.convert(new GroupConverterRequest(lastGroup))); //Previous winner with no draw if (lastGroup != null && ranking.get(0) != null && ranking.get(0).size() == 1) { final Team previousWinner = teamConverter.reverse(ranking.get(0).get(0)); diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/tournaments/LeagueHandler.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/tournaments/LeagueHandler.java index eebeb7d7b..2385ffa97 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/tournaments/LeagueHandler.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/tournaments/LeagueHandler.java @@ -22,7 +22,7 @@ */ import com.softwaremagico.kt.core.controller.RankingController; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.converters.GroupConverter; import com.softwaremagico.kt.core.converters.models.GroupConverterRequest; import com.softwaremagico.kt.core.exceptions.TournamentFinishedException; @@ -215,7 +215,7 @@ public void createNextLevel() throws TournamentFinishedException { @Override public boolean hasDrawScore(Group group) { - final List teamsInDraw = rankingController.getFirstTeamsWithDrawScore( + final List teamsInDraw = rankingController.getFirstTeamsWithDrawScore( groupConverter.convert(new GroupConverterRequest(group)), group.getNumberOfWinners()); return (teamsInDraw != null); } diff --git a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/TournamentTestUtils.java b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/TournamentTestUtils.java index 845229805..7a1128d02 100644 --- a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/TournamentTestUtils.java +++ b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/TournamentTestUtils.java @@ -32,7 +32,7 @@ import com.softwaremagico.kt.core.controller.models.GroupDTO; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.persistence.values.RoleType; import com.softwaremagico.kt.persistence.values.TournamentType; @@ -135,7 +135,7 @@ protected void addTeams(TournamentDTO tournamentDTO, int members) { List competitorsRolesDTO = roleController.get(tournamentDTO, RoleType.COMPETITOR); int teamIndex = 0; - DTO teamDTO = null; + TeamDTO teamDTO = null; int teamMember = 0; final GroupDTO groupDTO = groupController.get(tournamentDTO).get(0); @@ -144,7 +144,7 @@ protected void addTeams(TournamentDTO tournamentDTO, int members) { // Create a new team. if (teamDTO == null) { teamIndex++; - teamDTO = new DTO("Team" + String.format("%02d", teamIndex), tournamentDTO); + teamDTO = new TeamDTO("Team" + String.format("%02d", teamIndex), tournamentDTO); teamMember = 0; } diff --git a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/StatisticsTest.java b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/StatisticsTest.java index d036fb3f0..a999e3cbf 100644 --- a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/StatisticsTest.java +++ b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/StatisticsTest.java @@ -37,7 +37,7 @@ import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.ParticipantStatisticsDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.controller.models.TournamentStatisticsDTO; import com.softwaremagico.kt.core.managers.TeamsOrder; @@ -144,7 +144,7 @@ private void addTeams(TournamentDTO tournamentDTO) { List competitorsRolesDTO = roleController.get(tournamentDTO, RoleType.COMPETITOR); int teamIndex = 0; - DTO teamDTO = null; + TeamDTO teamDTO = null; int teamMember = 0; final GroupDTO groupDTO = groupController.get(tournamentDTO).get(0); @@ -153,7 +153,7 @@ private void addTeams(TournamentDTO tournamentDTO) { // Create a new team. if (teamDTO == null) { teamIndex++; - teamDTO = new DTO("Team" + String.format("%02d", teamIndex), tournamentDTO); + teamDTO = new TeamDTO("Team" + String.format("%02d", teamIndex), tournamentDTO); teamMember = 0; } diff --git a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/Tournament5GroupsTest.java b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/Tournament5GroupsTest.java index 190371a50..0c4a93d43 100644 --- a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/Tournament5GroupsTest.java +++ b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/Tournament5GroupsTest.java @@ -34,7 +34,7 @@ import com.softwaremagico.kt.core.controller.models.GroupDTO; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.converters.FightConverter; import com.softwaremagico.kt.core.converters.GroupConverter; @@ -165,7 +165,7 @@ public void add5Groups() { @Test(dependsOnMethods = {"add5Groups"}) public void addTeams() { int teamIndex = 0; - DTO team = null; + TeamDTO team = null; int teamMember = 0; final List groups = groupController.getGroups(tournamentDTO, 0); @@ -174,7 +174,7 @@ public void addTeams() { // Create a new team. if (team == null) { teamIndex++; - team = new DTO("Team" + String.format("%02d", teamIndex), tournamentDTO); + team = new TeamDTO("Team" + String.format("%02d", teamIndex), tournamentDTO); teamMember = 0; } diff --git a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/Tournament5GroupsTwoWinnersTest.java b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/Tournament5GroupsTwoWinnersTest.java index 5ed137b8a..99187e18c 100644 --- a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/Tournament5GroupsTwoWinnersTest.java +++ b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/Tournament5GroupsTwoWinnersTest.java @@ -35,7 +35,7 @@ import com.softwaremagico.kt.core.controller.models.GroupDTO; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.controller.models.TournamentExtraPropertyDTO; import com.softwaremagico.kt.core.converters.FightConverter; @@ -175,7 +175,7 @@ public void add5Groups() { @Test(dependsOnMethods = {"add5Groups"}) public void addTeams() { int teamIndex = 0; - DTO team = null; + TeamDTO team = null; int teamMember = 0; final List groups = groupController.getGroups(tournamentDTO, 0); @@ -184,7 +184,7 @@ public void addTeams() { // Create a new team. if (team == null) { teamIndex++; - team = new DTO("Team" + String.format("%02d", teamIndex), tournamentDTO); + team = new TeamDTO("Team" + String.format("%02d", teamIndex), tournamentDTO); teamMember = 0; } diff --git a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentLevelNotFinishedTest.java b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentLevelNotFinishedTest.java index 732035c8a..99282b588 100644 --- a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentLevelNotFinishedTest.java +++ b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentLevelNotFinishedTest.java @@ -34,7 +34,7 @@ import com.softwaremagico.kt.core.controller.models.GroupDTO; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.converters.FightConverter; import com.softwaremagico.kt.core.converters.GroupConverter; @@ -165,7 +165,7 @@ public void add4Groups() { @Test(dependsOnMethods = {"add4Groups"}) public void addTeams() { int teamIndex = 0; - DTO team = null; + TeamDTO team = null; int teamMember = 0; final List groups = groupController.getGroups(tournamentDTO, 0); @@ -174,7 +174,7 @@ public void addTeams() { // Create a new team. if (team == null) { teamIndex++; - team = new DTO("Team" + String.format("%02d", teamIndex), tournamentDTO); + team = new TeamDTO("Team" + String.format("%02d", teamIndex), tournamentDTO); teamMember = 0; } diff --git a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentTest.java b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentTest.java index 28913fb2e..e02098724 100644 --- a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentTest.java +++ b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentTest.java @@ -34,7 +34,7 @@ import com.softwaremagico.kt.core.controller.models.GroupDTO; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.converters.FightConverter; import com.softwaremagico.kt.core.converters.GroupConverter; @@ -165,7 +165,7 @@ public void add4Groups() { @Test(dependsOnMethods = {"add4Groups"}) public void addTeams() { int teamIndex = 0; - DTO team = null; + TeamDTO team = null; int teamMember = 0; final List groups = groupController.getGroups(tournamentDTO, 0); @@ -174,7 +174,7 @@ public void addTeams() { // Create a new team. if (team == null) { teamIndex++; - team = new DTO("Team" + String.format("%02d", teamIndex), tournamentDTO); + team = new TeamDTO("Team" + String.format("%02d", teamIndex), tournamentDTO); teamMember = 0; } diff --git a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentTwoWinnersTest.java b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentTwoWinnersTest.java index d49eb8677..c2ddc3287 100644 --- a/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentTwoWinnersTest.java +++ b/backend/kendo-tournament-core/src/test/java/com/softwaremagico/kt/core/tests/tournament/TournamentTwoWinnersTest.java @@ -35,7 +35,7 @@ import com.softwaremagico.kt.core.controller.models.GroupDTO; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.controller.models.TournamentExtraPropertyDTO; import com.softwaremagico.kt.core.converters.FightConverter; @@ -174,7 +174,7 @@ public void add4Groups() { @Test(dependsOnMethods = {"add4Groups"}) public void addTeams() { int teamIndex = 0; - DTO team = null; + TeamDTO team = null; int teamMember = 0; final List groups = groupController.getGroups(tournamentDTO, 0); @@ -183,7 +183,7 @@ public void addTeams() { // Create a new team. if (team == null) { teamIndex++; - team = new DTO("Team" + String.format("%02d", teamIndex), tournamentDTO); + team = new TeamDTO("Team" + String.format("%02d", teamIndex), tournamentDTO); teamMember = 0; } diff --git a/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/controller/PdfController.java b/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/controller/PdfController.java index 2e802dca6..cdbacee33 100644 --- a/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/controller/PdfController.java +++ b/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/controller/PdfController.java @@ -33,7 +33,7 @@ import com.softwaremagico.kt.core.controller.models.RoleDTO; import com.softwaremagico.kt.core.controller.models.ScoreOfCompetitorDTO; import com.softwaremagico.kt.core.controller.models.ScoreOfTeamDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.controller.models.TournamentExtraPropertyDTO; import com.softwaremagico.kt.core.controller.models.TournamentImageDTO; @@ -110,8 +110,8 @@ public RoleList generateClubList(Locale locale, TournamentDTO tournamentDTO) { } public TeamList generateTeamList(TournamentDTO tournamentDTO) { - final List teams = teamController.getAllByTournament(tournamentDTO, null); - teams.sort(Comparator.comparing(DTO::getName)); + final List teams = teamController.getAllByTournament(tournamentDTO, null); + teams.sort(Comparator.comparing(TeamDTO::getName)); return new TeamList(tournamentDTO, teams); } diff --git a/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/lists/GroupList.java b/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/lists/GroupList.java index 3c63b6a17..d07561c9f 100644 --- a/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/lists/GroupList.java +++ b/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/lists/GroupList.java @@ -33,7 +33,7 @@ import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfWriter; import com.softwaremagico.kt.core.controller.models.GroupDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.pdf.BaseColor; import com.softwaremagico.kt.pdf.EmptyPdfBodyException; @@ -77,7 +77,7 @@ public PdfPTable groupTable(GroupDTO groupDTO) { teamTable.addCell(getHeader4(messageSource.getMessage("tournament.group", null, locale) + " " + (groupDTO.getIndex() + 1), 0)); - for (final DTO teamDTO : groupDTO.getTeams()) { + for (final TeamDTO teamDTO : groupDTO.getTeams()) { teamTable.addCell(getCell(teamDTO.getName())); } diff --git a/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/lists/TeamList.java b/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/lists/TeamList.java index fc5047e3d..9ca0f07c1 100644 --- a/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/lists/TeamList.java +++ b/backend/kendo-tournament-pdf/src/main/java/com/softwaremagico/kt/pdf/lists/TeamList.java @@ -33,7 +33,7 @@ import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfWriter; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.pdf.BaseColor; import com.softwaremagico.kt.pdf.EmptyPdfBodyException; @@ -48,9 +48,9 @@ public class TeamList extends ParentList { private static final int BORDER = 0; private final TournamentDTO tournament; - private final List teams; + private final List teams; - public TeamList(TournamentDTO tournament, List teams) { + public TeamList(TournamentDTO tournament, List teams) { this.tournament = tournament; this.teams = teams; } @@ -63,7 +63,7 @@ public void setTableProperties(PdfPTable mainTable) { mainTable.setWidthPercentage(TOTAL_WIDTH); } - public PdfPTable teamTable(DTO teamDTO) { + public PdfPTable teamTable(TeamDTO teamDTO) { final PdfPTable teamTable = new PdfPTable(1); teamTable.addCell(getHeader4(NameUtils.getShortName(teamDTO), 0)); diff --git a/backend/kendo-tournament-pdf/src/test/java/com/softwaremagico/kt/utils/BasicDataTest.java b/backend/kendo-tournament-pdf/src/test/java/com/softwaremagico/kt/utils/BasicDataTest.java index 9a276901b..058e9073d 100644 --- a/backend/kendo-tournament-pdf/src/test/java/com/softwaremagico/kt/utils/BasicDataTest.java +++ b/backend/kendo-tournament-pdf/src/test/java/com/softwaremagico/kt/utils/BasicDataTest.java @@ -34,7 +34,7 @@ import com.softwaremagico.kt.core.controller.models.GroupDTO; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.persistence.values.RoleType; import com.softwaremagico.kt.persistence.values.Score; @@ -59,7 +59,7 @@ public abstract class BasicDataTest extends AbstractTestNGSpringContextTests { protected TournamentDTO tournament; protected List members; protected List roles; - protected List teams; + protected List teams; protected GroupDTO group; protected List fights; @Autowired @@ -107,16 +107,16 @@ protected RoleDTO createReferee() { return roleController.create(new RoleDTO(tournament, referee, RoleType.REFEREE), null); } - protected List createTeams(List members, TournamentDTO tournament) { - List teams = new ArrayList<>(); + protected List createTeams(List members, TournamentDTO tournament) { + List teams = new ArrayList<>(); int teamIndex = 0; - DTO team = null; + TeamDTO team = null; int teamMember = 0; for (ParticipantDTO competitor : members) { // Create a new team. if (team == null) { teamIndex++; - team = new DTO("Team" + String.format("%02d", teamIndex), tournament); + team = new TeamDTO("Team" + String.format("%02d", teamIndex), tournament); teamMember = 0; team = teamController.create(team, null); teams.add(team); @@ -136,7 +136,7 @@ protected List createTeams(List members, TournamentDTO tour return teams; } - protected GroupDTO createGroup(TournamentDTO tournament, List teams) { + protected GroupDTO createGroup(TournamentDTO tournament, List teams) { final GroupDTO group = new GroupDTO(); group.setTournament(tournament); group.setLevel(0); @@ -144,7 +144,7 @@ protected GroupDTO createGroup(TournamentDTO tournament, List teams) { return groupController.create(group, null); } - protected List createFights(TournamentDTO tournament, List teams, GroupDTO group) { + protected List createFights(TournamentDTO tournament, List teams, GroupDTO group) { List fights = new ArrayList<>(); for (int i = 0; i < teams.size(); i++) { FightDTO fightDTO = new FightDTO(tournament, teams.get((i) % teams.size()), teams.get((i + 1) % teams.size()), SHIAIJO, LEVEL); diff --git a/backend/kendo-tournament-rest/src/main/java/com/softwaremagico/kt/rest/services/GroupServices.java b/backend/kendo-tournament-rest/src/main/java/com/softwaremagico/kt/rest/services/GroupServices.java index 556e04c65..c003705ce 100644 --- a/backend/kendo-tournament-rest/src/main/java/com/softwaremagico/kt/rest/services/GroupServices.java +++ b/backend/kendo-tournament-rest/src/main/java/com/softwaremagico/kt/rest/services/GroupServices.java @@ -25,7 +25,7 @@ import com.softwaremagico.kt.core.controller.TournamentController; import com.softwaremagico.kt.core.controller.models.DuelDTO; import com.softwaremagico.kt.core.controller.models.GroupDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.converters.GroupConverter; import com.softwaremagico.kt.core.converters.models.GroupConverterRequest; @@ -96,7 +96,7 @@ public GroupDTO get(@Parameter(description = "Id of an existing tournament", req @Operation(summary = "Set teams on a group.", security = @SecurityRequirement(name = "bearerAuth")) @PutMapping(value = "/{groupId}/teams", produces = MediaType.APPLICATION_JSON_VALUE) public GroupDTO updateTeam(@Parameter(description = "Id of the group to update", required = true) @PathVariable("groupId") Integer groupId, - @RequestBody List teamsDto, + @RequestBody List teamsDto, Authentication authentication, HttpServletRequest request) { return getController().setTeams(groupId, teamsDto, authentication.getName()); @@ -106,7 +106,7 @@ public GroupDTO updateTeam(@Parameter(description = "Id of the group to update", @Operation(summary = "Set teams on a group.", security = @SecurityRequirement(name = "bearerAuth")) @PatchMapping(value = "/{groupId}/teams/add", produces = MediaType.APPLICATION_JSON_VALUE) public GroupDTO addTeam(@Parameter(description = "Id of the group to update", required = true) @PathVariable("groupId") Integer groupId, - @RequestBody List teamsDto, + @RequestBody List teamsDto, Authentication authentication, HttpServletRequest request) { return getController().addTeams(groupId, teamsDto, authentication.getName()); @@ -116,7 +116,7 @@ public GroupDTO addTeam(@Parameter(description = "Id of the group to update", re @Operation(summary = "Set teams on a group.", security = @SecurityRequirement(name = "bearerAuth")) @PatchMapping(value = "/{groupId}/teams/delete", produces = MediaType.APPLICATION_JSON_VALUE) public GroupDTO deleteTeamFromGroup(@Parameter(description = "Id of the group to update", required = true) @PathVariable("groupId") Integer groupId, - @RequestBody List teamsDto, + @RequestBody List teamsDto, Authentication authentication, HttpServletRequest request) { return getController().deleteTeams(groupId, teamsDto, authentication.getName()); @@ -127,7 +127,7 @@ public GroupDTO deleteTeamFromGroup(@Parameter(description = "Id of the group to @PatchMapping(value = "/tournaments/{tournamentId}/teams/delete", produces = MediaType.APPLICATION_JSON_VALUE) public List deleteTeam(@Parameter(description = "Id of an existing tournament", required = true) @PathVariable("tournamentId") Integer tournamentId, - @RequestBody List teamsDto, + @RequestBody List teamsDto, Authentication authentication, HttpServletRequest request) { return getController().deleteTeamsFromTournament(tournamentId, teamsDto, authentication.getName()); @@ -146,7 +146,7 @@ public List deleteAllTeam(@Parameter(description = "Id of an existing @PreAuthorize("hasAnyRole('ROLE_EDITOR', 'ROLE_ADMIN')") @Operation(summary = "Set teams on the first group.", security = @SecurityRequirement(name = "bearerAuth")) @PutMapping(value = "/teams", produces = MediaType.APPLICATION_JSON_VALUE) - public GroupDTO updateTeam(@RequestBody List teamsDto, + public GroupDTO updateTeam(@RequestBody List teamsDto, Authentication authentication, HttpServletRequest request) { return getController().setTeams(teamsDto, authentication.getName()); diff --git a/backend/kendo-tournament-rest/src/main/java/com/softwaremagico/kt/rest/services/TeamServices.java b/backend/kendo-tournament-rest/src/main/java/com/softwaremagico/kt/rest/services/TeamServices.java index 1b73bcffa..b6564d70a 100644 --- a/backend/kendo-tournament-rest/src/main/java/com/softwaremagico/kt/rest/services/TeamServices.java +++ b/backend/kendo-tournament-rest/src/main/java/com/softwaremagico/kt/rest/services/TeamServices.java @@ -26,7 +26,7 @@ import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.ParticipantInTournamentDTO; import com.softwaremagico.kt.core.controller.models.ParticipantsInTournamentDTO; -import com.softwaremagico.kt.core.controller.models.DTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.converters.TeamConverter; import com.softwaremagico.kt.core.converters.models.TeamConverterRequest; @@ -63,7 +63,7 @@ @RestController @RequestMapping("/teams") -public class TeamServices extends BasicServices { private final TournamentController tournamentController; @@ -80,8 +80,8 @@ public TeamServices(TeamController teamController, TournamentController tourname @PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN')") @Operation(summary = "Gets all teams from a tournament.", security = @SecurityRequirement(name = "bearerAuth")) @GetMapping(value = "/tournaments/{tournamentId}", produces = MediaType.APPLICATION_JSON_VALUE) - public List getAll(@Parameter(description = "Id of an existing tournament", required = true) @PathVariable("tournamentId") Integer tournamentId, - Authentication authentication, HttpServletRequest request) { + public List getAll(@Parameter(description = "Id of an existing tournament", required = true) @PathVariable("tournamentId") Integer tournamentId, + Authentication authentication, HttpServletRequest request) { return getController().getAllByTournament(tournamentId, authentication.getName()); } @@ -97,8 +97,8 @@ public long countByTournamentId(@Parameter(description = "Id of an existing tour @PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN')") @Operation(summary = "Gets all teams.", security = @SecurityRequirement(name = "bearerAuth")) @PostMapping(value = "/tournaments", produces = MediaType.APPLICATION_JSON_VALUE) - public List getAll(@RequestBody TournamentDTO tournamentDto, - Authentication authentication, HttpServletRequest request) { + public List getAll(@RequestBody TournamentDTO tournamentDto, + Authentication authentication, HttpServletRequest request) { return getController().getAllByTournament(tournamentDto, authentication.getName()); } @@ -106,8 +106,8 @@ public List getAll(@RequestBody TournamentDTO tournamentDto, @PreAuthorize("hasAnyRole('ROLE_EDITOR', 'ROLE_ADMIN')") @Operation(summary = "Generates default teams.", security = @SecurityRequirement(name = "bearerAuth")) @PutMapping(value = "/tournaments", produces = MediaType.APPLICATION_JSON_VALUE) - public List create(@RequestBody TournamentDTO tournamentDto, - Authentication authentication, HttpServletRequest request) { + public List create(@RequestBody TournamentDTO tournamentDto, + Authentication authentication, HttpServletRequest request) { return getController().create(tournamentDto, authentication.getName()); } @@ -123,7 +123,7 @@ public void delete(@RequestBody TournamentDTO tournamentDto, HttpServletRequest @Operation(summary = "Defines the teams.", security = @SecurityRequirement(name = "bearerAuth")) @ResponseStatus(HttpStatus.CREATED) @PostMapping(value = "/set", produces = MediaType.APPLICATION_JSON_VALUE) - public List set(@RequestBody List teamsDTOs, Authentication authentication, HttpServletRequest request) { + public List set(@RequestBody List teamsDTOs, Authentication authentication, HttpServletRequest request) { if (teamsDTOs == null || teamsDTOs.isEmpty()) { throw new BadRequestException(getClass(), "Team data is missing"); } @@ -140,7 +140,7 @@ public List set(@RequestBody List teamsDTOs, Authentication authentica @Operation(summary = "Deletes a member from any team.", security = @SecurityRequirement(name = "bearerAuth")) @ResponseStatus(HttpStatus.NO_CONTENT) @PostMapping(value = "/delete/members", produces = MediaType.APPLICATION_JSON_VALUE) - public DTO delete(@RequestBody ParticipantInTournamentDTO participantInTournament, HttpServletRequest request) { + public TeamDTO delete(@RequestBody ParticipantInTournamentDTO participantInTournament, HttpServletRequest request) { return getController().delete(participantInTournament.getTournament(), participantInTournament.getParticipant()); } diff --git a/backend/kendo-tournament-rest/src/test/java/com/softwaremagico/kt/rest/RestSimpleChampionshipTest.java b/backend/kendo-tournament-rest/src/test/java/com/softwaremagico/kt/rest/RestSimpleChampionshipTest.java index 037d0fba6..24a665ecb 100644 --- a/backend/kendo-tournament-rest/src/test/java/com/softwaremagico/kt/rest/RestSimpleChampionshipTest.java +++ b/backend/kendo-tournament-rest/src/test/java/com/softwaremagico/kt/rest/RestSimpleChampionshipTest.java @@ -31,11 +31,11 @@ import com.softwaremagico.kt.core.controller.RoleController; import com.softwaremagico.kt.core.controller.TeamController; import com.softwaremagico.kt.core.controller.models.ClubDTO; -import com.softwaremagico.kt.core.controller.models.DTO; import com.softwaremagico.kt.core.controller.models.FightDTO; import com.softwaremagico.kt.core.controller.models.GroupDTO; import com.softwaremagico.kt.core.controller.models.ParticipantDTO; import com.softwaremagico.kt.core.controller.models.RoleDTO; +import com.softwaremagico.kt.core.controller.models.TeamDTO; import com.softwaremagico.kt.core.controller.models.TournamentDTO; import com.softwaremagico.kt.core.score.ScoreOfTeam; import com.softwaremagico.kt.persistence.values.RoleType; @@ -311,7 +311,7 @@ public void addRoles() throws Exception { @Test(dependsOnMethods = {"addRoles"}) public void addTeams() throws Exception { int teamIndex = 0; - DTO team = null; + TeamDTO team = null; int teamMember = 0; MvcResult createResult = this.mockMvc @@ -338,7 +338,7 @@ public void addTeams() throws Exception { // Create a new team. if (team == null) { teamIndex++; - team = new DTO("Team" + String.format("%02d", teamIndex), tournamentDTO); + team = new TeamDTO("Team" + String.format("%02d", teamIndex), tournamentDTO); teamMember = 0; } @@ -354,7 +354,7 @@ public void addTeams() throws Exception { .andExpect(MockMvcResultMatchers.status().is2xxSuccessful()) .andReturn(); - team = fromJson(createResult.getResponse().getContentAsString(), DTO.class); + team = fromJson(createResult.getResponse().getContentAsString(), TeamDTO.class); Assert.assertEquals(team.getTournament(), tournamentDTO); Assert.assertEquals(team.getName(), team.getName()); diff --git a/frontend/src/app/components/participant-picture/participant-picture.component.ts b/frontend/src/app/components/participant-picture/participant-picture.component.ts index 0115c9729..cc09801d0 100644 --- a/frontend/src/app/components/participant-picture/participant-picture.component.ts +++ b/frontend/src/app/components/participant-picture/participant-picture.component.ts @@ -4,6 +4,7 @@ import {FileService} from "../../services/file.service"; import {NameUtilsService} from "../../services/name-utils.service"; import {PictureDialogBoxComponent} from "./picture-dialog-box/picture-dialog-box.component"; import {MatDialog} from "@angular/material/dialog"; +import {ParticipantImage} from "../../models/participant-image.model"; @Component({ selector: 'app-participant-picture', @@ -22,8 +23,8 @@ export class ParticipantPictureComponent implements OnInit { } ngOnInit(): void { - if (this.participant! && this.participant.hasAvatar) { - this.fileService.getParticipantPicture(this.participant).subscribe(_picture => { + if (this.participant?.hasAvatar) { + this.fileService.getParticipantPicture(this.participant).subscribe((_picture: ParticipantImage): void => { if (_picture) { this.participantPicture = _picture.base64; } else { diff --git a/frontend/src/app/views/fight-list/fight-list.component.ts b/frontend/src/app/views/fight-list/fight-list.component.ts index 8760cbf68..fae17bac9 100644 --- a/frontend/src/app/views/fight-list/fight-list.component.ts +++ b/frontend/src/app/views/fight-list/fight-list.component.ts @@ -15,7 +15,6 @@ import {Team} from "../../models/team"; import {ConfirmationDialogComponent} from "../../components/basic/confirmation-dialog/confirmation-dialog.component"; import {TeamRankingComponent} from "../../components/team-ranking/team-ranking.component"; import {CompetitorsRankingComponent} from "../../components/competitors-ranking/competitors-ranking.component"; -import {TranslateService} from "@ngx-translate/core"; import {Duel} from "../../models/duel"; import {DuelService} from "../../services/duel.service"; import {TimeChangedService} from "../../services/notifications/time-changed.service"; @@ -31,9 +30,6 @@ import {RbacBasedComponent} from "../../components/RbacBasedComponent"; import {RbacService} from "../../services/rbac/rbac.service"; import {GroupUpdatedService} from "../../services/notifications/group-updated.service"; import {SystemOverloadService} from "../../services/notifications/system-overload.service"; -import {TournamentExtendedProperty} from "../../models/tournament-extended-property.model"; -import {TournamentExtraPropertyKey} from "../../models/tournament-extra-property-key"; -import {TournamentExtendedPropertiesService} from "../../services/tournament-extended-properties.service"; @Component({ selector: 'app-fight-list', @@ -212,7 +208,7 @@ export class FightListComponent extends RbacBasedComponent implements OnInit, On const fights: Fight[] = groups.flatMap((group: Group) => group.fights); for (let fight of fights) { for (let duel of fight.duels) { - if (duel.competitor1!.hasAvatar || duel.competitor2!.hasAvatar) { + if (duel.competitor1?.hasAvatar || duel.competitor2?.hasAvatar) { this.showAvatars = true; } } diff --git a/frontend/src/app/views/tournament-list/tournament-roles/tournament-roles.component.ts b/frontend/src/app/views/tournament-list/tournament-roles/tournament-roles.component.ts index d0ca4dfac..9f06b2a1d 100644 --- a/frontend/src/app/views/tournament-list/tournament-roles/tournament-roles.component.ts +++ b/frontend/src/app/views/tournament-list/tournament-roles/tournament-roles.component.ts @@ -73,7 +73,7 @@ export class TournamentRolesComponent extends RbacBasedComponent implements OnIn if (this.tournament.locked) { participant.locked = participant.locked || this.tournament.locked; } - if (participant.hasAvatar) { + if (participant?.hasAvatar) { this.showAvatars = true; } }