From dd5f96a906f825e357411bc1e48ca3d9691c0fb8 Mon Sep 17 00:00:00 2001
From: Jonas <jonas.fischer14@gmx.de>
Date: Wed, 6 Dec 2023 17:24:19 +0100
Subject: [PATCH] 06.12.2023 - add methods to models #4

---
 .idea/.gitignore                              |  8 ++++
 .idea/misc.xml                                |  6 +++
 .idea/modules.xml                             |  8 ++++
 .../15d493c652d20750608adb0a33ec5d3ad17ece3d  |  0
 .../81d8eb2bc5a911b258c49bed79926844ea3988f0  |  0
 .../8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d  |  0
 .../ad9815cb514700b7f513e4aad039536e258c58d9  |  0
 .../d4d373a247368212c60cc99595abbf323611ed8f  |  0
 .../ef8def03dc8f162799089e9b5f4321201c8810d5  |  0
 .../f764c0a37a5c9f7a04bea4edf778d74fc41a085c  |  0
 .../ffa88f39108e02aca02fbfcfdefda86d60005743  |  0
 .idea/sonarlint/issuestore/index.pb           | 17 ++++++++
 .../15d493c652d20750608adb0a33ec5d3ad17ece3d  |  0
 .../81d8eb2bc5a911b258c49bed79926844ea3988f0  |  0
 .../8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d  |  0
 .../ad9815cb514700b7f513e4aad039536e258c58d9  |  0
 .../d4d373a247368212c60cc99595abbf323611ed8f  |  0
 .../ef8def03dc8f162799089e9b5f4321201c8810d5  |  0
 .../f764c0a37a5c9f7a04bea4edf778d74fc41a085c  |  0
 .../ffa88f39108e02aca02fbfcfdefda86d60005743  |  0
 .idea/sonarlint/securityhotspotstore/index.pb | 17 ++++++++
 .idea/student-tournament-hub.iml              | 12 ++++++
 .idea/vcs.xml                                 |  6 +++
 .../exeptions/PlayerIdNotFoundException.java  |  7 +++
 .../TeamMatchScoreIdNotFoundException.java    |  7 +++
 .../java/hdm/mi/sthbackend/model/Match.java   | 43 +++++++++++++++----
 .../java/hdm/mi/sthbackend/model/Team.java    | 34 ++++++++++++++-
 .../mi/sthbackend/model/TeamMatchScore.java   |  5 ++-
 sth-frontend/.idea/.gitignore                 |  5 +++
 sth-frontend/.idea/modules.xml                |  8 ++++
 sth-frontend/.idea/sth-frontend.iml           | 12 ++++++
 sth-frontend/.idea/vcs.xml                    |  6 +++
 32 files changed, 190 insertions(+), 11 deletions(-)
 create mode 100644 .idea/.gitignore
 create mode 100644 .idea/misc.xml
 create mode 100644 .idea/modules.xml
 create mode 100644 .idea/sonarlint/issuestore/1/5/15d493c652d20750608adb0a33ec5d3ad17ece3d
 create mode 100644 .idea/sonarlint/issuestore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0
 create mode 100644 .idea/sonarlint/issuestore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
 create mode 100644 .idea/sonarlint/issuestore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9
 create mode 100644 .idea/sonarlint/issuestore/d/4/d4d373a247368212c60cc99595abbf323611ed8f
 create mode 100644 .idea/sonarlint/issuestore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5
 create mode 100644 .idea/sonarlint/issuestore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c
 create mode 100644 .idea/sonarlint/issuestore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743
 create mode 100644 .idea/sonarlint/issuestore/index.pb
 create mode 100644 .idea/sonarlint/securityhotspotstore/1/5/15d493c652d20750608adb0a33ec5d3ad17ece3d
 create mode 100644 .idea/sonarlint/securityhotspotstore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0
 create mode 100644 .idea/sonarlint/securityhotspotstore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
 create mode 100644 .idea/sonarlint/securityhotspotstore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9
 create mode 100644 .idea/sonarlint/securityhotspotstore/d/4/d4d373a247368212c60cc99595abbf323611ed8f
 create mode 100644 .idea/sonarlint/securityhotspotstore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5
 create mode 100644 .idea/sonarlint/securityhotspotstore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c
 create mode 100644 .idea/sonarlint/securityhotspotstore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743
 create mode 100644 .idea/sonarlint/securityhotspotstore/index.pb
 create mode 100644 .idea/student-tournament-hub.iml
 create mode 100644 .idea/vcs.xml
 create mode 100644 sth-backend/src/main/java/hdm/mi/sthbackend/exeptions/PlayerIdNotFoundException.java
 create mode 100644 sth-backend/src/main/java/hdm/mi/sthbackend/exeptions/TeamMatchScoreIdNotFoundException.java
 create mode 100644 sth-frontend/.idea/.gitignore
 create mode 100644 sth-frontend/.idea/modules.xml
 create mode 100644 sth-frontend/.idea/sth-frontend.iml
 create mode 100644 sth-frontend/.idea/vcs.xml

diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..dbb096c
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" project-jdk-name="20" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..f22b051
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/student-tournament-hub.iml" filepath="$PROJECT_DIR$/.idea/student-tournament-hub.iml" />
+    </modules>
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/sonarlint/issuestore/1/5/15d493c652d20750608adb0a33ec5d3ad17ece3d b/.idea/sonarlint/issuestore/1/5/15d493c652d20750608adb0a33ec5d3ad17ece3d
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/issuestore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0 b/.idea/sonarlint/issuestore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/issuestore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d b/.idea/sonarlint/issuestore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/issuestore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9 b/.idea/sonarlint/issuestore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/issuestore/d/4/d4d373a247368212c60cc99595abbf323611ed8f b/.idea/sonarlint/issuestore/d/4/d4d373a247368212c60cc99595abbf323611ed8f
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/issuestore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5 b/.idea/sonarlint/issuestore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/issuestore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c b/.idea/sonarlint/issuestore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/issuestore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743 b/.idea/sonarlint/issuestore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb
new file mode 100644
index 0000000..709b569
--- /dev/null
+++ b/.idea/sonarlint/issuestore/index.pb
@@ -0,0 +1,17 @@
+
+9
+	README.md,8\e\8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
+I
+tournament-factory-adr.md,8\1\81d8eb2bc5a911b258c49bed79926844ea3988f0
+C
+docker-compose.yaml,e\f\ef8def03dc8f162799089e9b5f4321201c8810d5
+F
+sth-backend/Dockerfile,a\d\ad9815cb514700b7f513e4aad039536e258c58d9
+@
+sth-backend/mvnw,f\7\f764c0a37a5c9f7a04bea4edf778d74fc41a085c
+C
+sth-backend/pom.xml,f\f\ffa88f39108e02aca02fbfcfdefda86d60005743
+m
+=sth-backend/src/main/java/hdm/mi/sthbackend/model/IMatch.java,1\5\15d493c652d20750608adb0a33ec5d3ad17ece3d
+r
+Bsth-backend/src/main/java/hdm/mi/sthbackend/model/ITournament.java,d\4\d4d373a247368212c60cc99595abbf323611ed8f
\ No newline at end of file
diff --git a/.idea/sonarlint/securityhotspotstore/1/5/15d493c652d20750608adb0a33ec5d3ad17ece3d b/.idea/sonarlint/securityhotspotstore/1/5/15d493c652d20750608adb0a33ec5d3ad17ece3d
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/securityhotspotstore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0 b/.idea/sonarlint/securityhotspotstore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/securityhotspotstore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d b/.idea/sonarlint/securityhotspotstore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/securityhotspotstore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9 b/.idea/sonarlint/securityhotspotstore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/securityhotspotstore/d/4/d4d373a247368212c60cc99595abbf323611ed8f b/.idea/sonarlint/securityhotspotstore/d/4/d4d373a247368212c60cc99595abbf323611ed8f
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/securityhotspotstore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5 b/.idea/sonarlint/securityhotspotstore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/securityhotspotstore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c b/.idea/sonarlint/securityhotspotstore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/securityhotspotstore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743 b/.idea/sonarlint/securityhotspotstore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/sonarlint/securityhotspotstore/index.pb b/.idea/sonarlint/securityhotspotstore/index.pb
new file mode 100644
index 0000000..709b569
--- /dev/null
+++ b/.idea/sonarlint/securityhotspotstore/index.pb
@@ -0,0 +1,17 @@
+
+9
+	README.md,8\e\8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d
+I
+tournament-factory-adr.md,8\1\81d8eb2bc5a911b258c49bed79926844ea3988f0
+C
+docker-compose.yaml,e\f\ef8def03dc8f162799089e9b5f4321201c8810d5
+F
+sth-backend/Dockerfile,a\d\ad9815cb514700b7f513e4aad039536e258c58d9
+@
+sth-backend/mvnw,f\7\f764c0a37a5c9f7a04bea4edf778d74fc41a085c
+C
+sth-backend/pom.xml,f\f\ffa88f39108e02aca02fbfcfdefda86d60005743
+m
+=sth-backend/src/main/java/hdm/mi/sthbackend/model/IMatch.java,1\5\15d493c652d20750608adb0a33ec5d3ad17ece3d
+r
+Bsth-backend/src/main/java/hdm/mi/sthbackend/model/ITournament.java,d\4\d4d373a247368212c60cc99595abbf323611ed8f
\ No newline at end of file
diff --git a/.idea/student-tournament-hub.iml b/.idea/student-tournament-hub.iml
new file mode 100644
index 0000000..ad374d0
--- /dev/null
+++ b/.idea/student-tournament-hub.iml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+  <component name="SonarLintModuleSettings">
+    <option name="uniqueId" value="496df6ed-8d28-4ba0-bd76-20bf08cf48f0" />
+  </component>
+</module>
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/sth-backend/src/main/java/hdm/mi/sthbackend/exeptions/PlayerIdNotFoundException.java b/sth-backend/src/main/java/hdm/mi/sthbackend/exeptions/PlayerIdNotFoundException.java
new file mode 100644
index 0000000..59f5501
--- /dev/null
+++ b/sth-backend/src/main/java/hdm/mi/sthbackend/exeptions/PlayerIdNotFoundException.java
@@ -0,0 +1,7 @@
+package hdm.mi.sthbackend.exeptions;
+
+public class PlayerIdNotFoundException extends Exception {
+    public PlayerIdNotFoundException (String playerId) {
+        super(String.format("PlayerId %s not found", playerId));
+    }
+}
diff --git a/sth-backend/src/main/java/hdm/mi/sthbackend/exeptions/TeamMatchScoreIdNotFoundException.java b/sth-backend/src/main/java/hdm/mi/sthbackend/exeptions/TeamMatchScoreIdNotFoundException.java
new file mode 100644
index 0000000..d00a766
--- /dev/null
+++ b/sth-backend/src/main/java/hdm/mi/sthbackend/exeptions/TeamMatchScoreIdNotFoundException.java
@@ -0,0 +1,7 @@
+package hdm.mi.sthbackend.exeptions;
+
+public class TeamMatchScoreIdNotFoundException extends Exception{
+    public TeamMatchScoreIdNotFoundException(String message) {
+        super(message);
+    }
+}
diff --git a/sth-backend/src/main/java/hdm/mi/sthbackend/model/Match.java b/sth-backend/src/main/java/hdm/mi/sthbackend/model/Match.java
index 467639b..1d480af 100644
--- a/sth-backend/src/main/java/hdm/mi/sthbackend/model/Match.java
+++ b/sth-backend/src/main/java/hdm/mi/sthbackend/model/Match.java
@@ -1,33 +1,60 @@
 package hdm.mi.sthbackend.model;
 
