Projekt

Obecné

Profil

« Předchozí | Další » 

Revize ba0044c8

Přidáno uživatelem Dominik Poch před téměř 6 roky(ů)

Re #7390 Base domain classes

Zobrazit rozdíly:

server/src/main/java/cz/zcu/yamanager/domain/DefaultSettings.java
1
package cz.zcu.yamanager.domain;
2

  
3
import java.time.LocalDate;
4

  
5
/**
6
 * A domain class {@code DefaultSettings} represents a single record in the Default_settings table of a database.
7
 * It contains default settings of the application.
8
 */
9
public class DefaultSettings {
10

  
11
    /**
12
     * ID of the default settings.
13
     */
14
    private final int id;
15

  
16
    /**
17
     * Default remaining vacation hours.
18
     */
19
    private int noVacations;
20

  
21
    /**
22
     * Default remaining sick days.
23
     */
24
    private int noSickDays;
25

  
26
    /**
27
     * Default date of an email warning about an incoming reset of the vacation hours and sick days.
28
     */
29
    private LocalDate alertDate;
30

  
31
    /**
32
     * Creates a new instance of the class {@code DefaultSettings}.
33
     * @param id ID of the default settings.
34
     * @param noVacations Default remaining vacation hours.
35
     * @param noSickDays Default remaining sick days.
36
     * @param alertDate Default date of an email warning about an incoming reset of the vacation hours and sick days.
37
     */
38
    public DefaultSettings(int id, int noVacations, int noSickDays, LocalDate alertDate) {
39
        this.id = id;
40
        this.noVacations = noVacations;
41
        this.noSickDays = noSickDays;
42
        this.alertDate = alertDate;
43
    }
44

  
45
    /**
46
     * Gets an ID of the default settings.
47
     * @return The ID of the default settings.
48
     */
49
    public int getId() {
50
        return id;
51
    }
52

  
53
    /**
54
     * Gets a default remaining vacation hours.
55
     * @return The default remaining vacation hours.
56
     */
57
    public int getNoVacations() {
58
        return noVacations;
59
    }
60

  
61
    /**
62
     * Sets a new default remaining vacation hours.
63
     * @param noVacations The new default remaining vacation hours.
64
     */
65
    public void setNoVacations(int noVacations) {
66
        this.noVacations = noVacations;
67
    }
68

  
69
    /**
70
     * Gets a default remaining sick days.
71
     * @return The default remaining sick days.
72
     */
73
    public int getNoSickDays() {
74
        return noSickDays;
75
    }
76

  
77
    /**
78
     * Sets a new default remaining sick days.
79
     * @param noSickDays The new default remaining sick days.
80
     */
81
    public void setNoSickDays(int noSickDays) {
82
        this.noSickDays = noSickDays;
83
    }
84

  
85
    /**
86
     * Gets a default date of an email warning about an incoming reset of the vacation hours and sick days.
87
     * @return The default date of an email warning about an incoming reset of the vacation hours and sick days.
88
     */
89
    public LocalDate getAlertDate() {
90
        return alertDate;
91
    }
92

  
93
    /**
94
     * Sets a new default date of an email warning about an incoming reset of the vacation hours and sick days.
95
     * @param alertDate The new default date of an email warning about an incoming reset of the vacation hours and sick days.
96
     */
97
    public void setAlertDate(LocalDate alertDate) {
98
        this.alertDate = alertDate;
99
    }
100

  
101
    /**
102
     * Gets a string representation of the class {@code DefaultSettings}.
103
     * @return The string representation of the class.
104
     */
105
    @Override
106
    public String toString() {
107
        return "DefaultSettings{" +
108
                "id=" + id +
109
                ", noVacations=" + noVacations +
110
                ", noSickDays=" + noSickDays +
111
                ", alertDate=" + alertDate +
112
                '}';
113
    }
114
}
server/src/main/java/cz/zcu/yamanager/domain/Right.java
1
package cz.zcu.yamanager.domain;
2

  
3
/**
4
 * A domain class {@code Right} represents a single record in the Right table of a database.
5
 * It holds informations about a user's right, which says what can a user do in the application.
6
 * Rights are grouped to roles ({@code Role}).
7
 */
