1 | package edu.ucsb.cs156.frontiers.services; | |
2 | ||
3 | import com.opencsv.bean.StatefulBeanToCsv; | |
4 | import com.opencsv.bean.StatefulBeanToCsvBuilder; | |
5 | import edu.ucsb.cs156.frontiers.entities.RosterStudent; | |
6 | import edu.ucsb.cs156.frontiers.models.RosterStudentDTO; | |
7 | import edu.ucsb.cs156.frontiers.repositories.RosterStudentRepository; | |
8 | import java.io.IOException; | |
9 | import java.io.Writer; | |
10 | import java.util.List; | |
11 | import java.util.stream.Collectors; | |
12 | import java.util.stream.StreamSupport; | |
13 | import org.springframework.beans.factory.annotation.Autowired; | |
14 | import org.springframework.stereotype.Service; | |
15 | ||
16 | @Service | |
17 | public class RosterStudentDTOService { | |
18 | ||
19 | @Autowired private RosterStudentRepository rosterStudentRepository; | |
20 | ||
21 | /** | |
22 | * This method gets a list of RosterStudentDTOs based on the courseId | |
23 | * | |
24 | * @param courseId if of the course | |
25 | * @return a list of RosterStudentDTOs | |
26 | */ | |
27 | public List<RosterStudentDTO> getRosterStudentDTOs(Long courseId) { | |
28 | Iterable<RosterStudent> matchedStudents = rosterStudentRepository.findByCourseId(courseId); | |
29 | ||
30 |
1
1. getRosterStudentDTOs : replaced return value with Collections.emptyList for edu/ucsb/cs156/frontiers/services/RosterStudentDTOService::getRosterStudentDTOs → KILLED |
return StreamSupport.stream(matchedStudents.spliterator(), false) |
31 | .map(RosterStudentDTO::new) | |
32 | .collect(Collectors.toList()); | |
33 | } | |
34 | ||
35 | public StatefulBeanToCsv<RosterStudentDTO> getStatefulBeanToCSV(Writer writer) | |
36 | throws IOException { | |
37 |
1
1. getStatefulBeanToCSV : replaced return value with null for edu/ucsb/cs156/frontiers/services/RosterStudentDTOService::getStatefulBeanToCSV → KILLED |
return new StatefulBeanToCsvBuilder<RosterStudentDTO>(writer).build(); |
38 | } | |
39 | } | |
Mutations | ||
30 |
1.1 |
|
37 |
1.1 |