-
Notifications
You must be signed in to change notification settings - Fork 20
updated auditdetails logic #974
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -236,6 +236,7 @@ public List<WaterConnection> updateWaterConnection(WaterConnectionRequest waterC | |
mDMSValidator.validateMISFields(waterConnectionRequest); | ||
waterConnectionValidator.validateWaterConnection(waterConnectionRequest, WCConstants.UPDATE_APPLICATION); | ||
List<WaterConnection> waterConnection = getWaterConnectionForOldConnectionNo(waterConnectionRequest); | ||
AuditDetails auditDetails=waterConnection.get(0).getAuditDetails(); | ||
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. Potential At line 239, Apply this diff to fix the issue: +if (waterConnection != null && !waterConnection.isEmpty()) {
AuditDetails auditDetails = waterConnection.get(0).getAuditDetails();
+} else {
+ // Handle the scenario where waterConnection is null or empty
+ throw new CustomException("WATER_CONNECTION_NOT_FOUND", "No water connections found for the given criteria");
+}
|
||
if(waterConnection != null && waterConnection.size() > 0) { | ||
throw new CustomException("DUPLICATE_OLD_CONNECTION_NUMBER", | ||
"Duplicate Old connection number"); | ||
|
@@ -252,7 +253,7 @@ public List<WaterConnection> updateWaterConnection(WaterConnectionRequest waterC | |
String previousApplicationStatus = workflowService.getApplicationStatus(waterConnectionRequest.getRequestInfo(), | ||
waterConnectionRequest.getWaterConnection().getApplicationNo(), | ||
waterConnectionRequest.getWaterConnection().getTenantId(), config.getBusinessServiceValue()); | ||
enrichmentService.enrichUpdateWaterConnection(waterConnectionRequest); | ||
enrichmentService.enrichUpdateWaterConnection(auditDetails, waterConnectionRequest); | ||
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. Ensure At line 256, |
||
actionValidator.validateUpdateRequest(waterConnectionRequest, businessService, previousApplicationStatus); | ||
waterConnectionValidator.validateUpdate(waterConnectionRequest, searchResult, WCConstants.UPDATE_APPLICATION); | ||
userService.updateUser(waterConnectionRequest, searchResult); | ||
|
@@ -326,6 +327,7 @@ private List<WaterConnection> getWaterConnectionForOldConnectionNo(WaterConnecti | |
private List<WaterConnection> updateWaterConnectionForModifyFlow(WaterConnectionRequest waterConnectionRequest) { | ||
waterConnectionValidator.validateWaterConnection(waterConnectionRequest, WCConstants.MODIFY_CONNECTION); | ||
List<WaterConnection> waterConnection = getWaterConnectionForOldConnectionNo(waterConnectionRequest); | ||
AuditDetails auditDetails=waterConnection.get(0).getAuditDetails(); | ||
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. Potential At line 330, Apply this diff to fix the issue: +if (waterConnection != null && !waterConnection.isEmpty()) {
AuditDetails auditDetails = waterConnection.get(0).getAuditDetails();
+} else {
+ // Handle the scenario where waterConnection is null or empty
+ throw new CustomException("WATER_CONNECTION_NOT_FOUND", "No water connections found for the given criteria");
+}
|
||
if(waterConnection != null && waterConnection.size() > 0 && !waterConnectionRequest.getWaterConnection().getConnectionNo() | ||
.equalsIgnoreCase(waterConnection.get(0).getConnectionNo())) { | ||
throw new CustomException("DUPLICATE_OLD_CONNECTION_NUMBER", | ||
|
@@ -342,7 +344,7 @@ private List<WaterConnection> updateWaterConnectionForModifyFlow(WaterConnection | |
String previousApplicationStatus = workflowService.getApplicationStatus(waterConnectionRequest.getRequestInfo(), | ||
waterConnectionRequest.getWaterConnection().getApplicationNo(), | ||
waterConnectionRequest.getWaterConnection().getTenantId(), config.getModifyWSBusinessServiceName()); | ||
enrichmentService.enrichUpdateWaterConnection(waterConnectionRequest); | ||
enrichmentService.enrichUpdateWaterConnection(auditDetails, waterConnectionRequest); | ||
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. Ensure At line 347, |
||
actionValidator.validateUpdateRequest(waterConnectionRequest, businessService, previousApplicationStatus); | ||
userService.updateUser(waterConnectionRequest, searchResult); | ||
waterConnectionValidator.validateUpdate(waterConnectionRequest, searchResult, WCConstants.MODIFY_CONNECTION); | ||
|
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
Consider refactoring for improved maintainability.
The
enrichUpdateWaterConnection
method is quite long and handles multiple responsibilities. Consider breaking it down into smaller, more focused methods to improve readability and maintainability.For example, you could extract the document, plumber info, and road cutting info enrichment into separate methods:
Then, call these methods from
enrichUpdateWaterConnection
:This refactoring would make the method easier to understand and maintain.