8
public class Right {
9

  
10
    /**
11
     * ID of the right.
12
     */
13
    private final int id;
14

  
15
    /**
16
     * Name of the right.
17
     */
18
    private String name;
19

  
20
    /**
21
     * Description of the right.
22
     */
23
    private String description;
24

  
25
    /**
26
     * Creates a new instance of the class {@code Right}.
27
     * @param id ID of the right.
28
     * @param name Name of the right.
29
     * @param description Description of the right.
30
     */
31
    public Right(int id, String name, String description) {
32
        this.id = id;
33
        this.name = name;
34
        this.description = description;
35
    }
36

  
37
    /**
38
     * Gets an ID of the right.
39
     * @return The ID of the right.
40
     */
41
    public int getId() {
42
        return this.id;
43
    }
44

  
45
    /**
46
     * Gets a name of the right.
47
     * @return The name of the right.
48
     */
49
    public String getName() {
50
        return this.name;
51
    }
52

  
53
    /**
54
     * Sets a new name.
55
     * @param name The new name.
56
     */
57
    public void setName(String name) {
58
        this.name = name;
59
    }
60

  
61
    /**
62
     * Gets a description of the right.
63
     * @return The description of the right.
64
     */
65
    public String getDescription() {
66
        return this.description;
67
    }
68

  
69
    /**
70
     * Sets a new description.
71
     * @param description The new description.
72
     */
73
    public void setDescription(String description) {
74
        this.description = description;
75
    }
76

  
77
    /**
78
     * Gets a string representation of the class {@code Right}.
79
     * @return The string representation of the class.
80
     */
81
    @Override
82
    public String toString() {
83
        return "Right{" +
84
                "id=" + this.id +
85
                ", name='" + this.name + '\'' +
86
                ", description='" + this.description + '\'' +
87
                '}';
88
    }
89
}
server/src/main/java/cz/zcu/yamanager/domain/Role.java
1
package cz.zcu.yamanager.domain;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
/**
7
 * A domain class {@code Role} represents a single record in the Role table of a database.
8
 * Role groups user's rights to a bigger wholes.
9
 */
10
public class Role {
11

  
12
    /**
13
     * ID of the role.
14
     */
15
    private final int id;
16

  
17
    /**
18
     * Name of the role.
19
     */
20
    private String name;
21

  
22
    /**
23
     * List of rights of the role.
24
     */
25
    private List<Right> rightList;
26

  
27
    /**
28
     * Creates a new instance of the class {@code Role}.
29
     * @param id ID of the role.
30
     * @param name Name of the role.
31
     * @param rightList List of rights of the role.
32
     */
33
    public Role(int id, String name, List<Right> rightList) {
34
        this.id = id;
35
        this.name = name;
36
        this.rightList = rightList;
37
    }
38

  
39
    /**
40
     * Gets an ID of the role.
41
     * @return The ID of the right.
42
     */
43
    public int getId() {
44
        return this.id;
45
    }
46

  
47
    /**
48
     * Gets a name of the role.
49
     * @return The name of the role.
50
     */
51
    public String getName() {
52
        return this.name;
53
    }
54

  
55
    /**
56
     * Sets a new name.
57
     * @param name The new name.
58
     */
59
    public void setName(String name) {
60
        this.name = name;
61
    }
62

  
63
    /**
64
     * Returns a copy of a list of rights.
65
     * @return The copy of the list of rights.
66
     */
67
    public List<Right> getRightList() {
68
        return new ArrayList<>(this.rightList);
69
    }
70

  
71
    /**
72
     * Sets a copy of the given list of rights.
73
     * @param rightList The given list of rights.
74
     */
75
    public void setRightList(List<Right> rightList) {
76
        this.rightList = new ArrayList<>(rightList);
77
    }
78

  
79
    /**
80
     * Gets a string representation of the class {@code Role}.
81
     * @return The string representation of the class.
82
     */
83
    @Override
84
    public String toString() {
85
        return "Role{" +
86
                "id=" + id +
87
                ", name='" + name + '\'' +
88
                ", rightList=" + rightList +
89
                '}';
90
    }
91
}
server/src/main/java/cz/zcu/yamanager/domain/SickDay.java
1
package cz.zcu.yamanager.domain;
2

  
3
import java.time.LocalDate;
4

  
5
/**
6
 * A domain class {@code SickDay} represents a single record in the Sick_days table of a database.
7
 * Class holds informations of a sick day taken by a user.
8
 */
