Class TeamsController

java.lang.Object
edu.ucsb.cs156.frontiers.controllers.ApiController
edu.ucsb.cs156.frontiers.controllers.TeamsController

@RequestMapping("/api/teams") @RestController public class TeamsController extends ApiController
  • Field Details

  • 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 team
      courseId - 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 for
      file - 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 team
      rosterStudentId - 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

      public TeamsController.TeamSourceType getRosterSourceType(String[] headers)
    • fromCSVRow

      public TeamsController.TeamMemberResult fromCSVRow(String[] row, TeamsController.TeamSourceType sourceType, Course course)
    • teamMemberFromSimpleCsv

      public TeamsController.TeamMemberResult teamMemberFromSimpleCsv(String[] row, Course course)