Unverified Commit d8a67851 authored by mshaik-nisum-com's avatar mshaik-nisum-com Committed by GitHub

Merge pull request #185 from nisum-inc/FEATURE/MT-53_2_ImportEmployeeDataValidations

MT-53_2 :SNS :: ImportEmployeeDataValidations
parents 324a252b 7c4a570a
......@@ -572,14 +572,14 @@ public class UserServiceImpl implements UserService {
for (EmployeeRoles employee : employees) {
findAndModifyEmployeeRole(employee,empId);
}
}
if (null != validationResult && ! (validationResult.entrySet().size() > MyTimeUtils.INT_ZERO) ) {
resultMap.put("Success", "Success");
log.info("Exported {} employee records from file: {}", employees.size(), file.getOriginalFilename());
} else {
resultMap.put("Validation Erroe ", validationResult);
resultMap.put("Validation Error", validationResult);
log.info( "Uploaded file: {}, does not contain valid employee records", file.getOriginalFilename());
}
}
} catch (Exception e) {
log.error("Exception occured while exporting the data from excel file due to: {}",e);
throw new MyTimeException("");
......@@ -621,7 +621,7 @@ public class UserServiceImpl implements UserService {
private Map<String,Object> validateExcelRecords(List<EmployeeRoles> employees) {
boolean flag = false;
Map<String, String> invalidEmpRecsMap = new HashMap<String, String>();
List<String> invalidEmpRecsList = new ArrayList<String>();
Map<String,Object> finalMap = new HashMap<String, Object>();
......@@ -635,7 +635,7 @@ public class UserServiceImpl implements UserService {
List<EmployeeRoles> existingEmployess = employeeRolesRepo.findByEmployeeIdIn(empIdsSet);
if(existingEmployess.size() > MyTimeUtils.INT_ZERO) {
finalMap.put("Below emp records already avilable in db", existingEmployess.stream().map(EmployeeRoles :: getEmployeeId).collect(Collectors.toSet()).toString());
finalMap.put("Below emp records ids existed ", existingEmployess.stream().map(EmployeeRoles :: getEmployeeId).collect(Collectors.toSet()));
employees.removeAll(existingEmployess);
}
......@@ -684,11 +684,11 @@ public class UserServiceImpl implements UserService {
}
}
if(!flag) {
invalidEmpRecsMap.put(Integer.toString(rowNumber), empRole.getEmployeeName());
invalidEmpRecsList.add(Integer.toString(rowNumber));
invalidEmpRecs.add(empRole);
}
}else {
invalidEmpRecsMap.put(Integer.toString(rowNumber), empRole.getEmployeeName());
invalidEmpRecsList.add(Integer.toString(rowNumber));
invalidEmpRecs.add(empRole);
}
rowNumber += 1;
......@@ -700,7 +700,7 @@ public class UserServiceImpl implements UserService {
}
}
if(finalMap.entrySet().size() > MyTimeUtils.INT_ZERO) {
finalMap.put("Below emp records are not valid", invalidEmpRecsMap);
finalMap.put("Please check the following row number records", invalidEmpRecsList);
}
return finalMap;
}
......
......@@ -58,10 +58,17 @@ myApp
function mySuccess(response) {
$mdDialog.hide();
console.log(response.data);
if(response.data == "Success")
showAlert('Data imported from file successfully.');
else if(response.data == "Failure")
showAlert('Uploaded file does not contain valid employee data...!!!');
var parsedResponse = JSON.parse(response.data);
var resp = Object.keys(parsedResponse)
if(Object.keys(parsedResponse)[0] == "Validation Error"){
var empIdError = parsedResponse[resp[0]]["Below emp records are not valid"];
var excelRowError = parsedResponse[resp[0]]["Below emp records already avilable in db"];
showAlert(Object.keys(parsedResponse[resp[0]])[0] + " " + empIdError.join() + "\n" + Object.keys(parsedResponse[resp[0]])[1] + " " + excelRowError.join());
}
else{
showAlert('Successfully Uploaded');
}
$scope.refreshPage();
}, function myError(response) {
$mdDialog.hide();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment