From d8bf4efec332c84ec9b0763eab0b38854aa3971d Mon Sep 17 00:00:00 2001 From: Radheshhathwar <radheshhathwar.bh@gmail.com> Date: Fri, 22 Dec 2023 09:42:14 +0530 Subject: [PATCH] Changes for assign alternative examCenter --- .../upsmf/examsAndAdmissions/model/ExamCenter.java | 11 +++++++++++ .../examsAndAdmissions/service/ExamCenterService.java | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCenter.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCenter.java index 65ba6b8..e425241 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCenter.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCenter.java @@ -1,5 +1,6 @@ package com.tarento.upsmf.examsAndAdmissions.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.tarento.upsmf.examsAndAdmissions.enums.ApprovalStatus; import lombok.*; @@ -43,6 +44,16 @@ public class ExamCenter { private Boolean alternateExamCenterAssigned = false; @OneToOne @JoinColumn(name = "alternate_exam_center_id") +// @JsonIgnore // Ignore this field during JSON serialization private ExamCenter alternateExamCenter; + @Override + public String toString() { + return "ExamCenter{" + + "id=" + id + + ", name='" + name + '\'' + + // ... (other fields) + ", alternateExamCenter=" + (alternateExamCenter != null ? alternateExamCenter.getId() : null) + // Handle alternateExamCenter to break the cyclic reference + '}'; + } } diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java index d6fbbc4..6c19413 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java @@ -78,13 +78,13 @@ public class ExamCenterService { // Set the alternate exam center for the unverified exam center unverifiedExamCenter.setAlternateExamCenter(alternateExamCenter); unverifiedExamCenter.setAlternateExamCenterAssigned(true); - examCenterRepository.save(unverifiedExamCenter); + unverifiedExamCenter = examCenterRepository.save(unverifiedExamCenter); // Save the updated registrations List<StudentExamRegistration> updatedRegistrations = studentExamRegistrationRepository.saveAll(affectedRegistrations); response.put("message", "Alternate Exam Center assigned successfully."); - response.put(Constants.RESPONSE, updatedRegistrations); + response.put(Constants.RESPONSE, unverifiedExamCenter); response.setResponseCode(HttpStatus.OK); } } catch (EntityNotFoundException e) { -- GitLab