Class TeamsController
java.lang.Object
edu.ucsb.cs156.frontiers.controllers.ApiController
edu.ucsb.cs156.frontiers.controllers.TeamsController
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
static final record
static final record
static enum
static enum
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTeamMember
(Long teamId, Long rosterStudentId, Long courseId) This method adds a roster student as a team memberThis method returns a list of all teams for a coursedeleteTeam
(Long id, Long courseId) This method deletes a team by its idfromCSVRow
(String[] row, TeamsController.TeamSourceType sourceType, Course course) getRosterSourceType
(String[] headers) getTeamById
(Long id, Long courseId) This method returns a single team by its idThis method creates a new Team.removeTeamMember
(Long teamMemberId, Long courseId) This method removes a team memberteamMemberFromSimpleCsv
(String[] row, Course course) teamMemberMapping
(Long courseId) Retrieves a list of mappings between roster students and teams for a given course.uploadTeamsCsv
(Long courseId, org.springframework.web.multipart.MultipartFile file) Upload teams in CSV format (team, email) It is important to keep the code in this method consistent with the code for adding a single roster studentMethods inherited from class edu.ucsb.cs156.frontiers.controllers.ApiController
doesCurrentUserHaveRole, genericMessage, getCurrentUser, handleEntityNotFoundException, handleIllegalArgument, handleNoLinkedOrgException, handleUnsupportedOperation, isCurrentUserAdmin
-
Field Details
-
SIMPLE_HEADERS
- See Also:
-
-
Constructor Details
-
TeamsController
public TeamsController()
-
-
Method Details
-
postTeam
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @PostMapping("/post") public Team postTeam(@RequestParam String name, @RequestParam Long courseId) This method creates a new Team.- Parameters:
name
- the name of the teamcourseId
- the ID of the course this team belongs to- Returns:
- the created team
-
uploadTeamsCsv
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @PostMapping(value="/upload/csv", consumes="multipart/form-data") public TeamsController.TeamCreationResponse uploadTeamsCsv(@RequestParam Long courseId, @RequestParam("file") org.springframework.web.multipart.MultipartFile file) throws IOException, com.opencsv.exceptions.CsvException Upload teams in CSV format (team, email) It is important to keep the code in this method consistent with the code for adding a single roster student- Parameters:
courseId
- course the teams are forfile
- csv file with roster student emails and team assignments- Returns:
- Count of students added to teams, already existing, and rejected students
- Throws:
IOException
com.opencsv.exceptions.CsvException
-
allTeams
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @GetMapping("/all") public Iterable<Team> allTeams(@RequestParam Long courseId) This method returns a list of all teams for a course- Returns:
- a list of all teams for a course
-
teamMemberMapping
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @GetMapping("/mapping") public Iterable<TeamsController.TeamMemberMapping> teamMemberMapping(@RequestParam Long courseId) Retrieves a list of mappings between roster students and teams for a given course. Each mapping represents a relationship between a team and its members.- Parameters:
courseId
- the unique identifier of the course for which team mappings are retrieved- Returns:
- an iterable collection of
TeamMemberMapping
objects representing the mappings
-
getTeamById
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @GetMapping("") public Team getTeamById(@RequestParam Long id, @RequestParam Long courseId) This method returns a single team by its id- Parameters:
id
- the id of the team- Returns:
- the team
-
deleteTeam
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @DeleteMapping("") @Transactional public Object deleteTeam(@RequestParam Long id, @RequestParam Long courseId) This method deletes a team by its id- Parameters:
id
- the id of the team to delete- Returns:
- a message indicating the team was deleted
-
addTeamMember
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @PostMapping("/addMember") public TeamMember addTeamMember(@RequestParam Long teamId, @RequestParam Long rosterStudentId, @RequestParam Long courseId) This method adds a roster student as a team member- Parameters:
teamId
- the ID of the teamrosterStudentId
- the ID of the roster student to add- Returns:
- the created team member
-
removeTeamMember
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @DeleteMapping("/removeMember") @Transactional public Object removeTeamMember(@RequestParam Long teamMemberId, @RequestParam Long courseId) This method removes a team member- Parameters:
teamMemberId
- the ID of the team member to remove- Returns:
- a message indicating the team member was removed
-
getRosterSourceType
-
fromCSVRow
public TeamsController.TeamMemberResult fromCSVRow(String[] row, TeamsController.TeamSourceType sourceType, Course course) -
teamMemberFromSimpleCsv
-