diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /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 0000000000000000000000000000000000000000..dbb096cd6d54e582fa1f05a952f900aff209bf72 --- /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 0000000000000000000000000000000000000000..f22b0514c88c9e7d3cb3185d592709fa11428d53 --- /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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0 b/.idea/sonarlint/issuestore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d b/.idea/sonarlint/issuestore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9 b/.idea/sonarlint/issuestore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/d/4/d4d373a247368212c60cc99595abbf323611ed8f b/.idea/sonarlint/issuestore/d/4/d4d373a247368212c60cc99595abbf323611ed8f new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5 b/.idea/sonarlint/issuestore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c b/.idea/sonarlint/issuestore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743 b/.idea/sonarlint/issuestore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb new file mode 100644 index 0000000000000000000000000000000000000000..709b569b73e4ff515d56973c80bb33eb1facd1f4 --- /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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0 b/.idea/sonarlint/securityhotspotstore/8/1/81d8eb2bc5a911b258c49bed79926844ea3988f0 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d b/.idea/sonarlint/securityhotspotstore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9 b/.idea/sonarlint/securityhotspotstore/a/d/ad9815cb514700b7f513e4aad039536e258c58d9 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/d/4/d4d373a247368212c60cc99595abbf323611ed8f b/.idea/sonarlint/securityhotspotstore/d/4/d4d373a247368212c60cc99595abbf323611ed8f new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5 b/.idea/sonarlint/securityhotspotstore/e/f/ef8def03dc8f162799089e9b5f4321201c8810d5 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c b/.idea/sonarlint/securityhotspotstore/f/7/f764c0a37a5c9f7a04bea4edf778d74fc41a085c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743 b/.idea/sonarlint/securityhotspotstore/f/f/ffa88f39108e02aca02fbfcfdefda86d60005743 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/index.pb b/.idea/sonarlint/securityhotspotstore/index.pb new file mode 100644 index 0000000000000000000000000000000000000000..709b569b73e4ff515d56973c80bb33eb1facd1f4 --- /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 0000000000000000000000000000000000000000..ad374d022aed5c40a4269d539eab810e124ec75c --- /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 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /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 0000000000000000000000000000000000000000..59f5501b5ced9e64462d9a239ff0f72b5c6f858e --- /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 0000000000000000000000000000000000000000..d00a7668e4100c345de3764cd046cceafcb4e3f8 --- /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 467639b5db65b94b1eb297bfec486e642c546845..1d480af8438336f19bc693642c9796f8043c33a2 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 b6563d548b6eec7884fc7b0e5321f82a16127d56..ed541ebae402b22e91f6aa9e467933da77ff6af0 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 fde8ebd629951693c073399490abc912aad570be..14c7535362cc4ae84338fd5af8d3282338b9af62 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 0000000000000000000000000000000000000000..b58b603fea78041071d125a30db58d79b3d49217 --- /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 0000000000000000000000000000000000000000..eb0968383d20df1d15c95facf84d3da3e9289b4b --- /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 0000000000000000000000000000000000000000..24643cc37449b4bde54411a80b8ed61258225e34 --- /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 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc --- /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