-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.java
More file actions
161 lines (127 loc) · 3.42 KB
/
Copy pathProject.java
File metadata and controls
161 lines (127 loc) · 3.42 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package ch.fhnw.timerecordingbackend.model;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Set;
/**
* Entität Klasse für Projekte
* @author PD
* Code von anderen Teammitgliedern oder Quellen wird durch einzelne Kommentare deklariert
* @version 1.0
*/
@Entity
@Table(name = "projects")
public class Project {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, length = 100)
private String name;
@Column(length = 255)
private String description;
@Column(name = "created_at")
private LocalDateTime createdAt;
@Column(name = "updated_at")
private LocalDateTime updatedAt;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "manager_id")
private User manager;
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<TimeEntry> timeEntries = new HashSet<>();
@Column(nullable = false)
private boolean active = true;
/**
* Konstruktor
*/
public Project() {}
public Project(String name) {
this.name = name;
this.createdAt = LocalDateTime.now();
this.updatedAt = LocalDateTime.now();
}
public Project(String name, String description) {
this.name = name;
this.description = description;
this.createdAt = LocalDateTime.now();
this.updatedAt = LocalDateTime.now();
}
/**
* Aktivieren und deaktivieren
*/
public void deactivate() {
this.active = false;
this.updatedAt = LocalDateTime.now();
}
public void activate() {
this.active = true;
this.updatedAt = LocalDateTime.now();
}
/**
* Zeitstempel aktualisiern
*/
@PreUpdate
public void preUpdate() {
this.updatedAt = LocalDateTime.now();
}
/**
* Getter und Setter
* Automatisch generiert mit IntelliJ
*/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
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;
}
public User getManager() {
return manager;
}
public void setManager(User manager) {
this.manager = manager;
}
public Set<TimeEntry> getTimeEntries() {
return timeEntries;
}
public void setTimeEntries(Set<TimeEntry> timeEntries) {
this.timeEntries = timeEntries;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
@Override
public String toString() {
return "Project{" +
"id=" + id +
", name='" + name + '\'' +
", description='" + description + '\'' +
", active=" + active +
'}';
}
}