| 1 | package edu.ucsb.cs156.frontiers.jobs; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.frontiers.entities.Course; | |
| 4 | import edu.ucsb.cs156.frontiers.services.GithubTeamService; | |
| 5 | import edu.ucsb.cs156.frontiers.services.jobs.JobContext; | |
| 6 | import edu.ucsb.cs156.frontiers.services.jobs.JobContextConsumer; | |
| 7 | import lombok.Builder; | |
| 8 | ||
| 9 | @Builder | |
| 10 | public class DeleteTeamFromGithubJob implements JobContextConsumer { | |
| 11 | Integer githubTeamId; | |
| 12 | Course course; | |
| 13 | GithubTeamService githubTeamService; | |
| 14 | ||
| 15 | @Override | |
| 16 | public void accept(JobContext ctx) throws Exception { | |
| 17 | ctx.log("Starting delete team from GitHub job for team ID " + githubTeamId); | |
| 18 | ||
| 19 |
1
1. accept : negated conditional → KILLED |
if (githubTeamId == null) { |
| 20 | ctx.log("ERROR: Team has no GitHub team ID"); | |
| 21 | return; | |
| 22 | } | |
| 23 | ||
| 24 |
2
1. accept : negated conditional → KILLED 2. accept : negated conditional → KILLED |
if (course.getOrgName() == null || course.getInstallationId() == null) { |
| 25 | ctx.log("ERROR: Course has no linked GitHub organization"); | |
| 26 | return; | |
| 27 | } | |
| 28 | // Get the organization id | |
| 29 | Integer orgId = null; | |
| 30 | try { | |
| 31 | orgId = githubTeamService.getOrgId(course.getOrgName(), course); | |
| 32 | ||
| 33 | } catch (Exception e) { | |
| 34 | ctx.log( | |
| 35 | "ERROR: Failed to get organization ID for org: " | |
| 36 | + course.getOrgName() | |
| 37 | + " - " | |
| 38 | + e.getMessage()); | |
| 39 | return; | |
| 40 | } | |
| 41 | ||
| 42 | try { | |
| 43 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/services/GithubTeamService::deleteGithubTeam → KILLED |
githubTeamService.deleteGithubTeam(orgId, githubTeamId, course); |
| 44 | ctx.log("Successfully deleted GitHub team"); | |
| 45 | } catch (Exception e) { | |
| 46 | ctx.log("ERROR: Failed to delete GitHub team: " + e.getMessage()); | |
| 47 | } | |
| 48 | ||
| 49 | ctx.log("Done"); | |
| 50 | } | |
| 51 | } | |
Mutations | ||
| 19 |
1.1 |
|
| 24 |
1.1 2.2 |
|
| 43 |
1.1 |