-import org.hibernate.id.uuid.UuidGenerator;
+import hdm.mi.sthbackend.exeptions.TeamMatchScoreIdNotFoundException;
+import lombok.Getter;
+import lombok.Setter;
 
 import java.util.List;
+import java.util.Objects;
 import java.util.UUID;
 
 public class Match {
-    private String matchId;
-    private List<TeamMatchScore> teams;
+    @Getter
+    private final UUID matchId;
+    private final List<TeamMatchScore> teams;
 
+    @Getter
+    @Setter
     private Team winner;
 
+    @Getter
+    @Setter
     private String comment;
 
+    @Getter
+    @Setter
     private Match nextMatch;
 
-    public Match(String matchId, List<TeamMatchScore> teams, Team winner, String comment, Match nextMatch) {
-        this.matchId = matchId;
+    public Match(List<TeamMatchScore> teams, Team winner, String comment, Match nextMatch) {
+        this.matchId = UUID.randomUUID();
         this.teams = teams;
         this.winner = winner;
         this.comment = comment;
         this.nextMatch = nextMatch;
     }
 
-    public Match(String matchId, List<TeamMatchScore> teams, Team winner, Match nextMatch) {
-        this(matchId, teams, winner, "", nextMatch);
+    public Match(List<TeamMatchScore> teams, Team winner, Match nextMatch) {
+        this(teams, winner, "", nextMatch);
     }
 
     public void addTeam(Team team) {
-        teams.add(new TeamMatchScore( team, 0));
+        teams.add(new TeamMatchScore(team, 0));
     }
+
+    public void removeTeam(UUID teamMatchScoreId) throws Exception {
+        TeamMatchScore team = teams.stream().filter(t -> t.getTeamMatchScoreId().equals(teamMatchScoreId)).findFirst().orElse(null);
+        if (team == null) {
+            throw new TeamMatchScoreIdNotFoundException(String.format("TeamMatchScoreID %s was not found", teamMatchScoreId));
+        }
+        teams.remove(team);
+    }
+
+    public void removeTeam(TeamMatchScore team) {
+        teams.remove(team);
+    }
+
+    public TeamMatchScore[] getAllTeams() {
+        return (TeamMatchScore[]) teams.stream().filter(Objects::nonNull).toArray();
+    }
+
 }
diff --git a/sth-backend/src/main/java/hdm/mi/sthbackend/model/Team.java b/sth-backend/src/main/java/hdm/mi/sthbackend/model/Team.java
index b6563d5..ed541eb 100644
--- a/sth-backend/src/main/java/hdm/mi/sthbackend/model/Team.java
+++ b/sth-backend/src/main/java/hdm/mi/sthbackend/model/Team.java
@@ -1,9 +1,39 @@
 package hdm.mi.sthbackend.model;
 
+import hdm.mi.sthbackend.exeptions.PlayerIdNotFoundException;
+import lombok.Getter;
+
+import java.util.ArrayList;
 import java.util.List;
+import java.util.UUID;
 
 public class Team {
-    private String teamId;
-    private List<Player> teamMembers;
+    @Getter
+    private final UUID teamId;
+    private final List<Player> teamMembers;
+
+    public Team() {
+        this.teamId = UUID.randomUUID();
+        this.teamMembers = new ArrayList<>();
+    }
+
+    public void addPlayer(Player player) {
+        this.teamMembers.add(player);
+    }
+
+    public void removePlayer(UUID playerId) throws PlayerIdNotFoundException {
+        Player player = this.teamMembers.stream().filter(p -> p.getPlayerId().equals(playerId)).findFirst().orElse(null);
+        if (player == null) {
+            throw new PlayerIdNotFoundException(playerId.toString());
+        }
+        teamMembers.remove(player);
+    }
+
+    public void removePlayer(Player player) {
+        teamMembers.remove(player);
+    }
+
+
+
 
 }
diff --git a/sth-backend/src/main/java/hdm/mi/sthbackend/model/TeamMatchScore.java b/sth-backend/src/main/java/hdm/mi/sthbackend/model/TeamMatchScore.java
index fde8ebd..14c7535 100644
--- a/sth-backend/src/main/java/hdm/mi/sthbackend/model/TeamMatchScore.java
+++ b/sth-backend/src/main/java/hdm/mi/sthbackend/model/TeamMatchScore.java
@@ -1,9 +1,12 @@
 package hdm.mi.sthbackend.model;
 
+import lombok.Getter;
+
 import java.util.UUID;
 
 public class TeamMatchScore {
-    private UUID teamMatchScoreId;
+    @Getter
+    private final UUID teamMatchScoreId;
     private Team team;
 
     private int score;
diff --git a/sth-frontend/.idea/.gitignore b/sth-frontend/.idea/.gitignore
new file mode 100644
index 0000000..b58b603
--- /dev/null
+++ b/sth-frontend/.idea/.gitignore
@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/sth-frontend/.idea/modules.xml b/sth-frontend/.idea/modules.xml
new file mode 100644
index 0000000..eb09683
--- /dev/null
+++ b/sth-frontend/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/sth-frontend.iml" filepath="$PROJECT_DIR$/.idea/sth-frontend.iml" />
+    </modules>
+  </component>
+</project>
\ No newline at end of file
diff --git a/sth-frontend/.idea/sth-frontend.iml b/sth-frontend/.idea/sth-frontend.iml
new file mode 100644
index 0000000..24643cc
--- /dev/null
+++ b/sth-frontend/.idea/sth-frontend.iml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/.tmp" />
+      <excludeFolder url="file://$MODULE_DIR$/temp" />
+      <excludeFolder url="file://$MODULE_DIR$/tmp" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
\ No newline at end of file
diff --git a/sth-frontend/.idea/vcs.xml b/sth-frontend/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/sth-frontend/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
+  </component>
+</project>
\ No newline at end of file
-- 
GitLab