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 9d36d710cc443e71aa3928e6b25c4d64fe73dd26..bb7c8f35ca9b6a6742c02351aaa4bb995dadf4da 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 15d2fb4afeaad6eb14c5d756a56b4ced03780b59..9abeb5bc533cf71469100a045abb472388060799 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");