| 1 | package edu.ucsb.cs156.frontiers.jobs; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.frontiers.entities.Course; | |
| 4 | import edu.ucsb.cs156.frontiers.entities.Team; | |
| 5 | import edu.ucsb.cs156.frontiers.repositories.TeamRepository; | |
| 6 | import edu.ucsb.cs156.frontiers.services.GithubTeamService; | |
| 7 | import edu.ucsb.cs156.frontiers.services.jobs.JobContext; | |
| 8 | import edu.ucsb.cs156.frontiers.services.jobs.JobContextConsumer; | |
| 9 | import lombok.Builder; | |
| 10 | ||
| 11 | @Builder | |
| 12 | public class AddTeamToGithubJob implements JobContextConsumer { | |
| 13 | Course course; | |
| 14 | String teamName; | |
| 15 | TeamRepository teamRepository; | |
| 16 | GithubTeamService githubTeamService; | |
| 17 | ||
| 18 | @Override | |
| 19 | public Course getCourse() { | |
| 20 |
1
1. getCourse : replaced return value with null for edu/ucsb/cs156/frontiers/jobs/AddTeamToGithubJob::getCourse → KILLED |
return course; |
| 21 | } | |
| 22 | ||
| 23 | @Override | |
| 24 | public void accept(JobContext ctx) throws Exception { | |
| 25 | ctx.log("Starting add team to GitHub job for team: " + teamName); | |
| 26 | ||
| 27 |
1
1. accept : negated conditional → KILLED |
if (teamName == null) { |
| 28 | ctx.log("ERROR: Team has no name"); | |
| 29 | return; | |
| 30 | } | |
| 31 | ||
| 32 |
2
1. accept : negated conditional → KILLED 2. accept : negated conditional → KILLED |
if (course.getOrgName() == null || course.getInstallationId() == null) { |
| 33 | ctx.log("ERROR: Course has no linked GitHub organization"); | |
| 34 | return; | |
| 35 | } | |
| 36 | ||
| 37 | Team team = teamRepository.findByCourseIdAndName(course.getId(), teamName).orElse(null); | |
| 38 |
1
1. accept : negated conditional → KILLED |
if (team == null) { |
| 39 | ctx.log( | |
| 40 | "ERROR: Team with name '" | |
| 41 | + teamName | |
| 42 | + "' not found for course " | |
| 43 | + course.getCourseName()); | |
| 44 | return; | |
| 45 | } | |
| 46 | ||
| 47 | try { | |
| 48 | Integer githubTeamId = githubTeamService.createTeam(teamName, course); | |
| 49 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/entities/Team::setGithubTeamId → KILLED |
team.setGithubTeamId(githubTeamId); |
| 50 | teamRepository.save(team); | |
| 51 | ctx.log( | |
| 52 | "Successfully added team '" | |
| 53 | + team.getName() | |
| 54 | + "' to GitHub with GitHub team ID: " | |
| 55 | + githubTeamId); | |
| 56 | } catch (Exception e) { | |
| 57 | ctx.log("ERROR: Failed to add team to GitHub: " + e.getMessage()); | |
| 58 | } | |
| 59 | ||
| 60 | ctx.log("Done"); | |
| 61 | } | |
| 62 | } | |
Mutations | ||
| 20 |
1.1 |
|
| 27 |
1.1 |
|
| 32 |
1.1 2.2 |
|
| 38 |
1.1 |
|
| 49 |
1.1 |