7
pom.xml
7
pom.xml
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.5.7</version>
|
||||
<version>3.5.6</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>nl.connected-it</groupId>
|
||||
@@ -50,7 +50,10 @@
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Event extends AbstractEntity {
|
||||
@ManyToOne
|
||||
private Tournament tournament;
|
||||
|
||||
@OneToMany(mappedBy = "event", cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||
@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||
private List<Registration> registrations;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
|
||||
@@ -30,11 +30,9 @@ public class Match extends AbstractEntity {
|
||||
private Round round;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "team1_id")
|
||||
private Team team1;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "team2_id")
|
||||
private Team team2;
|
||||
|
||||
private Boolean played;
|
||||
|
||||
@@ -58,11 +58,11 @@ public class Player extends AbstractEntity {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private PlayerStrength strength;
|
||||
|
||||
@OneToMany(mappedBy = "player", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Registration> registrations;
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Registration> registrations;// = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "partner", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Registration> partnerRegistrations;
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Registration> partnerRegistrations;// = new ArrayList<>();
|
||||
|
||||
public String getFullName() {
|
||||
return hasLength(middleName) ?
|
||||
|
||||
@@ -20,8 +20,8 @@ public class Registration extends AbstractEntity {
|
||||
@ManyToOne
|
||||
private Event event;
|
||||
|
||||
// @ManyToOne
|
||||
// private Tournament tournament;
|
||||
@ManyToOne
|
||||
private Tournament tournament;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "player_id")
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Round extends AbstractEntity {
|
||||
|
||||
private Status status;
|
||||
|
||||
@OneToMany(mappedBy = "round", cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||
@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||
@OrderBy("id")
|
||||
private List<Match> matches;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Tournament extends AbstractEntity {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private TournamentStatus status;
|
||||
|
||||
@OneToMany(mappedBy = "tournament", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Event> events;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
|
||||
@@ -94,15 +94,13 @@ public class TournamentMapper implements DtoMapper<Tournament, TournamentDto>, E
|
||||
var playersCounting = new ArrayList<Long>();
|
||||
|
||||
for (var event : tournament.getEvents()) {
|
||||
if (event.getGroups() != null) {
|
||||
for (var group : event.getGroups()) {
|
||||
for (var round : group.getRounds()) {
|
||||
for (var match : round.getMatches()) {
|
||||
if (match.getStatus() == Status.IN_PROGRESS && match.getCounter() != null) {
|
||||
var counter = getTournamentPlayerFromPlayerId(tournament, match.getCounter().getId());
|
||||
if (counter != null) {
|
||||
playersCounting.add(counter.getId());
|
||||
}
|
||||
for (var group : event.getGroups()) {
|
||||
for (var round : group.getRounds()) {
|
||||
for (var match : round.getMatches()) {
|
||||
if (match.getStatus() == Status.IN_PROGRESS && match.getCounter() != null) {
|
||||
var counter = getTournamentPlayerFromPlayerId(tournament, match.getCounter().getId());
|
||||
if (counter != null) {
|
||||
playersCounting.add(counter.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,13 +114,11 @@ public class TournamentMapper implements DtoMapper<Tournament, TournamentDto>, E
|
||||
var playersPlaying = new ArrayList<Long>();
|
||||
|
||||
for (var event : tournament.getEvents()) {
|
||||
if (event.getGroups() != null) {
|
||||
for (var group : event.getGroups()) {
|
||||
for (var round : group.getRounds()) {
|
||||
for (var match : round.getMatches()) {
|
||||
if (match.getStatus() == Status.IN_PROGRESS) {
|
||||
playersPlaying.addAll(getPlayersInMatch(tournament, match));
|
||||
}
|
||||
for (var group : event.getGroups()) {
|
||||
for (var round : group.getRounds()) {
|
||||
for (var match : round.getMatches()) {
|
||||
if (match.getStatus() == Status.IN_PROGRESS) {
|
||||
playersPlaying.addAll(getPlayersInMatch(tournament, match));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,10 +129,6 @@ public class TournamentMapper implements DtoMapper<Tournament, TournamentDto>, E
|
||||
}
|
||||
|
||||
private List<Long> getPlayersAvailable(Tournament tournament) {
|
||||
if (tournament.getTournamentPlayers() == null) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
var playersAvailable = tournament.getTournamentPlayers()
|
||||
.stream()
|
||||
.map(TournamentPlayer::getId)
|
||||
|
||||
@@ -27,7 +27,7 @@ public class RegistrationService {
|
||||
.findAny();
|
||||
if (optionalExistingPlayerRegistration.isEmpty()) { // no previous registration for this event
|
||||
var newRegistration = new Registration();
|
||||
// newRegistration.setTournament(tournament);
|
||||
newRegistration.setTournament(tournament);
|
||||
newRegistration.setEvent(event);
|
||||
newRegistration.setPlayer(player);
|
||||
if (eventRegistration.getPartner() != null) {
|
||||
|
||||
Reference in New Issue
Block a user