From ccb95607345a062d4e184439913039a3c21c461c Mon Sep 17 00:00:00 2001 From: Radheshhathwar <radheshhathwar.bh@gmail.com> Date: Thu, 16 Nov 2023 13:34:00 +0530 Subject: [PATCH] Approve request changes --- .../StudentExamRegistrationRepository.java | 2 +- .../service/HallTicketService.java | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentExamRegistrationRepository.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentExamRegistrationRepository.java index 9d36d71..bb7c8f3 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentExamRegistrationRepository.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentExamRegistrationRepository.java @@ -58,7 +58,7 @@ public interface StudentExamRegistrationRepository extends JpaRepository<Student @Query("SELECT s FROM Student s WHERE s.verificationStatus = com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus.VERIFIED AND s.institute.id = :instituteId AND NOT EXISTS (SELECT ser FROM StudentExamRegistration ser WHERE ser.student.id = s.id AND ser.examCycle.id = :examCycleId)") List<Student> findVerifiedStudentsNotRegisteredForExamCycleByInstitute(Long examCycleId, Long instituteId); - StudentExamRegistration getByStudentId(Long id); + List<StudentExamRegistration> getByStudentId(Long id); StudentExamRegistration getByStudentIdAndExamCycleId(Long studentId, Long examCycleId); diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java index 15d2fb4..9abeb5b 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java @@ -354,22 +354,22 @@ public class HallTicketService { formattedRequest.put("prevDob", student.getDateOfBirth()); formattedRequest.put("enrollmentNumber", student.getEnrollmentNumber()); if (Objects.equals(request.getUpdatedFirstName(), student.getFirstName())){ - formattedRequest.put("firstNameFlag",TRUE); + formattedRequest.put("firstNameFlag",FALSE); } else { - formattedRequest.put("firstNameFlag",FALSE); + formattedRequest.put("firstNameFlag",TRUE); } if (Objects.equals(request.getUpdatedLastName(), student.getSurname())){ - formattedRequest.put("lastNameFlag",TRUE); + formattedRequest.put("lastNameFlag",FALSE); } else { - formattedRequest.put("lastNameFlag",FALSE); + formattedRequest.put("lastNameFlag",TRUE); } if (request.getUpdatedDOB() == student.getDateOfBirth()){ - formattedRequest.put("dobFlag",TRUE); + formattedRequest.put("dobFlag",FALSE); } else { - formattedRequest.put("dobFlag",FALSE); + formattedRequest.put("dobFlag",TRUE); } List<StudentExamRegistration> registration = studentExamRegistrationRepository.getByExamCycleIdAndStudentId(request.getExamCycle().getId(), request.getStudent().getId()); @@ -440,9 +440,11 @@ public class HallTicketService { studentRepository.save(student); // 2. Regenerate the hall ticket with the updated details - Optional<StudentExamRegistration> registrationOptional = Optional.ofNullable(studentExamRegistrationRepository.findByStudent(student)); - if (registrationOptional.isPresent()) { - StudentExamRegistration registration = registrationOptional.get(); +// Optional<StudentExamRegistration> registrationOptional = Optional.ofNullable(studentExamRegistrationRepository.findByStudent(student)); + List<StudentExamRegistration> registrationOptional = studentExamRegistrationRepository.getByStudentId(student.getId()); + + if (!registrationOptional.isEmpty()) { + StudentExamRegistration registration = registrationOptional.get(0); byte[] hallTicketData = generateHallTicket(registration); if (hallTicketData.length > 0) { MultipartFile hallTicket = new ByteArrayMultipartFile(hallTicketData, "hallticket_updated_" + student.getId() + ".pdf"); -- GitLab