-
Notifications
You must be signed in to change notification settings - Fork 51
AMM-1146 | API to save complaint resolution and remarks for a grievance #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a7a9518
e1b5318
eddabe3
6e626bb
6cf8550
2303d60
68d0483
b7718c0
f9feef6
019d315
507f830
21be52e
0a90728
ea9ff9e
8825473
2d639c4
b0e039b
9831500
5cb6886
9e8e1f2
67b2f86
7b3b990
d834aa9
734551a
47ceb56
f26b8ff
d3534d9
6b58965
8d97517
b5798d2
abe5bd3
3c8fbb9
ef1021e
3451ad5
fa02a49
822ec19
c8e85ab
6557199
9c8afce
4c4cce0
17a159f
c20c9ab
b2d99be
76bf328
eeaf00d
b36477c
48ac080
3fe65c4
b45a6da
55c469a
e6acf34
584f97e
4a4de76
650e573
45b088e
f9ef91b
0e77f26
aaf8db8
713867e
42f00ce
f2478cd
c1cabf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,9 +104,9 @@ public String allocatedGrievanceRecordsCount(String request) throws IEMRExceptio | |
| GrievanceDetails grievanceRequest = InputMapper.gson().fromJson(request, GrievanceDetails.class); | ||
|
|
||
| Integer providerServiceMapID = grievanceRequest.getProviderServiceMapID(); | ||
| Integer assignedUserID = grievanceRequest.getAssignedUserID(); | ||
| Integer userID = grievanceRequest.getUserID(); | ||
|
|
||
| Set<Object[]> resultSet = grievanceDataRepo.fetchGrievanceRecordsCount(providerServiceMapID, assignedUserID); | ||
| Set<Object[]> resultSet = grievanceDataRepo.fetchGrievanceRecordsCount(providerServiceMapID, userID); | ||
|
|
||
| JSONObject result = new JSONObject(); | ||
| result.put("All", 0); | ||
|
|
@@ -194,7 +194,7 @@ public String moveToBin(String request) throws Exception { | |
| // Step 2: Fetch grievances based on assigned user, language | ||
| // condition | ||
| List<GrievanceDetails> grievances = grievanceDataRepo.findGrievancesByUserAndLanguage( | ||
| moveToBinRequest.getAssignedUserID(), moveToBinRequest.getPreferredLanguageName()); | ||
| moveToBinRequest.getUserID(), moveToBinRequest.getPreferredLanguageName()); | ||
|
|
||
| if (grievances.isEmpty()) { | ||
| throw new Exception("No grievances found for the given user, language, and condition."); | ||
|
|
@@ -220,22 +220,22 @@ public String moveToBin(String request) throws Exception { | |
| int totalUnassigned = 0; | ||
| for (GrievanceDetails grievance : grievancesToMove) { | ||
| int rowsAffected = grievanceDataRepo.unassignGrievance(grievance.getGrievanceId(), | ||
| moveToBinRequest.getAssignedUserID()); | ||
| moveToBinRequest.getUserID()); | ||
| if (rowsAffected > 0) { | ||
| grievance.setIsAllocated(false); // Assuming there's a setter for this flag | ||
| int updateFlagResult = grievanceDataRepo.updateGrievanceAllocationStatus(grievance.getGrievanceId(), | ||
| false); | ||
| if (updateFlagResult > 0) { | ||
| totalUnassigned++; | ||
| logger.debug("Unassigned grievance ID {} from user ID {}", grievance.getGrievanceId(), | ||
| moveToBinRequest.getAssignedUserID()); | ||
| moveToBinRequest.getUserID()); | ||
| } else { | ||
| logger.error("Failed to unassign grievance ID {} from user ID {}", grievance.getGrievanceId(), | ||
| moveToBinRequest.getAssignedUserID()); | ||
| moveToBinRequest.getUserID()); | ||
| } | ||
| } else { | ||
| logger.error("Failed to unassign grievance ID {} from user ID {}", grievance.getGrievanceId(), | ||
| moveToBinRequest.getAssignedUserID()); | ||
| moveToBinRequest.getUserID()); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -326,4 +326,65 @@ public List<GrievanceWorklistDTO> getFormattedGrievanceData(String request) thro | |
| return formattedGrievances; | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Saves the complaint resolution and remarks for a grievance. | ||
| * | ||
| * @param request JSON string containing complaint resolution details | ||
| * @return Success message if the update is successful | ||
| */ | ||
|
|
||
| @Transactional | ||
| public String saveComplaintResolution(String request) throws Exception { | ||
|
Comment on lines
+337
to
+338
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Verification agent π§© Analysis chainAdd @OverRide annotation if implementing interface method. If this method is part of the π Script executed: #!/bin/bash
# Check if saveComplaintResolution is defined in GrievanceHandlingService interface
rg -A 3 "interface GrievanceHandlingService" --include="*.java"
rg "saveComplaintResolution" --include="*GrievanceHandlingService.java"Length of output: 1021 Verification Concern: Verify whether saveComplaintResolution is an interface method The initial script couldnβt complete due to invalid command options, so please re-run the search with corrected syntax or perform a manual check. For example, try: If you confirm that π Script executed: [run_scripts]
#!/bin/bash
# Search for the interface declaration and its context
rg -A 3 "interface GrievanceHandlingService" -g "*.java"
# Search for the method usage in files related to GrievanceHandlingService
rg "saveComplaintResolution" -g "*GrievanceHandlingService.java"Length of output: 924 Action Required: Add @OverRide Annotation We verified that @Override
@Transactional
public String saveComplaintResolution(String request) throws Exception {
// method implementation
}This change will help catch interface changes during compilation. |
||
| // Parse the request JSON into a GrievanceDetails object | ||
| GrievanceDetails grievanceRequest = InputMapper.gson().fromJson(request, GrievanceDetails.class); | ||
|
|
||
| if (grievanceRequest.getComplaintID() == null || grievanceRequest.getComplaintID().trim().isEmpty()) { | ||
| throw new IllegalArgumentException("ComplaintID is required"); | ||
| } | ||
| if (grievanceRequest.getComplaintResolution() == null || grievanceRequest.getComplaintResolution().trim().isEmpty()) { | ||
| throw new IllegalArgumentException("ComplaintResolution is required"); | ||
| } | ||
| if (grievanceRequest.getBeneficiaryRegID() == null) { | ||
| throw new IllegalArgumentException("BeneficiaryRegID is required"); | ||
| } | ||
| if (grievanceRequest.getProviderServiceMapID() == null) { | ||
| throw new IllegalArgumentException("ProviderServiceMapID is required"); | ||
| } | ||
| if (grievanceRequest.getUserID() == null) { | ||
| throw new IllegalArgumentException("AssignedUserID is required"); | ||
| } | ||
| if (grievanceRequest.getCreatedBy() == null) { | ||
| throw new IllegalArgumentException("CreatedBy is required"); | ||
| } | ||
| // Extract values from the request | ||
| String complaintID = grievanceRequest.getComplaintID(); | ||
| String complaintResolution = grievanceRequest.getComplaintResolution(); | ||
| String remarks = grievanceRequest.getRemarks(); | ||
| Long beneficiaryRegID = grievanceRequest.getBeneficiaryRegID(); | ||
| Integer providerServiceMapID = grievanceRequest.getProviderServiceMapID(); | ||
| Integer userID = grievanceRequest.getUserID(); | ||
| String createdBy = grievanceRequest.getCreatedBy(); | ||
|
|
||
|
|
||
| String modifiedBy = createdBy; | ||
| int updateCount = 0; | ||
| if (remarks == null) { | ||
| updateCount = grievanceDataRepo.updateComplaintResolution(complaintResolution, modifiedBy, complaintID, | ||
| beneficiaryRegID, providerServiceMapID, userID); | ||
| logger.debug("updated complaint resolution without remarks for complaint id: {}", complaintID); | ||
| } | ||
| else { | ||
| updateCount = grievanceDataRepo.updateComplaintResolution(complaintResolution, remarks, modifiedBy, complaintID, | ||
| beneficiaryRegID, providerServiceMapID, userID); | ||
| logger.debug("updated complaint resolution with remarks for complaint id: {}", complaintID); | ||
|
|
||
| } | ||
| if (updateCount > 0) { | ||
| return "Complaint resolution updated successfully"; | ||
| } else { | ||
| throw new Exception("Failed to update complaint resolution"); | ||
| } | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Add transaction management.
The method performs database updates but lacks transaction management. Add
@Transactionalto ensure atomic operations.+ @Transactional public String saveComplaintResolution(String request) throws Exception {π Committable suggestion
π οΈ Refactor suggestion
Add documentation and input validation.
The method would benefit from:
@NotNulland@NotBlankvalidation for the request parameterπ Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srishtigrp78 You're absolutely right. I can confirm that you've already implemented both suggestions:
@Transactionalannotation is present on thesaveComplaintResolutionmethodThank you for proactively addressing these code quality improvements!