Commit 65c9aaa9 authored by Vijay Akula's avatar Vijay Akula

Added request format for domain controller. Refactored the code in

DomainController, DomainService, DomainRepo 
parent 35c50907
...@@ -6,6 +6,8 @@ import java.util.List; ...@@ -6,6 +6,8 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -22,8 +24,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -22,8 +24,8 @@ import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.exception.handler.ResponseDetails; import com.nisum.mytime.exception.handler.ResponseDetails;
import com.nisum.mytime.model.Domains; import com.nisum.mytime.model.Domain;
import com.nisum.mytime.service.DomainService; import com.nisum.mytime.service.IDomainService;
import com.nisum.mytime.utils.MyTimeUtils; import com.nisum.mytime.utils.MyTimeUtils;
...@@ -35,48 +37,66 @@ import com.nisum.mytime.utils.MyTimeUtils; ...@@ -35,48 +37,66 @@ import com.nisum.mytime.utils.MyTimeUtils;
public class DomainController { public class DomainController {
@Autowired @Autowired
private DomainService domainService; private IDomainService domainService;
@RequestMapping(value = "/domains", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) private static final Logger logger = LoggerFactory.getLogger(DomainController.class);
public ResponseEntity<?> addDomain(@RequestBody Domains domain, HttpServletRequest request) throws MyTimeException {
String response = null; @RequestMapping(value = "/domains", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
response = domainService.addDomains(domain); public ResponseEntity<?> createDomain(@RequestBody Domain domain, HttpServletRequest request)
throws MyTimeException {
logger.info("Domain Creation");
if (!domainService.isDomainExists(domain)) {
Domain domainPeristed = domainService.create(domain);
ResponseDetails createRespDetails = new ResponseDetails(new Date(), 801, "Domain has been created", ResponseDetails createRespDetails = new ResponseDetails(new Date(), 801, "Domain has been created",
"Domain Creation", null, request.getContextPath(), "details", domain); "Domain Creation", null, "", "details", domainPeristed);
return new ResponseEntity<ResponseDetails>(createRespDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(createRespDetails, HttpStatus.OK);
}
logger.info("A domain is already existed with the requested name" + domain.getDomainName());
ResponseDetails responseDetails = new ResponseDetails(new Date(), 802, "Domain is already existed",
"Choose the different domain name", null, request.getRequestURI(), "Domain details", domain);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
} }
@RequestMapping(value = "/domains", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/domains", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAccounts(HttpServletRequest request) throws MyTimeException { public ResponseEntity<?> getDomains(HttpServletRequest request) throws MyTimeException {
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 804, "Retrieved the domains successfully", ResponseDetails getRespDetails = new ResponseDetails(new Date(), 804, "Retrieved the domains successfully",
"Domains list", domainService.getAllDomains(), request.getContextPath(), "details", null); "Domains list", domainService.getDomainsList(), request.getRequestURI(), "details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
} }
@RequestMapping(value = "/domains", method = RequestMethod.PUT, produces = MediaType.TEXT_PLAIN_VALUE) @RequestMapping(value = "/domains", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateDomain(@RequestBody Domains domains, HttpServletRequest request) public ResponseEntity<?> updateDomain(@RequestBody Domain domain, HttpServletRequest request)
throws MyTimeException { throws MyTimeException {
String response = null;
response = domainService.updateDomain(domains);
boolean isDomainExists = domainService.isDomainExists(domain);
if (isDomainExists == true) {
Domain domainPersisted = domainService.update(domain);
ResponseDetails updateRespDetails = new ResponseDetails(new Date(), 802, "Domain has been updated", ResponseDetails updateRespDetails = new ResponseDetails(new Date(), 802, "Domain has been updated",
"Domain Updation", null, request.getContextPath(), "Updation Domain details", domains); "Domain Updation", null, request.getRequestURI(), "Updation Domain details", domainPersisted);
return new ResponseEntity<ResponseDetails>(updateRespDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(updateRespDetails, HttpStatus.OK);
}
ResponseDetails responseDetails = new ResponseDetails(new Date(), 803, "Domain is Not found",
"Choose the correct updating domain name", null, request.getRequestURI(), "details", domain);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
} }
@RequestMapping(value = "/domains", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE) @RequestMapping(value = "/domains/{domainId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deleteDomain(@RequestParam String domainId, HttpServletRequest request) public ResponseEntity<?> deleteDomain(@PathVariable String domainId, HttpServletRequest request)
throws MyTimeException { throws MyTimeException {
domainService.deleteDomain(domainId); domainService.delete(domainId);
ResponseDetails deleteRespDetails = new ResponseDetails(new Date(), 804, "Domain has been deleted", ResponseDetails deleteRespDetails = new ResponseDetails(new Date(), 804, "Domain has been deleted",
"Domain Deletion", null, request.getContextPath(), "Deletion Domain details", domainId); "Domain Deletion", null, request.getRequestURI(), "Deletion Domain details", domainId);
return new ResponseEntity<ResponseDetails>(deleteRespDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(deleteRespDetails, HttpStatus.OK);
......
...@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account; import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.repository.AccountRepo; import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.repository.ProjectRepo; import com.nisum.mytime.repository.ProjectRepo;
...@@ -40,9 +40,9 @@ public class ProjectController { ...@@ -40,9 +40,9 @@ public class ProjectController {
private ProjectRepo projectRepo; private ProjectRepo projectRepo;
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRole(@RequestParam("emailId") String emailId) public ResponseEntity<Employee> getEmployeeRole(@RequestParam("emailId") String emailId)
throws MyTimeException { throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId); Employee employeesRole = userService.getEmployeesRole(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
...@@ -124,9 +124,9 @@ public class ProjectController { ...@@ -124,9 +124,9 @@ public class ProjectController {
} }
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRoleData(@RequestParam("empId") String empId) public ResponseEntity<Employee> getEmployeeRoleData(@RequestParam("empId") String empId)
throws MyTimeException { throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId); Employee employeesRole = userService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
......
...@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.BillingDetails; import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.EmployeeDashboardVO; import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeVisa; import com.nisum.mytime.model.EmployeeVisa;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
...@@ -42,9 +42,9 @@ public class ProjectTeamController { ...@@ -42,9 +42,9 @@ public class ProjectTeamController {
@RequestMapping(value = "/employee", method = RequestMethod.GET, @RequestMapping(value = "/employee", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRole( public ResponseEntity<Employee> getEmployeeRole(
@RequestParam("emailId") String emailId) throws MyTimeException { @RequestParam("emailId") String emailId) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId); Employee employeesRole = userService.getEmployeesRole(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
...@@ -60,9 +60,9 @@ public class ProjectTeamController { ...@@ -60,9 +60,9 @@ public class ProjectTeamController {
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST, @RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> updateEmployeeRole(@RequestBody EmployeeRoles emp, public ResponseEntity<Employee> updateEmployeeRole(@RequestBody Employee emp,
@RequestParam(value="empId") String loginEmpId) throws MyTimeException { @RequestParam(value="empId") String loginEmpId) throws MyTimeException {
EmployeeRoles employeeRole = userService.updateEmployeeRole(emp, loginEmpId); Employee employeeRole = userService.updateEmployeeRole(emp, loginEmpId);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
...@@ -76,9 +76,9 @@ public class ProjectTeamController { ...@@ -76,9 +76,9 @@ public class ProjectTeamController {
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, @RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRoleData( public ResponseEntity<Employee> getEmployeeRoleData(
@RequestParam("empId") String empId) throws MyTimeException { @RequestParam("empId") String empId) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId); Employee employeesRole = userService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
...@@ -95,9 +95,9 @@ public class ProjectTeamController { ...@@ -95,9 +95,9 @@ public class ProjectTeamController {
@RequestMapping(value = "/getEmployeesToTeam", method = RequestMethod.GET, @RequestMapping(value = "/getEmployeesToTeam", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getManagers() public ResponseEntity<List<Employee>> getManagers()
throws MyTimeException { throws MyTimeException {
List<EmployeeRoles> employeesRoles = new ArrayList<>(); List<Employee> employeesRoles = new ArrayList<>();
if (userService.getEmployeeRoles() != null) { if (userService.getEmployeeRoles() != null) {
employeesRoles = userService.getEmployeeRoles().stream() employeesRoles = userService.getEmployeeRoles().stream()
.sorted((o1, o2) -> o1.getEmployeeName() .sorted((o1, o2) -> o1.getEmployeeName()
...@@ -171,9 +171,9 @@ public class ProjectTeamController { ...@@ -171,9 +171,9 @@ public class ProjectTeamController {
@RequestMapping(value = "/getUnAssignedEmployees", @RequestMapping(value = "/getUnAssignedEmployees",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getUnAssignedEmployees() public ResponseEntity<List<Employee>> getUnAssignedEmployees()
throws MyTimeException { throws MyTimeException {
List<EmployeeRoles> employeesRoles = projectService List<Employee> employeesRoles = projectService
.getUnAssignedEmployees(); .getUnAssignedEmployees();
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
...@@ -288,9 +288,9 @@ public class ProjectTeamController { ...@@ -288,9 +288,9 @@ public class ProjectTeamController {
@RequestMapping(value = "/getEmployeesHavingVisa", @RequestMapping(value = "/getEmployeesHavingVisa",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getEmployeesHavingVisa( public ResponseEntity<List<Employee>> getEmployeesHavingVisa(
@RequestParam("visa") String passport) throws MyTimeException { @RequestParam("visa") String passport) throws MyTimeException {
List<EmployeeRoles> employees = new ArrayList<>(); List<Employee> employees = new ArrayList<>();
if (passport != null && !"passport".equalsIgnoreCase(passport)) { if (passport != null && !"passport".equalsIgnoreCase(passport)) {
List<EmployeeVisa> employeeVisas = employeeVisaRepo List<EmployeeVisa> employeeVisas = employeeVisaRepo
.findByVisaName(passport); .findByVisaName(passport);
...@@ -301,8 +301,8 @@ public class ProjectTeamController { ...@@ -301,8 +301,8 @@ public class ProjectTeamController {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
if (employeeIds != null && !employeeIds.isEmpty()) { if (employeeIds != null && !employeeIds.isEmpty()) {
List<EmployeeRoles> emps = userService.getEmployeeRoles(); List<Employee> emps = userService.getEmployeeRoles();
for (EmployeeRoles emp : emps) { for (Employee emp : emps) {
if (employeeIds.contains(emp.getEmployeeId())) { if (employeeIds.contains(emp.getEmployeeId())) {
employees.add(emp); employees.add(emp);
} }
......
...@@ -35,7 +35,7 @@ import com.nisum.mytime.exception.handler.MyTimeException; ...@@ -35,7 +35,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account; import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.BillingDetails; import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.ColumnChartData; import com.nisum.mytime.model.ColumnChartData;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.GroupByCount; import com.nisum.mytime.model.GroupByCount;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.model.ReportSeriesRecord; import com.nisum.mytime.model.ReportSeriesRecord;
...@@ -83,7 +83,7 @@ public class ReportsController { ...@@ -83,7 +83,7 @@ public class ReportsController {
// Convert the aggregation result into a List // Convert the aggregation result into a List
AggregationResults<GroupByCount> groupResults = mongoTemplate AggregationResults<GroupByCount> groupResults = mongoTemplate
.aggregate(agg, EmployeeRoles.class, GroupByCount.class); .aggregate(agg, Employee.class, GroupByCount.class);
List<GroupByCount> result = groupResults.getMappedResults(); List<GroupByCount> result = groupResults.getMappedResults();
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
...@@ -111,7 +111,7 @@ public class ReportsController { ...@@ -111,7 +111,7 @@ public class ReportsController {
// Convert the aggregation result into a List // Convert the aggregation result into a List
AggregationResults<GroupByCount> groupResults = mongoTemplate AggregationResults<GroupByCount> groupResults = mongoTemplate
.aggregate(agg, EmployeeRoles.class, GroupByCount.class); .aggregate(agg, Employee.class, GroupByCount.class);
List<GroupByCount> result = groupResults.getMappedResults(); List<GroupByCount> result = groupResults.getMappedResults();
ColumnChartData reportData = new ColumnChartData(); ColumnChartData reportData = new ColumnChartData();
reportData.setCategories("data"); reportData.setCategories("data");
...@@ -302,7 +302,7 @@ public class ReportsController { ...@@ -302,7 +302,7 @@ public class ReportsController {
// Convert the aggregation result into a List // Convert the aggregation result into a List
AggregationResults<GroupByCount> groupResults = mongoTemplate AggregationResults<GroupByCount> groupResults = mongoTemplate
.aggregate(agg, EmployeeRoles.class, GroupByCount.class); .aggregate(agg, Employee.class, GroupByCount.class);
List<GroupByCount> result = groupResults.getMappedResults(); List<GroupByCount> result = groupResults.getMappedResults();
Map<String, List<GroupByCount>> map = new HashMap<String, List<GroupByCount>>(); Map<String, List<GroupByCount>> map = new HashMap<String, List<GroupByCount>>();
map.put("data", result); map.put("data", result);
...@@ -315,9 +315,9 @@ public class ReportsController { ...@@ -315,9 +315,9 @@ public class ReportsController {
@RequestMapping(value = "/fetchEmployeeDetailsByFG", @RequestMapping(value = "/fetchEmployeeDetailsByFG",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getEmployeesByFG( public ResponseEntity<List<Employee>> getEmployeesByFG(
@RequestParam("fGroup") String fGroup) throws MyTimeException { @RequestParam("fGroup") String fGroup) throws MyTimeException {
List<EmployeeRoles> empList = new ArrayList<>(); List<Employee> empList = new ArrayList<>();
empList = userService.getEmployeesByFunctionalGrp(fGroup); empList = userService.getEmployeesByFunctionalGrp(fGroup);
return new ResponseEntity<>(empList, HttpStatus.OK); return new ResponseEntity<>(empList, HttpStatus.OK);
......
...@@ -21,9 +21,9 @@ import com.nisum.mytime.exception.handler.MyTimeException; ...@@ -21,9 +21,9 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account; import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.AccountInfo; import com.nisum.mytime.model.AccountInfo;
import com.nisum.mytime.model.Designation; import com.nisum.mytime.model.Designation;
import com.nisum.mytime.model.Domains; import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.EmployeeLocationDetails; import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Location; import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.MasterData; import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.model.Shift; import com.nisum.mytime.model.Shift;
...@@ -46,9 +46,9 @@ public class UserController { ...@@ -46,9 +46,9 @@ public class UserController {
@RequestMapping(value = "/employee", method = RequestMethod.GET, @RequestMapping(value = "/employee", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRole( public ResponseEntity<Employee> getEmployeeRole(
@RequestParam("emailId") String emailId) throws MyTimeException { @RequestParam("emailId") String emailId) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId); Employee employeesRole = userService.getEmployeesRole(emailId);
if (employeesRole != null) { if (employeesRole != null) {
if (employeesRole.getRole() != null if (employeesRole.getRole() != null
&& employeesRole.getRole().equalsIgnoreCase("Admin")) { && employeesRole.getRole().equalsIgnoreCase("Admin")) {
...@@ -68,9 +68,9 @@ public class UserController { ...@@ -68,9 +68,9 @@ public class UserController {
@RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST, @RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> assigingEmployeeRole( public ResponseEntity<Employee> assigingEmployeeRole(
@RequestBody EmployeeRoles employeeRoles, @RequestParam(value="empId") String loginEmpId) throws MyTimeException { @RequestBody Employee employeeRoles, @RequestParam(value="empId") String loginEmpId) throws MyTimeException {
EmployeeRoles employeeRole = userService Employee employeeRole = userService
.assigingEmployeeRole(employeeRoles,loginEmpId); .assigingEmployeeRole(employeeRoles,loginEmpId);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
...@@ -78,10 +78,10 @@ public class UserController { ...@@ -78,10 +78,10 @@ public class UserController {
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST, @RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> updateEmployeeRole( public ResponseEntity<Employee> updateEmployeeRole(
@RequestBody EmployeeRoles employeeRoles, @RequestBody Employee employeeRoles,
@RequestParam(value="empId") String loginEmpId) throws MyTimeException { @RequestParam(value="empId") String loginEmpId) throws MyTimeException {
EmployeeRoles employeeRole = userService Employee employeeRole = userService
.updateEmployeeRole(employeeRoles,loginEmpId); .updateEmployeeRole(employeeRoles,loginEmpId);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
...@@ -96,17 +96,17 @@ public class UserController { ...@@ -96,17 +96,17 @@ public class UserController {
@RequestMapping(value = "/getUserRoles", method = RequestMethod.GET, @RequestMapping(value = "/getUserRoles", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getUserRoles() public ResponseEntity<List<Employee>> getUserRoles()
throws MyTimeException { throws MyTimeException {
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles(); List<Employee> employeesRoles = userService.getEmployeeRoles();
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, @RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRoleData( public ResponseEntity<Employee> getEmployeeRoleData(
@RequestParam("empId") String empId) throws MyTimeException { @RequestParam("empId") String empId) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId); Employee employeesRole = userService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
...@@ -121,16 +121,16 @@ public class UserController { ...@@ -121,16 +121,16 @@ public class UserController {
@RequestMapping(value = "/getManagers", method = RequestMethod.GET, @RequestMapping(value = "/getManagers", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getManagers() public ResponseEntity<List<Employee>> getManagers()
throws MyTimeException { throws MyTimeException {
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles(); List<Employee> employeesRoles = userService.getEmployeeRoles();
List<EmployeeRoles> managers = employeesRoles.stream() List<Employee> managers = employeesRoles.stream()
.filter(e -> ("Director".equalsIgnoreCase(e.getRole()) .filter(e -> ("Director".equalsIgnoreCase(e.getRole())
|| "Delivery Manager".equalsIgnoreCase(e.getRole()) || "Delivery Manager".equalsIgnoreCase(e.getRole())
|| "Manager".equalsIgnoreCase(e.getRole()) || "Manager".equalsIgnoreCase(e.getRole())
|| "HR Manager".equalsIgnoreCase(e.getRole()) || "HR Manager".equalsIgnoreCase(e.getRole())
|| "Lead".equalsIgnoreCase(e.getRole()))) || "Lead".equalsIgnoreCase(e.getRole())))
.sorted(Comparator.comparing(EmployeeRoles::getEmployeeName)) .sorted(Comparator.comparing(Employee::getEmployeeName))
.collect(Collectors.toList()); .collect(Collectors.toList());
return new ResponseEntity<>(managers, HttpStatus.OK); return new ResponseEntity<>(managers, HttpStatus.OK);
} }
...@@ -183,9 +183,9 @@ public class UserController { ...@@ -183,9 +183,9 @@ public class UserController {
@RequestMapping(value = "/updateProfile", method = RequestMethod.POST, @RequestMapping(value = "/updateProfile", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> updateProfile( public ResponseEntity<Employee> updateProfile(
@RequestBody EmployeeRoles employeeRoles) throws MyTimeException { @RequestBody Employee employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService.updateProfile(employeeRoles); Employee employeeRole = userService.updateProfile(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
...@@ -203,11 +203,11 @@ public class UserController { ...@@ -203,11 +203,11 @@ public class UserController {
@RequestMapping(value = "/getEmployeeRoleDataForSearchCriteria", @RequestMapping(value = "/getEmployeeRoleDataForSearchCriteria",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRoleDataForSearchCriteria( public ResponseEntity<Employee> getEmployeeRoleDataForSearchCriteria(
@RequestParam("searchId") String searchId, @RequestParam("searchId") String searchId,
@RequestParam("searchAttribute") String searchAttribute) @RequestParam("searchAttribute") String searchAttribute)
throws MyTimeException { throws MyTimeException {
EmployeeRoles employeesRole = userService Employee employeesRole = userService
.getEmployeeRoleDataForSearchCriteria(searchId, .getEmployeeRoleDataForSearchCriteria(searchId,
searchAttribute); searchAttribute);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
...@@ -243,10 +243,10 @@ public class UserController { ...@@ -243,10 +243,10 @@ public class UserController {
@RequestMapping(value = "/getEmployeeByStatus", method = RequestMethod.GET, @RequestMapping(value = "/getEmployeeByStatus", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getEmployeeByStatus( public ResponseEntity<List<Employee>> getEmployeeByStatus(
@RequestParam("status") String status) { @RequestParam("status") String status) {
List<EmployeeRoles> employeesRoles = userService List<Employee> employeesRoles = userService
.getEmployeesByStatus(status); .getEmployeesByStatus(status);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
...@@ -272,10 +272,10 @@ public class UserController { ...@@ -272,10 +272,10 @@ public class UserController {
@RequestMapping(value = "/getDomains", method = RequestMethod.GET, @RequestMapping(value = "/getDomains", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Domains>> getDomains( public ResponseEntity<List<Domain>> getDomains(
@RequestParam("accountId") String accountId) @RequestParam("accountId") String accountId)
throws MyTimeException { throws MyTimeException {
List<Domains> domains = userService.getDomains(accountId).stream() List<Domain> domains = userService.getDomains(accountId).stream()
.filter(e -> "Active".equalsIgnoreCase(e.getStatus())) .filter(e -> "Active".equalsIgnoreCase(e.getStatus()))
.collect(Collectors.toList()); .collect(Collectors.toList());
return new ResponseEntity<>(domains, HttpStatus.OK); return new ResponseEntity<>(domains, HttpStatus.OK);
......
...@@ -3,7 +3,11 @@ package com.nisum.mytime.model; ...@@ -3,7 +3,11 @@ package com.nisum.mytime.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
...@@ -19,15 +23,20 @@ import lombok.ToString; ...@@ -19,15 +23,20 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "Domains") @Document(collection = "Domains")
public class Domains implements Serializable { public class Domain implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// private ObjectId id;
@Id @Id
private ObjectId id;
private String domainId; private String domainId;
@NotNull
@Size(min = 2, max = 80, message = "Domain Name should have atlast 2 and less than 80 characters")
private String domainName; private String domainName;
@NotBlank
private String accountId; private String accountId;
@NotBlank
private String status; private String status;
List<String> deliveryManagers; @NotNull
List<?> deliveryManagers;
} }
package com.nisum.mytime.model; package com.nisum.mytime.model;
import java.io.Serializable;
import java.util.Date;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import com.poiji.annotation.ExcelCellName;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
@Setter @Setter
@Getter @Getter
public class Employee { @AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "EmployeeDetails")
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String id;
@ExcelCellName("Employee ID")
private String employeeId;
@ExcelCellName("Employee Name")
private String employeeName;
@ExcelCellName("Email ID")
private String emailId;
@ExcelCellName("Role")
private String role;
@ExcelCellName("Designation")
private String designation;
@ExcelCellName("Shift")
private String shift;
@ExcelCellName("Primary Skill")
private String baseTechnology;
@ExcelCellName("Domain")
private String domain;
@ExcelCellName("Location")
private String empLocation;
@ExcelCellName("Skills")
private String technologyKnown;
@ExcelCellName("Primary Mobile")
private String mobileNumber;
@ExcelCellName("Alternate Mobile")
private String alternateMobileNumber;
@ExcelCellName("Personal Email")
private String personalEmailId;
@ExcelCellName("Functional Group")
private String functionalGroup;
@ExcelCellName("Employment Status")
private String empStatus;
@ExcelCellName("Employment Type")
private String employmentType;
@ExcelCellName("Date Of Joining")
private Date dateOfJoining;
@ExcelCellName("Date Of Birth")
private Date dateOfBirth;
@ExcelCellName("Gender")
private String gender;
@ExcelCellName("Has Passport")
private String hasPassort;
@ExcelCellName("Passport Expiry Date")
private Date passportExpiryDate;
@ExcelCellName("Has B1")
private String hasB1;
@ExcelCellName("B1 Expiry Date")
private Date b1ExpiryDate;
@ExcelCellName("Created")
private Date createdOn;
@ExcelCellName("Last Modified")
private Date lastModifiedOn;
@ExcelCellName("Exit Date")
private Date endDate;
private String createdBy;
private String modifiedBy;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((employeeId == null) ? 0 : employeeId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employee other = (Employee) obj;
if (employeeId == null) {
if (other.employeeId != null)
return false;
} else if (!employeeId.equals(other.employeeId))
return false;
return true;
}
private String email;
private String name;
private String givenName;
private String familyName;
} }
package com.nisum.mytime.model;
import java.io.Serializable;
import java.util.Date;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import com.poiji.annotation.ExcelCellName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "EmployeeDetails")
public class EmployeeRoles implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String id;
@ExcelCellName("Employee ID")
private String employeeId;
@ExcelCellName("Employee Name")
private String employeeName;
@ExcelCellName("Email ID")
private String emailId;
@ExcelCellName("Role")
private String role;
@ExcelCellName("Designation")
private String designation;
@ExcelCellName("Shift")
private String shift;
@ExcelCellName("Primary Skill")
private String baseTechnology;
@ExcelCellName("Domain")
private String domain;
@ExcelCellName("Location")
private String empLocation;
@ExcelCellName("Skills")
private String technologyKnown;
@ExcelCellName("Primary Mobile")
private String mobileNumber;
@ExcelCellName("Alternate Mobile")
private String alternateMobileNumber;
@ExcelCellName("Personal Email")
private String personalEmailId;
@ExcelCellName("Functional Group")
private String functionalGroup;
@ExcelCellName("Employment Status")
private String empStatus;
@ExcelCellName("Employment Type")
private String employmentType;
@ExcelCellName("Date Of Joining")
private Date dateOfJoining;
@ExcelCellName("Date Of Birth")
private Date dateOfBirth;
@ExcelCellName("Gender")
private String gender;
@ExcelCellName("Has Passport")
private String hasPassort;
@ExcelCellName("Passport Expiry Date")
private Date passportExpiryDate;
@ExcelCellName("Has B1")
private String hasB1;
@ExcelCellName("B1 Expiry Date")
private Date b1ExpiryDate;
@ExcelCellName("Created")
private Date createdOn;
@ExcelCellName("Last Modified")
private Date lastModifiedOn;
@ExcelCellName("Exit Date")
private Date endDate;
private String createdBy;
private String modifiedBy;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((employeeId == null) ? 0 : employeeId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EmployeeRoles other = (EmployeeRoles) obj;
if (employeeId == null) {
if (other.employeeId != null)
return false;
} else if (!employeeId.equals(other.employeeId))
return false;
return true;
}
}
package com.nisum.mytime.repository; package com.nisum.mytime.repository;
import java.util.List; import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Domains; import com.nisum.mytime.model.Domain;
public interface DomainRepo extends MongoRepository<Domains, String> { public interface DomainRepo extends MongoRepository<Domain, String> {
List<Domains> findByDomainNameAndAccountId(String domianName,String accountId); List<Domain> findByDomainNameAndAccountId(String domianName,String accountId);
List<Domains> findByAccountId(String accountId); List<Domain> findByAccountId(String accountId);
Domains findByDomainId(String domainId); Domain findByDomainId(String domainId);
List<Domain> findByDeliveryManagers(String empId);
} }
\ No newline at end of file
...@@ -5,24 +5,24 @@ import java.util.Set; ...@@ -5,24 +5,24 @@ import java.util.Set;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
public interface EmployeeRolesRepo public interface EmployeeRolesRepo
extends MongoRepository<EmployeeRoles, String> { extends MongoRepository<Employee, String> {
EmployeeRoles findByEmailId(String emailId); Employee findByEmailId(String emailId);
EmployeeRoles findByEmployeeId(String employeeId); Employee findByEmployeeId(String employeeId);
EmployeeRoles findByEmployeeName(String employeeName); Employee findByEmployeeName(String employeeName);
List<EmployeeRoles> findByEmpStatusAndFunctionalGroup(String empStatus, List<Employee> findByEmpStatusAndFunctionalGroup(String empStatus,
String functionalGroup); String functionalGroup);
List<EmployeeRoles> findByEmpStatusOrderByEmployeeNameAsc(String empStatus); List<Employee> findByEmpStatusOrderByEmployeeNameAsc(String empStatus);
List<EmployeeRoles> findByEmpStatus(String status); List<Employee> findByEmpStatus(String status);
List<EmployeeRoles> findByEmployeeIdIn(Set<String> empIdsSet); List<Employee> findByEmployeeIdIn(Set<String> empIdsSet);
} }
\ No newline at end of file
...@@ -19,7 +19,7 @@ import org.springframework.stereotype.Service; ...@@ -19,7 +19,7 @@ import org.springframework.stereotype.Service;
import com.nisum.mytime.controller.AccountController; import com.nisum.mytime.controller.AccountController;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account; import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.repository.AccountRepo; import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.utils.CommomUtil; import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeUtils; import com.nisum.mytime.utils.MyTimeUtils;
...@@ -102,7 +102,7 @@ public class AccountService implements IAccountService { ...@@ -102,7 +102,7 @@ public class AccountService implements IAccountService {
List<Map<String, String>> updatedEmployeeList = null; List<Map<String, String>> updatedEmployeeList = null;
for (Account account : accountRepo.findAll()) { for (Account account : accountRepo.findAll()) {
updatedEmployeeList = new ArrayList<>(); updatedEmployeeList = new ArrayList<>();
for (EmployeeRoles employeesRole : getEmployeeDetails(account)) { for (Employee employeesRole : getEmployeeDetails(account)) {
updatedEmployeeList.add(getEmployeeDetails(employeesRole)); updatedEmployeeList.add(getEmployeeDetails(employeesRole));
} }
updatedAccountList.add(getAccuntDetails(account, updatedEmployeeList)); updatedAccountList.add(getAccuntDetails(account, updatedEmployeeList));
...@@ -179,14 +179,14 @@ public class AccountService implements IAccountService { ...@@ -179,14 +179,14 @@ public class AccountService implements IAccountService {
} }
// fetching the employee details using employeeId. // fetching the employee details using employeeId.
private List<EmployeeRoles> getEmployeeDetails(Account account) { private List<Employee> getEmployeeDetails(Account account) {
List<EmployeeRoles> employeeRoles = mongoTemplate.find( List<Employee> employeeRoles = mongoTemplate.find(
new Query(Criteria.where(MyTimeUtils.EMPLOYEE_ID).in(account.getDeliveryManagers())), new Query(Criteria.where(MyTimeUtils.EMPLOYEE_ID).in(account.getDeliveryManagers())),
EmployeeRoles.class); Employee.class);
return employeeRoles; return employeeRoles;
} }
private HashMap<String, String> getEmployeeDetails(EmployeeRoles employeesRole) { private HashMap<String, String> getEmployeeDetails(Employee employeesRole) {
HashMap<String, String> employeeDetails = new HashMap<>(); HashMap<String, String> employeeDetails = new HashMap<>();
employeeDetails.put(MyTimeUtils.EMPLOYEE_ID, employeesRole.getEmployeeId()); employeeDetails.put(MyTimeUtils.EMPLOYEE_ID, employeesRole.getEmployeeId());
employeeDetails.put(MyTimeUtils.EMPLOYEE_NAME, employeesRole.getEmployeeName()); employeeDetails.put(MyTimeUtils.EMPLOYEE_NAME, employeesRole.getEmployeeName());
......
package com.nisum.mytime.service; package com.nisum.mytime.service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.mongodb.WriteResult; import com.mongodb.WriteResult;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Domains; import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.repository.DomainRepo;
import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeUtils;
/** /**
* @author Vijay * @author Vijay
* *
*/ */
public interface DomainService { @Service
public class DomainService implements IDomainService {
@Autowired
private DomainRepo domainRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private RoleInfoService roleInfoService;
@Autowired
private RoleMappingService roleMappingService;
private static final Logger logger = LoggerFactory.getLogger(DomainService.class);
public boolean isDomainExists(Domain domainReq) {
boolean isDomainExists = false;
int count = 0;
List<Domain> domainListByName = domainRepo.findByDomainNameAndAccountId(domainReq.getDomainName(),
domainReq.getAccountId());
List<Domain> domainListbyAccountId = domainRepo.findByAccountId(domainReq.getAccountId());
// Case sensitive logic
for (Domain domainItr : domainListbyAccountId) {
if (domainItr.getDomainName().equalsIgnoreCase(domainReq.getDomainName()))
count++;
}
if (count > 0 || domainListByName.size() > 0) {
isDomainExists = true;
}
return isDomainExists;
}
@Override
public Domain create(Domain domainReq) throws MyTimeException {
if (StringUtils.isEmpty(domainReq.getDomainId())) {
domainReq.setDomainId((MyTimeUtils.DOM + MyTimeUtils.ZERO_) + (getDomainsList().size() + 1));
}
domainReq.setStatus(MyTimeUtils.ACTIVE);
Domain domainPersisted = domainRepo.save(domainReq);
if (domainPersisted != null) {
saveEmployeeRole(domainReq);
}
return domainPersisted;
}
@Override
public Domain update(Domain domainReq) throws MyTimeException {
logger.info("updating the roles for DeliveryManager in EmployeeRoleMapping collection");
final String roleId = roleInfoService.getRole(MyTimeUtils.DOMAIN);
updateRoleIdsForDMs(domainReq, roleId);
logger.info("deleting roleids for DeliveryManagers in EmployeeRoleMapping collection");
deleteRoleIdsForDMs(domainReq, roleId);
logger.info("updating the domain details");
domainReq.setStatus(MyTimeUtils.ACTIVE);
Domain domainPersisted = domainRepo.save(domainReq);
logger.info("After update the domain details::" + domainPersisted);
return domainPersisted;
}
private void updateRoleIdsForDMs(Domain domainReq, String roleId) throws MyTimeException {
Domain domainDAO = getDomainById(domainReq.getDomainId());
List dmssListDAO = domainDAO.getDeliveryManagers();
List dmsListReq = domainReq.getDeliveryManagers();
List<String> managersAddedByUser = managersAddedByUser = CommomUtil.getAddedManagersListForDM(dmssListDAO,
dmsListReq);
roleMappingService.saveUniqueEmployeeAndRole(managersAddedByUser, roleId);
}
private void deleteRoleIdsForDMs(Domain domainUpdating, String roleId) throws MyTimeException {
Map<String, Integer> managersDomainCount = new HashMap<String, Integer>();
Domain domainDAO = getDomainById(domainUpdating.getDomainId());
List dmsListDAO = domainDAO.getDeliveryManagers();
List dmsListReq = domainUpdating.getDeliveryManagers();
List<String> managersDeletedByUser = CommomUtil.getDeletedManagersList(dmsListDAO, dmsListReq);
List<Domain> domainsPersistedList = domainRepo.findAll();
for (Domain domain : domainsPersistedList) {
List employeeIds = domain.getDeliveryManagers();
for (Object eId : employeeIds) {
if (managersDomainCount.get(eId) != null)
managersDomainCount.put(eId.toString(), managersDomainCount.get(eId) + 1);
else
managersDomainCount.put(eId.toString(), 1);
}
}
for (String managerId : managersDeletedByUser) {
if (managersDomainCount.get(managerId) == 1) {
// Call service to delete manager
roleMappingService.deleteRole(managerId, roleId);
}
}
}
@Override
public List<Domain> getDomainsList() throws MyTimeException {
List<Domain> domainsPersistedList = domainRepo.findAll();
for (Domain domainPersisted : domainsPersistedList) {
domainPersisted.setDeliveryManagers(prepareEmployeeList(domainPersisted));
}
return domainsPersistedList;
}
@Override
public WriteResult delete(String domainId) throws MyTimeException {
List<String> domEmpIds = new ArrayList<String>();
String roleId = roleInfoService.getRole(MyTimeUtils.DOMAIN);
List<Domain> domainsPersistedList = domainRepo.findAll();
Query selectedDomainQuery = new Query(
Criteria.where(MyTimeUtils.DOMAIN_ID).in(domainId).and(MyTimeUtils.STATUS).in(MyTimeUtils.ACTIVE));
List<Domain> selectedDomain = mongoTemplate.find(selectedDomainQuery, Domain.class);
for (Domain domain : domainsPersistedList) {
List employeeIds = domain.getDeliveryManagers();
for (Object eIds : employeeIds)
domEmpIds.add(eIds.toString());
}
for (Object empId : selectedDomain.get(0).getDeliveryManagers()) {
int occurrences = Collections.frequency(domEmpIds, empId.toString());
if (occurrences == 1) {
// Service call for RoleMapping
roleMappingService.deleteRole(empId.toString(), roleId);
}
}
Update update = new Update();
update.set(MyTimeUtils.STATUS, MyTimeUtils.IN_ACTIVE);
return mongoTemplate.upsert(selectedDomainQuery, update, Domain.class);
}
private void saveEmployeeRole(Domain domainReq) throws MyTimeException {
String roleId = roleInfoService.getRole(MyTimeUtils.DOMAIN);
List dmsList = domainReq.getDeliveryManagers();
roleMappingService.saveUniqueEmployeeAndRole(dmsList, roleId);
}
private List<HashMap<String, String>> prepareEmployeeList(Domain domainPersisted) {
ArrayList<HashMap<String, String>> empList = new ArrayList<HashMap<String, String>>();
Query query = new Query(Criteria.where(MyTimeUtils.EMPLOYEE_ID).in(domainPersisted.getDeliveryManagers()));
List<Employee> employeeList = mongoTemplate.find(query, Employee.class);
for (Employee employee : employeeList) {
HashMap<String, String> employeeMap = new HashMap<>();
employeeMap.put(MyTimeUtils.EMPLOYEE_ID, employee.getEmployeeId());
employeeMap.put(MyTimeUtils.EMPLOYEE_NAME, employee.getEmployeeName());
empList.add(employeeMap);
}
return empList;
}
String addDomains(Domains d)throws MyTimeException; // Custom methods
private Domain getDomainById(String domainId) {
Query selectedDomainQuery = new Query(
Criteria.where(MyTimeUtils.DOMAIN_ID).in(domainId).and(MyTimeUtils.STATUS).in(MyTimeUtils.ACTIVE));
List<Domain> selectedDomain = mongoTemplate.find(selectedDomainQuery, Domain.class);
if (selectedDomain.size() == 1)
return selectedDomain.get(0);
return null;
}
List<HashMap<Object,Object>> getAllDomains() throws MyTimeException; private boolean duplicateCheck(String domainName, String accountId, List<String> fromDB, List fromUser) {
boolean check = false;
int count = 0;
List<Domain> domainListbyAccountId = domainRepo.findByAccountId(accountId);
boolean deleveryManagersCheck = fromDB.toString().contentEquals(fromUser.toString());
List<Domain> domainList = domainRepo.findByDomainNameAndAccountId(domainName, accountId);
for (Domain domains : domainListbyAccountId) {
if (domains.getDomainName().equalsIgnoreCase(domainName))
count++;
}
if ((domainList.size() > 0 && deleveryManagersCheck) || count > 1)
check = true;
return check;
}
String updateDomain(Domains d) throws MyTimeException; @Override
public Set<String> accountsAssignedToDeliveryLead(String empId) {
Set<String> accIdsSet = new HashSet<String>();
List<Domain> domainList = domainRepo.findByDeliveryManagers(empId);
if (null != domainList && !domainList.isEmpty() && domainList.size() > MyTimeUtils.INT_ZERO) {
for (Domain domain : domainList) {
accIdsSet.add(domain.getAccountId());
}
}
return accIdsSet;
}
WriteResult deleteDomain(String id) throws MyTimeException;
} }
\ No newline at end of file
package com.nisum.mytime.service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.mongodb.WriteResult;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Domains;
import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.repository.DomainRepo;
import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeUtils;
/**
* @author Vijay
*
*/
@Service
public class DomainServiceImpl implements DomainService {
List<Domains> domainList = null;
List<HashMap<Object, Object>> updatedDomainList = null;
List<HashMap<String, String>> updatedEmployeeList = null;
@Autowired
private DomainRepo domainRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private RoleInfoService roleInfoService;
@Autowired
private RoleMappingService roleMappingService;
@Override
public String addDomains(Domains d) throws MyTimeException {
String response=null;
int count=0;
List<Domains> domainList=domainRepo.findByDomainNameAndAccountId(d.getDomainName(), d.getAccountId());
List<Domains> domainListbyAccountId=domainRepo.findByAccountId(d.getAccountId());
//Case sensitive logic
for(Domains domains:domainListbyAccountId )
{
if(domains.getDomainName().equalsIgnoreCase(d.getDomainName()))
count++;
}
if(count>0 || domainList.size()>0) {
return response="Domain already exists";
}
if (StringUtils.isEmpty(d.getDomainId()) && d.getId()==null) {
d.setDomainId((MyTimeUtils.DOM + MyTimeUtils.ZERO_) + (getAllDomains().size() +1));
}
d.setStatus(MyTimeUtils.ACTIVE);
if(d.getId()==null){
response="Domain saved successfully";
}else{
response="Domain updated successfully";
}
domainRepo.save(d);
String roleId = roleInfoService.getRole(MyTimeUtils.DOMAIN);
roleMappingService.saveUniqueEmployeeAndRole(d.getDeliveryManagers(), roleId);
return response;
}
@Override
public List<HashMap<Object, Object>> getAllDomains() throws MyTimeException {
domainList=domainRepo.findAll();
updatedDomainList = new ArrayList<>();
for (Domains domain : domainList) {
HashMap<Object, Object> domainMap = new HashMap<>();
domainMap.put(MyTimeUtils.ID_,domain.getId());
domainMap.put(MyTimeUtils.DOMAIN_ID, domain.getDomainId());
domainMap.put(MyTimeUtils.DOMAIN_NAME,domain.getDomainName());
domainMap.put(MyTimeUtils.STATUS,domain.getStatus());
domainMap.put(MyTimeUtils.ACCOUNT_ID, domain.getAccountId());
Query accountInfoQuery = new Query(Criteria.where(MyTimeUtils.ACCOUNT_ID).in(domain.getAccountId()));
List<Account> accountList = mongoTemplate.find(accountInfoQuery, Account.class);
if(accountList!=null && accountList.size()>0)
domainMap.put(MyTimeUtils.ACCOUNT_NAME, accountList.get(0).getAccountName());
updatedEmployeeList = new ArrayList<>();
List<String> employeeIds=domain.getDeliveryManagers();
Query query = new Query(Criteria.where(MyTimeUtils.EMPLOYEE_ID).in(employeeIds));
List<EmployeeRoles> employeeRoles = mongoTemplate.find(query, EmployeeRoles.class);
for(EmployeeRoles employeesRole : employeeRoles){
HashMap<String, String> employeeMap = new HashMap<>();
employeeMap.put(MyTimeUtils.EMPLOYEE_ID,employeesRole.getEmployeeId());
employeeMap.put(MyTimeUtils.EMPLOYEE_NAME,employeesRole.getEmployeeName());
updatedEmployeeList.add(employeeMap);
}
domainMap.put(MyTimeUtils.DELIVERY_MANAGERS,updatedEmployeeList);
updatedDomainList.add(domainMap);
}
return updatedDomainList;
}
@Override
public String updateDomain(Domains d) throws MyTimeException{
String response = null;
List<String> deliveryManagersListFromUser = null;
List<String> deliveryManagersListFromDb = null;
List<String> managersAddedByUser = null;
List<String> managersDeletedByUser = null;
Map<String, Integer> managersDomainCount = new HashMap<String,Integer>();
Domains domainDetailsFromDb = getDomainById(d.getDomainId());
deliveryManagersListFromUser = d.getDeliveryManagers();
if (null != domainDetailsFromDb)
deliveryManagersListFromDb = domainDetailsFromDb.getDeliveryManagers();
boolean isDuplicate=duplicateCheck(d.getDomainName(), d.getAccountId(),deliveryManagersListFromDb,d.getDeliveryManagers());
if(isDuplicate) {
return response="Domain already exists";
}else{
response="Domain updated successfully";
}
managersAddedByUser = CommomUtil.getAddedManagersList(deliveryManagersListFromDb, deliveryManagersListFromUser);
managersDeletedByUser = CommomUtil.getDeletedManagersList(deliveryManagersListFromDb, deliveryManagersListFromUser);
domainList = domainRepo.findAll();
String roleId = roleInfoService.getRole(MyTimeUtils.DOMAIN);
for (Domains domain : domainList) {
List<String> employeeIds = domain.getDeliveryManagers();
for (String eId : employeeIds) {
if(managersDomainCount.get(eId)!=null)
managersDomainCount.put(eId, managersDomainCount.get(eId)+1);
else
managersDomainCount.put(eId, 1);
}
}
for(String managerId : managersDeletedByUser) {
if(managersDomainCount.get(managerId)==1) {
// Call service to delete manager
roleMappingService.deleteRole(managerId,roleId);
}
}
d.setStatus(MyTimeUtils.ACTIVE);
domainRepo.save(d);
roleMappingService.saveUniqueEmployeeAndRole(managersAddedByUser, roleId);
return response;
}
@Override
public WriteResult deleteDomain(String id) throws MyTimeException{
List<String> domEmpIds=new ArrayList<String>();
String roleId = roleInfoService.getRole(MyTimeUtils.DOMAIN);
domainList=domainRepo.findAll();
Query selectedDomainQuery = new Query(Criteria.where(MyTimeUtils.DOMAIN_ID).in(id).and(MyTimeUtils.STATUS).in(MyTimeUtils.ACTIVE) );
List<Domains> selectedDomain = mongoTemplate.find(selectedDomainQuery, Domains.class);
for (Domains domain : domainList) {
List<String> employeeIds=domain.getDeliveryManagers();
for(String eIds:employeeIds)
domEmpIds.add(eIds);
}
for (String empId : selectedDomain.get(0).getDeliveryManagers()) {
int occurrences = Collections.frequency(domEmpIds, empId);
if(occurrences==1) {
//Service call for RoleMapping
roleMappingService.deleteRole(empId,roleId);
}
}
Update update = new Update();
update.set(MyTimeUtils.STATUS,MyTimeUtils.IN_ACTIVE);
return mongoTemplate.upsert(selectedDomainQuery, update,Domains.class);
}
//Custom methods
private Domains getDomainById(String id) {
Query selectedDomainQuery = new Query(Criteria.where(MyTimeUtils.DOMAIN_ID).in(id).and(MyTimeUtils.STATUS).in(MyTimeUtils.ACTIVE) );
List<Domains> selectedDomain = mongoTemplate.find(selectedDomainQuery, Domains.class);
if(selectedDomain.size()==1)
return selectedDomain.get(0);
return null;
}
private boolean duplicateCheck(String domainName,String accountId,List<String> fromDB,List<String> fromUser)
{
boolean check=false;
int count=0;
List<Domains> domainListbyAccountId=domainRepo.findByAccountId(accountId);
boolean deleveryManagersCheck=fromDB.toString().contentEquals(fromUser.toString());
List<Domains> domainList=domainRepo.findByDomainNameAndAccountId(domainName, accountId);
for(Domains domains:domainListbyAccountId )
{
if(domains.getDomainName().equalsIgnoreCase(domainName))
count++;
}
if((domainList.size()>0 && deleveryManagersCheck) || count>1)
check= true;
return check;
}
}
\ No newline at end of file
package com.nisum.mytime.service;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.springframework.stereotype.Service;
import com.mongodb.WriteResult;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Domain;
/**
* @author Vijay
*
*/
@Service
public interface IDomainService {
boolean isDomainExists(Domain domainReq);
Domain create(Domain domain) throws MyTimeException;
// List<HashMap<Object,Object>> getAllDomains() throws MyTimeException;
Domain update(Domain domain) throws MyTimeException;
WriteResult delete(String id) throws MyTimeException;
List<Domain> getDomainsList() throws MyTimeException;
Set<String> accountsAssignedToDeliveryLead(String empId) throws MyTimeException;
}
...@@ -10,7 +10,7 @@ import com.nisum.mytime.exception.handler.MyTimeException; ...@@ -10,7 +10,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.BillingDetails; import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.EmpLoginData; import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeDashboardVO; import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
...@@ -26,13 +26,13 @@ public interface ProjectService { ...@@ -26,13 +26,13 @@ public interface ProjectService {
String generatePdfReport(long id, String fromDate, String toDate) String generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException; throws MyTimeException;
EmployeeRoles getEmployeesRole(String emailId); Employee getEmployeesRole(String emailId);
void deleteProject(String projectId); void deleteProject(String projectId);
Project updateProject(Project project, String loginEmpId)throws MyTimeException; Project updateProject(Project project, String loginEmpId)throws MyTimeException;
EmployeeRoles getEmployeesRoleData(String empId); Employee getEmployeesRoleData(String empId);
List<ProjectTeamMate> getTeamDetails(String empId); List<ProjectTeamMate> getTeamDetails(String empId);
...@@ -50,7 +50,7 @@ public interface ProjectService { ...@@ -50,7 +50,7 @@ public interface ProjectService {
List<ProjectTeamMate> getMyTeamDetails(String empId); List<ProjectTeamMate> getMyTeamDetails(String empId);
List<EmployeeRoles> getUnAssignedEmployees(); List<Employee> getUnAssignedEmployees();
List<ProjectTeamMate> getShiftDetails(String shift); List<ProjectTeamMate> getShiftDetails(String shift);
......
...@@ -29,11 +29,11 @@ import com.nisum.mytime.controller.DomainController; ...@@ -29,11 +29,11 @@ import com.nisum.mytime.controller.DomainController;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account; import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.BillingDetails; import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.Domains; import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.EmpLoginData; import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmpShiftDetails; import com.nisum.mytime.model.EmpShiftDetails;
import com.nisum.mytime.model.EmployeeDashboardVO; import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.repository.AccountRepo; import com.nisum.mytime.repository.AccountRepo;
...@@ -90,7 +90,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -90,7 +90,7 @@ public class ProjectServiceImpl implements ProjectService {
private DomainRepo domainRepo; private DomainRepo domainRepo;
@Autowired @Autowired
private ProjectService projectService; private IDomainService domainService;
@Override @Override
public List<EmpLoginData> employeeLoginsBasedOnDate(long id, public List<EmpLoginData> employeeLoginsBasedOnDate(long id,
...@@ -120,7 +120,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -120,7 +120,7 @@ public class ProjectServiceImpl implements ProjectService {
projectMap.put("projectId", p.getProjectId()); projectMap.put("projectId", p.getProjectId());
projectMap.put("projectName", p.getProjectName()); projectMap.put("projectName", p.getProjectName());
Account account = accountRepo.findByAccountId(p.getAccountId()); Account account = accountRepo.findByAccountId(p.getAccountId());
Domains domain = domainRepo.findByDomainId(p.getDomainId()); Domain domain = domainRepo.findByDomainId(p.getDomainId());
if (domain != null) if (domain != null)
projectMap.put("domain", domain.getDomainName()); projectMap.put("domain", domain.getDomainName());
if (account != null) if (account != null)
...@@ -157,15 +157,15 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -157,15 +157,15 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public Project addProject(Project project, String loginEmpId) throws MyTimeException { public Project addProject(Project project, String loginEmpId) throws MyTimeException {
if (project.getDomainId() == null) { if (project.getDomainId() == null) {
Domains domain = new Domains(); Domain domain = new Domain();
domain.setAccountId(project.getAccountId()); domain.setAccountId(project.getAccountId());
domain.setDomainName(project.getDomain()); domain.setDomainName(project.getDomain());
domain.setDeliveryManagers(project.getManagerIds()); domain.setDeliveryManagers(project.getManagerIds());
domain.setStatus(project.getStatus()); domain.setStatus(project.getStatus());
domainController.addDomain(domain); domainController.createDomain(domain,null);
List<Domains> domainsList = domainRepo List<Domain> domainsList = domainRepo
.findByAccountId(project.getAccountId()); .findByAccountId(project.getAccountId());
Domains savedDomain = domainsList.get(0); Domain savedDomain = domainsList.get(0);
project.setDomainId(savedDomain.getDomainId()); project.setDomainId(savedDomain.getDomainId());
project.setDomain(savedDomain.getDomainName()); project.setDomain(savedDomain.getDomainName());
} }
...@@ -174,7 +174,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -174,7 +174,7 @@ public class ProjectServiceImpl implements ProjectService {
} }
@Override @Override
public EmployeeRoles getEmployeesRole(String emailId) { public Employee getEmployeesRole(String emailId) {
return employeeRolesRepo.findByEmailId(emailId); return employeeRolesRepo.findByEmailId(emailId);
} }
...@@ -305,7 +305,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -305,7 +305,7 @@ public class ProjectServiceImpl implements ProjectService {
} }
@Override @Override
public EmployeeRoles getEmployeesRoleData(String employeeId) { public Employee getEmployeesRoleData(String employeeId) {
return employeeRolesRepo.findByEmployeeId(employeeId); return employeeRolesRepo.findByEmployeeId(employeeId);
} }
...@@ -555,7 +555,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -555,7 +555,7 @@ public class ProjectServiceImpl implements ProjectService {
|| (projectTeamMate.getShift() != null) && !projectTeamMate.getShift().equalsIgnoreCase(existingTeammate.getShift())) { || (projectTeamMate.getShift() != null) && !projectTeamMate.getShift().equalsIgnoreCase(existingTeammate.getShift())) {
updateShiftDetails(existingTeammate, loginEmpId); updateShiftDetails(existingTeammate, loginEmpId);
existingTeammate.setShift(projectTeamMate.getShift()); existingTeammate.setShift(projectTeamMate.getShift());
EmployeeRoles employeeDB = employeeRolesRepo.findByEmployeeId(projectTeamMate.getEmployeeId()); Employee employeeDB = employeeRolesRepo.findByEmployeeId(projectTeamMate.getEmployeeId());
employeeDB.setShift(projectTeamMate.getShift()); employeeDB.setShift(projectTeamMate.getShift());
employeeDB.setModifiedBy(loginEmpId); employeeDB.setModifiedBy(loginEmpId);
employeeDB.setLastModifiedOn(new Date()); employeeDB.setLastModifiedOn(new Date());
...@@ -691,9 +691,9 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -691,9 +691,9 @@ public class ProjectServiceImpl implements ProjectService {
} }
@Override @Override
public List<EmployeeRoles> getUnAssignedEmployees() { public List<Employee> getUnAssignedEmployees() {
List<EmployeeRoles> allEmployees = employeeRolesRepo.findAll(); List<Employee> allEmployees = employeeRolesRepo.findAll();
List<EmployeeRoles> notAssignedEmployees = new ArrayList<>(); List<Employee> notAssignedEmployees = new ArrayList<>();
List<String> teamMates = new ArrayList<>(); List<String> teamMates = new ArrayList<>();
List<ProjectTeamMate> empRecords = projectTeamMatesRepo.findAll(); List<ProjectTeamMate> empRecords = projectTeamMatesRepo.findAll();
for (ProjectTeamMate pt : empRecords) { for (ProjectTeamMate pt : empRecords) {
...@@ -703,7 +703,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -703,7 +703,7 @@ public class ProjectServiceImpl implements ProjectService {
teamMates.add(pt.getEmployeeId()); teamMates.add(pt.getEmployeeId());
} }
} }
for (EmployeeRoles emp : allEmployees) { for (Employee emp : allEmployees) {
if (!teamMates.contains(emp.getEmployeeId())) { if (!teamMates.contains(emp.getEmployeeId())) {
notAssignedEmployees.add(emp); notAssignedEmployees.add(emp);
...@@ -912,7 +912,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -912,7 +912,7 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public List<EmployeeDashboardVO> getEmployeesDashBoard() { public List<EmployeeDashboardVO> getEmployeesDashBoard() {
List<EmployeeRoles> allEmployees = employeeRolesRepo.findAll(); List<Employee> allEmployees = employeeRolesRepo.findAll();
List<EmployeeDashboardVO> employeeDashboard = new ArrayList<>(); List<EmployeeDashboardVO> employeeDashboard = new ArrayList<>();
Map<String, Object> teamMatesMap = new HashMap(); Map<String, Object> teamMatesMap = new HashMap();
Map<String, Object> teamMatesStatusMap = new HashMap(); Map<String, Object> teamMatesStatusMap = new HashMap();
...@@ -944,7 +944,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -944,7 +944,7 @@ public class ProjectServiceImpl implements ProjectService {
} }
} }
} }
for (EmployeeRoles emp : allEmployees) { for (Employee emp : allEmployees) {
if (teamMatesMap.containsKey(emp.getEmployeeId())) { if (teamMatesMap.containsKey(emp.getEmployeeId())) {
Object value = teamMatesMap.get(emp.getEmployeeId()); Object value = teamMatesMap.get(emp.getEmployeeId());
if (value instanceof List) { if (value instanceof List) {
...@@ -986,9 +986,9 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -986,9 +986,9 @@ public class ProjectServiceImpl implements ProjectService {
List<HashMap<String, String>> EmployeeList = new ArrayList<>(); List<HashMap<String, String>> EmployeeList = new ArrayList<>();
Query query = new Query(Criteria.where("employeeId").in(ids)); Query query = new Query(Criteria.where("employeeId").in(ids));
List<EmployeeRoles> employeeRoles = mongoTemplate.find(query, List<Employee> employeeRoles = mongoTemplate.find(query,
EmployeeRoles.class); Employee.class);
for (EmployeeRoles employeesRole : employeeRoles) { for (Employee employeesRole : employeeRoles) {
HashMap<String, String> managerMap = new HashMap<>(); HashMap<String, String> managerMap = new HashMap<>();
managerMap.put("employeeId", employeesRole.getEmployeeId()); managerMap.put("employeeId", employeesRole.getEmployeeId());
managerMap.put("employeeName", employeesRole.getEmployeeName()); managerMap.put("employeeName", employeesRole.getEmployeeName());
...@@ -1063,7 +1063,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -1063,7 +1063,7 @@ public class ProjectServiceImpl implements ProjectService {
Project project= null; Project project= null;
Account account = null; Account account = null;
Domains domain = null; Domain domain = null;
List<ProjectTeamMate> projectAllocations = getMyProjectAllocations(empId); List<ProjectTeamMate> projectAllocations = getMyProjectAllocations(empId);
...@@ -1128,12 +1128,12 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -1128,12 +1128,12 @@ public class ProjectServiceImpl implements ProjectService {
public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTimeException { public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTimeException {
List<HashMap<Object, Object>> projectsList = new ArrayList<HashMap<Object, Object>> (); List<HashMap<Object, Object>> projectsList = new ArrayList<HashMap<Object, Object>> ();
Set<String> accIdsSet = projectService.accountsAssignedToDl(empId); Set<String> accIdsSet = domainService.accountsAssignedToDeliveryLead(empId);
List<Project> prjts= projectRepo.findByAccountIdIn(accIdsSet); List<Project> prjts= projectRepo.findByAccountIdIn(accIdsSet);
if(null != prjts && !prjts.isEmpty() && MyTimeUtils.INT_ZERO < prjts.size()) { if(null != prjts && !prjts.isEmpty() && MyTimeUtils.INT_ZERO < prjts.size()) {
Account account = null; Account account = null;
Domains domain =null; Domain domain =null;
HashMap<Object, Object> projectMap = null; HashMap<Object, Object> projectMap = null;
......
...@@ -10,10 +10,10 @@ import com.nisum.mytime.exception.handler.MyTimeException; ...@@ -10,10 +10,10 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account; import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.AccountInfo; import com.nisum.mytime.model.AccountInfo;
import com.nisum.mytime.model.Designation; import com.nisum.mytime.model.Designation;
import com.nisum.mytime.model.Domains; import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.EmpLoginData; import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeLocationDetails; import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Location; import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.MasterData; import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.model.Shift; import com.nisum.mytime.model.Shift;
...@@ -27,9 +27,9 @@ public interface UserService { ...@@ -27,9 +27,9 @@ public interface UserService {
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException; String toDate) throws MyTimeException;
List<EmployeeRoles> getEmployeeRoles() throws MyTimeException; List<Employee> getEmployeeRoles() throws MyTimeException;
EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles, String empId) Employee assigingEmployeeRole(Employee employeeRoles, String empId)
throws MyTimeException; throws MyTimeException;
List generatePdfReport(long id, String fromDate, String toDate) List generatePdfReport(long id, String fromDate, String toDate)
...@@ -38,18 +38,18 @@ public interface UserService { ...@@ -38,18 +38,18 @@ public interface UserService {
List generatePdfReport(long id, String fromDate, String toDate,String fromTime,String toTime) List generatePdfReport(long id, String fromDate, String toDate,String fromTime,String toTime)
throws MyTimeException, ParseException; throws MyTimeException, ParseException;
EmployeeRoles getEmployeesRole(String emailId); Employee getEmployeesRole(String emailId);
void deleteEmployee(String empId); void deleteEmployee(String empId);
EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles,String empId); Employee updateEmployeeRole(Employee employeeRoles,String empId);
void updateEmployeeLocationDetails(EmployeeRoles employeeRoles, void updateEmployeeLocationDetails(Employee employeeRoles,
boolean delete); boolean delete);
void saveEmployeeLocationDetails(EmployeeRoles employeeRoles); void saveEmployeeLocationDetails(Employee employeeRoles);
EmployeeRoles getEmployeesRoleData(String empId); Employee getEmployeesRoleData(String empId);
List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId); List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId);
...@@ -59,29 +59,29 @@ public interface UserService { ...@@ -59,29 +59,29 @@ public interface UserService {
List<Skill> getTechnologies() throws MyTimeException; List<Skill> getTechnologies() throws MyTimeException;
public EmployeeRoles updateProfile(EmployeeRoles employeeRoles) public Employee updateProfile(Employee employeeRoles)
throws MyTimeException; throws MyTimeException;
public List<Account> getAccounts() throws MyTimeException; public List<Account> getAccounts() throws MyTimeException;
List<Location> getLocations() throws MyTimeException; List<Location> getLocations() throws MyTimeException;
EmployeeRoles getEmployeeRoleDataForSearchCriteria(String searchId, Employee getEmployeeRoleDataForSearchCriteria(String searchId,
String searchAttribute); String searchAttribute);
List<String> getEmployeeDetailsForAutocomplete(); List<String> getEmployeeDetailsForAutocomplete();
List<MasterData> getMasterData() throws MyTimeException; List<MasterData> getMasterData() throws MyTimeException;
List<EmployeeRoles> getEmployeesByFunctionalGrp(String functionalGrp); List<Employee> getEmployeesByFunctionalGrp(String functionalGrp);
List<EmployeeRoles> getEmployeesByStatus(String status); List<Employee> getEmployeesByStatus(String status);
List<HashMap<String, String>> getDeliveryLeads(String domainId); List<HashMap<String, String>> getDeliveryLeads(String domainId);
public List<AccountInfo> getAccountsInfo() throws MyTimeException; public List<AccountInfo> getAccountsInfo() throws MyTimeException;
public List<Domains> getDomains(String accountId)throws MyTimeException; public List<Domain> getDomains(String accountId)throws MyTimeException;
public boolean verifyRole(String empId, String roleName); public boolean verifyRole(String empId, String roleName);
......
...@@ -19,6 +19,17 @@ public class CommomUtil { ...@@ -19,6 +19,17 @@ public class CommomUtil {
return addedManagers; return addedManagers;
} }
public static List<String> getAddedManagersListForDM(List<Object> fromDb, List<Object> fromUser) {
List<String> addedManagers = new ArrayList<String>();
if (fromDb != null)
for (Object managerFromUser : fromUser) {
if (!fromDb.contains(managerFromUser.toString()))
addedManagers.add(managerFromUser.toString());
}
return addedManagers;
}
public static List<String> getDeletedManagersList(List<String> fromDb, List<String> fromUser) { public static List<String> getDeletedManagersList(List<String> fromDb, List<String> fromUser) {
List<String> deletedManager = new ArrayList<String>(); List<String> deletedManager = new ArrayList<String>();
if (fromDb != null) if (fromDb != null)
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
function renderButton() { function renderButton() {
gapi.load('auth2', function () { gapi.load('auth2', function () {
gapi.auth2.init({ gapi.auth2.init({
client_id: "685521475239-ujm7l2hkgrltk7loi8efl0ed702asm2r.apps.googleusercontent.com", //client_id: "685521475239-ujm7l2hkgrltk7loi8efl0ed702asm2r.apps.googleusercontent.com",
client_id: "10230597574-gv1bg8nehm0a63n9hh5mu9um563uqaq1.apps.googleusercontent.com",
hosted_domain: 'nisum.com' hosted_domain: 'nisum.com'
}); });
}); });
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
} }
</script> </script>
<script src="https://apis.google.com/js/platform.js?onload=renderButton"></script> <script src="https://apis.google.com/js/platform.js?onload=renderButton"></script>
<meta name="google-signin-client_id" content="685521475239-ujm7l2hkgrltk7loi8efl0ed702asm2r.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="10230597574-gv1bg8nehm0a63n9hh5mu9um563uqaq1.apps.googleusercontent.com">
<link rel="stylesheet" href="css/login.css" /> <link rel="stylesheet" href="css/login.css" />
</head> </head>
<div class="myteam-login" ng-controller="loginController" id="popupContainer"> <div class="myteam-login" ng-controller="loginController" id="popupContainer">
......
...@@ -25,15 +25,15 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; ...@@ -25,15 +25,15 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.nisum.mytime.controller.DomainController; import com.nisum.mytime.controller.DomainController;
import com.nisum.mytime.model.Domains; import com.nisum.mytime.model.Domain;
import com.nisum.mytime.service.DomainService; import com.nisum.mytime.service.IDomainService;
public class DomainControllerTest { public class DomainControllerTest {
@Mock @Mock
DomainService domainService; IDomainService domainService;
@InjectMocks @InjectMocks
DomainController domainController; DomainController domainController;
...@@ -52,11 +52,12 @@ public class DomainControllerTest { ...@@ -52,11 +52,12 @@ public class DomainControllerTest {
list.add("16620"); list.add("16620");
list.add("16632"); list.add("16632");
String responce=null; String responce=null;
Domains domains = new Domains( Domain domainPeristed=null;
new ObjectId("9976ef15874c902c98b8a05d"), "DOM002", "Marketing", "Acc002", Domain domains = new Domain(
"DOM002", "Marketing", "Acc002",
"Active",list); "Active",list);
when(domainService.addDomains(domains)) when(domainService.create(domains))
.thenReturn(responce); .thenReturn(domainPeristed);
String jsonvalue = (new ObjectMapper()) String jsonvalue = (new ObjectMapper())
.writeValueAsString(domains).toString(); .writeValueAsString(domains).toString();
mockMvc.perform(post("/domains") mockMvc.perform(post("/domains")
...@@ -67,12 +68,13 @@ public class DomainControllerTest { ...@@ -67,12 +68,13 @@ public class DomainControllerTest {
@Test @Test
public void testgetDomains() throws Exception { public void testgetDomains() throws Exception {
List<HashMap<Object,Object>> domains = CreateDomainDetails(); //List<HashMap<Object,Object>> domains = CreateDomainDetails();
when(domainService.getAllDomains()).thenReturn(domains); List domains = CreateDomainDetails();
when(domainService.getDomainsList()).thenReturn(domains);
mockMvc.perform(get("/domains") mockMvc.perform(get("/domains")
.contentType(MediaType.APPLICATION_JSON_VALUE)) .contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()); .andExpect(MockMvcResultMatchers.status().isOk());
verify(domainService).getAllDomains(); verify(domainService).getDomainsList();
} }
@Test @Test
...@@ -82,16 +84,16 @@ public class DomainControllerTest { ...@@ -82,16 +84,16 @@ public class DomainControllerTest {
employeeIds.add("16650"); employeeIds.add("16650");
employeeIds.add("16651"); employeeIds.add("16651");
String responce=null; String responce=null;
Domains Domain = new Domains(new ObjectId("9976ef15874c902c98b8a05d"), "DOM002", "Marketing", "Acc002", Domain domain = new Domain( "DOM002", "Marketing", "Acc002",
"Active",employeeIds); "Active",employeeIds);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(Domain); String jsonString = mapper.writeValueAsString(domain);
when(domainService.updateDomain(any())).thenReturn(responce); when(domainService.update(any())).thenReturn(domain);
mockMvc.perform(put("/domains") mockMvc.perform(put("/domains")
.contentType(MediaType.APPLICATION_JSON_VALUE) .contentType(MediaType.APPLICATION_JSON_VALUE)
.content(jsonString)) .content(jsonString))
.andExpect(MockMvcResultMatchers.status().isOk()); .andExpect(MockMvcResultMatchers.status().isOk());
verify(domainService).updateDomain(any()); verify(domainService).update(any());
} }
@Test @Test
...@@ -99,7 +101,7 @@ public class DomainControllerTest { ...@@ -99,7 +101,7 @@ public class DomainControllerTest {
mockMvc.perform( mockMvc.perform(
delete("/domains").param("domainId", "DOM001")) delete("/domains").param("domainId", "DOM001"))
.andExpect(MockMvcResultMatchers.status().isOk()); .andExpect(MockMvcResultMatchers.status().isOk());
verify(domainService).deleteDomain("DOM001"); verify(domainService).delete("DOM001");
} }
...@@ -108,8 +110,8 @@ public class DomainControllerTest { ...@@ -108,8 +110,8 @@ public class DomainControllerTest {
HashMap<Object,Object> map1 = new HashMap<Object,Object>(); HashMap<Object,Object> map1 = new HashMap<Object,Object>();
HashMap<Object,Object> map2 = new HashMap<Object,Object>(); HashMap<Object,Object> map2 = new HashMap<Object,Object>();
Domains data1 = new Domains(); Domain data1 = new Domain();
data1.setId(new ObjectId("5976ef15874c902c98b8a05d")); //data1.setId(new ObjectId("5976ef15874c902c98b8a05d"));
data1.setDomainId("DOM003"); data1.setDomainId("DOM003");
data1.setDomainName("MOC"); data1.setDomainName("MOC");
data1.setAccountId("ACC001"); data1.setAccountId("ACC001");
...@@ -123,8 +125,8 @@ public class DomainControllerTest { ...@@ -123,8 +125,8 @@ public class DomainControllerTest {
map1.put(new ObjectId("5976ef15874c902c98b8a05d"), data1); map1.put(new ObjectId("5976ef15874c902c98b8a05d"), data1);
Domains data2 = new Domains(); Domain data2 = new Domain();
data2.setId(new ObjectId("9976ef15874c902c98b8a05d")); //data2.setId(new ObjectId("9976ef15874c902c98b8a05d"));
data2.setDomainId("DOM004"); data2.setDomainId("DOM004");
data2.setDomainName("BIGTICKET"); data2.setDomainName("BIGTICKET");
data2.setAccountId("ACC001"); data2.setAccountId("ACC001");
......
...@@ -32,9 +32,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -32,9 +32,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.nisum.mytime.controller.UserController; import com.nisum.mytime.controller.UserController;
import com.nisum.mytime.model.Account; import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Designation; import com.nisum.mytime.model.Designation;
import com.nisum.mytime.model.Domains; import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.EmployeeLocationDetails; import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Location; import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.MasterData; import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.model.Shift; import com.nisum.mytime.model.Shift;
...@@ -63,7 +63,7 @@ public class UserControllerTest { ...@@ -63,7 +63,7 @@ public class UserControllerTest {
@Test @Test
public void testgetEmployeeRoleAsAdmin() throws Exception { public void testgetEmployeeRoleAsAdmin() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5b307d7e708ef705c4ca64d8", "16694", "Mahesh Deekonda", Employee employeesRole = new Employee("5b307d7e708ef705c4ca64d8", "16694", "Mahesh Deekonda",
"mdeekonda@nisum.com", "Admin", "Senior software engineer", null, null, "Support", "Hyderabad", null, "mdeekonda@nisum.com", "Admin", "Senior software engineer", null, null, "Support", "Hyderabad", null,
null, null, null, "ACI - Support", "Active", null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23), null, null, null, "ACI - Support", "Active", null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23),
"Male", null, new Date(2020 - 01 - 01), null, new Date(2018 - 01 - 01), new Date(2018 - 02 - 15), "Male", null, new Date(2020 - 01 - 01), null, new Date(2018 - 01 - 01), new Date(2018 - 02 - 15),
...@@ -77,7 +77,7 @@ public class UserControllerTest { ...@@ -77,7 +77,7 @@ public class UserControllerTest {
@Test @Test
public void testgetEmployeeRoleAsEmp() throws Exception { public void testgetEmployeeRoleAsEmp() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5b307d7e708ef705c4ca64d8", "16694", "Mahesh Deekonda", Employee employeesRole = new Employee("5b307d7e708ef705c4ca64d8", "16694", "Mahesh Deekonda",
"mdeekonda@nisum.com", "Employee", "Senior software engineer", null, null, "Support", "Hyderabad", null, "mdeekonda@nisum.com", "Employee", "Senior software engineer", null, null, "Support", "Hyderabad", null,
null, null, null, "ACI - Support", "Active", null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23), null, null, null, "ACI - Support", "Active", null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23),
"Male", null, new Date(2020 - 01 - 01), null, new Date(2018 - 01 - 01), new Date(2018 - 02 - 15), "Male", null, new Date(2020 - 01 - 01), null, new Date(2018 - 01 - 01), new Date(2018 - 02 - 15),
...@@ -92,7 +92,7 @@ public class UserControllerTest { ...@@ -92,7 +92,7 @@ public class UserControllerTest {
@Test @Test
public void testassigingEmployeeRole() throws Exception { public void testassigingEmployeeRole() throws Exception {
EmployeeRoles employeeRole = new EmployeeRoles("5976ef15874c902c98b8a05d", null, null, null, null, null, null, Employee employeeRole = new Employee("5976ef15874c902c98b8a05d", null, null, null, null, null, null,
null, null, null, null, null, null, "user@nisum.com", null, null, null, new Date(2017 - 11 - 20), null, null, null, null, null, null, "user@nisum.com", null, null, null, new Date(2017 - 11 - 20),
new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01),
new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh"); new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh");
...@@ -107,7 +107,7 @@ public class UserControllerTest { ...@@ -107,7 +107,7 @@ public class UserControllerTest {
@Test @Test
public void testupdateEmployeeRole() throws Exception { public void testupdateEmployeeRole() throws Exception {
EmployeeRoles employeeRole2 = new EmployeeRoles("5976ef15874c902c98b8a05d", null, null, null, null, null, null, Employee employeeRole2 = new Employee("5976ef15874c902c98b8a05d", null, null, null, null, null, null,
null, null, null, null, null, null, "user@nisum.com", null, null, null, new Date(2017 - 11 - 20), null, null, null, null, null, null, "user@nisum.com", null, null, null, new Date(2017 - 11 - 20),
new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01),
new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh"); new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh");
...@@ -129,7 +129,7 @@ public class UserControllerTest { ...@@ -129,7 +129,7 @@ public class UserControllerTest {
@Test @Test
public void testgetUserRoles() throws Exception { public void testgetUserRoles() throws Exception {
List<EmployeeRoles> employeesRole3 = CreateUserRoles(); List<Employee> employeesRole3 = CreateUserRoles();
when(userService.getEmployeeRoles()).thenReturn(employeesRole3); when(userService.getEmployeeRoles()).thenReturn(employeesRole3);
mockMvc.perform(get("/user/getUserRoles").contentType(MediaType.APPLICATION_JSON_VALUE)) mockMvc.perform(get("/user/getUserRoles").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()); .andExpect(MockMvcResultMatchers.status().isOk());
...@@ -138,7 +138,7 @@ public class UserControllerTest { ...@@ -138,7 +138,7 @@ public class UserControllerTest {
@Test @Test
public void testgetEmployeeRoleData() throws Exception { public void testgetEmployeeRoleData() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5b307d7e708ef705c4ca64d8", "16694", "Mahesh Deekonda", Employee employeesRole = new Employee("5b307d7e708ef705c4ca64d8", "16694", "Mahesh Deekonda",
"mdeekonda@nisum.com", "Admin", "Senior software engineer", null, null, "Support", "Hyderabad", null, "mdeekonda@nisum.com", "Admin", "Senior software engineer", null, null, "Support", "Hyderabad", null,
null, null, null, "ACI - Support", "Active", null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23), null, null, null, "ACI - Support", "Active", null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23),
"Male", null, new Date(2020 - 01 - 01), null, new Date(2018 - 01 - 01), new Date(2018 - 02 - 15), "Male", null, new Date(2020 - 01 - 01), null, new Date(2018 - 01 - 01), new Date(2018 - 02 - 15),
...@@ -168,7 +168,7 @@ public class UserControllerTest { ...@@ -168,7 +168,7 @@ public class UserControllerTest {
@Test @Test
public void testgetEmployeeRoleDataForEmailIdSearch() throws Exception { public void testgetEmployeeRoleDataForEmailIdSearch() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5b307d7d708ef705c4ca5c90", "16209", "Mahesh Kumar Gutam", Employee employeesRole = new Employee("5b307d7d708ef705c4ca5c90", "16209", "Mahesh Kumar Gutam",
"dummy@nisum.com", "Employee", "Software Engineer", null, null, "Sell", "Hyderabad", null, null, null, "dummy@nisum.com", "Employee", "Software Engineer", null, null, "Sell", "Hyderabad", null, null, null,
null, "APPS", "Active", "Full Time", new Date(2017 - 11 - 20), new Date(2107 - 12 - 23), "Male", null, null, "APPS", "Active", "Full Time", new Date(2017 - 11 - 20), new Date(2107 - 12 - 23), "Male", null,
null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2018 - 02 - 15), null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2018 - 02 - 15),
...@@ -183,7 +183,7 @@ public class UserControllerTest { ...@@ -183,7 +183,7 @@ public class UserControllerTest {
@Test @Test
public void testgetEmployeeRoleDataForEmployeeNameSearch() throws Exception { public void testgetEmployeeRoleDataForEmployeeNameSearch() throws Exception {
EmployeeRoles employeesRole = new EmployeeRoles("5b307d7d708ef705c4ca5c90", "16209", "Mahesh Kumar Gutam", Employee employeesRole = new Employee("5b307d7d708ef705c4ca5c90", "16209", "Mahesh Kumar Gutam",
"dummy@nisum.com", "Employee", "Software Engineer", null, null, "Sell", "Hyderabad", null, null, null, "dummy@nisum.com", "Employee", "Software Engineer", null, null, "Sell", "Hyderabad", null, null, null,
null, "APPS", "Active", "Full Time", new Date(2017 - 11 - 20), new Date(2107 - 12 - 23), "Male", null, null, "APPS", "Active", "Full Time", new Date(2017 - 11 - 20), new Date(2107 - 12 - 23), "Male", null,
null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2018 - 02 - 15), null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2018 - 02 - 15),
...@@ -224,7 +224,7 @@ public class UserControllerTest { ...@@ -224,7 +224,7 @@ public class UserControllerTest {
@Test @Test
public void testgetManagers() throws Exception { public void testgetManagers() throws Exception {
List<EmployeeRoles> employeesRole4 = CreateUserRoles(); List<Employee> employeesRole4 = CreateUserRoles();
System.out.println(employeesRole4); System.out.println(employeesRole4);
when(userService.getEmployeeRoles()).thenReturn(employeesRole4); when(userService.getEmployeeRoles()).thenReturn(employeesRole4);
mockMvc.perform(get("/user/getManagers")).andExpect(MockMvcResultMatchers.status().isOk()); mockMvc.perform(get("/user/getManagers")).andExpect(MockMvcResultMatchers.status().isOk());
...@@ -265,7 +265,7 @@ public class UserControllerTest { ...@@ -265,7 +265,7 @@ public class UserControllerTest {
@Test @Test
public void testupdateProfile() throws Exception { public void testupdateProfile() throws Exception {
EmployeeRoles employeeRole = new EmployeeRoles("5976ef15874c902c98b8a05d", null, null, null, null, null, null, Employee employeeRole = new Employee("5976ef15874c902c98b8a05d", null, null, null, null, null, null,
null, null, null, null, null, null, "user@nisum.com", null, null, null, new Date(2017 - 11 - 20), null, null, null, null, null, null, "user@nisum.com", null, null, null, new Date(2017 - 11 - 20),
new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01),
new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh"); new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh");
...@@ -298,7 +298,7 @@ public class UserControllerTest { ...@@ -298,7 +298,7 @@ public class UserControllerTest {
@Test @Test
public void testGetEmployeeByStatus() throws Exception { public void testGetEmployeeByStatus() throws Exception {
List<EmployeeRoles> empRolesList = employeeRoles(); List<Employee> empRolesList = employeeRoles();
when(userService.getEmployeesByStatus("Active")).thenReturn(empRolesList); when(userService.getEmployeesByStatus("Active")).thenReturn(empRolesList);
mockMvc.perform(get("/user/getEmployeeByStatus").param("status", "Active")) mockMvc.perform(get("/user/getEmployeeByStatus").param("status", "Active"))
.andExpect(MockMvcResultMatchers.status().isOk()); .andExpect(MockMvcResultMatchers.status().isOk());
...@@ -418,10 +418,10 @@ public class UserControllerTest { ...@@ -418,10 +418,10 @@ public class UserControllerTest {
return data; return data;
} }
private List<EmployeeRoles> CreateUserRoles() { private List<Employee> CreateUserRoles() {
List<EmployeeRoles> data = new ArrayList<>(); List<Employee> data = new ArrayList<>();
EmployeeRoles data1 = new EmployeeRoles(); Employee data1 = new Employee();
data1.setId("3976ef15874c902c98b8a05d"); data1.setId("3976ef15874c902c98b8a05d");
data1.setEmployeeId("16101"); data1.setEmployeeId("16101");
data1.setEmployeeName("Abc"); data1.setEmployeeName("Abc");
...@@ -437,7 +437,7 @@ public class UserControllerTest { ...@@ -437,7 +437,7 @@ public class UserControllerTest {
data1.setCreatedOn(new Date(2017 - 11 - 21)); data1.setCreatedOn(new Date(2017 - 11 - 21));
data1.setLastModifiedOn(new Date(2017 - 12 - 22)); data1.setLastModifiedOn(new Date(2017 - 12 - 22));
EmployeeRoles data2 = new EmployeeRoles(); Employee data2 = new Employee();
data2.setId("4976ef15874c902c98b8a05d"); data2.setId("4976ef15874c902c98b8a05d");
data2.setEmployeeId("16102"); data2.setEmployeeId("16102");
data2.setEmployeeName("Xyz"); data2.setEmployeeName("Xyz");
...@@ -483,14 +483,14 @@ public class UserControllerTest { ...@@ -483,14 +483,14 @@ public class UserControllerTest {
return masterDataList; return masterDataList;
} }
private List<EmployeeRoles> employeeRoles() { private List<Employee> employeeRoles() {
List<EmployeeRoles> employeeRoles = new ArrayList<EmployeeRoles>(); List<Employee> employeeRoles = new ArrayList<Employee>();
EmployeeRoles employeesRole1 = new EmployeeRoles("5b307d7d708ef705c4ca5c90", null, null, null, null, null, null, Employee employeesRole1 = new Employee("5b307d7d708ef705c4ca5c90", null, null, null, null, null, null,
null, null, null, null, null, null, "dummy@nisum.com", null, null, null, new Date(2017 - 11 - 20), null, null, null, null, null, null, "dummy@nisum.com", null, null, null, new Date(2017 - 11 - 20),
new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01),
new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh"); new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh");
EmployeeRoles employeesRole2 = new EmployeeRoles("5976ef15874c902c98b8a05d", null, null, null, null, null, null, Employee employeesRole2 = new Employee("5976ef15874c902c98b8a05d", null, null, null, null, null, null,
null, null, null, null, null, null, "user@nisum.com", null, null, null, new Date(2017 - 11 - 20), null, null, null, null, null, null, "user@nisum.com", null, null, null, new Date(2017 - 11 - 20),
new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2107 - 12 - 23), null, null, null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01),
new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh"); new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh");
...@@ -511,7 +511,7 @@ public class UserControllerTest { ...@@ -511,7 +511,7 @@ public class UserControllerTest {
return empLocation; return empLocation;
} }
private List<Domains> domains() { private List<Domain> domains() {
List<String> dl1 = new ArrayList<String>(); List<String> dl1 = new ArrayList<String>();
dl1.add("16120"); dl1.add("16120");
dl1.add("16121"); dl1.add("16121");
...@@ -520,11 +520,11 @@ public class UserControllerTest { ...@@ -520,11 +520,11 @@ public class UserControllerTest {
dl2.add("16122"); dl2.add("16122");
dl2.add("16123"); dl2.add("16123");
List<Domains> domains = new ArrayList<Domains>(); List<Domain> domains = new ArrayList<Domain>();
Domains d1 = new Domains(new ObjectId("5b61be677c43a53a634f77b1"), "DOM001", "Customer", "Acc001", "Active", Domain d1 = new Domain( "DOM001", "Customer", "Acc001", "Active",
dl1); dl1);
Domains d2 = new Domains(new ObjectId("5b76b7f5094e433005abbede"), "DOM005", "rajesh", "Acc001", "Active", dl2); Domain d2 = new Domain( "DOM005", "rajesh", "Acc001", "Active", dl2);
domains.add(d1); domains.add(d1);
domains.add(d2); domains.add(d2);
......
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