Skip to content

Commit

Permalink
2024-10-21 - feedback - external reviewer - server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
Luch76 committed Oct 22, 2024
1 parent 5c1c584 commit 20ee809
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public class FeedbackExternalRecipient {
private String companyName;

public FeedbackExternalRecipient(
@NotBlank String email, @Nullable String firstName, @Nullable String lastName, @Nullable String company
@NotBlank String email, @Nullable String firstName, @Nullable String lastName, @Nullable String companyName
) {
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
this.companyName = company;
this.companyName = companyName;
}

public FeedbackExternalRecipient() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.objectcomputing.checkins.services.feedback_external_recipient;

import com.objectcomputing.checkins.services.feedback_request.FeedbackRequest;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.data.annotation.Query;
import io.micronaut.data.annotation.TypeDef;
import io.micronaut.data.jdbc.annotation.JdbcRepository;
import io.micronaut.data.model.DataType;
import io.micronaut.data.model.query.builder.sql.Dialect;
import io.micronaut.data.repository.CrudRepository;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

import java.time.LocalDate;
import java.util.List;
import java.util.UUID;

@JdbcRepository(dialect = Dialect.POSTGRES)
public interface FeedbackExternalRecipientRepository extends CrudRepository<FeedbackExternalRecipient, UUID> {

@Override
<S extends FeedbackExternalRecipient> S save(@Valid @NotNull @NonNull S entity);
@Override
<S extends FeedbackExternalRecipient> S update(@NotNull @NonNull S entity);
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@

@Singleton
public class FeedbackExternalRecipientServicesImpl implements FeedbackExternalRecipientServices {

private final FeedbackExternalRecipientRepository feedbackExternalRecipientRepository;

public FeedbackExternalRecipientServicesImpl(FeedbackExternalRecipientRepository feedbackExternalRecipientRepository) {
this.feedbackExternalRecipientRepository = feedbackExternalRecipientRepository;
}

@Override
public FeedbackExternalRecipient save(FeedbackExternalRecipient feedbackExternalRecipient) {
return null;
return feedbackExternalRecipientRepository.save(feedbackExternalRecipient);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public class FeedbackRequest {
private UUID requesteeId;

@Column(name = "recipient_id")
@Nullable
@TypeDef(type = DataType.STRING)
@Schema(description = "id of the person who was requested to give feedback")
@Nullable
private UUID recipientId;

@Column(name = "template_id")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.objectcomputing.checkins.services.feedback_request;

import com.objectcomputing.checkins.services.feedback_external_recipient.FeedbackExternalRecipient;
import com.objectcomputing.checkins.services.feedback_external_recipient.FeedbackExternalRecipientServices;
import com.objectcomputing.checkins.services.permissions.Permission;
import com.objectcomputing.checkins.services.permissions.RequiredPermission;
import io.micronaut.core.annotation.Nullable;
Expand Down Expand Up @@ -35,9 +37,11 @@
public class FeedbackRequestController {

private final FeedbackRequestServices feedbackReqServices;
private final FeedbackExternalRecipientServices feedbackExternalRecipientServices;

public FeedbackRequestController(FeedbackRequestServices feedbackReqServices) {
public FeedbackRequestController(FeedbackRequestServices feedbackReqServices, FeedbackExternalRecipientServices feedbackExternalRecipientServices) {
this.feedbackReqServices = feedbackReqServices;
this.feedbackExternalRecipientServices = feedbackExternalRecipientServices;
}

/**
Expand All @@ -49,8 +53,22 @@ public FeedbackRequestController(FeedbackRequestServices feedbackReqServices) {
@RequiredPermission(Permission.CAN_CREATE_FEEDBACK_REQUEST)
@Post
public HttpResponse<FeedbackRequestResponseDTO> save(@Body @Valid @NotNull FeedbackRequestCreateDTO requestBody) {
FeedbackRequest savedFeedbackRequest;
FeedbackRequest feedbackRequest = fromDTO(requestBody);
FeedbackRequest savedFeedbackRequest = feedbackReqServices.save(feedbackRequest);
/*
FeedbackExternalRecipient feedbackExternalRecipient = new FeedbackExternalRecipient();
feedbackExternalRecipient.setEmail("[email protected]");
feedbackExternalRecipient.setCompanyName("OCI");
feedbackExternalRecipient.setFirstName("None");
feedbackExternalRecipient.setLastName("None");
feedbackExternalRecipient = feedbackExternalRecipientServices.save(feedbackExternalRecipient);
feedbackRequest.setExternalRecipientId(feedbackExternalRecipient.getId());
*/
try {
savedFeedbackRequest = feedbackReqServices.save(feedbackRequest);
} catch (Exception e) {
throw e;
}
return HttpResponse.created(fromEntity(savedFeedbackRequest))
.headers(headers -> headers.location(URI.create("/feedback_request/" + savedFeedbackRequest.getId())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ public class FeedbackRequestResponseDTO {
@Schema(description = "unique id of the feedback request")
private UUID id;

@Nullable
@Schema(description = "id of the person who was requested to give feedback")
private UUID recipientId;

@NotNull
@Schema(description = "id of the feedback request creator")
private UUID creatorId;

@Nullable
@NotNull
@Schema(description = "id of the person who is getting feedback requested on them")
private UUID requesteeId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ private void validateMembers(FeedbackRequest feedbackRequest) {
throw new BadArgException("Cannot save feedback request with invalid recipient ID");
}

/** TODO Luch
try {
if (feedbackRequest.getExternalRecipientId() != null) {
memberProfileServices.getById(feedbackRequest.getExternalRecipientId());
}
} catch (NotFoundException e) {
throw new BadArgException("Cannot save feedback request with invalid external-recipient ID");
}
**/

try {
memberProfileServices.getById(feedbackRequest.getRequesteeId());
Expand All @@ -128,7 +130,6 @@ public FeedbackRequest save(FeedbackRequest feedbackRequest) {
throw new BadArgException("Attempted to save feedback request with non-auto-populated ID");
}


if (feedbackRequest.getDueDate() != null && feedbackRequest.getSendDate().isAfter(feedbackRequest.getDueDate())) {
throw new BadArgException("Send date of feedback request must be before the due date.");
}
Expand All @@ -149,7 +150,7 @@ public void sendNewRequestEmail(FeedbackRequest storedRequest) {
UUID recipientOrExternalRecipientId;
String reviewerFirstName, reviewerEmail;

if (memberProfileServices.getById(storedRequest.getExternalRecipientId()) != null) {
if (storedRequest.getExternalRecipientId() != null) {
recipientOrExternalRecipientId = storedRequest.getExternalRecipientId();
reviewerFirstName = "";
reviewerEmail = "";
Expand Down

0 comments on commit 20ee809

Please sign in to comment.