| 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 DeleteTeamMemberFromGithubJob implements JobContextConsumer { | |
| 11 | String memberGithubLogin; | |
| 12 | Integer githubTeamId; | |
| 13 | Course course; | |
| 14 | GithubTeamService githubTeamService; | |
| 15 | ||
| 16 | @Override | |
| 17 | public void accept(JobContext ctx) throws Exception { | |
| 18 | ctx.log( | |
| 19 | "Starting delete team member from GitHub job for team ID " | |
| 20 | + githubTeamId | |
| 21 | + " member " | |
| 22 | + memberGithubLogin); | |
| 23 | ||
| 24 |
1
1. accept : negated conditional → KILLED |
if (githubTeamId == null) { |
| 25 | ctx.log("ERROR: Team has no GitHub team ID"); | |
| 26 | return; | |
| 27 | } | |
| 28 | ||
| 29 |
1
1. accept : negated conditional → KILLED |
if (memberGithubLogin == null) { |
| 30 | ctx.log("ERROR: Team member has no GitHub login"); | |
| 31 | return; | |
| 32 | } | |
| 33 | ||
| 34 |
2
1. accept : negated conditional → KILLED 2. accept : negated conditional → KILLED |
if (course.getOrgName() == null || course.getInstallationId() == null) { |
| 35 | ctx.log("ERROR: Course has no linked GitHub organization"); | |
| 36 | return; | |
| 37 | } | |
| 38 | // Get the organization id | |
| 39 | Integer orgId = null; | |
| 40 | try { | |
| 41 | orgId = githubTeamService.getOrgId(course.getOrgName(), course); | |
| 42 | ||
| 43 | } catch (Exception e) { | |
| 44 | ctx.log( | |
| 45 | "ERROR: Failed to get organization ID for org: " | |
| 46 | + course.getOrgName() | |
| 47 | + " - " | |
| 48 | + e.getMessage()); | |
| 49 | return; | |
| 50 | } | |
| 51 | ||
| 52 | try { | |
| 53 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/services/GithubTeamService::removeMemberFromGithubTeam → KILLED |
githubTeamService.removeMemberFromGithubTeam(orgId, memberGithubLogin, githubTeamId, course); |
| 54 | ctx.log("Successfully removed user from GitHub team"); | |
| 55 | } catch (Exception e) { | |
| 56 | ctx.log("ERROR: Failed to remove user from GitHub team: " + e.getMessage()); | |
| 57 | } | |
| 58 | ||
| 59 | ctx.log("Done"); | |
| 60 | } | |
| 61 | } | |
Mutations | ||
| 24 |
1.1 |
|
| 29 |
1.1 |
|
| 34 |
1.1 2.2 |
|
| 53 |
1.1 |