Move to new server
This commit is contained in:
15
src/main/java/nl/connectedit/swiss/domain/EventDivision.java
Normal file
15
src/main/java/nl/connectedit/swiss/domain/EventDivision.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import nl.connectedit.swiss.domain.entity.Group;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class EventDivision {
|
||||
|
||||
private Long eventId;
|
||||
|
||||
private List<Group> groups = new ArrayList<>();
|
||||
}
|
||||
20
src/main/java/nl/connectedit/swiss/domain/EventType.java
Normal file
20
src/main/java/nl/connectedit/swiss/domain/EventType.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum EventType {
|
||||
|
||||
HE("Herenenkel", false),
|
||||
DE("Damesenkel", false),
|
||||
HD("Herendubbel", true),
|
||||
DD("Damesdubbel", true),
|
||||
GD("Gemengd dubbel", true);
|
||||
|
||||
private final String text;
|
||||
|
||||
private final boolean isDoublesEvent;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class EventValidation {
|
||||
private Long eventId;
|
||||
|
||||
@Builder.Default
|
||||
private List<Validation> validations = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum PlayerStrength {
|
||||
D5(8),
|
||||
D6(6),
|
||||
D7(4),
|
||||
D8(3),
|
||||
D9(2),
|
||||
DR(1);
|
||||
|
||||
private final int coefficient;
|
||||
}
|
||||
10
src/main/java/nl/connectedit/swiss/domain/Sex.java
Normal file
10
src/main/java/nl/connectedit/swiss/domain/Sex.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public enum Sex {
|
||||
|
||||
M, V
|
||||
|
||||
}
|
||||
8
src/main/java/nl/connectedit/swiss/domain/Status.java
Normal file
8
src/main/java/nl/connectedit/swiss/domain/Status.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
public enum Status {
|
||||
NOT_STARTED,
|
||||
READY_TO_PLAY,
|
||||
IN_PROGRESS,
|
||||
FINISHED
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TournamentDivision {
|
||||
|
||||
private Long tournamentId;
|
||||
|
||||
private boolean divided;
|
||||
|
||||
private List<EventDivision> eventDivisions = new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum TournamentStatus {
|
||||
UPCOMING("Nieuw"),
|
||||
DIVIDED("Ingedeeld"),
|
||||
DRAWN("Geloot"),
|
||||
ONGOING("Bezig"),
|
||||
CLOSED("Gesloten");
|
||||
|
||||
private final String text;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TournamentValidation {
|
||||
|
||||
private Long tournamentId;
|
||||
|
||||
private List<Validation> validations;
|
||||
|
||||
private List<EventValidation> eventValidations;
|
||||
|
||||
public boolean hasErrors() {
|
||||
return !validations.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
19
src/main/java/nl/connectedit/swiss/domain/Validation.java
Normal file
19
src/main/java/nl/connectedit/swiss/domain/Validation.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package nl.connectedit.swiss.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Validation {
|
||||
public enum Severity {
|
||||
INFO, WARN, ERROR
|
||||
}
|
||||
private Severity severity;
|
||||
|
||||
private String message;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class AbstractEntity {
|
||||
|
||||
protected abstract Long getId();
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null) return false;
|
||||
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
|
||||
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
|
||||
if (thisEffectiveClass != oEffectiveClass) return false;
|
||||
AbstractEntity abstractEntity = (AbstractEntity) o;
|
||||
return getId() != null && Objects.equals(getId(), abstractEntity.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
62
src/main/java/nl/connectedit/swiss/domain/entity/Event.java
Normal file
62
src/main/java/nl/connectedit/swiss/domain/entity/Event.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import nl.connectedit.swiss.domain.EventType;
|
||||
import nl.connectedit.swiss.domain.Status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class Event extends AbstractEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
private Tournament tournament;
|
||||
|
||||
@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||
// @Builder.Default
|
||||
private List<Registration> registrations;// = new ArrayList<>();
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status status;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private EventType type;
|
||||
|
||||
@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||
private List<Group> groups;// = new ArrayList<>();
|
||||
|
||||
public static List<Event> getBlankEventSet(Tournament tournament) {
|
||||
return Arrays.stream(EventType.values())
|
||||
.map(type -> Event
|
||||
.builder()
|
||||
.type(type)
|
||||
.status(Status.NOT_STARTED)
|
||||
.tournament(tournament)
|
||||
.build()
|
||||
)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
public void addRegistration(Registration registration) {
|
||||
this.registrations.add(registration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getType().getText();
|
||||
}
|
||||
}
|
||||
26
src/main/java/nl/connectedit/swiss/domain/entity/Game.java
Normal file
26
src/main/java/nl/connectedit/swiss/domain/entity/Game.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Game extends AbstractEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
private Match match;
|
||||
|
||||
private Long score1;
|
||||
|
||||
private Long score2;
|
||||
|
||||
}
|
||||
38
src/main/java/nl/connectedit/swiss/domain/entity/Group.java
Normal file
38
src/main/java/nl/connectedit/swiss/domain/entity/Group.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import nl.connectedit.swiss.domain.EventType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import nl.connectedit.swiss.domain.Status;
|
||||
|
||||
@Entity
|
||||
@Table(name = "eventgroup")
|
||||
@Getter
|
||||
@Setter
|
||||
public class Group extends AbstractEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToOne
|
||||
private Event event;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status status;
|
||||
|
||||
private EventType type;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Round> rounds;// = new ArrayList<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Team> teams;// = new ArrayList<>();
|
||||
|
||||
}
|
||||
49
src/main/java/nl/connectedit/swiss/domain/entity/Match.java
Normal file
49
src/main/java/nl/connectedit/swiss/domain/entity/Match.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import nl.connectedit.swiss.domain.EventType;
|
||||
import nl.connectedit.swiss.domain.Status;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public class Match extends AbstractEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private EventType type;
|
||||
|
||||
private Status status;
|
||||
|
||||
@ManyToOne
|
||||
private Round round;
|
||||
|
||||
@ManyToOne
|
||||
private Team team1;
|
||||
|
||||
@ManyToOne
|
||||
private Team team2;
|
||||
|
||||
private Boolean played;
|
||||
|
||||
private Long court;
|
||||
|
||||
@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||
private List<Game> games;// = new ArrayList<>();
|
||||
|
||||
private LocalDateTime startTime;
|
||||
|
||||
private LocalDateTime endTime;
|
||||
|
||||
}
|
||||
77
src/main/java/nl/connectedit/swiss/domain/entity/Player.java
Normal file
77
src/main/java/nl/connectedit/swiss/domain/entity/Player.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import nl.connectedit.swiss.domain.PlayerStrength;
|
||||
import nl.connectedit.swiss.domain.Sex;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.util.StringUtils.hasLength;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class Player extends AbstractEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
@NotEmpty
|
||||
private String firstName;
|
||||
|
||||
@Column
|
||||
private String middleName;
|
||||
|
||||
@Column(nullable = false)
|
||||
@NotEmpty
|
||||
private String lastName;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Sex sex;
|
||||
|
||||
@Column(nullable = false)
|
||||
@DateTimeFormat(pattern = "dd-MM-yyyy")
|
||||
private LocalDate birthday;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String phoneNumber;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String email;
|
||||
|
||||
@Column
|
||||
private String club;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
private PlayerStrength strength;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Registration> registrations;// = new ArrayList<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Registration> partnerRegistrations;// = new ArrayList<>();
|
||||
|
||||
public String getFullName() {
|
||||
return hasLength(middleName) ?
|
||||
String.join(" ", firstName, middleName, lastName) :
|
||||
String.join(" ", firstName, lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getFullName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public class Registration extends AbstractEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
private Event event;
|
||||
|
||||
@ManyToOne
|
||||
private Tournament tournament;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "player_id")
|
||||
private Player player;
|
||||
|
||||
@Nullable
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "partner_id")
|
||||
private Player partner;
|
||||
|
||||
}
|
||||
39
src/main/java/nl/connectedit/swiss/domain/entity/Round.java
Normal file
39
src/main/java/nl/connectedit/swiss/domain/entity/Round.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import nl.connectedit.swiss.domain.Status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public class Round extends AbstractEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToOne
|
||||
private Group group;
|
||||
|
||||
private Status status;
|
||||
|
||||
@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||
private List<Match> matches;// = new ArrayList<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||
private List<Team> quit;// = new ArrayList<>();
|
||||
|
||||
@ManyToOne
|
||||
private Team drawnOut;
|
||||
|
||||
}
|
||||
34
src/main/java/nl/connectedit/swiss/domain/entity/Team.java
Normal file
34
src/main/java/nl/connectedit/swiss/domain/entity/Team.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public class Team extends AbstractEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
private Group group;
|
||||
|
||||
@ManyToOne
|
||||
private Player player1;
|
||||
|
||||
@Nullable
|
||||
@ManyToOne
|
||||
private Player player2;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return player2 != null ? player1.toString() + " + " + player2.toString() : player1.toString();
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package nl.connectedit.swiss.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@Getter
|
||||
@Setter
|
||||
public class TournamentPlayer extends AbstractEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
private Tournament tournament;
|
||||
|
||||
@ElementCollection
|
||||
private List<String> events;
|
||||
|
||||
@ManyToOne
|
||||
private Player player;
|
||||
|
||||
private boolean paid;
|
||||
|
||||
private boolean present;
|
||||
}
|
||||
Reference in New Issue
Block a user