9
public class SickDay {
10

  
11
    /**
12
     * ID of the sick day.
13
     */
14
    private final int id;
15

  
16
    /**
17
     * Date of the sick day.
18
     */
19
    private LocalDate date;
20

  
21
    /**
22
     * Approval status of the sick day.
23
     */
24
    private Status status;
25

  
26
    /**
27
     * Creates a new instance of the class {@code SickDay}.
28
     * @param id ID of the sick day.
29
     * @param date Date of the sick day.
30
     * @param status Approval status of the sick day.
31
     */
32
    public SickDay(int id, LocalDate date, Status status) {
33
        this.id = id;
34
        this.date = date;
35
        this.status = status;
36
    }
37

  
38
    /**
39
     * Gets an ID of the sick day.
40
     * @return The ID of the sick day.
41
     */
42
    public int getId() {
43
        return id;
44
    }
45

  
46
    /**
47
     * Gets a date of the sick day.
48
     * @return The date of the sick day.
49
     */
50
    public LocalDate getDate() {
51
        return date;
52
    }
53

  
54
    /**
55
     * Sets a new date.
56
     * @param date The new date.
57
     */
58
    public void setDate(LocalDate date) {
59
        this.date = date;
60
    }
61

  
62
    /**
63
     * Gets an approval status of the sick day.
64
     * @return The approval status of the sick day.
65
     */
66
    public Status getStatus() {
67
        return status;
68
    }
69

  
70
    /**
71
     * Sets a new approval status.
72
     * @param status The new approval status.
73
     */
74
    public void setStatus(Status status) {
75
        this.status = status;
76
    }
77

  
78
    /**
79
     * Gets a string representation of the class {@code SickDay}.
80
     * @return The string representation of the class.
81
     */
82
    @Override
83
    public String toString() {
84
        return "SickDay{" +
85
                "id=" + id +
86
                ", date=" + date +
87
                ", status=" + status +
88
                '}';
89
    }
90
}
server/src/main/java/cz/zcu/yamanager/domain/Status.java
1
package cz.zcu.yamanager.domain;
2

  
3
/**
4
 * A domain class {@code Status} represents a single record in the Approval_status table of a database.
5
 * Approval status indicates state of user's authorization or vacation/sick days confirmation.
6
 */
7
public class Status {
8

  
9
    /**
10
     * ID of the status.
11
     */
12
    private final int id;
13

  
14
    /**
15
     * Name of the status.
16
     */
17
    private String name;
18

  
19
    /**
20
     * Creates a new instance of the class {@code Status}.
21
     * @param id ID of the status.
22
     * @param name Name of the status.
23
     */
24
    public Status(int id, String name) {
25
        this.id = id;
26
        this.name = name;
27
    }
28

  
29
    /**
30
     * Gets an ID of the status.
31
     * @return The ID of the status.
32
     */
33
    public int getId() {
34
        return id;
35
    }
36

  
37
    /**
38
     * Gets a name of the status.
39
     * @return The name of the status.
40
     */
41
    public String getName() {
42
        return name;
43
    }
44

  
45
    /**
46
     * Sets a new name.
47
     * @param name The new name.
48
     */
49
    public void setName(String name) {
50
        this.name = name;
51
    }
52

  
53
    /**
54
     * Gets a string representation of the class {@code Status}.
55
     * @return The string representation of the class.
56
     */
57
    @Override
58
    public String toString() {
59
        return "Status{" +
60
                "id=" + id +
61
                ", name='" + name + '\'' +
62
                '}';
63
    }
64
}
server/src/main/java/cz/zcu/yamanager/domain/User.java
1
package cz.zcu.yamanager.domain;
2

  
3
import java.time.LocalDate;
4

  
5
/**
6
 * A domain class {@code User} represents a single record in the User table of a database.
7
 * User hold all informations about a user which logged to the application.
8
 */
9
public class User {
10

  
11
    /**
12
     * User's ID.
13
     */
14
    private final int id;
15

  
16
    /**
17
     * User's first name.
18
     */
19
    private String firstName;
20

  
21
    /**
22
     * User's last name.
23
     */
24
    private String lastName;
25

  
26
    /**
27
     * User's remaining vacation hours.
28
     */
29
    private int noVacations;
30

  
31
    /**
32
     * User's remaining sick days.
33
     */
34
    private int noSickDays;
35

  
36
    /**
37
     * Date of an email warning about an incoming reset of the vacation hours and sick days.
38
     */
39
    private LocalDate alertDate;
40

  
41
    /**
42
     * Token for the Google oAuth.
43
     */
44
    private String token;
45

  
46
    /**
47
     * User's email address.
48
     */
49
    private String email;
50

  
51
    /**
52
     * URL of a user's photo.
53
     */
54
    private String photo;
55

  
56
    /**
57
     * User's role.
58
     */
59
    private Role role;
60

  
61
    /**
62
     * User's approval status.
63
     */
64
    private Status status;
65

  
66
    /**
67
     * Creates a new instance of the class {@code User}.
68
     * @param id User's ID.
69
     * @param firstName User's first name.
70
     * @param lastName User's last name.
71
     * @param noVacations User's remaining vacation hours.
72
     * @param noSickDays User's remaining sick days.
73
     * @param alertDate Date of email warning about an incoming reset of the vacation hours and sick days.
74
     * @param token Token for the Google oAuth.
75
     * @param email User's email address.
76
     * @param photo URL of a user's photo.
77
     * @param role User's role.
78
     * @param status User's approval status.
79
     */
80
    public User(int id, String firstName, String lastName, int noVacations, int noSickDays, LocalDate alertDate, String token, String email, String photo, Role role, Status status) {
81
        this.id = id;
82
        this.firstName = firstName;
83
        this.lastName = lastName;
84
        this.noVacations = noVacations;
85
        this.noSickDays = noSickDays;
86
        this.alertDate = alertDate;
87
        this.token = token;
88
        this.email = email;
89
        this.photo = photo;
90
        this.role = role;
91
        this.status = status;
92
    }
93

  
94
    /**
95
     * Gets a user's ID.
96
     * @return The user's ID.
97
     */
98
    public int getId() {
99
        return id;
100
    }
101

  
102
    /**
103
     * Gets a user's first name.
104
     * @return The user's first name.
105
     */
106
    public String getFirstName() {
107
        return firstName;
108
    }
109

  
110
    /**
111
     * Sets a new first name.
112
     * @param firstName The new first name.
113
     */
114
    public void setFirstName(String firstName) {
115
        this.firstName = firstName;
116
    }
117

  
118
    /**
119
     * Gets a user's last name.
120
     * @return The user's last name.
121
     */
122
    public String getLastName() {
123
        return lastName;
124
    }
125

  
126
    /**
127
     * Sets a new last name.
128
     * @param lastName The new last name.
129
     */
130
    public void setLastName(String lastName) {
131
        this.lastName = lastName;
132
    }
133

  
134
    /**
135
     * Gets a user's remaining vacation hours.
136
     * @return The user's remaining vacation hours.
137
     */
138
    public int getNoVacations() {
139
        return noVacations;
140
    }
141

  
142
    /**
143
     * Sets a new number of remaining vacation hours.
144
     * If the given value is negative the number of vacation hours is set to zero.
145
     * @param noVacations The new number of remaining vacation hours.
146
     */
147
    public void setNoVacations(int noVacations) {
148
        this.noVacations = noVacations < 0 ? 0 : noVacations;
149
    }
150

  
151
    /**
152
     * Gets a user's remaining sick days.
153
     * @return The user's remaining sick days.
154
     */
155
    public int getNoSickDays() {
156
        return noSickDays;
157
    }
158

  
159
    /**
160
     * Sets a new number of remaining sick days.
161
     * If the given value is negative the number of sick days is set to zero.
162
     * @param noSickDays The new number of remaining sick days.
163
     */
164
    public void setNoSickDays(int noSickDays) {
165
        this.noSickDays = noSickDays < 0 ? 0 : noSickDays;
166
    }
167

  
168
    /**
169
     * Gets a date of an email warning about an incoming reset of the vacation hours and sick days.
170
     * @return The date of the email warning about the incoming reset of the vacation hours and sick days.
171
     */
172
    public LocalDate getAlertDate() {
173
        return alertDate;
174
    }
175

  
176
    /**
177
     * Sets a new date of an email warning about an incoming reset of the vacation hours and sick days.
178
     * @param alertDate The new date of the email warning about the incoming reset of the vacation hours and sick days.
179
     */
180
    public void setAlertDate(LocalDate alertDate) {
181
        this.alertDate = alertDate;
182
    }
183

  
184
    /**
185
     * Gets a user's token for the Google oAuth.
186
     * @return The user's token for the Google oAuth.
187
     */
188
    public String getToken() {
189
        return token;
190
    }
191

  
192
    /**
193
     * Sets a new token for the Google oAuth.
194
     * @param token The new token for the Google oAuth.
195
     */
196
    public void setToken(String token) {
197
        this.token = token;
198
    }
199

  
200
    /**
201
     * Gets a user's email address.
202
     * @return The user's email address.
203
     */
204
    public String getEmail() {
205
        return email;
206
    }
207

  
208
    /**
209
     * Sets a new email address.
210
     * @param email The new email address.
211
     */
212
    public void setEmail(String email) {
213
        this.email = email;
214
    }
215

  
216
    /**
217
     * Gets a URL of a user's photo.
218
     * @return The URL of the user's photo.
219
     */
220
    public String getPhoto() {
221
        return photo;
222
    }
223

  
224
    /**
225
     * Sets a new URL of a user's photo.
226
     * @param photo The new URL of a user's photo.
227
     */
228
    public void setPhoto(String photo) {
229
        this.photo = photo;
230
    }
231

  
232
    /**
233
     * Gets a user's role.
234
     * @return The user's role.
235
     */
236
    public Role getRole() {
237
        return role;
238
    }
239

  
240
    /**
241
     * Sets a new role.
242
     * @param role The new role.
243
     */
244
    public void setRole(Role role) {
245
        this.role = role;
246
    }
247

  
248
    /**
249
     * Gets a user's approval status.
250
     * @return The user's approval status.
251
     */
252
    public Status getStatus() {
253
        return status;
254
    }
255

  
256
    /**
257
     * Sets a new approval status.
258
     * @param status The new approval status.
259
     */
260
    public void setStatus(Status status) {
261
        this.status = status;
262
    }
263

  
264
    /**
265
     * Gets a string representation of the class {@code User}.
266
     * @return The string representation of the class.
267
     */
268
    @Override
269
    public String toString() {
270
        return "User{" +
271
                "id=" + id +
272
                ", firstName='" + firstName + '\'' +
273
                ", lastName='" + lastName + '\'' +
274
                ", noVacations=" + noVacations +
275
                ", noSickDays=" + noSickDays +
276
                ", alertDate=" + alertDate +
277
                ", token='" + token + '\'' +
278
                ", email='" + email + '\'' +
279
                ", photo='" + photo + '\'' +
280
                ", role=" + role +
281
                ", status=" + status +
282
                '}';
283
    }
284
}
server/src/main/java/cz/zcu/yamanager/domain/VacationDay.java
1
package cz.zcu.yamanager.domain;
2

  
3
import java.time.LocalDate;
4
import java.time.LocalTime;
5

  
6
/**
7
 * A domain class {@code VacationDay} represents a single record in the Vacation_day table of a database.
8
 * Class holds informations of a vacation day taken by a user.
9
 */
