| 1 | package edu.ucsb.cs156.frontiers.models; | |
| 2 | ||
| 3 | ||
| 4 | import edu.ucsb.cs156.frontiers.entities.RosterStudent; | |
| 5 | import edu.ucsb.cs156.frontiers.enums.OrgStatus; | |
| 6 | import edu.ucsb.cs156.frontiers.enums.RosterStatus; | |
| 7 | import jakarta.persistence.EnumType; | |
| 8 | import jakarta.persistence.Enumerated; | |
| 9 | import lombok.AllArgsConstructor; | |
| 10 | import lombok.Builder; | |
| 11 | import lombok.Data; | |
| 12 | import lombok.NoArgsConstructor; | |
| 13 | ||
| 14 | ||
| 15 | /** | |
| 16 | * This is a DTO class that represents a student in the roster. | |
| 17 | * It is used to transfer data between the server and the client. | |
| 18 | */ | |
| 19 | @Data | |
| 20 | @AllArgsConstructor | |
| 21 | @NoArgsConstructor | |
| 22 | @Builder | |
| 23 | public class RosterStudentDTO { | |
| 24 | | |
| 25 | private Long id; | |
| 26 | ||
| 27 | private Long courseId; | |
| 28 | | |
| 29 | private String studentId; | |
| 30 | private String firstName; | |
| 31 | private String lastName; | |
| 32 | private String email; | |
| 33 | ||
| 34 | private long userId; | |
| 35 | private Integer userGithubId; | |
| 36 | private String userGithubLogin; | |
| 37 | ||
| 38 | @Enumerated(EnumType.STRING) | |
| 39 | private RosterStatus rosterStatus; | |
| 40 | ||
| 41 | @Enumerated(EnumType.STRING) | |
| 42 | private OrgStatus orgStatus; | |
| 43 | ||
| 44 | ||
| 45 | public static RosterStudentDTO from(RosterStudent student) { | |
| 46 |
1
1. from : negated conditional → KILLED |
long userId = student.getUser() != null ? student.getUser().getId() : 0; |
| 47 | | |
| 48 |
1
1. from : replaced return value with null for edu/ucsb/cs156/frontiers/models/RosterStudentDTO::from → KILLED |
return RosterStudentDTO.builder() |
| 49 | .id(student.getId()) | |
| 50 | .courseId(student.getCourse().getId()) | |
| 51 | .studentId(student.getStudentId()) | |
| 52 | .firstName(student.getFirstName()) | |
| 53 | .lastName(student.getLastName()) | |
| 54 | .email(student.getEmail()) | |
| 55 | .userId(userId) | |
| 56 | .userGithubId(student.getGithubId()) | |
| 57 | .userGithubLogin(student.getGithubLogin()) | |
| 58 | .rosterStatus(student.getRosterStatus()) | |
| 59 | .orgStatus(student.getOrgStatus()) | |
| 60 | .build(); | |
| 61 | } | |
| 62 | } | |
Mutations | ||
| 46 |
1.1 |
|
| 48 |
1.1 |