Commit 67155c27 authored by Rajeshekar's avatar Rajeshekar

Verified the scenerio where user is not available in EmployeeDetailsand

fixed it
parent 8d974640
...@@ -34,184 +34,245 @@ import com.nisum.mytime.service.UserService; ...@@ -34,184 +34,245 @@ import com.nisum.mytime.service.UserService;
@RequestMapping("/user") @RequestMapping("/user")
public class UserController { public class UserController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired @Autowired
private RoleMappingService roleMappingService; private RoleMappingService roleMappingService;
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/employee", method = RequestMethod.GET,
public ResponseEntity<EmployeeRoles> getEmployeeRole(@RequestParam("emailId") String emailId) produces = MediaType.APPLICATION_JSON_VALUE)
throws MyTimeException { public ResponseEntity<EmployeeRoles> getEmployeeRole(
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId); @RequestParam("emailId") String emailId) throws MyTimeException {
if (employeesRole.getRole() != null && employeesRole.getRole().equalsIgnoreCase("Admin")) { EmployeeRoles employeesRole = userService.getEmployeesRole(emailId);
employeesRole.setRole("Admin"); if (employeesRole != null) {
} else { if (employeesRole.getRole() != null
String roleName = roleMappingService.getEmployeeRole(employeesRole.getEmployeeId()); && employeesRole.getRole().equalsIgnoreCase("Admin")) {
if (roleName != null) { employeesRole.setRole("Admin");
employeesRole.setRole(roleName); } else {
} String roleName = roleMappingService
} .getEmployeeRole(employeesRole.getEmployeeId());
System.out.println("emailId" + emailId + "result" + employeesRole); if (roleName != null) {
return new ResponseEntity<>(employeesRole, HttpStatus.OK); employeesRole.setRole(roleName);
} }
}
@RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) }
public ResponseEntity<EmployeeRoles> assigingEmployeeRole(@RequestBody EmployeeRoles employeeRoles) System.out.println("emailId" + emailId + "result" + employeesRole);
throws MyTimeException { return new ResponseEntity<>(employeesRole, HttpStatus.OK);
EmployeeRoles employeeRole = userService.assigingEmployeeRole(employeeRoles); }
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} @RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> updateEmployeeRole(@RequestBody EmployeeRoles employeeRoles) public ResponseEntity<EmployeeRoles> assigingEmployeeRole(
throws MyTimeException { @RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService.updateEmployeeRole(employeeRoles); EmployeeRoles employeeRole = userService
return new ResponseEntity<>(employeeRole, HttpStatus.OK); .assigingEmployeeRole(employeeRoles);
} return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> deleteEmployee(@RequestParam("empId") String empId) throws MyTimeException { @RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST,
userService.deleteEmployee(empId); produces = MediaType.APPLICATION_JSON_VALUE,
return new ResponseEntity<>("Success", HttpStatus.OK); consumes = MediaType.APPLICATION_JSON_VALUE)
} public ResponseEntity<EmployeeRoles> updateEmployeeRole(
@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
@RequestMapping(value = "/getUserRoles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) EmployeeRoles employeeRole = userService
public ResponseEntity<List<EmployeeRoles>> getUserRoles() throws MyTimeException { .updateEmployeeRole(employeeRoles);
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles(); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); }
}
@RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE,
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRoleData(@RequestParam("empId") String empId) public ResponseEntity<String> deleteEmployee(
throws MyTimeException { @RequestParam("empId") String empId) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId); userService.deleteEmployee(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>("Success", HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeeLocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getUserRoles", method = RequestMethod.GET,
public ResponseEntity<List<EmployeeLocationDetails>> getEmployeeLocations(@RequestParam("employeeId") String empId) produces = MediaType.APPLICATION_JSON_VALUE)
throws MyTimeException { public ResponseEntity<List<EmployeeRoles>> getUserRoles()
List<EmployeeLocationDetails> employeeLocationDetails = userService.getEmployeeLocationDetails(empId); throws MyTimeException {
return new ResponseEntity<>(employeeLocationDetails, HttpStatus.OK); List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles();
} return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
@RequestMapping(value = "/getManagers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getManagers() throws MyTimeException { @RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET,
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles(); produces = MediaType.APPLICATION_JSON_VALUE)
List<EmployeeRoles> managers = employeesRoles.stream() public ResponseEntity<EmployeeRoles> getEmployeeRoleData(
.filter(e -> ("Director".equalsIgnoreCase(e.getRole()) @RequestParam("empId") String empId) throws MyTimeException {
|| "Delivery Manager".equalsIgnoreCase(e.getRole()) || "Manager".equalsIgnoreCase(e.getRole()) EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId);
|| "HR Manager".equalsIgnoreCase(e.getRole()) || "Lead".equalsIgnoreCase(e.getRole()))) return new ResponseEntity<>(employeesRole, HttpStatus.OK);
.sorted(Comparator.comparing(EmployeeRoles::getEmployeeName)).collect(Collectors.toList()); }
return new ResponseEntity<>(managers, HttpStatus.OK);
} @RequestMapping(value = "/getEmployeeLocations", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/getAllShifts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<EmployeeLocationDetails>> getEmployeeLocations(
public ResponseEntity<List<String>> getAllShifts() throws MyTimeException { @RequestParam("employeeId") String empId) throws MyTimeException {
List<String> shifts = userService.getAllShifts().stream().filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())) List<EmployeeLocationDetails> employeeLocationDetails = userService
.map(Shift::getShiftName).sorted().collect(Collectors.toList()); .getEmployeeLocationDetails(empId);
return new ResponseEntity<>(shifts, HttpStatus.OK); return new ResponseEntity<>(employeeLocationDetails, HttpStatus.OK);
} }
@RequestMapping(value = "/getAllDesignations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getManagers", method = RequestMethod.GET,
public ResponseEntity<List<String>> getAllDesignations() throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE)
List<String> designations = userService.getAllDesignations().stream() public ResponseEntity<List<EmployeeRoles>> getManagers()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Designation::getDesignationName).sorted() throws MyTimeException {
.collect(Collectors.toList()); List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles();
return new ResponseEntity<>(designations, HttpStatus.OK); List<EmployeeRoles> managers = employeesRoles.stream()
} .filter(e -> ("Director".equalsIgnoreCase(e.getRole())
|| "Delivery Manager".equalsIgnoreCase(e.getRole())
@RequestMapping(value = "/getSkills", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) || "Manager".equalsIgnoreCase(e.getRole())
public ResponseEntity<List<String>> getTechnologies() throws MyTimeException { || "HR Manager".equalsIgnoreCase(e.getRole())
List<String> technologies = userService.getTechnologies().stream() || "Lead".equalsIgnoreCase(e.getRole())))
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Skill::getSkillName).sorted() .sorted(Comparator.comparing(EmployeeRoles::getEmployeeName))
.collect(Collectors.toList()); .collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK); return new ResponseEntity<>(managers, HttpStatus.OK);
}
}
@RequestMapping(value = "/getAllShifts", method = RequestMethod.GET,
@RequestMapping(value = "/getLocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getLocations() throws MyTimeException { public ResponseEntity<List<String>> getAllShifts() throws MyTimeException {
System.out.println(" userService.getLocations()" + userService.getLocations()); List<String> shifts = userService.getAllShifts().stream()
List<String> locations = userService.getLocations().stream().filter(e -> (e.isActiveStatus() == true)) .filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Location::getLocation).sorted().collect(Collectors.toList()); .map(Shift::getShiftName).sorted().collect(Collectors.toList());
System.out.println("getLocations################ " + locations); return new ResponseEntity<>(shifts, HttpStatus.OK);
return new ResponseEntity<>(locations, HttpStatus.OK); }
} @RequestMapping(value = "/getAllDesignations", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/updateProfile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<String>> getAllDesignations()
public ResponseEntity<EmployeeRoles> updateProfile(@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
throws MyTimeException { List<String> designations = userService.getAllDesignations().stream()
EmployeeRoles employeeRole = userService.updateProfile(employeeRoles); .filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
return new ResponseEntity<>(employeeRole, HttpStatus.OK); .map(Designation::getDesignationName).sorted()
} .collect(Collectors.toList());
return new ResponseEntity<>(designations, HttpStatus.OK);
@RequestMapping(value = "/getAccounts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) }
public ResponseEntity<List<Account>> getAccounts() throws MyTimeException {
List<Account> technologies = userService.getAccounts().stream().filter(e -> "Y".equalsIgnoreCase(e.getStatus())) @RequestMapping(value = "/getSkills", method = RequestMethod.GET,
// .map(Account::getAccountName).sorted() produces = MediaType.APPLICATION_JSON_VALUE)
.collect(Collectors.toList()); public ResponseEntity<List<String>> getTechnologies()
return new ResponseEntity<>(technologies, HttpStatus.OK); throws MyTimeException {
} List<String> technologies = userService.getTechnologies().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
@RequestMapping(value = "/getEmployeeRoleDataForSearchCriteria", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) .map(Skill::getSkillName).sorted().collect(Collectors.toList());
public ResponseEntity<EmployeeRoles> getEmployeeRoleDataForSearchCriteria(@RequestParam("searchId") String searchId, return new ResponseEntity<>(technologies, HttpStatus.OK);
@RequestParam("searchAttribute") String searchAttribute) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeeRoleDataForSearchCriteria(searchId, searchAttribute); }
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} @RequestMapping(value = "/getLocations", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/getEmployeeDetailsForAutocomplete", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<String>> getLocations() throws MyTimeException {
public ResponseEntity<List<String>> getEmployeeDetailsForAutocomplete() throws MyTimeException { System.out.println(
List<String> details = userService.getEmployeeDetailsForAutocomplete(); " userService.getLocations()" + userService.getLocations());
return new ResponseEntity<>(details, HttpStatus.OK); List<String> locations = userService.getLocations().stream()
} .filter(e -> (e.isActiveStatus() == true))
.map(Location::getLocation).sorted()
@RequestMapping(value = "/getMasterData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) .collect(Collectors.toList());
public ResponseEntity<Map<String, List<String>>> getMasterData() throws MyTimeException { System.out.println("getLocations################ " + locations);
Map<String, List<String>> masterDataMap = new HashMap<>(); return new ResponseEntity<>(locations, HttpStatus.OK);
Map<String, List<MasterData>> result = userService.getMasterData().stream()
.filter(e -> (e.isActiveStatus() == true)) }
.collect(Collectors.groupingBy(MasterData::getMasterDataType));
for (String key : result.keySet()) { @RequestMapping(value = "/updateProfile", method = RequestMethod.POST,
List<MasterData> valueList = result.get(key); produces = MediaType.APPLICATION_JSON_VALUE,
List<String> technologies = valueList.stream().map(MasterData::getMasterDataName).sorted() consumes = MediaType.APPLICATION_JSON_VALUE)
.collect(Collectors.toList()); public ResponseEntity<EmployeeRoles> updateProfile(
masterDataMap.put(key, technologies); @RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
} EmployeeRoles employeeRole = userService.updateProfile(employeeRoles);
return new ResponseEntity<>(masterDataMap, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
}
@RequestMapping(value = "/getAccounts", method = RequestMethod.GET,
@RequestMapping(value = "/getEmployeeByStatus", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getEmployeeByStatus(@RequestParam("status") String status) { public ResponseEntity<List<Account>> getAccounts() throws MyTimeException {
List<Account> technologies = userService.getAccounts().stream()
List<EmployeeRoles> employeesRoles = userService.getEmployeesByStatus(status); .filter(e -> "Y".equalsIgnoreCase(e.getStatus()))
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); // .map(Account::getAccountName).sorted()
} .collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
@RequestMapping(value = "/getDeliveryLeads", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) }
public ResponseEntity<List<HashMap<String, String>>> getDeliveryLeads(@RequestParam("domainId") String domainId)
throws MyTimeException { @RequestMapping(value = "/getEmployeeRoleDataForSearchCriteria",
List<HashMap<String, String>> managers = userService.getDeliveryLeads(domainId); method = RequestMethod.GET,
return new ResponseEntity<>(managers, HttpStatus.OK); produces = MediaType.APPLICATION_JSON_VALUE)
} public ResponseEntity<EmployeeRoles> getEmployeeRoleDataForSearchCriteria(
@RequestParam("searchId") String searchId,
@RequestMapping(value = "/getAccountsInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestParam("searchAttribute") String searchAttribute)
public ResponseEntity<List<AccountInfo>> getAccountsInfo() throws MyTimeException { throws MyTimeException {
List<AccountInfo> technologies = userService.getAccountsInfo().stream() EmployeeRoles employeesRole = userService
.filter(e -> "Active".equalsIgnoreCase(e.getStatus())).collect(Collectors.toList()); .getEmployeeRoleDataForSearchCriteria(searchId,
return new ResponseEntity<>(technologies, HttpStatus.OK); searchAttribute);
} return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/getDomains", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Domains>> getDomains(@RequestParam("accountId") String accountId) @RequestMapping(value = "/getEmployeeDetailsForAutocomplete",
throws MyTimeException { method = RequestMethod.GET,
List<Domains> domains = userService.getDomains(accountId).stream() produces = MediaType.APPLICATION_JSON_VALUE)
.filter(e -> "Active".equalsIgnoreCase(e.getStatus())).collect(Collectors.toList()); public ResponseEntity<List<String>> getEmployeeDetailsForAutocomplete()
return new ResponseEntity<>(domains, HttpStatus.OK); throws MyTimeException {
} List<String> details = userService.getEmployeeDetailsForAutocomplete();
return new ResponseEntity<>(details, HttpStatus.OK);
}
@RequestMapping(value = "/getMasterData", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, List<String>>> getMasterData()
throws MyTimeException {
Map<String, List<String>> masterDataMap = new HashMap<>();
Map<String, List<MasterData>> result = userService.getMasterData()
.stream().filter(e -> (e.isActiveStatus() == true))
.collect(Collectors.groupingBy(MasterData::getMasterDataType));
for (String key : result.keySet()) {
List<MasterData> valueList = result.get(key);
List<String> technologies = valueList.stream()
.map(MasterData::getMasterDataName).sorted()
.collect(Collectors.toList());
masterDataMap.put(key, technologies);
}
return new ResponseEntity<>(masterDataMap, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeByStatus", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getEmployeeByStatus(
@RequestParam("status") String status) {
List<EmployeeRoles> employeesRoles = userService
.getEmployeesByStatus(status);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
@RequestMapping(value = "/getDeliveryLeads", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<HashMap<String, String>>> getDeliveryLeads(
@RequestParam("domainId") String domainId) throws MyTimeException {
List<HashMap<String, String>> managers = userService
.getDeliveryLeads(domainId);
return new ResponseEntity<>(managers, HttpStatus.OK);
}
@RequestMapping(value = "/getAccountsInfo", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<AccountInfo>> getAccountsInfo()
throws MyTimeException {
List<AccountInfo> technologies = userService.getAccountsInfo().stream()
.filter(e -> "Active".equalsIgnoreCase(e.getStatus()))
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
}
@RequestMapping(value = "/getDomains", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Domains>> getDomains(
@RequestParam("accountId") String accountId)
throws MyTimeException {
List<Domains> domains = userService.getDomains(accountId).stream()
.filter(e -> "Active".equalsIgnoreCase(e.getStatus()))
.collect(Collectors.toList());
return new ResponseEntity<>(domains, HttpStatus.OK);
}
} }
\ No newline at end of file
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