Move to new server
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import nl.connectedit.swiss.domain.EventType;
|
||||
import nl.connectedit.swiss.domain.TournamentStatus;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Getter
|
||||
@Setter
|
||||
public class Tournament extends AbstractEntity {
|
||||
|
||||
public Tournament() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private LocalDate date;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private TournamentStatus status;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Event> events;// = new ArrayList<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<TournamentPlayer> tournamentPlayers;
|
||||
|
||||
private Long maxEvents;
|
||||
|
||||
@ElementCollection
|
||||
private List<Float> costsPerEvent;
|
||||
|
||||
private Long courts;
|
||||
|
||||
public void initialize() {
|
||||
this.events = new ArrayList<>();
|
||||
this.events.addAll(Event.getBlankEventSet(this));
|
||||
this.status = TournamentStatus.UPCOMING;
|
||||
}
|
||||
|
||||
public Event getEventByType(EventType type) {
|
||||
return events
|
||||
.stream()
|
||||
.filter(event -> event.getType().equals(type))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public List<Registration> getRegistrations() {
|
||||
return events
|
||||
.stream()
|
||||
.map(Event::getRegistrations)
|
||||
.flatMap(List::stream)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user