Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
postgresql:
image: postgres:17.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ public class MemberProfile {
@TypeDef(type = DataType.DATE, converter = LocalDateConverter.class)
private LocalDate lastSeen;

@Column(name="ignore_birthday")
@Schema(description = "flag indicating the member would like to have their birthday ignored")
@Nullable
private Boolean ignoreBirthday;

public MemberProfile(@NotBlank String firstName,
@Nullable String middleName,
@NotBlank String lastName,
Expand All @@ -171,9 +176,10 @@ public MemberProfile(@NotBlank String firstName,
@Nullable LocalDate birthDate,
@Nullable Boolean voluntary,
@Nullable Boolean excluded,
@Nullable LocalDate lastSeen) {
@Nullable LocalDate lastSeen,
@Nullable Boolean ignoreBirthday) {
this(null, firstName, middleName, lastName, suffix, title, pdlId, location, workEmail,
employeeId, startDate, bioText, supervisorid, terminationDate,birthDate, voluntary, excluded, lastSeen);
employeeId, startDate, bioText, supervisorid, terminationDate,birthDate, voluntary, excluded, lastSeen, ignoreBirthday);
}

public MemberProfile(UUID id,
Expand All @@ -193,7 +199,8 @@ public MemberProfile(UUID id,
@Nullable LocalDate birthDate,
@Nullable Boolean voluntary,
@Nullable Boolean excluded,
@Nullable LocalDate lastSeen) {
@Nullable LocalDate lastSeen,
@Nullable Boolean ignoreBirthday) {
this.id = id;
this.firstName = firstName;
this.middleName = middleName;
Expand All @@ -212,6 +219,7 @@ public MemberProfile(UUID id,
this.voluntary = voluntary;
this.excluded = excluded;
this.lastSeen = lastSeen;
this.ignoreBirthday = ignoreBirthday;
}

public MemberProfile() {
Expand Down Expand Up @@ -246,14 +254,15 @@ public boolean equals(Object o) {
Objects.equals(birthDate, that.birthDate) &&
Objects.equals(voluntary, that.voluntary) &&
Objects.equals(excluded, that.excluded) &&
Objects.equals(lastSeen, that.lastSeen);
Objects.equals(lastSeen, that.lastSeen) &&
Objects.equals(ignoreBirthday, that.ignoreBirthday);
}

@Override
public int hashCode() {
return Objects.hash(id, firstName, middleName, lastName, suffix, title, pdlId, location,
workEmail, employeeId, startDate, bioText, supervisorid, terminationDate,birthDate,
voluntary, excluded, lastSeen);
voluntary, excluded, lastSeen, ignoreBirthday);
}

@Override
Expand All @@ -274,6 +283,7 @@ public String toString() {
", voluntary=" + voluntary +
", excluded=" + excluded +
", lastSeen=" + lastSeen +
", ignoreBirthday=" + ignoreBirthday +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public HttpResponse<MemberProfileResponseDTO> getById(UUID id) {
public List<MemberProfileResponseDTO> getSupervisorsForId(UUID id) {
return memberProfileServices.getSupervisorsForId(id)
.stream()
.map(this::fromEntity)
.map(MemberProfileController::fromEntity)
.toList();
}

Expand All @@ -83,7 +83,7 @@ public List<MemberProfileResponseDTO> findByValue(@Nullable String firstName,
@QueryValue(value = "terminated", defaultValue = "false") Boolean terminated) {
return memberProfileServices.findByValues(firstName, lastName, title, pdlId, workEmail, supervisorId, terminated)
.stream()
.map(this::fromEntity)
.map(MemberProfileController::fromEntity)
.toList();
}

Expand Down Expand Up @@ -128,7 +128,7 @@ protected URI location(UUID id) {
return URI.create("/member-profiles/" + id);
}

private MemberProfileResponseDTO fromEntity(MemberProfile entity) {
public static MemberProfileResponseDTO fromEntity(MemberProfile entity) {
MemberProfileResponseDTO dto = new MemberProfileResponseDTO();
dto.setId(entity.getId());
dto.setFirstName(entity.getFirstName());
Expand All @@ -147,20 +147,21 @@ private MemberProfileResponseDTO fromEntity(MemberProfile entity) {
dto.setTerminationDate(entity.getTerminationDate());
dto.setBirthDay(entity.getBirthDate());
dto.setLastSeen(entity.getLastSeen());
dto.setIgnoreBirthday(entity.getIgnoreBirthday());
return dto;
}

private MemberProfile fromDTO(MemberProfileUpdateDTO dto) {
return new MemberProfile(dto.getId(), dto.getFirstName(), dto.getMiddleName(), dto.getLastName(),
dto.getSuffix(), dto.getTitle(), dto.getPdlId(), dto.getLocation(), dto.getWorkEmail(),
dto.getEmployeeId(), dto.getStartDate(), dto.getBioText(), dto.getSupervisorid(),
dto.getTerminationDate(), dto.getBirthDay(), dto.getVoluntary(), dto.getExcluded(), dto.getLastSeen());
dto.getTerminationDate(), dto.getBirthDay(), dto.getVoluntary(), dto.getExcluded(), dto.getLastSeen(), dto.getIgnoreBirthday());
}

private MemberProfile fromDTO(MemberProfileCreateDTO dto) {
return new MemberProfile(dto.getFirstName(), dto.getMiddleName(), dto.getLastName(), dto.getSuffix(),
dto.getTitle(), dto.getPdlId(), dto.getLocation(), dto.getWorkEmail(), dto.getEmployeeId(),
dto.getStartDate(), dto.getBioText(), dto.getSupervisorid(), dto.getTerminationDate(), dto.getBirthDay(),
dto.getVoluntary(), dto.getExcluded(), dto.getLastSeen());
dto.getVoluntary(), dto.getExcluded(), dto.getLastSeen(), dto.getIgnoreBirthday());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public class MemberProfileCreateDTO {
@Schema(description = "Last date employee logged in")
private LocalDate lastSeen;

@Nullable
@Schema(description = "The employee would like their birthday to not be celebrated", nullable = true)
private Boolean ignoreBirthday;

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -106,14 +110,15 @@ public boolean equals(Object o) {
Objects.equals(birthDay, that.birthDay) &&
Objects.equals(voluntary, that.voluntary) &&
Objects.equals(excluded, that.excluded) &&
Objects.equals(lastSeen, that.lastSeen);
Objects.equals(lastSeen, that.lastSeen) &&
Objects.equals(ignoreBirthday, that.ignoreBirthday);

}

@Override
public int hashCode() {
return Objects.hash(firstName, middleName, lastName, suffix, title, pdlId, location,
workEmail, employeeId, startDate, bioText, supervisorid, terminationDate, birthDay,
voluntary, excluded, lastSeen);
voluntary, excluded, lastSeen, ignoreBirthday);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface MemberProfileRepository extends CrudRepository<MemberProfile, U
"PGP_SYM_DECRYPT(cast(workEmail as bytea), '${aes.key}') as workEmail, " +
"employeeId, startDate, " +
"PGP_SYM_DECRYPT(cast(bioText as bytea), '${aes.key}') as bioText, " +
"supervisorid, terminationDate, birthDate, voluntary, excluded, last_seen " +
"supervisorid, terminationDate, birthDate, voluntary, excluded, last_seen, ignore_birthday " +
"FROM \"member_profile\" mp " +
"WHERE (:workEmail IS NULL OR PGP_SYM_DECRYPT(cast(mp.workEmail as bytea), '${aes.key}') = :workEmail) ",
nativeQuery = true)
Expand All @@ -44,7 +44,7 @@ public interface MemberProfileRepository extends CrudRepository<MemberProfile, U
"PGP_SYM_DECRYPT(cast(workEmail as bytea), '${aes.key}') as workEmail, " +
"employeeId, startDate, " +
"PGP_SYM_DECRYPT(cast(bioText as bytea), '${aes.key}') as bioText, " +
"supervisorid, terminationDate, birthDate, voluntary, excluded, last_seen " +
"supervisorid, terminationDate, birthDate, voluntary, excluded, last_seen, ignore_birthday " +
"FROM \"member_profile\" mp " +
"WHERE (:firstName IS NULL OR PGP_SYM_DECRYPT(cast(mp.firstName as bytea),'${aes.key}') = :firstName) " +
"AND (:middleName IS NULL OR PGP_SYM_DECRYPT(cast(mp.middleName as bytea),'${aes.key}') = :middleName) " +
Expand Down Expand Up @@ -72,12 +72,12 @@ WHERE mp.id IN (:ids)""",
List<String> findWorkEmailByIdIn(Set<String> ids);

@Query(value = "WITH RECURSIVE subordinate AS (SELECT " +
"id, firstname, middlename, lastname, suffix, title, pdlid, location, workemail, employeeid, startdate, biotext, supervisorid, terminationdate, birthdate, voluntary, excluded, last_seen, 0 as level " +
"id, firstname, middlename, lastname, suffix, title, pdlid, location, workemail, employeeid, startdate, biotext, supervisorid, terminationdate, birthdate, voluntary, excluded, last_seen, ignore_birthday, 0 as level " +
"FROM member_profile " +
"WHERE id = :id and terminationdate is NULL " +
" UNION ALL " +
"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 " +
"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.ignore_birthday, level + 1 " +
"FROM member_profile e " +
"JOIN subordinate s " +
"ON s.supervisorid = e.id " +
Expand All @@ -96,7 +96,7 @@ WHERE mp.id IN (:ids)""",
"PGP_SYM_DECRYPT(cast(s.workemail as bytea), '${aes.key}') as workemail, " +
"s.employeeid, s.startdate, " +
"PGP_SYM_DECRYPT(cast(s.biotext as bytea), '${aes.key}') as biotext, " +
"s.supervisorid, s.terminationdate, s.birthdate, s.voluntary, s.excluded, s.last_seen, " +
"s.supervisorid, s.terminationdate, s.birthdate, s.voluntary, s.excluded, s.last_seen, s.ignore_birthday, " +
"s.level " +
"FROM subordinate s " +
"WHERE s.id <> :id " +
Expand All @@ -106,11 +106,11 @@ WHERE mp.id IN (:ids)""",
@Query(
value = """
WITH RECURSIVE subordinate AS (
SELECT id, firstname, middlename, lastname, suffix, title, pdlid, location, workemail, employeeid, startdate, biotext, supervisorid, terminationdate, birthdate, voluntary, excluded, last_seen, 0 as level
SELECT id, firstname, middlename, lastname, suffix, title, pdlid, location, workemail, employeeid, startdate, biotext, supervisorid, terminationdate, birthdate, voluntary, excluded, last_seen, ignore_birthday, 0 as level
FROM member_profile
WHERE id = :id and terminationdate is NULL
UNION ALL
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
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.ignore_birthday, level + 1
FROM member_profile AS e JOIN subordinate AS s ON s.id = e.supervisorid
WHERE e.terminationdate is NULL
)
Expand All @@ -126,7 +126,7 @@ WITH RECURSIVE subordinate AS (
PGP_SYM_DECRYPT(cast(s.workemail as bytea), '${aes.key}') as workemail,
s.employeeid, s.startdate,
PGP_SYM_DECRYPT(cast(s.biotext as bytea), '${aes.key}') as biotext,
s.supervisorid, s.terminationdate, s.birthdate, s.voluntary, s.excluded, s.last_seen,
s.supervisorid, s.terminationdate, s.birthdate, s.voluntary, s.excluded, s.last_seen, s.ignore_birthday,
s.level
FROM subordinate s
WHERE s.id <> :id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public class MemberProfileResponseDTO {
@Schema(description = "Last date employee logged in")
private LocalDate lastSeen;

@Nullable
@Schema(description = "The employee would like their birthday to not be celebrated", nullable = true)
private Boolean ignoreBirthday;

@Override
public String toString() {
return "MemberProfileResponseDTO{" +
Expand All @@ -114,6 +118,7 @@ public String toString() {
", voluntary=" + voluntary +
", excluded=" + excluded +
", lastSeen=" + lastSeen +
", ignoreBirthday=" + ignoreBirthday +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ public class MemberProfileUpdateDTO {
@Nullable
@Schema(description = "Last date employee logged in", nullable = true)
private LocalDate lastSeen;

@Nullable
@Schema(description = "The employee would like their birthday to not be celebrated", nullable = true)
private Boolean ignoreBirthday;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public List<BirthDayResponseDTO> findByValue(String[] months, Integer[] daysOfMo
if (month != null) {
memberProfileAll = memberProfileAll
.stream()
.filter(member -> member.getBirthDate() != null && month.equalsIgnoreCase(member.getBirthDate().getMonth().name()) && member.getTerminationDate() == null)
.filter(member -> member.getBirthDate() != null && month.equalsIgnoreCase(member.getBirthDate().getMonth().name()) && member.getTerminationDate() == null && (member.getIgnoreBirthday() == null || member.getIgnoreBirthday() == Boolean.FALSE))
.toList();
}
}
Expand All @@ -48,7 +48,7 @@ public List<BirthDayResponseDTO> findByValue(String[] months, Integer[] daysOfMo
if (day != null) {
memberProfileAll = memberProfiles
.stream()
.filter(member -> member.getBirthDate() != null && day.equals(member.getBirthDate().getDayOfMonth()) && member.getTerminationDate() == null)
.filter(member -> member.getBirthDate() != null && day.equals(member.getBirthDate().getDayOfMonth()) && member.getTerminationDate() == null && (member.getIgnoreBirthday() == null || member.getIgnoreBirthday() == Boolean.FALSE))
.toList();
}
}
Expand All @@ -63,7 +63,7 @@ public List<BirthDayResponseDTO> getTodaysBirthdays() {
LocalDate today = LocalDate.now();
List<MemberProfile> results = memberProfiles
.stream()
.filter(member -> member.getBirthDate() != null && today.getMonthValue() == member.getBirthDate().getMonthValue())
.filter(member -> member.getBirthDate() != null && today.getMonthValue() == member.getBirthDate().getMonthValue() && (member.getIgnoreBirthday() == null || member.getIgnoreBirthday() == Boolean.FALSE))
.toList();
return profileToBirthDateResponseDto(results);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.objectcomputing.checkins.services.memberprofile.currentuser;

import com.objectcomputing.checkins.services.memberprofile.MemberProfile;
import com.objectcomputing.checkins.services.memberprofile.MemberProfileController;
import com.objectcomputing.checkins.services.memberprofile.MemberProfileServices;
import com.objectcomputing.checkins.services.memberprofile.MemberProfileUtils;
import com.objectcomputing.checkins.services.permissions.Permission;
Expand Down Expand Up @@ -86,7 +87,7 @@ private CurrentUserDTO fromEntity(MemberProfile entity, String imageUrl, List<Pe
dto.setPermissions(permissions);
dto.setRole(roles);
dto.setImageUrl(imageUrl);
dto.setMemberProfile(entity);
dto.setMemberProfile(MemberProfileController.fromEntity(entity));
return dto;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.objectcomputing.checkins.services.memberprofile.currentuser;

import com.objectcomputing.checkins.services.memberprofile.MemberProfile;
import com.objectcomputing.checkins.services.memberprofile.MemberProfileResponseDTO;
import com.objectcomputing.checkins.services.permissions.Permission;
import io.micronaut.core.annotation.Introspected;
import io.micronaut.core.annotation.Nullable;
Expand Down Expand Up @@ -45,6 +46,6 @@ public class CurrentUserDTO {

@NotNull
@Schema(implementation = MemberProfile.class)
private MemberProfile memberProfile;
private MemberProfileResponseDTO memberProfile;

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private MemberProfile saveNewUser(String firstName, String lastName, String work
}
LocalDate lastSeen = LocalDate.now();
MemberProfile createdMember = memberProfileRepo.save(new MemberProfile(firstName, null, lastName, null, "", null,
"", workEmail, "", null, "", null, null, null, null, null, lastSeen));
"", workEmail, "", null, "", null, null, null, null, null, lastSeen, false));

Optional<Role> role = roleServices.findByRole("MEMBER");
if(role.isPresent()){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE member_profile ADD column ignore_birthday boolean;
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ default MemberProfile createADefaultRecipient() {
null, "Parks Director", null, "Pawnee, Indiana",
"ron@objectcomputing.com", "mr-ron-swanson",
LocalDate.now(), "enjoys woodworking, breakfast meats, and saxophone jazz",
null, null, null, false, false, null));
null, null, null, false, false, null, false));
}

default MemberProfile createASecondDefaultRecipient() {
return getMemberProfileRepository().save(new MemberProfile("Leslie", null, "Knope",
null, "Parks Deputy Director", null, "Pawnee, Indiana",
"leslie@objectcomputing.com", "ms-leslie-knope",
LocalDate.now(), "proud member of numerous action committees",
null, null, null, false, false, null));
null, null, null, false, false, null, false));
}

default FeedbackRequest createFeedbackRequest(MemberProfile creator, MemberProfile requestee, MemberProfile recipient) {
Expand Down
Loading
Loading