diff --git a/src/de/steamwar/sql/Event.java b/src/de/steamwar/sql/Event.java index f06f95e..c554063 100644 --- a/src/de/steamwar/sql/Event.java +++ b/src/de/steamwar/sql/Event.java @@ -25,6 +25,7 @@ import de.steamwar.sql.internal.Statement; import de.steamwar.sql.internal.Table; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.Setter; import java.sql.Timestamp; import java.util.List; @@ -41,8 +42,8 @@ public class Event { private static final SelectStatement byCurrent = new SelectStatement<>(table, "SELECT * FROM Event WHERE Start < now() AND End > now()"); private static final SelectStatement byId = table.select(Table.PRIMARY); private static final SelectStatement allShort = new SelectStatement<>(table, "SELECT * FROM Event"); - private static final Statement create = table.insertFields(true, "eventName", "deadline", "start", "end", "maximumTeamMembers", "publicSchemsOnly", "spectateSystem"); - private static final Statement update = table.update(Table.PRIMARY, "eventName", "deadline", "start", "end", "schemType", "maximumTeamMembers", "publicSchemsOnly", "spectateSystem"); + private static final Statement create = table.insertFields(true, "eventName", "deadline", "start", "end", "maximumTeamMembers", "publicSchemsOnly"); + private static final Statement update = table.update(Table.PRIMARY, "eventName", "deadline", "start", "end", "schemType", "maximumTeamMembers", "publicSchemsOnly"); private static final Statement delete = table.delete(Table.PRIMARY); @@ -65,23 +66,30 @@ public class Event { @Getter @Field(keys = {Table.PRIMARY}, autoincrement = true) private final int eventID; + @Setter @Getter @Field(keys = {"eventName"}) private String eventName; + @Setter @Getter @Field private Timestamp deadline; + @Setter @Getter @Field private Timestamp start; + @Setter @Getter @Field private Timestamp end; + @Setter @Getter @Field private int maximumTeamMembers; + @Setter @Field(nullable = true) private SchematicType schemType; + @Setter @Field private boolean publicSchemsOnly; @Deprecated @@ -91,6 +99,8 @@ public class Event { public boolean publicSchemsOnly() { return publicSchemsOnly; } + + @Deprecated public boolean spectateSystem(){ return spectateSystem; } @@ -99,39 +109,12 @@ public class Event { return schemType; } - public void setEventName(String eventName) { - this.eventName = eventName; - } - - public void setDeadline(Timestamp deadline) { - this.deadline = deadline; - } - - public void setStart(Timestamp start) { - this.start = start; - } - - public void setEnd(Timestamp end) { - this.end = end; - } - - public void setMaximumTeamMembers(int maximumTeamMembers) { - this.maximumTeamMembers = maximumTeamMembers; - } - - public void setPublicSchemsOnly(boolean publicSchemsOnly) { - this.publicSchemsOnly = publicSchemsOnly; - } - + @Deprecated public void setSpectateSystem(boolean spectateSystem) { this.spectateSystem = spectateSystem; } - public void setSchemType(SchematicType schemType) { - this.schemType = schemType; - } - public void update(){ - update.update(eventName, deadline, start, end, schemType, maximumTeamMembers, publicSchemsOnly, spectateSystem, eventID); + update.update(eventName, deadline, start, end, schemType, maximumTeamMembers, publicSchemsOnly, eventID); } } diff --git a/src/de/steamwar/sql/EventFight.java b/src/de/steamwar/sql/EventFight.java index b2a86c4..48faf81 100644 --- a/src/de/steamwar/sql/EventFight.java +++ b/src/de/steamwar/sql/EventFight.java @@ -47,7 +47,7 @@ public class EventFight { private static final Statement setFight = table.update(Table.PRIMARY, "Fight"); private static final SelectStatement byEvent = table.selectFields("eventID"); private static final Statement update = table.update(Table.PRIMARY, "startTime", "spielModus", "map", "teamBlue", "teamRed", "kampfleiter"); - private static final Statement create = table.insertFields(true, "eventID", "startTime", "spielModus", "map", "teamBlue", "teamRed", "kampfleiter"); + private static final Statement create = table.insertFields(true, "eventID", "startTime", "spielModus", "map", "teamBlue", "teamRed", "spectatePort"); private static final Statement delete = table.delete(Table.PRIMARY); private static final Queue fights = new PriorityQueue<>(); @@ -96,8 +96,9 @@ public class EventFight { @Deprecated private int kampfleiter; @Getter - @Field - private int spectatePort; + @Setter + @Field(nullable = true) + private Integer spectatePort; @Getter @Field(def = "0") private int ergebnis; @@ -116,7 +117,7 @@ public class EventFight { } public void update() { - update.update(startTime, spielModus, map, teamBlue, teamRed, kampfleiter, fightID); + update.update(startTime, spielModus, map, teamBlue, teamRed, spectatePort, fightID); } public void delete() { diff --git a/src/de/steamwar/sql/Referee.java b/src/de/steamwar/sql/Referee.java index 2f606a9..013eea1 100644 --- a/src/de/steamwar/sql/Referee.java +++ b/src/de/steamwar/sql/Referee.java @@ -21,6 +21,7 @@ package de.steamwar.sql; import de.steamwar.sql.internal.Field; import de.steamwar.sql.internal.SelectStatement; +import de.steamwar.sql.internal.Statement; import de.steamwar.sql.internal.Table; import lombok.AllArgsConstructor; @@ -32,6 +33,16 @@ public class Referee { private static final Table table = new Table<>(Referee.class); private static final SelectStatement byEvent = table.select("eventID"); + private static final Statement insert = table.insertAll(); + private static final Statement delete = table.delete("eventReferee"); + + public static void add(int eventID, int userID) { + insert.update(eventID, userID); + } + + public static void remove(int eventID, int userID) { + delete.update(eventID, userID); + } public static Set get(int eventID) { return byEvent.listSelect(eventID).stream().map(referee -> referee.userID).collect(Collectors.toSet());