| 1 | package edu.ucsb.cs156.frontiers.jobs; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.frontiers.entities.Course; | |
| 4 | import edu.ucsb.cs156.frontiers.entities.RosterStudent; | |
| 5 | import edu.ucsb.cs156.frontiers.enums.OrgStatus; | |
| 6 | import edu.ucsb.cs156.frontiers.repositories.RosterStudentRepository; | |
| 7 | import edu.ucsb.cs156.frontiers.services.OrganizationMemberService; | |
| 8 | import edu.ucsb.cs156.frontiers.services.jobs.JobContext; | |
| 9 | import edu.ucsb.cs156.frontiers.services.jobs.JobContextConsumer; | |
| 10 | import java.util.List; | |
| 11 | import lombok.Builder; | |
| 12 | import lombok.EqualsAndHashCode; | |
| 13 | import org.springframework.http.HttpStatus; | |
| 14 | import org.springframework.web.client.HttpStatusCodeException; | |
| 15 | ||
| 16 | @Builder | |
| 17 | @EqualsAndHashCode | |
| 18 | public class RemoveStudentsJob implements JobContextConsumer { | |
| 19 | private OrganizationMemberService organizationMemberService; | |
| 20 | private List<RosterStudent> students; | |
| 21 | private RosterStudentRepository rosterStudentRepository; | |
| 22 | ||
| 23 | @Override | |
| 24 | public Course getCourse() { | |
| 25 | return null; | |
| 26 | } | |
| 27 | ||
| 28 | @Override | |
| 29 | public void accept(JobContext c) throws Exception { | |
| 30 | for (RosterStudent student : students) { | |
| 31 |
1
1. accept : negated conditional → KILLED |
if (student.getCourse().getOrgName() != null |
| 32 |
1
1. accept : negated conditional → KILLED |
&& student.getCourse().getInstallationId() != null) { |
| 33 |
2
1. accept : negated conditional → KILLED 2. accept : negated conditional → KILLED |
if (student.getGithubLogin() != null && student.getGithubId() != null) { |
| 34 | try { | |
| 35 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/services/OrganizationMemberService::removeOrganizationMember → KILLED |
organizationMemberService.removeOrganizationMember(student); |
| 36 | c.log("Removed student %s from Organization".formatted(student.getGithubLogin())); | |
| 37 | } catch (HttpStatusCodeException e) { | |
| 38 |
1
1. accept : negated conditional → KILLED |
if (e.getStatusCode() == HttpStatus.NOT_FOUND) { |
| 39 | c.log("Student %s not in Organization".formatted(student.getGithubLogin())); | |
| 40 | } else { | |
| 41 | throw new IllegalStateException( | |
| 42 | "Failed to remove student " | |
| 43 | + student.getGithubLogin() | |
| 44 | + " from Organization: " | |
| 45 | + e.getMessage(), | |
| 46 | e); | |
| 47 | } | |
| 48 | } | |
| 49 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/entities/RosterStudent::setGithubId → KILLED |
student.setGithubId(null); |
| 50 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/entities/RosterStudent::setGithubLogin → KILLED |
student.setGithubLogin(null); |
| 51 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/entities/RosterStudent::setOrgStatus → KILLED |
student.setOrgStatus(OrgStatus.REMOVED); |
| 52 | rosterStudentRepository.save(student); | |
| 53 | } | |
| 54 | } | |
| 55 | } | |
| 56 | } | |
| 57 | } | |
Mutations | ||
| 31 |
1.1 |
|
| 32 |
1.1 |
|
| 33 |
1.1 2.2 |
|
| 35 |
1.1 |
|
| 38 |
1.1 |
|
| 49 |
1.1 |
|
| 50 |
1.1 |
|
| 51 |
1.1 |