-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbsenceResponse.java
More file actions
125 lines (96 loc) · 4.27 KB
/
Copy pathAbsenceResponse.java
File metadata and controls
125 lines (96 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package ch.fhnw.timerecordingbackend.dto.absence;
import ch.fhnw.timerecordingbackend.model.enums.AbsenceStatus;
import ch.fhnw.timerecordingbackend.model.enums.AbsenceType;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* DTO Antwort für Abwesenheiten Anfragen
* @author PD
* Code von anderen Teammitgliedern oder Quellen wird durch einzelne Kommentare deklariert
* @version 1.0
* Quelle: https://techkluster.com/2023/08/21/dto-for-a-java-spring-application/
*/
public class AbsenceResponse {
// Basis-Informationen
private Long id;
private LocalDate startDate;
private LocalDate endDate;
private AbsenceType type;
private String comment; // NEU!
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
// Benutzer-Informationen
private Long userId;
private String firstName;
private String lastName;
private String email;
// Genehmiger-Informationen (NEU!)
private Long processedById;
private String processedByName;
private LocalDateTime processedDate;
// Ablehnungs-Informationen (NEU!)
private String rejectionReason;
// Status für UI (NEU!)
private AbsenceStatus status; // Für Backward Compatibility
public AbsenceResponse() {}
// Getter und Setter
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public LocalDate getStartDate() { return startDate; }
public void setStartDate(LocalDate startDate) { this.startDate = startDate; }
public LocalDate getEndDate() { return endDate; }
public void setEndDate(LocalDate endDate) { this.endDate = endDate; }
public AbsenceType getType() { return type; }
public void setType(AbsenceType type) { this.type = type; }
public String getComment() { return comment; }
public void setComment(String comment) { this.comment = comment; }
public LocalDateTime getCreatedAt() { return createdAt; }
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
public LocalDateTime getUpdatedAt() { return updatedAt; }
public void setUpdatedAt(LocalDateTime updatedAt) { this.updatedAt = updatedAt; }
// Benutzer-Informationen
public Long getUserId() { return userId; }
public void setUserId(Long userId) { this.userId = userId; }
public String getFirstName() { return firstName; }
public void setFirstName(String firstName) { this.firstName = firstName; }
public String getLastName() { return lastName; }
public void setLastName(String lastName) { this.lastName = lastName; }
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
public String getFullName() {
if (firstName != null && lastName != null) {
return firstName + " " + lastName;
}
return email;
}
// Genehmiger-Informationen
public Long getProcessedById() { return processedById; }
public void setProcessedById(Long processedById) { this.processedById = processedById; }
public String getProcessedByName() { return processedByName; }
public void setProcessedByName(String processedByName) { this.processedByName = processedByName; }
public LocalDateTime getProcessedDate() { return processedDate; }
public void setProcessedDate(LocalDateTime processedDate) { this.processedDate = processedDate; }
// Ablehnungs-Informationen
public String getRejectionReason() { return rejectionReason; }
public void setRejectionReason(String rejectionReason) { this.rejectionReason = rejectionReason; }
// Backward Compatibility
public AbsenceStatus getStatus() { return status; } // Getter für Status
public void setStatus(AbsenceStatus status) { this.status = status; } // Setter für Status
public long getDurationInDays() {
if (startDate != null && endDate != null) {
return java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1;
}
return 0;
}
@Override
public String toString() {
return "AbsenceResponse{" +
"id=" + id +
", startDate=" + startDate +
", endDate=" + endDate +
", type=" + type +
", status=" + status +
", email='" + email + '\'' +
'}';
}
}