| 1 | package edu.ucsb.cs156.happiercows.jobs; | |
| 2 | ||
| 3 | import java.util.Optional; | |
| 4 | ||
| 5 | import edu.ucsb.cs156.happiercows.entities.Commons; | |
| 6 | import edu.ucsb.cs156.happiercows.entities.CommonsPlus; | |
| 7 | import edu.ucsb.cs156.happiercows.repositories.CommonsRepository; | |
| 8 | import edu.ucsb.cs156.happiercows.repositories.UserCommonsRepository; | |
| 9 | import edu.ucsb.cs156.happiercows.repositories.UserRepository; | |
| 10 | import edu.ucsb.cs156.happiercows.services.CommonsPlusBuilderService; | |
| 11 | import edu.ucsb.cs156.happiercows.services.jobs.JobContext; | |
| 12 | import edu.ucsb.cs156.happiercows.services.jobs.JobContextConsumer; | |
| 13 | import lombok.AllArgsConstructor; | |
| 14 | import lombok.Getter; | |
| 15 | ||
| 16 | @AllArgsConstructor | |
| 17 | public class UpdateCowHealthJobInd implements JobContextConsumer { | |
| 18 | ||
| 19 |     @Getter | |
| 20 |     private CommonsRepository commonsRepository; | |
| 21 |     @Getter | |
| 22 |     private UserCommonsRepository userCommonsRepository; | |
| 23 |     @Getter | |
| 24 |     private UserRepository userRepository; | |
| 25 |     @Getter | |
| 26 |     private CommonsPlusBuilderService commonsPlusBuilderService; | |
| 27 |     @Getter | |
| 28 |     private Long commonsID; | |
| 29 | ||
| 30 |     @Override | |
| 31 |     public void accept(JobContext ctx) throws Exception { | |
| 32 | 
1
1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED | 
        ctx.log("Updating cow health..."); | 
| 33 | ||
| 34 |        Optional<Commons> commonUpdatedOpt = commonsRepository.findById(commonsID); | |
| 35 | ||
| 36 | ||
| 37 | 
1
1. accept : negated conditional → KILLED | 
        if(commonUpdatedOpt.isPresent()){ | 
| 38 |             Commons commonsUpdated = commonUpdatedOpt.get(); | |
| 39 |             CommonsPlus commonsPlus = commonsPlusBuilderService.toCommonsPlus(commonsUpdated); | |
| 40 | 
1
1. accept : removed call to edu/ucsb/cs156/happiercows/jobs/UpdateCowHealthJob::runUpdateJobInCommons → KILLED | 
            UpdateCowHealthJob.runUpdateJobInCommons(commonsUpdated, commonsPlus, commonsPlusBuilderService, commonsRepository, userCommonsRepository, ctx);  | 
| 41 | 
1
1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED | 
            ctx.log("Cow health has been updated!"); | 
| 42 |         } else { | |
| 43 | 
1
1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED | 
            ctx.log(String.format("No commons found for id %d", commonsID)); | 
| 44 |         } | |
| 45 |     } | |
| 46 |      | |
| 47 | } | |
Mutations | ||
| 32 | 
 
 1.1  | 
|
| 37 | 
 
 1.1  | 
|
| 40 | 
 
 1.1  | 
|
| 41 | 
 
 1.1  | 
|
| 43 | 
 
 1.1  |