Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Submit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EIP
Labrador
Submit
Commits
03d753e8
Commit
03d753e8
authored
Nov 20, 2023
by
Ada Turgut
Browse files
Options
Downloads
Patches
Plain Diff
Add better return types
parent
4f15aba7
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!229
Version 2.2.1
,
!203
Resolve "Add verification to not put person in two groups at once"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/nl/tudelft/submit/service/StudentGroupService.java
+12
-14
12 additions, 14 deletions
...n/java/nl/tudelft/submit/service/StudentGroupService.java
with
12 additions
and
14 deletions
src/main/java/nl/tudelft/submit/service/StudentGroupService.java
+
12
−
14
View file @
03d753e8
...
...
@@ -277,15 +277,14 @@ public class StudentGroupService {
*
* @param personId the id of the person
* @param moduleId the id of the module
* @return false if there are no other groups the people are in
*/
private
Boolean
checkIfPersonIsAlreadyInAGroup
(
Long
personId
,
Long
moduleId
,
String
message
)
private
void
checkIfPersonIsAlreadyInAGroup
(
Long
personId
,
Long
moduleId
,
String
message
)
throws
GroupSwitchingException
{
Optional
<
StudentGroupDetailsDTO
>
currentGroup
=
getGroupForPersonInModule
(
personId
,
moduleId
);
// person is not in any other groups in the module
if
(
currentGroup
.
isEmpty
())
{
return
false
;
return
;
}
String
personName
=
personCache
.
get
(
personId
).
orElseThrow
().
getDisplayName
();
...
...
@@ -299,14 +298,13 @@ public class StudentGroupService {
*
* @param usernames list of usernames to be checked
* @param moduleId the id of the module
*
@return whether if there is a person that is already in a group in the same module
*
*/
private
Boolean
arePeopleAlreadyInAGroup
(
Long
moduleId
,
List
<
String
>
usernames
,
String
message
)
{
return
usernames
.
stream
()
.
map
(
name
->
personCache
.
get
(
name
).
getId
())
.
map
(
id
->
checkIfPersonIsAlreadyInAGroup
(
id
,
moduleId
,
message
))
.
reduce
(
false
,
(
x
,
y
)
->
x
||
y
);
private
void
arePeopleAlreadyInAGroup
(
Long
moduleId
,
List
<
String
>
usernames
,
String
message
)
{
for
(
String
name
:
usernames
)
{
Long
id
=
personCache
.
get
(
name
).
getId
();
checkIfPersonIsAlreadyInAGroup
(
id
,
moduleId
,
message
);
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment