Skip to content

Commit 4cc8836

Browse files
committed
added flag for ignoring birthday celebrations
1 parent 0031caf commit 4cc8836

File tree

14 files changed

+113
-58
lines changed

14 files changed

+113
-58
lines changed

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfile.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ public class MemberProfile {
155155
@TypeDef(type = DataType.DATE, converter = LocalDateConverter.class)
156156
private LocalDate lastSeen;
157157

158+
@Column(name="ignorebirthday")
159+
@Schema(description = "flag indicating the member would like to have their birthday ignored")
160+
@Nullable
161+
private Boolean ignoreBirthday;
162+
158163
public MemberProfile(@NotBlank String firstName,
159164
@Nullable String middleName,
160165
@NotBlank String lastName,
@@ -171,9 +176,10 @@ public MemberProfile(@NotBlank String firstName,
171176
@Nullable LocalDate birthDate,
172177
@Nullable Boolean voluntary,
173178
@Nullable Boolean excluded,
174-
@Nullable LocalDate lastSeen) {
179+
@Nullable LocalDate lastSeen,
180+
@Nullable Boolean ignoreBirthday) {
175181
this(null, firstName, middleName, lastName, suffix, title, pdlId, location, workEmail,
176-
employeeId, startDate, bioText, supervisorid, terminationDate,birthDate, voluntary, excluded, lastSeen);
182+
employeeId, startDate, bioText, supervisorid, terminationDate,birthDate, voluntary, excluded, lastSeen, ignoreBirthday);
177183
}
178184

179185
public MemberProfile(UUID id,
@@ -193,7 +199,8 @@ public MemberProfile(UUID id,
193199
@Nullable LocalDate birthDate,
194200
@Nullable Boolean voluntary,
195201
@Nullable Boolean excluded,
196-
@Nullable LocalDate lastSeen) {
202+
@Nullable LocalDate lastSeen,
203+
@Nullable Boolean ignoreBirthday) {
197204
this.id = id;
198205
this.firstName = firstName;
199206
this.middleName = middleName;
@@ -212,6 +219,7 @@ public MemberProfile(UUID id,
212219
this.voluntary = voluntary;
213220
this.excluded = excluded;
214221
this.lastSeen = lastSeen;
222+
this.ignoreBirthday = ignoreBirthday;
215223
}
216224

217225
public MemberProfile() {
@@ -246,14 +254,15 @@ public boolean equals(Object o) {
246254
Objects.equals(birthDate, that.birthDate) &&
247255
Objects.equals(voluntary, that.voluntary) &&
248256
Objects.equals(excluded, that.excluded) &&
249-
Objects.equals(lastSeen, that.lastSeen);
257+
Objects.equals(lastSeen, that.lastSeen) &&
258+
Objects.equals(ignoreBirthday, that.ignoreBirthday);
250259
}
251260

252261
@Override
253262
public int hashCode() {
254263
return Objects.hash(id, firstName, middleName, lastName, suffix, title, pdlId, location,
255264
workEmail, employeeId, startDate, bioText, supervisorid, terminationDate,birthDate,
256-
voluntary, excluded, lastSeen);
265+
voluntary, excluded, lastSeen, ignoreBirthday);
257266
}
258267

259268
@Override
@@ -274,6 +283,7 @@ public String toString() {
274283
", voluntary=" + voluntary +
275284
", excluded=" + excluded +
276285
", lastSeen=" + lastSeen +
286+
", ignoreBirthday=" + ignoreBirthday +
277287
'}';
278288
}
279289
}

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,21 @@ private MemberProfileResponseDTO fromEntity(MemberProfile entity) {
147147
dto.setTerminationDate(entity.getTerminationDate());
148148
dto.setBirthDay(entity.getBirthDate());
149149
dto.setLastSeen(entity.getLastSeen());
150+
dto.setIgnoreBirthday(entity.getIgnoreBirthday());
150151
return dto;
151152
}
152153

153154
private MemberProfile fromDTO(MemberProfileUpdateDTO dto) {
154155
return new MemberProfile(dto.getId(), dto.getFirstName(), dto.getMiddleName(), dto.getLastName(),
155156
dto.getSuffix(), dto.getTitle(), dto.getPdlId(), dto.getLocation(), dto.getWorkEmail(),
156157
dto.getEmployeeId(), dto.getStartDate(), dto.getBioText(), dto.getSupervisorid(),
157-
dto.getTerminationDate(), dto.getBirthDay(), dto.getVoluntary(), dto.getExcluded(), dto.getLastSeen());
158+
dto.getTerminationDate(), dto.getBirthDay(), dto.getVoluntary(), dto.getExcluded(), dto.getLastSeen(), dto.getIgnoreBirthday());
158159
}
159160

160161
private MemberProfile fromDTO(MemberProfileCreateDTO dto) {
161162
return new MemberProfile(dto.getFirstName(), dto.getMiddleName(), dto.getLastName(), dto.getSuffix(),
162163
dto.getTitle(), dto.getPdlId(), dto.getLocation(), dto.getWorkEmail(), dto.getEmployeeId(),
163164
dto.getStartDate(), dto.getBioText(), dto.getSupervisorid(), dto.getTerminationDate(), dto.getBirthDay(),
164-
dto.getVoluntary(), dto.getExcluded(), dto.getLastSeen());
165+
dto.getVoluntary(), dto.getExcluded(), dto.getLastSeen(), dto.getIgnoreBirthday());
165166
}
166167
}

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileCreateDTO.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public class MemberProfileCreateDTO {
8585
@Schema(description = "Last date employee logged in")
8686
private LocalDate lastSeen;
8787

88+
@Nullable
89+
@Schema(description = "The employee would like their birthday to not be celebrated", nullable = true)
90+
private Boolean ignoreBirthday;
91+
8892
@Override
8993
public boolean equals(Object o) {
9094
if (this == o) return true;
@@ -106,14 +110,15 @@ public boolean equals(Object o) {
106110
Objects.equals(birthDay, that.birthDay) &&
107111
Objects.equals(voluntary, that.voluntary) &&
108112
Objects.equals(excluded, that.excluded) &&
109-
Objects.equals(lastSeen, that.lastSeen);
113+
Objects.equals(lastSeen, that.lastSeen) &&
114+
Objects.equals(ignoreBirthday, that.ignoreBirthday);
110115

111116
}
112117

113118
@Override
114119
public int hashCode() {
115120
return Objects.hash(firstName, middleName, lastName, suffix, title, pdlId, location,
116121
workEmail, employeeId, startDate, bioText, supervisorid, terminationDate, birthDay,
117-
voluntary, excluded, lastSeen);
122+
voluntary, excluded, lastSeen, ignoreBirthday);
118123
}
119124
}

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileRepository.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public interface MemberProfileRepository extends CrudRepository<MemberProfile, U
2727
"PGP_SYM_DECRYPT(cast(workEmail as bytea), '${aes.key}') as workEmail, " +
2828
"employeeId, startDate, " +
2929
"PGP_SYM_DECRYPT(cast(bioText as bytea), '${aes.key}') as bioText, " +
30-
"supervisorid, terminationDate, birthDate, voluntary, excluded, last_seen " +
30+
"supervisorid, terminationDate, birthDate, voluntary, excluded, last_seen, ignoreBirthday " +
3131
"FROM \"member_profile\" mp " +
3232
"WHERE (:workEmail IS NULL OR PGP_SYM_DECRYPT(cast(mp.workEmail as bytea), '${aes.key}') = :workEmail) ",
3333
nativeQuery = true)
@@ -44,7 +44,7 @@ public interface MemberProfileRepository extends CrudRepository<MemberProfile, U
4444
"PGP_SYM_DECRYPT(cast(workEmail as bytea), '${aes.key}') as workEmail, " +
4545
"employeeId, startDate, " +
4646
"PGP_SYM_DECRYPT(cast(bioText as bytea), '${aes.key}') as bioText, " +
47-
"supervisorid, terminationDate, birthDate, voluntary, excluded, last_seen " +
47+
"supervisorid, terminationDate, birthDate, voluntary, excluded, last_seen, ignoreBirthday " +
4848
"FROM \"member_profile\" mp " +
4949
"WHERE (:firstName IS NULL OR PGP_SYM_DECRYPT(cast(mp.firstName as bytea),'${aes.key}') = :firstName) " +
5050
"AND (:middleName IS NULL OR PGP_SYM_DECRYPT(cast(mp.middleName as bytea),'${aes.key}') = :middleName) " +
@@ -72,12 +72,12 @@ WHERE mp.id IN (:ids)""",
7272
List<String> findWorkEmailByIdIn(Set<String> ids);
7373

7474
@Query(value = "WITH RECURSIVE subordinate AS (SELECT " +
75-
"id, firstname, middlename, lastname, suffix, title, pdlid, location, workemail, employeeid, startdate, biotext, supervisorid, terminationdate, birthdate, voluntary, excluded, last_seen, 0 as level " +
75+
"id, firstname, middlename, lastname, suffix, title, pdlid, location, workemail, employeeid, startdate, biotext, supervisorid, terminationdate, birthdate, voluntary, excluded, last_seen, ignoreBirthday, 0 as level " +
7676
"FROM member_profile " +
7777
"WHERE id = :id and terminationdate is NULL " +
7878
" UNION ALL " +
7979
"SELECT " +
80-
"e.id, e.firstname, e.middlename, e.lastname, e.suffix, e.title, e.pdlid, e.location, e.workemail, e.employeeid, e.startdate, e.biotext, e.supervisorid, e.terminationdate, e.birthdate, e.voluntary, e.excluded, e.last_seen, level + 1 " +
80+
"e.id, e.firstname, e.middlename, e.lastname, e.suffix, e.title, e.pdlid, e.location, e.workemail, e.employeeid, e.startdate, e.biotext, e.supervisorid, e.terminationdate, e.birthdate, e.voluntary, e.excluded, e.last_seen, e.ignoreBirthday, level + 1 " +
8181
"FROM member_profile e " +
8282
"JOIN subordinate s " +
8383
"ON s.supervisorid = e.id " +
@@ -96,7 +96,7 @@ WHERE mp.id IN (:ids)""",
9696
"PGP_SYM_DECRYPT(cast(s.workemail as bytea), '${aes.key}') as workemail, " +
9797
"s.employeeid, s.startdate, " +
9898
"PGP_SYM_DECRYPT(cast(s.biotext as bytea), '${aes.key}') as biotext, " +
99-
"s.supervisorid, s.terminationdate, s.birthdate, s.voluntary, s.excluded, s.last_seen, " +
99+
"s.supervisorid, s.terminationdate, s.birthdate, s.voluntary, s.excluded, s.last_seen, s.ignoreBirthday, " +
100100
"s.level " +
101101
"FROM subordinate s " +
102102
"WHERE s.id <> :id " +
@@ -106,11 +106,11 @@ WHERE mp.id IN (:ids)""",
106106
@Query(
107107
value = """
108108
WITH RECURSIVE subordinate AS (
109-
SELECT id, firstname, middlename, lastname, suffix, title, pdlid, location, workemail, employeeid, startdate, biotext, supervisorid, terminationdate, birthdate, voluntary, excluded, last_seen, 0 as level
109+
SELECT id, firstname, middlename, lastname, suffix, title, pdlid, location, workemail, employeeid, startdate, biotext, supervisorid, terminationdate, birthdate, voluntary, excluded, last_seen, ignoreBirthday, 0 as level
110110
FROM member_profile
111111
WHERE id = :id and terminationdate is NULL
112112
UNION ALL
113-
SELECT e.id, e.firstname, e.middlename, e.lastname, e.suffix, e.title, e.pdlid, e.location, e.workemail, e.employeeid, e.startdate, e.biotext, e.supervisorid, e.terminationdate, e.birthdate, e.voluntary, e.excluded, e.last_seen, level + 1
113+
SELECT e.id, e.firstname, e.middlename, e.lastname, e.suffix, e.title, e.pdlid, e.location, e.workemail, e.employeeid, e.startdate, e.biotext, e.supervisorid, e.terminationdate, e.birthdate, e.voluntary, e.excluded, e.last_seen, e.ignoreBirthday, level + 1
114114
FROM member_profile AS e JOIN subordinate AS s ON s.id = e.supervisorid
115115
WHERE e.terminationdate is NULL
116116
)
@@ -126,7 +126,7 @@ WITH RECURSIVE subordinate AS (
126126
PGP_SYM_DECRYPT(cast(s.workemail as bytea), '${aes.key}') as workemail,
127127
s.employeeid, s.startdate,
128128
PGP_SYM_DECRYPT(cast(s.biotext as bytea), '${aes.key}') as biotext,
129-
s.supervisorid, s.terminationdate, s.birthdate, s.voluntary, s.excluded, s.last_seen,
129+
s.supervisorid, s.terminationdate, s.birthdate, s.voluntary, s.excluded, s.last_seen, s.ignoreBirthday,
130130
s.level
131131
FROM subordinate s
132132
WHERE s.id <> :id

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileResponseDTO.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ public class MemberProfileResponseDTO {
9292
@Schema(description = "Last date employee logged in")
9393
private LocalDate lastSeen;
9494

95+
@Nullable
96+
@Schema(description = "The employee would like their birthday to not be celebrated", nullable = true)
97+
private Boolean ignoreBirthday;
98+
9599
@Override
96100
public String toString() {
97101
return "MemberProfileResponseDTO{" +
@@ -114,6 +118,7 @@ public String toString() {
114118
", voluntary=" + voluntary +
115119
", excluded=" + excluded +
116120
", lastSeen=" + lastSeen +
121+
", ignoreBirthday=" + ignoreBirthday +
117122
'}';
118123
}
119124
}

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileUpdateDTO.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,8 @@ public class MemberProfileUpdateDTO {
8787
@Nullable
8888
@Schema(description = "Last date employee logged in", nullable = true)
8989
private LocalDate lastSeen;
90+
91+
@Nullable
92+
@Schema(description = "The employee would like their birthday to not be celebrated", nullable = true)
93+
private Boolean ignoreBirthday;
9094
}

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/birthday/BirthDayServicesImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public List<BirthDayResponseDTO> findByValue(String[] months, Integer[] daysOfMo
3838
if (month != null) {
3939
memberProfileAll = memberProfileAll
4040
.stream()
41-
.filter(member -> member.getBirthDate() != null && month.equalsIgnoreCase(member.getBirthDate().getMonth().name()) && member.getTerminationDate() == null)
41+
.filter(member -> member.getBirthDate() != null && month.equalsIgnoreCase(member.getBirthDate().getMonth().name()) && member.getTerminationDate() == null && (member.getIgnoreBirthday() == null || member.getIgnoreBirthday() == Boolean.FALSE))
4242
.toList();
4343
}
4444
}
@@ -48,7 +48,7 @@ public List<BirthDayResponseDTO> findByValue(String[] months, Integer[] daysOfMo
4848
if (day != null) {
4949
memberProfileAll = memberProfiles
5050
.stream()
51-
.filter(member -> member.getBirthDate() != null && day.equals(member.getBirthDate().getDayOfMonth()) && member.getTerminationDate() == null)
51+
.filter(member -> member.getBirthDate() != null && day.equals(member.getBirthDate().getDayOfMonth()) && member.getTerminationDate() == null && (member.getIgnoreBirthday() == null || member.getIgnoreBirthday() == Boolean.FALSE))
5252
.toList();
5353
}
5454
}
@@ -63,7 +63,7 @@ public List<BirthDayResponseDTO> getTodaysBirthdays() {
6363
LocalDate today = LocalDate.now();
6464
List<MemberProfile> results = memberProfiles
6565
.stream()
66-
.filter(member -> member.getBirthDate() != null && today.getMonthValue() == member.getBirthDate().getMonthValue())
66+
.filter(member -> member.getBirthDate() != null && today.getMonthValue() == member.getBirthDate().getMonthValue() && (member.getIgnoreBirthday() == null || member.getIgnoreBirthday() == Boolean.FALSE))
6767
.toList();
6868
return profileToBirthDateResponseDto(results);
6969
}

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserServicesImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private MemberProfile saveNewUser(String firstName, String lastName, String work
9898
}
9999
LocalDate lastSeen = LocalDate.now();
100100
MemberProfile createdMember = memberProfileRepo.save(new MemberProfile(firstName, null, lastName, null, "", null,
101-
"", workEmail, "", null, "", null, null, null, null, null, lastSeen));
101+
"", workEmail, "", null, "", null, null, null, null, null, lastSeen, false));
102102

103103
Optional<Role> role = roleServices.findByRole("MEMBER");
104104
if(role.isPresent()){
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE member_profile ADD column ignoreBirthday boolean;

server/src/test/java/com/objectcomputing/checkins/services/fixture/FeedbackRequestFixture.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ default MemberProfile createADefaultRecipient() {
103103
null, "Parks Director", null, "Pawnee, Indiana",
104104
"[email protected]", "mr-ron-swanson",
105105
LocalDate.now(), "enjoys woodworking, breakfast meats, and saxophone jazz",
106-
null, null, null, false, false, null));
106+
null, null, null, false, false, null, false));
107107
}
108108

109109
default MemberProfile createASecondDefaultRecipient() {
110110
return getMemberProfileRepository().save(new MemberProfile("Leslie", null, "Knope",
111111
null, "Parks Deputy Director", null, "Pawnee, Indiana",
112112
"[email protected]", "ms-leslie-knope",
113113
LocalDate.now(), "proud member of numerous action committees",
114-
null, null, null, false, false, null));
114+
null, null, null, false, false, null, false));
115115
}
116116

117117
default FeedbackRequest createFeedbackRequest(MemberProfile creator, MemberProfile requestee, MemberProfile recipient) {

0 commit comments

Comments
 (0)