Skip to content
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

Pfm 571 #265

Open
wants to merge 1 commit into
base: UAT
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,45 @@ private void updateValidToDate(List<String> sorIds, MdmsCriteriaReqV2 mdmsCriter
}
}

// Code for bulk update of SOR Definitions
private List<Map<String, Object>> updateSorDescriptions(MdmsCriteriaReqV2 mdmsSearchCriteriaReqV2, List<Map<String, Object>> fileData) {

// Create a HashMap to store sorId-description pairs
Map<Object, String> sorIdDescriptionMap = new HashMap<>();
for (Map<String, Object> details : fileData) {
sorIdDescriptionMap.put(details.get("sorId"), (String) details.get("description"));
}

List<Mdms> mdmsDataList = getMdmsV2Data(mdmsSearchCriteriaReqV2);

for (Mdms mdms : mdmsDataList) {
ObjectNode data = (ObjectNode) mdms.getData();
Object uniqueIdentifier = mdms.getUniqueIdentifier();

// Check if the sorId exists in the HashMap
if (sorIdDescriptionMap.containsKey(uniqueIdentifier)) {
String description = sorIdDescriptionMap.get(uniqueIdentifier);
data.put("description", description);
MdmsRequest mdmsRequest = MdmsRequest.builder().requestInfo(mdmsSearchCriteriaReqV2.getRequestInfo()).mdms(mdms).build();
MdmsResponseV2 mdmsResponseV2 = bulkUploadUtil.update(mdmsRequest);
}
}

return fileData;
}


public List<Map<String, Object>> sorBulkUpdate(MultipartFile file, String mdmsSearchCriteria) throws IOException{

// Reading new SOR Definitions File
List<Map<String, Object>> fileData = readFile(file);

// Parsing mdmsSearchCriteria to MdmsSearchCrtiteria of MDMS-V2
MdmsCriteriaReqV2 mdmsSearchCriteriaReqV2 = bulkUploadUtil.getMdmsV2Request(mdmsSearchCriteria);


return updateSorDescriptions(mdmsSearchCriteriaReqV2, fileData);
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public List<Map<String, Object>> bulkUpdate(@RequestParam("file") MultipartFile
return bulkUploadService.bulkUpdate(file, mdmsSearchCriteria, newValidToDate);
}

@PostMapping("/_sorBulkUpdate")
public List<Map<String, Object>> sorBulkUpdate(@RequestParam("file") MultipartFile file, @Valid @RequestParam("mdmsSearchCriteria") String mdmsSearchCriteria) throws Exception{
return bulkUploadService.sorBulkUpdate(file, mdmsSearchCriteria);
}



}