From 1eb4f781fe06533ea5706a958817b593486dc8c4 Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Fri, 20 Sep 2024 10:46:13 +0100 Subject: [PATCH 1/5] Use SLF4J formatting for log messages --- .../checkins/services/email/EmailServicesImpl.java | 2 +- .../checkins/services/kudos/KudosServicesImpl.java | 4 ++-- .../kudos/kudos_recipient/KudosRecipientServicesImpl.java | 2 +- .../services/memberprofile/MemberProfileServicesImpl.java | 2 +- .../checkins/services/pulse/PulseServicesImpl.java | 6 +++--- .../checkins/services/reports/CompensationHistory.java | 7 ++++--- .../checkins/services/reports/CurrentInformation.java | 2 +- .../checkins/services/reports/PositionHistory.java | 7 ++++--- .../checkins/services/reports/ReportDataServicesImpl.java | 2 +- .../services/request_notifications/CheckServicesImpl.java | 2 +- .../services/reviews/ReviewAssignmentServicesImpl.java | 4 ++-- 11 files changed, 21 insertions(+), 19 deletions(-) diff --git a/server/src/main/java/com/objectcomputing/checkins/services/email/EmailServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/email/EmailServicesImpl.java index 548807218..a2e1b68ab 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/email/EmailServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/email/EmailServicesImpl.java @@ -76,7 +76,7 @@ public List sendAndSaveEmail(String subject, String content, boolean html Email savedEmail = emailRepository.save(email); sentEmails.add(savedEmail); } else { - LOG.warn(String.format("Prevented sending email to terminated member: %s", recipientEmail)); + LOG.warn("Prevented sending email to terminated member: {}", recipientEmail); } } } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosServicesImpl.java index aa5f06123..c672dbd43 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosServicesImpl.java @@ -324,7 +324,7 @@ private void sendNotification(Kudos kudos, NotificationType notificationType) { // Send email to receivers of kudos that they have new kudos... MemberProfile sender = memberProfileRetrievalServices.getById(kudos.getSenderId()).orElse(null); if (sender == null) { - LOG.error(String.format("Unable to locate member %s.", kudos.getSenderId().toString())); + LOG.error("Unable to locate member {}", kudos.getSenderId()); } else { String fromEmail = sender.getWorkEmail(); String fromName = sender.getFirstName() + " " + sender.getLastName(); @@ -336,7 +336,7 @@ private void sendNotification(Kudos kudos, NotificationType notificationType) { for (KudosRecipient kudosRecipient : recipients) { MemberProfile member = memberProfileRetrievalServices.getById(kudosRecipient.getMemberId()).orElse(null); if (member == null) { - LOG.error(String.format("Unable to locate member %s.", kudosRecipient.getMemberId().toString())); + LOG.error("Unable to locate member {}", kudosRecipient.getMemberId()); } else { recipientAddresses.add(member.getWorkEmail()); } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/kudos/kudos_recipient/KudosRecipientServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/kudos/kudos_recipient/KudosRecipientServicesImpl.java index 4d156f47d..8cde58be7 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/kudos/kudos_recipient/KudosRecipientServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/kudos/kudos_recipient/KudosRecipientServicesImpl.java @@ -87,7 +87,7 @@ private void sendNotification(Kudos kudos, MemberProfile member) { // This is a private kudos, so notify the receiver directly. MemberProfile sender = memberProfileRetrievalServices.getById(kudos.getSenderId()).orElse(null); if (sender == null) { - LOG.error(String.format("Unable to locate member %s.", kudos.getSenderId().toString())); + LOG.error("Unable to locate member {}", kudos.getSenderId()); } else { String fromEmail = sender.getWorkEmail(); String fromName = sender.getFirstName() + " " + sender.getLastName(); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileServicesImpl.java index d55e1225d..9d1321dd3 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileServicesImpl.java @@ -104,7 +104,7 @@ public MemberProfile saveProfile(MemberProfile memberProfile) { Optional existingProfileOpt = memberProfileRepository.findById(memberProfile.getId()); MemberProfile updatedMemberProfile = memberProfileRepository.update(memberProfile); if (existingProfileOpt.isEmpty()) { - LOG.error(String.format("MemberProfile with id %s not found", memberProfile.getId())); + LOG.error("MemberProfile with id {} not found", memberProfile.getId()); } else { MemberProfile existingProfile = existingProfileOpt.get(); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseServicesImpl.java index 79e040443..3731950de 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseServicesImpl.java @@ -73,14 +73,14 @@ public void sendPendingEmail(LocalDate check) { if (frequency.containsKey(freq.getValue())) { setting = freq.getValue(); } else { - LOG.error("Invalid Pulse Email Frequency Setting: " + freq.getValue()); + LOG.error("Invalid Pulse Email Frequency Setting: {}", freq); } } catch(NotFoundException ex) { // Use the default setting. - LOG.error("Pulse Frequency Error: " + ex.toString()); + LOG.error("Pulse Frequency Error", ex); } - LOG.info("Using Pulse Frequency: " + setting); + LOG.info("Using Pulse Frequency: {}", setting); final Frequency freq = frequency.get(setting); do { if (start.getDayOfMonth() == check.getDayOfMonth()) { diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java index bfabaf4b5..c265592da 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java @@ -44,9 +44,10 @@ protected void loadImpl(MemberProfileRepository memberProfileRepository, Optional memberProfile = memberProfileRepository.findByWorkEmail(emailAddress); if (memberProfile.isPresent()) { - LocalDate date = parseDate(csvRecord.get("startDate")); + String startDate = csvRecord.get("startDate"); + LocalDate date = parseDate(startDate); if (date == null) { - LOG.error("Unable to parse date: " + csvRecord.get("startDate")); + LOG.error("Unable to parse date: {}", startDate); } else { Compensation comp = new Compensation( memberProfile.get().getId(), @@ -56,7 +57,7 @@ protected void loadImpl(MemberProfileRepository memberProfileRepository, history.add(comp); } } else { - LOG.error("Unable to find a profile for " + emailAddress); + LOG.error("Unable to find a profile for {}", emailAddress); } } catch(IllegalArgumentException ex) { throw new BadArgException("Unable to parse the compensation history"); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/CurrentInformation.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/CurrentInformation.java index ec44709df..2391b0a53 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/CurrentInformation.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/CurrentInformation.java @@ -54,7 +54,7 @@ protected void loadImpl(MemberProfileRepository memberProfileRepository, ); information.add(comp); } else { - LOG.error("Unable to find a profile for " + emailAddress); + LOG.error("Unable to find a profile for {}", emailAddress); } } catch(IllegalArgumentException ex) { throw new BadArgException("Unable to parse the current information"); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java index 957ff6344..47bdd3c8d 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java @@ -44,9 +44,10 @@ protected void loadImpl(MemberProfileRepository memberProfileRepository, Optional memberProfile = memberProfileRepository.findByWorkEmail(emailAddress); if (memberProfile.isPresent()) { - LocalDate date = parseDate(csvRecord.get("date")); + String csvDate = csvRecord.get("date"); + LocalDate date = parseDate(csvDate); if (date == null) { - LOG.error("Unable to parse date: " + csvRecord.get("date")); + LOG.error("Unable to parse date: {}", csvDate); } else { Position position = new Position( memberProfile.get().getId(), @@ -55,7 +56,7 @@ protected void loadImpl(MemberProfileRepository memberProfileRepository, history.add(position); } } else { - LOG.error("Unable to find a profile for " + emailAddress); + LOG.error("Unable to find a profile for {}", emailAddress); } } catch(IllegalArgumentException ex) { throw new BadArgException("Unable to parse the position history"); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportDataServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportDataServicesImpl.java index a56057b63..b4c70a935 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportDataServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportDataServicesImpl.java @@ -105,7 +105,7 @@ public synchronized void run() { for (Map.Entry entry : storedUploads.entrySet()) { Stored value = entry.getValue(); if (current >= (value.timestamp.getTime() + expiration)) { - LOG.warn("Removing stored data for " + entry.getKey().toString()); + LOG.warn("Removing stored data for {}", entry.getKey()); storedUploads.remove(entry.getKey()); } } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/request_notifications/CheckServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/request_notifications/CheckServicesImpl.java index 4ca8627c6..34b5a8f27 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/request_notifications/CheckServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/request_notifications/CheckServicesImpl.java @@ -31,7 +31,7 @@ public CheckServicesImpl(FeedbackRequestServicesImpl feedbackRequestServices, public boolean sendScheduledEmails() { LocalDate today = LocalDate.now(); List feedbackRequests = feedbackRequestRepository.findBySendDateNotAfterAndStatusEqual(today, "pending"); - LOG.info("About to send emails: " + feedbackRequests.size()); + LOG.info("About to send {} emails", feedbackRequests.size()); for (FeedbackRequest req: feedbackRequests) { feedbackRequestServices.sendNewRequestEmail(req); req.setStatus("sent"); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewAssignmentServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewAssignmentServicesImpl.java index 60aee1bba..b731a4b16 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewAssignmentServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewAssignmentServicesImpl.java @@ -47,7 +47,7 @@ public ReviewAssignment save(ReviewAssignment reviewAssignment) { public List saveAll(UUID reviewPeriodId, List reviewAssignments, boolean deleteExisting) { if(deleteExisting) { - LOG.warn(String.format("Deleting all review assignments for review period %s", reviewPeriodId)); + LOG.warn("Deleting all review assignments for review period {}", reviewPeriodId); reviewAssignmentRepository.deleteByReviewPeriodId(reviewPeriodId); } @@ -92,7 +92,7 @@ public Set findAllByReviewPeriodIdAndReviewerId(UUID reviewPer @Override public ReviewAssignment update(ReviewAssignment reviewAssignment) { - LOG.info(String.format("Updating entity %s", reviewAssignment)); + LOG.info("Updating entity {}", reviewAssignment); if (reviewAssignment.getId() != null && reviewAssignmentRepository.findById(reviewAssignment.getId()).isPresent()) { return reviewAssignmentRepository.update(reviewAssignment); } else { From 0f2c9e9ba2bee3a07f404a84689ee3fd10786282 Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Fri, 20 Sep 2024 11:06:53 +0100 Subject: [PATCH 2/5] Remove unused injection points and imports --- .../checkins/services/checkins/CheckInServicesImpl.java | 5 +---- .../employee_hours/EmployeeHoursServicesImpl.java | 8 +------- .../feedback_request/FeedbackRequestController.java | 4 ---- .../checkins/services/guild/GuildController.java | 5 +---- .../kudos_recipient/KudosRecipientServicesImpl.java | 7 +------ .../services/memberprofile/MemberProfileController.java | 3 --- .../anniversaryreport/AnniversaryReportServicesImpl.java | 4 +--- .../services/private_notes/PrivateNoteServicesImpl.java | 9 +++------ .../checkins/services/reports/CompensationHistory.java | 4 ---- .../checkins/services/reports/PositionHistory.java | 4 ---- 10 files changed, 8 insertions(+), 45 deletions(-) diff --git a/server/src/main/java/com/objectcomputing/checkins/services/checkins/CheckInServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/checkins/CheckInServicesImpl.java index 17398c02e..00801fb84 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/checkins/CheckInServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/checkins/CheckInServicesImpl.java @@ -6,7 +6,6 @@ import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; import com.objectcomputing.checkins.services.memberprofile.currentuser.CurrentUserServices; import com.objectcomputing.checkins.services.permissions.Permission; -import com.objectcomputing.checkins.services.role.RoleServices; import com.objectcomputing.checkins.services.role.role_permissions.RolePermissionServices; import com.objectcomputing.checkins.util.Util; import jakarta.inject.Singleton; @@ -32,17 +31,15 @@ public class CheckInServicesImpl implements CheckInServices { private final CheckInRepository checkinRepo; private final MemberProfileRepository memberRepo; private final CurrentUserServices currentUserServices; - private final RoleServices roleServices; private final RolePermissionServices rolePermissionServices; public CheckInServicesImpl(CheckInRepository checkinRepo, MemberProfileRepository memberRepo, CurrentUserServices currentUserServices, - RoleServices roleServices, RolePermissionServices rolePermissionServices) { + RolePermissionServices rolePermissionServices) { this.checkinRepo = checkinRepo; this.memberRepo = memberRepo; this.currentUserServices = currentUserServices; - this.roleServices = roleServices; this.rolePermissionServices = rolePermissionServices; } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/employee_hours/EmployeeHoursServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/employee_hours/EmployeeHoursServicesImpl.java index 087f5292c..18326b981 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/employee_hours/EmployeeHoursServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/employee_hours/EmployeeHoursServicesImpl.java @@ -2,7 +2,6 @@ import com.objectcomputing.checkins.exceptions.BadArgException; import com.objectcomputing.checkins.services.memberprofile.MemberProfile; -import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; import com.objectcomputing.checkins.services.memberprofile.currentuser.CurrentUserServices; import com.objectcomputing.checkins.services.memberprofile.memberphoto.MemberPhotoServiceImpl; import io.micronaut.http.multipart.CompletedFileUpload; @@ -24,16 +23,11 @@ public class EmployeeHoursServicesImpl implements EmployeeHoursServices{ private static final Logger LOG = LoggerFactory.getLogger(MemberPhotoServiceImpl.class); - private final MemberProfileRepository memberRepo; private final CurrentUserServices currentUserServices; private final EmployeeHoursRepository employeehourRepo; - - - public EmployeeHoursServicesImpl(MemberProfileRepository memberRepo, - CurrentUserServices currentUserServices, + public EmployeeHoursServicesImpl(CurrentUserServices currentUserServices, EmployeeHoursRepository employeehourRepo) { - this.memberRepo = memberRepo; this.currentUserServices = currentUserServices; this.employeehourRepo = employeehourRepo; } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestController.java b/server/src/main/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestController.java index b691ca873..1e2fa3a27 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestController.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestController.java @@ -21,8 +21,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.net.URI; import java.time.LocalDate; @@ -36,8 +34,6 @@ @Tag(name = "feedback request") public class FeedbackRequestController { - private static final Logger LOG = LoggerFactory.getLogger(FeedbackRequestController.class); - private final FeedbackRequestServices feedbackReqServices; public FeedbackRequestController(FeedbackRequestServices feedbackReqServices) { diff --git a/server/src/main/java/com/objectcomputing/checkins/services/guild/GuildController.java b/server/src/main/java/com/objectcomputing/checkins/services/guild/GuildController.java index ec0d0666d..8f8f9992c 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/guild/GuildController.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/guild/GuildController.java @@ -1,6 +1,5 @@ package com.objectcomputing.checkins.services.guild; -import com.objectcomputing.checkins.services.memberprofile.MemberProfileServices; import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; @@ -32,11 +31,9 @@ public class GuildController { private final GuildServices guildService; - private final MemberProfileServices profileServices; - public GuildController(GuildServices guildService, MemberProfileServices profileServices) { + public GuildController(GuildServices guildService) { this.guildService = guildService; - this.profileServices = profileServices; } /** diff --git a/server/src/main/java/com/objectcomputing/checkins/services/kudos/kudos_recipient/KudosRecipientServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/kudos/kudos_recipient/KudosRecipientServicesImpl.java index 8cde58be7..167495e7e 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/kudos/kudos_recipient/KudosRecipientServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/kudos/kudos_recipient/KudosRecipientServicesImpl.java @@ -1,6 +1,5 @@ package com.objectcomputing.checkins.services.kudos.kudos_recipient; -import com.objectcomputing.checkins.configuration.CheckInsConfiguration; import com.objectcomputing.checkins.notifications.email.EmailSender; import com.objectcomputing.checkins.notifications.email.MailJetFactory; import com.objectcomputing.checkins.exceptions.BadArgException; @@ -17,7 +16,6 @@ import org.slf4j.LoggerFactory; import java.time.LocalDate; -import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -32,20 +30,17 @@ public class KudosRecipientServicesImpl implements KudosRecipientServices { private final KudosRepository kudosRepository; private final MemberProfileRetrievalServices memberProfileRetrievalServices; private final EmailSender emailSender; - private final CheckInsConfiguration checkInsConfiguration; public KudosRecipientServicesImpl(KudosRecipientRepository kudosRecipientRepository, CurrentUserServices currentUserServices, KudosRepository kudosRepository, MemberProfileRetrievalServices memberProfileRetrievalServices, - @Named(MailJetFactory.HTML_FORMAT) EmailSender emailSender, - CheckInsConfiguration checkInsConfiguration) { + @Named(MailJetFactory.HTML_FORMAT) EmailSender emailSender) { this.kudosRecipientRepository = kudosRecipientRepository; this.currentUserServices = currentUserServices; this.kudosRepository = kudosRepository; this.memberProfileRetrievalServices = memberProfileRetrievalServices; this.emailSender = emailSender; - this.checkInsConfiguration = checkInsConfiguration; } @Override diff --git a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileController.java b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileController.java index b7e8e2316..1b35173a8 100755 --- a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileController.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileController.java @@ -20,8 +20,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.net.URI; import java.util.List; @@ -33,7 +31,6 @@ @Tag(name = "member profiles") public class MemberProfileController { - private static final Logger LOG = LoggerFactory.getLogger(MemberProfileController.class); private final MemberProfileServices memberProfileServices; public MemberProfileController(MemberProfileServices memberProfileServices) { diff --git a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/anniversaryreport/AnniversaryReportServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/anniversaryreport/AnniversaryReportServicesImpl.java index 119505cc8..c58e34acc 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/anniversaryreport/AnniversaryReportServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/anniversaryreport/AnniversaryReportServicesImpl.java @@ -6,8 +6,6 @@ import com.objectcomputing.checkins.services.memberprofile.currentuser.CurrentUserServices; import io.micronaut.core.annotation.Nullable; import jakarta.inject.Singleton; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.math.RoundingMode; import java.text.DecimalFormat; @@ -18,7 +16,7 @@ @Singleton public class AnniversaryReportServicesImpl implements AnniversaryServices { - private static final Logger LOG = LoggerFactory.getLogger(AnniversaryReportServicesImpl.class); + private final MemberProfileServices memberProfileServices; private final CurrentUserServices currentUserServices; diff --git a/server/src/main/java/com/objectcomputing/checkins/services/private_notes/PrivateNoteServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/private_notes/PrivateNoteServicesImpl.java index ed60feda2..48a8cbaac 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/private_notes/PrivateNoteServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/private_notes/PrivateNoteServicesImpl.java @@ -4,9 +4,7 @@ import com.objectcomputing.checkins.exceptions.NotFoundException; import com.objectcomputing.checkins.exceptions.PermissionException; import com.objectcomputing.checkins.services.checkins.CheckIn; -import com.objectcomputing.checkins.services.checkins.CheckInRepository; import com.objectcomputing.checkins.services.checkins.CheckInServices; -import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; import com.objectcomputing.checkins.services.memberprofile.MemberProfileServices; import com.objectcomputing.checkins.services.memberprofile.currentuser.CurrentUserServices; import io.micronaut.core.annotation.Nullable; @@ -24,16 +22,15 @@ public class PrivateNoteServicesImpl implements PrivateNoteServices { private final CheckInServices checkinServices; private final PrivateNoteRepository privateNoteRepository; - private final MemberProfileRepository memberRepo; private final MemberProfileServices memberProfileServices; private final CurrentUserServices currentUserServices; - public PrivateNoteServicesImpl(CheckInServices checkinServices, CheckInRepository checkinRepo, PrivateNoteRepository privateNoteRepository, - MemberProfileRepository memberRepo, MemberProfileServices memberProfileServices, + public PrivateNoteServicesImpl(CheckInServices checkinServices, + PrivateNoteRepository privateNoteRepository, + MemberProfileServices memberProfileServices, CurrentUserServices currentUserServices) { this.checkinServices = checkinServices; this.privateNoteRepository = privateNoteRepository; - this.memberRepo = memberRepo; this.memberProfileServices = memberProfileServices; this.currentUserServices = currentUserServices; } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java index c265592da..31bb082ac 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java @@ -8,9 +8,6 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; -import lombok.AllArgsConstructor; -import lombok.Getter; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,7 +16,6 @@ import java.util.List; import java.util.UUID; import java.util.Optional; -import java.util.stream.Collectors; public class CompensationHistory extends CSVProcessor { diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java index 47bdd3c8d..e3426680d 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java @@ -8,9 +8,6 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; -import lombok.AllArgsConstructor; -import lombok.Getter; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,7 +16,6 @@ import java.util.List; import java.util.UUID; import java.util.Optional; -import java.util.stream.Collectors; public class PositionHistory extends CSVProcessor { From b12a2102d16254de24ba8bf496b2907bce71fe4e Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Fri, 20 Sep 2024 11:28:47 +0100 Subject: [PATCH 3/5] More unused imports --- .../checkins/security/ImpersonationController.java | 14 +++++++++++--- .../checkins/security/LocalLoginController.java | 1 - .../services/agenda_item/AgendaItemController.java | 14 ++++++++++---- .../checkins/services/kudos/KudosController.java | 1 - .../checkins/services/kudos/KudosCreateDTO.java | 1 - .../skillsreport/SkillsReportServicesImpl.java | 7 +++++-- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/server/src/main/java/com/objectcomputing/checkins/security/ImpersonationController.java b/server/src/main/java/com/objectcomputing/checkins/security/ImpersonationController.java index 1cc707239..42ec7b322 100644 --- a/server/src/main/java/com/objectcomputing/checkins/security/ImpersonationController.java +++ b/server/src/main/java/com/objectcomputing/checkins/security/ImpersonationController.java @@ -14,7 +14,11 @@ import io.micronaut.http.HttpResponse; import io.micronaut.http.MediaType; import io.micronaut.http.MutableHttpResponse; -import io.micronaut.http.annotation.*; +import io.micronaut.http.annotation.Consumes; +import io.micronaut.http.annotation.Controller; +import io.micronaut.http.annotation.Get; +import io.micronaut.http.annotation.Post; +import io.micronaut.http.annotation.Produces; import io.micronaut.http.cookie.Cookie; import io.micronaut.http.cookie.SameSite; import io.micronaut.http.netty.cookies.NettyCookie; @@ -25,12 +29,16 @@ import io.micronaut.security.event.LoginSuccessfulEvent; import io.micronaut.security.handlers.LoginHandler; import io.micronaut.security.rules.SecurityRule; -import io.micronaut.security.utils.SecurityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.net.URI; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; @Requires(env = {Environments.LOCAL, Environment.DEVELOPMENT}) diff --git a/server/src/main/java/com/objectcomputing/checkins/security/LocalLoginController.java b/server/src/main/java/com/objectcomputing/checkins/security/LocalLoginController.java index c9b050911..e305dcf7d 100644 --- a/server/src/main/java/com/objectcomputing/checkins/security/LocalLoginController.java +++ b/server/src/main/java/com/objectcomputing/checkins/security/LocalLoginController.java @@ -3,7 +3,6 @@ import com.objectcomputing.checkins.Environments; import com.objectcomputing.checkins.services.memberprofile.MemberProfile; import com.objectcomputing.checkins.services.memberprofile.currentuser.CurrentUserServices; -import com.objectcomputing.checkins.security.ImpersonationController; import io.micronaut.http.MutableHttpResponse; import io.micronaut.http.netty.cookies.NettyCookie; import io.micronaut.context.annotation.Requires; diff --git a/server/src/main/java/com/objectcomputing/checkins/services/agenda_item/AgendaItemController.java b/server/src/main/java/com/objectcomputing/checkins/services/agenda_item/AgendaItemController.java index 9fd91b054..64224b4fb 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/agenda_item/AgendaItemController.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/agenda_item/AgendaItemController.java @@ -1,12 +1,19 @@ package com.objectcomputing.checkins.services.agenda_item; import com.objectcomputing.checkins.exceptions.NotFoundException; +import com.objectcomputing.checkins.services.checkins.CheckIn; import com.objectcomputing.checkins.services.permissions.Permission; import com.objectcomputing.checkins.services.permissions.RequiredPermission; import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; -import io.micronaut.http.annotation.*; +import io.micronaut.http.annotation.Body; +import io.micronaut.http.annotation.Controller; +import io.micronaut.http.annotation.Delete; +import io.micronaut.http.annotation.Get; +import io.micronaut.http.annotation.Post; +import io.micronaut.http.annotation.Put; +import io.micronaut.http.annotation.Status; import io.micronaut.http.uri.UriBuilder; import io.micronaut.scheduling.TaskExecutors; import io.micronaut.scheduling.annotation.ExecuteOn; @@ -16,7 +23,6 @@ import jakarta.validation.Valid; import java.net.URI; -import java.util.List; import java.util.Set; import java.util.UUID; @@ -52,7 +58,7 @@ HttpResponse createAgendaItem(@Body @Valid AgendaItemCreateDTO agend * Update a agenda item * * @param agendaItem, {@link AgendaItem} - * @return {@link HttpResponse< AgendaItem >} + * @return {@link HttpResponse} */ @Put("/") @RequiredPermission(Permission.CAN_UPDATE_CHECKINS) @@ -72,7 +78,7 @@ HttpResponse updateAgendaItem(@Body @Valid AgendaItem agendaItem) { * * @param checkinid {@link UUID} of checkin * @param createdbyid {@link UUID} of member - * @return {@link List list of checkins + * @return a Set of {@link CheckIn} */ @Get("/{?checkinid,createdbyid}") @RequiredPermission(Permission.CAN_VIEW_CHECKINS) diff --git a/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosController.java b/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosController.java index 98f32e5c1..e8591d57e 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosController.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosController.java @@ -2,7 +2,6 @@ import com.objectcomputing.checkins.services.permissions.Permission; import com.objectcomputing.checkins.services.permissions.RequiredPermission; -import com.objectcomputing.checkins.services.role.RoleType; import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpStatus; import io.micronaut.http.annotation.Body; diff --git a/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosCreateDTO.java b/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosCreateDTO.java index 4384c0743..aaae82b7d 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosCreateDTO.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosCreateDTO.java @@ -1,6 +1,5 @@ package com.objectcomputing.checkins.services.kudos; -import com.fasterxml.jackson.annotation.JsonProperty; import com.objectcomputing.checkins.services.memberprofile.MemberProfile; import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; diff --git a/server/src/main/java/com/objectcomputing/checkins/services/member_skill/skillsreport/SkillsReportServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/member_skill/skillsreport/SkillsReportServicesImpl.java index e37ba880f..b0637005b 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/member_skill/skillsreport/SkillsReportServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/member_skill/skillsreport/SkillsReportServicesImpl.java @@ -3,7 +3,6 @@ import com.objectcomputing.checkins.exceptions.BadArgException; import com.objectcomputing.checkins.services.member_skill.MemberSkill; import com.objectcomputing.checkins.services.member_skill.MemberSkillRepository; -import com.objectcomputing.checkins.services.memberprofile.MemberProfile; import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; import com.objectcomputing.checkins.services.memberprofile.MemberProfileServices; import com.objectcomputing.checkins.services.memberprofile.MemberProfileUtils; @@ -11,7 +10,11 @@ import jakarta.inject.Singleton; import jakarta.validation.constraints.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Set; +import java.util.UUID; @Singleton public class SkillsReportServicesImpl implements SkillsReportServices { From f0225b27225f691ed48948ee352d762f7f2250c4 Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Fri, 20 Sep 2024 11:40:55 +0100 Subject: [PATCH 4/5] Replace filter().findFirst().isPresent() with anyMatch() or noneMatch() --- .../services/feedback_answer/FeedbackAnswerServicesImpl.java | 4 ++-- .../question_and_answer/QuestionAndAnswerServicesImpl.java | 2 +- .../checkins/services/guild/GuildServicesImpl.java | 2 +- .../checkins/services/team/TeamServicesImpl.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/FeedbackAnswerServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/FeedbackAnswerServicesImpl.java index a8e316d4b..d32806b24 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/FeedbackAnswerServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/FeedbackAnswerServicesImpl.java @@ -110,7 +110,7 @@ public List findByValues(@Nullable UUID questionId, @Nullable UU final UUID requestCreatorId = feedbackRequest.getCreatorId(); final UUID requesteeId = feedbackRequest.getRequesteeId(); final UUID recipientId = feedbackRequest.getRecipientId(); - boolean isRequesteesSupervisor = requesteeId != null ? memberProfileServices.getSupervisorsForId(requesteeId).stream().filter(profile -> currentUserId.equals(profile.getId())).findAny().isPresent() : false; + boolean isRequesteesSupervisor = requesteeId != null ? memberProfileServices.getSupervisorsForId(requesteeId).stream().anyMatch(profile -> currentUserId.equals(profile.getId())) : false; MemberProfile requestee = memberProfileServices.getById(requesteeId); final UUID requesteePDL = requestee.getPdlId(); if (currentUserServices.isAdmin() || currentUserId.equals(requesteePDL) || isRequesteesSupervisor || requestCreatorId.equals(currentUserId) || recipientId.equals(currentUserId)) { @@ -151,7 +151,7 @@ public boolean getIsPermitted(FeedbackRequest feedbackRequest) { MemberProfile requestee = memberProfileServices.getById(requesteeId); final UUID currentUserId = currentUserServices.getCurrentUser().getId(); final UUID recipientId = feedbackRequest.getRecipientId(); - boolean isRequesteesSupervisor = requesteeId != null ? memberProfileServices.getSupervisorsForId(requesteeId).stream().filter(profile -> currentUserId.equals(profile.getId())).findAny().isPresent() : false; + boolean isRequesteesSupervisor = requesteeId != null ? memberProfileServices.getSupervisorsForId(requesteeId).stream().anyMatch(profile -> currentUserId.equals(profile.getId())) : false; final UUID requesteePDL = requestee.getPdlId(); return isAdmin || currentUserId.equals(requesteePDL) || isRequesteesSupervisor || requestCreatorId.equals(currentUserId) || recipientId.equals(currentUserId); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/question_and_answer/QuestionAndAnswerServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/question_and_answer/QuestionAndAnswerServicesImpl.java index 97295783d..bdff6d7e2 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/question_and_answer/QuestionAndAnswerServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/question_and_answer/QuestionAndAnswerServicesImpl.java @@ -109,7 +109,7 @@ public boolean getIsPermitted(FeedbackRequest feedbackRequest) { MemberProfile requestee = memberProfileServices.getById(requesteeId); final UUID currentUserId = currentUserServices.getCurrentUser().getId(); final UUID recipientId = feedbackRequest.getRecipientId(); - boolean isRequesteesSupervisor = requesteeId != null ? memberProfileServices.getSupervisorsForId(requesteeId).stream().filter(profile -> currentUserId.equals(profile.getId())).findAny().isPresent() : false; + boolean isRequesteesSupervisor = requesteeId != null ? memberProfileServices.getSupervisorsForId(requesteeId).stream().anyMatch(profile -> currentUserId.equals(profile.getId())) : false; final UUID requesteePDL = requestee.getPdlId(); return isAdmin || currentUserId.equals(requesteePDL) || isRequesteesSupervisor || requestCreatorId.equals(currentUserId) || recipientId.equals(currentUserId); diff --git a/server/src/main/java/com/objectcomputing/checkins/services/guild/GuildServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/guild/GuildServicesImpl.java index df7876324..388eed72a 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/guild/GuildServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/guild/GuildServicesImpl.java @@ -181,7 +181,7 @@ public GuildResponseDTO update(GuildUpdateDTO guildDTO) { //delete any removed members from guild existingGuildMembers.forEach(existingMember -> { - if(!guildDTO.getGuildMembers().stream().filter(updatedTeamMember -> updatedTeamMember.getMemberId().equals(existingMember.getMemberId())).findFirst().isPresent()) { + if(guildDTO.getGuildMembers().stream().noneMatch(updatedTeamMember -> updatedTeamMember.getMemberId().equals(existingMember.getMemberId()))) { guildMemberServices.delete(existingMember.getId(), false); removedMembers.add(memberProfileServices.getById(existingMember.getMemberId())); } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/team/TeamServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/team/TeamServicesImpl.java index 08f3b0eb2..b2bfa95d6 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/team/TeamServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/team/TeamServicesImpl.java @@ -115,7 +115,7 @@ public TeamResponseDTO update(TeamUpdateDTO teamDTO) { //delete any removed members existingTeamMembers.forEach(existingMember -> { - if (!teamDTO.getTeamMembers().stream().filter(updatedTeamMember -> updatedTeamMember.getMemberId().equals(existingMember.getMemberId())).findFirst().isPresent()) { + if (teamDTO.getTeamMembers().stream().noneMatch(updatedTeamMember -> updatedTeamMember.getMemberId().equals(existingMember.getMemberId()))) { teamMemberServices.delete(existingMember.getId()); } }); From 870bc7f472ef8ede7275f6bbd3b7b9f978037a06 Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Fri, 20 Sep 2024 12:01:22 +0100 Subject: [PATCH 5/5] Use toList instead of Collectors.asList --- .../FeedbackRequestServicesImpl.java | 3 +-- .../currentuser/CurrentUserController.java | 4 +--- .../checkins/services/pulse/PulseEmail.java | 3 +-- .../services/settings/SettingsController.java | 13 +++++++++---- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestServicesImpl.java b/server/src/main/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestServicesImpl.java index 212eea2a9..2753e6cb7 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestServicesImpl.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestServicesImpl.java @@ -25,7 +25,6 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; -import java.util.stream.Collectors; import static com.objectcomputing.checkins.services.validate.PermissionsValidation.NOT_AUTHORIZED_MSG; @@ -264,7 +263,7 @@ public List findByValues(UUID creatorId, UUID requesteeId, UUID if (currentUserId.equals(request.getRecipientId())) visible = true; } return visible; - }).collect(Collectors.toList()); + }).toList(); return feedbackReqList; } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserController.java b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserController.java index 8cf3ad912..abd220755 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserController.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserController.java @@ -23,8 +23,6 @@ import java.util.List; import java.util.Set; import java.util.UUID; -import java.util.stream.Collectors; - @Controller("/services/member-profiles/current") @ExecuteOn(TaskExecutors.BLOCKING) @@ -70,7 +68,7 @@ public HttpResponse currentUser(@Nullable Authentication authent List permissions = rolePermissionServices.findUserPermissions(user.getId()); Set roles = roleServices.findUserRoles(user.getId()); - List rolesAsString = roles.stream().map(Role::getRole).collect(Collectors.toList()); + List rolesAsString = roles.stream().map(Role::getRole).toList(); return HttpResponse .ok() diff --git a/server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseEmail.java b/server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseEmail.java index 978e02bbd..bac3a3f40 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseEmail.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseEmail.java @@ -7,7 +7,6 @@ import jakarta.inject.Named; -import java.util.stream.Collectors; import java.util.List; class PulseEmail { @@ -29,7 +28,7 @@ private List getActiveTeamMembers() { List profiles = memberProfileServices.findAll().stream() .filter(p -> p.getTerminationDate() == null) .map(p -> p.getWorkEmail()) - .collect(Collectors.toList()); + .toList(); return profiles; } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/settings/SettingsController.java b/server/src/main/java/com/objectcomputing/checkins/services/settings/SettingsController.java index 84be66928..5e772b553 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/settings/SettingsController.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/settings/SettingsController.java @@ -1,11 +1,17 @@ package com.objectcomputing.checkins.services.settings; +import com.objectcomputing.checkins.exceptions.NotFoundException; import com.objectcomputing.checkins.services.permissions.Permission; import com.objectcomputing.checkins.services.permissions.RequiredPermission; -import com.objectcomputing.checkins.exceptions.NotFoundException; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; -import io.micronaut.http.annotation.*; +import io.micronaut.http.annotation.Body; +import io.micronaut.http.annotation.Controller; +import io.micronaut.http.annotation.Delete; +import io.micronaut.http.annotation.Get; +import io.micronaut.http.annotation.PathVariable; +import io.micronaut.http.annotation.Post; +import io.micronaut.http.annotation.Put; import io.micronaut.http.uri.UriBuilder; import io.micronaut.scheduling.TaskExecutors; import io.micronaut.scheduling.annotation.ExecuteOn; @@ -19,7 +25,6 @@ import java.net.URI; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; @Controller(SettingsController.PATH) @ExecuteOn(TaskExecutors.BLOCKING) @@ -85,7 +90,7 @@ public List getOptions() { uuid, option.name(), option.getDescription(), option.getCategory(), option.getType(), value); - }).collect(Collectors.toList()); + }).toList(); } /**