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