Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
examsAndAdmissions
Commits
4d9d7894
Unverified
Commit
4d9d7894
authored
1 year ago
by
Ankit Verma
Committed by
GitHub
1 year ago
Browse files
Options
Download
Plain Diff
Merge pull request #178 from Radheshhathwar/development
parents
f394a823
db1ffe5a
github/fork/ruksana2808/filter_bug_examCycle
development
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/ExamCenterController.java
+3
-3
...f/examsAndAdmissions/controller/ExamCenterController.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/ExamCenterRepository.java
+1
-0
...f/examsAndAdmissions/repository/ExamCenterRepository.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java
+24
-25
...o/upsmf/examsAndAdmissions/service/ExamCenterService.java
with
28 additions
and
28 deletions
+28
-28
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/ExamCenterController.java
+
3
−
3
View file @
4d9d7894
...
...
@@ -20,9 +20,9 @@ public class ExamCenterController {
return
new
ResponseEntity
<>(
examCenterService
.
getVerifiedExamCentersInDistrict
(
district
,
examCycleId
),
HttpStatus
.
OK
);
}
@PutMapping
(
"/assignAlternate
/{originalExamCenterId}
"
)
public
ResponseEntity
<
ResponseDto
>
assignAlternateExamCenter
(
@
PathVariable
Long
originalExamCenterId
,
@RequestParam
Long
alternateInstituteId
)
{
return
new
ResponseEntity
<>(
examCenterService
.
assignAlternateExamCenter
(
originalExamCenterId
,
alternateInstituteId
),
HttpStatus
.
OK
);
@PutMapping
(
"/assignAlternate"
)
public
ResponseEntity
<
ResponseDto
>
assignAlternateExamCenter
(
@
RequestParam
Long
originalExamCenterId
,
@RequestParam
Long
alternateInstituteId
,
@RequestParam
Long
examCycleId
)
{
return
new
ResponseEntity
<>(
examCenterService
.
assignAlternateExamCenter
(
originalExamCenterId
,
alternateInstituteId
,
examCycleId
),
HttpStatus
.
OK
);
}
@GetMapping
(
"/examCenters"
)
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/ExamCenterRepository.java
+
1
−
0
View file @
4d9d7894
...
...
@@ -26,4 +26,5 @@ public interface ExamCenterRepository extends JpaRepository<ExamCenter, Long> {
List
<
ExamCenter
>
findByExamCycle_Id
(
Long
examCycleId
);
Optional
<
ExamCenter
>
findByExamCycleIdAndId
(
Long
examCycleId
,
Long
examCenterId
);
List
<
ExamCenter
>
findByDistrictAndExamCycleAndApprovalStatus
(
String
district
,
ExamCycle
examCycleId
,
ApprovalStatus
approvalStatus
);
Optional
<
ExamCenter
>
getByIdAndExamCycle
(
Long
unverifiedExamCenterId
,
ExamCycle
examCycle
);
}
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCenterService.java
+
24
−
25
View file @
4d9d7894
...
...
@@ -49,44 +49,44 @@ public class ExamCenterService {
return
response
;
}
@Transactional
public
ResponseDto
assignAlternateExamCenter
(
Long
unverifiedExamCenterId
,
Long
alternateExamCenterId
)
{
public
ResponseDto
assignAlternateExamCenter
(
Long
unverifiedExamCenterId
,
Long
alternateExamCenterId
,
Long
examCycleId
)
{
ResponseDto
response
=
new
ResponseDto
(
"API_ASSIGN_ALTERNATE_EXAM_CENTER"
);
ExamCycle
examCycle
=
examCycleRepository
.
findById
(
examCycleId
).
orElseThrow
();
try
{
// Fetch the unverified exam center
ExamCenter
unverifiedExamCenter
=
examCenterRepository
.
findById
(
unverifiedExamCenterId
)
.
orElseThrow
(()
->
new
EntityNotFoundException
(
"Unverified Exam Center not found
"
));
ExamCenter
unverifiedExamCenter
=
examCenterRepository
.
getByIdAndExamCycle
(
unverifiedExamCenterId
,
examCycle
)
.
orElseThrow
(()
->
new
EntityNotFoundException
(
"Unverified Exam Center not found
for examCycle:"
+
examCycle
.
getId
()
));
// Fetch the alternate exam center
ExamCenter
alternateExamCenter
=
examCenterRepository
.
findById
(
alternateExamCenterId
)
.
orElseThrow
(()
->
new
EntityNotFoundException
(
"Alternate Exam Center not found
"
));
ExamCenter
alternateExamCenter
=
examCenterRepository
.
getByIdAndExamCycle
(
alternateExamCenterId
,
examCycle
)
.
orElseThrow
(()
->
new
EntityNotFoundException
(
"Alternate Exam Center not found
for examCycle:"
+
examCycle
.
getId
()
));
// Ensure both the exam centers belong to the same district
if
(!
unverifiedExamCenter
.
getDistrict
().
equals
(
alternateExamCenter
.
getDistrict
()))
{
throw
new
IllegalArgumentException
(
"Unverified and Alternate Exam Centers do not belong to the same district."
);
}
}
else
if
(
unverifiedExamCenter
.
getExamCycle
().
getId
().
equals
(
alternateExamCenter
.
getExamCycle
().
getId
()))
{
// Fetch all student registrations where the exam center is null
List
<
StudentExamRegistration
>
affectedRegistrations
=
studentExamRegistrationRepository
.
findByExamCenterIsNullAndInstitute
(
unverifiedExamCenter
.
getInstitute
());
// Fetch all student registrations where the exam center is null
List
<
StudentExamRegistration
>
affectedRegistrations
=
studentExamRegistrationRepository
.
findByExamCenterIsNullAndInstitute
(
unverifiedExamCenter
.
getInstitute
());
// Update the exam center for these registrations
for
(
StudentExamRegistration
registration
:
affectedRegistrations
)
{
registration
.
setExamCenter
(
alternateExamCenter
);
registration
.
setAlternateExamCenterAssigned
(
true
);
// This is the new change
}
// Update the exam center for these registrations
for
(
StudentExamRegistration
registration
:
affectedRegistrations
)
{
registration
.
setExamCenter
(
alternateExamCenter
);
registration
.
setAlternateExamCenterAssigned
(
true
);
// This is the new change
}
// Set the alternate exam center for the unverified exam center
unverifiedExamCenter
.
setAlternateExamCenter
(
alternateExamCenter
);
unverifiedExamCenter
.
setAlternateExamCenterAssigned
(
true
);
examCenterRepository
.
save
(
unverifiedExamCenter
);
// Set the alternate exam center for the unverified exam center
unverifiedExamCenter
.
setAlternateExamCenter
(
alternateExamCenter
);
unverifiedExamCenter
.
setAlternateExamCenterAssigned
(
true
);
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
.
setResponseCode
(
HttpStatus
.
OK
);
// Save the updated registrations
List
<
StudentExamRegistration
>
updatedRegistrations
=
studentExamRegistrationRepository
.
saveAll
(
affectedRegistrations
);
response
.
put
(
"message"
,
"Alternate Exam Center assigned successfully."
);
response
.
put
(
Constants
.
RESPONSE
,
updatedRegistrations
);
response
.
setResponseCode
(
HttpStatus
.
OK
);
}
}
catch
(
EntityNotFoundException
e
)
{
ResponseDto
.
setErrorResponse
(
response
,
"NOT_FOUND"
,
e
.
getMessage
(),
HttpStatus
.
NOT_FOUND
);
}
catch
(
IllegalArgumentException
e
)
{
...
...
@@ -94,7 +94,6 @@ public class ExamCenterService {
}
catch
(
Exception
e
)
{
ResponseDto
.
setErrorResponse
(
response
,
"GENERAL_ERROR"
,
"An unexpected error occurred: "
+
e
.
getMessage
(),
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
return
response
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets