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