10
public class VacationDay {
11

  
12
    /**
13
     * ID of the vacation day.
14
     */
15
    private final int id;
16

  
17
    /**
18
     * Date of the vacation day.
19
     */
20
    private LocalDate date;
21

  
22
    /**
23
     * Starting time of a vacation.
24
     */
25
    private LocalTime from;
26

  
27
    /**
28
     * Ending time of a vacation.
29
     */
30
    private LocalTime to;
31

  
32
    /**
33
     * Approval status of the vacation day.
34
     */
35
    private Status status;
36

  
37
    /**
38
     * Creates a new instance of the class {@code VacationDay}.
39
     * @param id ID of the vacation day.
40
     * @param date Date of the vacation day.
41
     * @param from Starting time of a vacation.
42
     * @param to Ending time of a vacation.
43
     * @param status Approval status of the vacation day.
44
     */
45
    public VacationDay(int id, LocalDate date, LocalTime from, LocalTime to, Status status) {
46
        this.id = id;
47
        this.date = date;
48
        this.from = from;
49
        this.to = to;
50
        this.status = status;
51
    }
52

  
53
    /**
54
     * Gets an ID of the vacation day.
55
     * @return The ID of the vacation day.
56
     */
57
    public int getId() {
58
        return id;
59
    }
60

  
61
    /**
62
     * Gets a date of the vacation day.
63
     * @return The date of the vacation day.
64
     */
65
    public LocalDate getDate() {
66
        return date;
67
    }
68

  
69
    /**
70
     * Sets a new date.
71
     * @param date The new date.
72
     */
73
    public void setDate(LocalDate date) {
74
        this.date = date;
75
    }
76

  
77
    /**
78
     * Gets a starting time of a vacation.
79
     * @return The starting time of a vacation.
80
     */
81
    public LocalTime getFrom() {
82
        return from;
83
    }
84

  
85
    /**
86
     * Sets a new starting time.
87
     * @param from The new starting time.
88
     */
89
    public void setFrom(LocalTime from) {
90
        this.from = from;
91
    }
92

  
93
    /**
94
     * Gets an ending time of a vacation.
95
     * @return The ending time of a vacation.
96
     */
97
    public LocalTime getTo() {
98
        return to;
99
    }
100

  
101
    /**
102
     * Sets a new ending time.
103
     * @param to The new ending time.
104
     */
105
    public void setTo(LocalTime to) {
106
        this.to = to;
107
    }
108

  
109
    /**
110
     * Gets an approval status of the vacation day.
111
     * @return The approval status of the vacation day.
112
     */
113
    public Status getStatus() {
114
        return status;
115
    }
116

  
117
    /**
118
     * Sets a new approval status.
119
     * @param status The new approval status.
120
     */
121
    public void setStatus(Status status) {
122
        this.status = status;
123
    }
124

  
125
    /**
126
     * Gets a string representation of the class {@code VacationDay}.
127
     * @return The string representation of the class.
128
     */
129
    @Override
130
    public String toString() {
131
        return "VacationDay{" +
132
                "id=" + id +
133
                ", date=" + date +
134
                ", from=" + from +
135
                ", to=" + to +
136
                ", status=" + status +
137
                '}';
138
    }
139
}

Také k dispozici: Unified diff