| 1 | package edu.ucsb.cs156.happiercows.jobs; | |
| 2 | ||
| 3 | ||
| 4 | import java.util.Optional; | |
| 5 | ||
| 6 | import edu.ucsb.cs156.happiercows.entities.Commons; | |
| 7 | import edu.ucsb.cs156.happiercows.entities.Report; | |
| 8 | import edu.ucsb.cs156.happiercows.repositories.CommonsRepository; | |
| 9 | import edu.ucsb.cs156.jobs.services.JobContext; | |
| 10 | import edu.ucsb.cs156.jobs.services.JobContextConsumer; | |
| 11 | import edu.ucsb.cs156.happiercows.services.ReportService; | |
| 12 | import lombok.AllArgsConstructor; | |
| 13 | import lombok.Getter; | |
| 14 | ||
| 15 | @AllArgsConstructor | |
| 16 | public class InstructorReportJobSingleCommons implements JobContextConsumer { | |
| 17 | ||
| 18 | @Getter | |
| 19 | private long commonsId; | |
| 20 | ||
| 21 | @Getter | |
| 22 | private ReportService reportService; | |
| 23 | ||
| 24 | @Getter | |
| 25 | private CommonsRepository commonsRepository; | |
| 26 | ||
| 27 | @Override | |
| 28 | public void accept(JobContext ctx) throws Exception { | |
| 29 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log("Producing instructor report for commons id: " + commonsId); |
| 30 | Optional<Commons> commonsOpt = commonsRepository.findById(commonsId); | |
| 31 |
1
1. accept : negated conditional → KILLED |
if (!commonsOpt.isPresent()) { |
| 32 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log(String.format("No commons found for id %d", commonsId)); |
| 33 | return; | |
| 34 | } | |
| 35 |
1
1. accept : negated conditional → KILLED |
if (!CommonsGate.shouldProcess(commonsOpt.get(), commonsRepository, ctx)) { |
| 36 | return; | |
| 37 | } | |
| 38 | Report report = reportService.createReport(commonsId); | |
| 39 |
1
1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED |
ctx.log(String.format("Instructor report %d for commons %s has been produced!", report.getId(), report.getName())); |
| 40 | } | |
| 41 | } | |
Mutations | ||
| 29 |
1.1 |
|
| 31 |
1.1 |
|
| 32 |
1.1 |
|
| 35 |
1.1 |
|
| 39 |
1.1 |