Commit deb28aca authored by Vijay Akula's avatar Vijay Akula

Refactored the code related to UserController,UserService and UserRepo.

parent 65c9aaa9
......@@ -18,18 +18,18 @@ import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.AttendenceData;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.service.AttendanceService;
import com.nisum.mytime.service.UserService;
import com.nisum.mytime.service.IAttendanceService;
import com.nisum.mytime.service.IEmployeeService;
@RestController
@RequestMapping("/attendance")
public class AttendanceController {
@Autowired
private UserService userService;
private IEmployeeService userService;
@Autowired
private AttendanceService attendanceService;
private IAttendanceService attendanceService;
@RequestMapping(value = "employeeLoginsBasedOnDate",
method = RequestMethod.GET,
......
package com.nisum.mytime.controller;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Designation;
import com.nisum.mytime.service.impl.DesignationService;
@RestController
public class DesignationController {
@Autowired
DesignationService designationService;
// @RequestMapping(value = "/getAllDesignations", method =
// RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/designations/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllDesignations() throws MyTimeException {
List<String> designations = designationService.getAllDesignations().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Designation::getDesignationName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(designations, HttpStatus.OK);
}
}
......@@ -11,13 +11,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.model.EmailDomain;
import com.nisum.mytime.service.MailService;
import com.nisum.mytime.service.IMailService;
@RestController
public class EmailController {
@Autowired
private MailService mailService;
private IMailService mailService;
@RequestMapping(value = "/sendEmail", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> sendAttachmentMail(@RequestBody EmailDomain emailObj) {
......
package com.nisum.mytime.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.AccountInfo;
import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.service.IEmployeeService;
import com.nisum.mytime.service.IRoleMappingService;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class EmployeeController {
@Autowired
private IEmployeeService empService;
@Autowired
private IRoleMappingService roleMappingService;
private static final Logger logger = LoggerFactory.getLogger(EmployeeController.class);
@RequestMapping(value = "/employees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployee(@RequestParam("emailId") String emailId) throws MyTimeException {
Employee employee = empService.getEmployeeByEmaillId(emailId);
if (employee != null) {
if (employee.getRole() != null && employee.getRole().equalsIgnoreCase("Admin")) {
employee.setRole("Admin");
} else {
String roleName = roleMappingService.getEmployeeRole(employee.getEmployeeId());
if (roleName != null) {
employee.setRole(roleName);
}
}
}
System.out.println("emailId" + emailId + "result" + employee);
return new ResponseEntity<>(employee, HttpStatus.OK);
}
@RequestMapping(value = "/employees/{empId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> createEmployee(@RequestBody Employee employeeReq,
@PathVariable(value = "empId") String loginEmpId) throws MyTimeException {
Employee employeePersisted = empService.createEmployee(employeeReq, loginEmpId);
return new ResponseEntity<>(employeePersisted, HttpStatus.OK);
}
@RequestMapping(value = "/employees/{empId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> updateEmployee(@RequestBody Employee employeeRoles,
@PathVariable(value = "empId") String loginEmpId) throws MyTimeException {
Employee employeeRole = empService.updateEmployeeRole(employeeRoles, loginEmpId);
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/employees/{empId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteEmployee(@PathVariable("empId") String empId) throws MyTimeException {
empService.deleteEmployee(empId);
return new ResponseEntity<>("Success", HttpStatus.OK);
}
//@RequestMapping(value = "/getUserRoles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getUserRoles() throws MyTimeException {
List<Employee> employeesRoles = empService.getActiveEmployees();
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
//@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/{empId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRoleData(@PathVariable("empId") String empId) throws MyTimeException {
Employee employeesRole = empService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
/*
@RequestMapping(value = "/getEmployeeLocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeLocationDetails>> getEmployeeLocations(@RequestParam("employeeId") String empId)
throws MyTimeException {
List<EmployeeLocationDetails> employeeLocationDetails = empService.getEmployeeLocationDetails(empId);
return new ResponseEntity<>(employeeLocationDetails, HttpStatus.OK);
}
*/
// @RequestMapping(value = "/getManagers"
@RequestMapping(value = "/employees/managers/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getManagers() throws MyTimeException {
List<Employee> managersList = empService.getManagers();
return new ResponseEntity<>(managersList, HttpStatus.OK);
}
/*
// @RequestMapping(value = "/getAllShifts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/shifts/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllShifts() throws MyTimeException {
List<String> shifts = empService.getAllShifts().stream().filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Shift::getShiftName).sorted().collect(Collectors.toList());
return new ResponseEntity<>(shifts, HttpStatus.OK);
}
*/
/*
// @RequestMapping(value = "/getAllDesignations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/designations/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllDesignations() throws MyTimeException {
List<String> designations = empService.getAllDesignations().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Designation::getDesignationName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(designations, HttpStatus.OK);
}
*/
/*
// @RequestMapping(value = "/getSkills", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/skills/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getTechnologies() throws MyTimeException {
List<String> technologies = empService.getTechnologies().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Skill::getSkillName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
}
*/
/*
//@RequestMapping(value = "/getLocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/locations/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getLocations() throws MyTimeException {
System.out.println(" userService.getLocations()" + empService.getLocations());
List<String> locations = empService.getLocations().stream().filter(e -> (e.isActiveStatus() == true))
.map(Location::getLocation).sorted().collect(Collectors.toList());
logger.info("getLocations " + locations);
return new ResponseEntity<>(locations, HttpStatus.OK);
}
*/
@RequestMapping(value = "/updateProfile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> updateProfile(@RequestBody Employee employeeRoles) throws MyTimeException {
Employee employeeRole = empService.updateProfile(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
//@RequestMapping(value = "/getAccounts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employee/accounts/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Account>> getAccounts() throws MyTimeException {
List<Account> technologies = empService.getAccounts().stream().filter(e -> "Y".equalsIgnoreCase(e.getStatus()))
// .filter(a -> !("Nisum
// India".equalsIgnoreCase(a.getAccountName())))
// .map(Account::getAccountName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeRoleDataForSearchCriteria", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRoleDataForSearchCriteria(@RequestParam("searchId") String searchId,
@RequestParam("searchAttribute") String searchAttribute) throws MyTimeException {
Employee employeesRole = empService.getEmployeeRoleDataForSearchCriteria(searchId, searchAttribute);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeDetailsForAutocomplete", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getEmployeeDetailsForAutocomplete() throws MyTimeException {
List<String> details = empService.getEmployeeDetailsForAutocomplete();
return new ResponseEntity<>(details, HttpStatus.OK);
}
/*@RequestMapping(value = "/getMasterData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, List<String>>> getMasterData() throws MyTimeException {
Map<String, List<String>> masterDataMap = new HashMap<>();
Map<String, List<MasterData>> result = empService.getMasterData().stream()
.filter(e -> (e.isActiveStatus() == true))
.collect(Collectors.groupingBy(MasterData::getMasterDataType));
for (String key : result.keySet()) {
List<MasterData> valueList = result.get(key);
List<String> technologies = valueList.stream().map(MasterData::getMasterDataName).sorted()
.collect(Collectors.toList());
masterDataMap.put(key, technologies);
}
return new ResponseEntity<>(masterDataMap, HttpStatus.OK);
}
*/
//@RequestMapping(value = "/getEmployeeByStatus", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/status/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getEmployeeByStatus(@RequestParam("status") String status) {
List<Employee> employeesRoles = empService.getEmployeesByStatus(status);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
//@RequestMapping(value = "/getDeliveryLeads", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/deliveryLeads/{domainId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<HashMap<String, String>>> getDeliveryLeads(@PathVariable("domainId") String domainId)
throws MyTimeException {
List<HashMap<String, String>> managers = empService.getDeliveryLeads(domainId);
return new ResponseEntity<>(managers, HttpStatus.OK);
}
@RequestMapping(value = "/getAccountsInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<AccountInfo>> getAccountsInfo() throws MyTimeException {
List<AccountInfo> technologies = empService.getAccountsInfo().stream()
.filter(e -> "Active".equalsIgnoreCase(e.getStatus())).collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
}
@RequestMapping(value = "/getDomains", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Domain>> getDomains(@RequestParam("accountId") String accountId) throws MyTimeException {
List<Domain> domains = empService.getDomains(accountId).stream()
.filter(e -> "Active".equalsIgnoreCase(e.getStatus())).collect(Collectors.toList());
return new ResponseEntity<>(domains, HttpStatus.OK);
}
@RequestMapping(value = "/fileUpload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> exportDataFromFile(@RequestParam(value = "file") MultipartFile file,
@RequestParam(value = "empId") String loginEmpId) throws MyTimeException {
log.info("Uploaded file: {} with size: {}", file.getOriginalFilename(), file.getSize());
String result = empService.importDataFromExcelFile(file, loginEmpId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
\ No newline at end of file
package com.nisum.mytime.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.service.impl.EmployeeLocationService;
@RestController
public class EmployeeLocationController {
@Autowired
EmployeeLocationService empLocationService;
@RequestMapping(value = "/getEmployeeLocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeLocationDetails>> getEmployeeLocations(@RequestParam("employeeId") String empId)
throws MyTimeException {
List<EmployeeLocationDetails> employeeLocationDetails = empLocationService.getEmployeeLocationDetails(empId);
return new ResponseEntity<>(employeeLocationDetails, HttpStatus.OK);
}
}
package com.nisum.mytime.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.service.impl.MasterDataService;
@RestController
public class MasterDataController {
@Autowired
MasterDataService masterDataService;
@RequestMapping(value = "/getMasterData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, List<String>>> getMasterData() throws MyTimeException {
Map<String, List<String>> masterDataMap = new HashMap<>();
Map<String, List<MasterData>> result = masterDataService.getMasterData().stream()
.filter(e -> (e.isActiveStatus() == true))
.collect(Collectors.groupingBy(MasterData::getMasterDataType));
for (String key : result.keySet()) {
List<MasterData> valueList = result.get(key);
List<String> technologies = valueList.stream().map(MasterData::getMasterDataName).sorted()
.collect(Collectors.toList());
masterDataMap.put(key, technologies);
}
return new ResponseEntity<>(masterDataMap, HttpStatus.OK);
}
}
package com.nisum.mytime.controller;
import java.util.List;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.service.impl.OrgLocationService;
@RestController
public class OrgLocationController {
@Autowired
OrgLocationService orgLocationService;
private static final Logger logger = LoggerFactory.getLogger(OrgLocationController.class);
// @RequestMapping(value = "/getLocations", method = RequestMethod.GET,
// produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/locations/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getLocations() throws MyTimeException {
// System.out.println(" userService.getLocations()" +
// orgLocationService.getLocations());
List<String> locations = orgLocationService.getLocations().stream().filter(e -> (e.isActiveStatus() == true))
.map(Location::getLocation).sorted().collect(Collectors.toList());
logger.info("getLocations " + locations);
return new ResponseEntity<>(locations, HttpStatus.OK);
}
}
......@@ -19,8 +19,8 @@ import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.repository.ProjectRepo;
import com.nisum.mytime.service.ProjectService;
import com.nisum.mytime.service.UserService;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IEmployeeService;
import com.nisum.mytime.utils.MyTimeUtils;
@RestController
......@@ -28,10 +28,10 @@ import com.nisum.mytime.utils.MyTimeUtils;
public class ProjectController {
@Autowired
private UserService userService;
private IEmployeeService userService;
@Autowired
private ProjectService projectService;
private IProjectService projectService;
@Autowired
private AccountRepo accountRepo;
......@@ -42,7 +42,7 @@ public class ProjectController {
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRole(@RequestParam("emailId") String emailId)
throws MyTimeException {
Employee employeesRole = userService.getEmployeesRole(emailId);
Employee employeesRole = userService.getEmployeeByEmaillId(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
......
......@@ -23,8 +23,8 @@ import com.nisum.mytime.model.EmployeeVisa;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.service.ProjectService;
import com.nisum.mytime.service.UserService;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IEmployeeService;
import com.nisum.mytime.utils.MyTimeUtils;
@RestController
......@@ -32,10 +32,10 @@ import com.nisum.mytime.utils.MyTimeUtils;
public class ProjectTeamController {
@Autowired
private UserService userService;
private IEmployeeService userService;
@Autowired
private ProjectService projectService;
private IProjectService projectService;
@Autowired
private EmployeeVisaRepo employeeVisaRepo;
......@@ -44,7 +44,7 @@ public class ProjectTeamController {
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRole(
@RequestParam("emailId") String emailId) throws MyTimeException {
Employee employeesRole = userService.getEmployeesRole(emailId);
Employee employeesRole = userService.getEmployeeByEmaillId(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
......@@ -98,8 +98,8 @@ public class ProjectTeamController {
public ResponseEntity<List<Employee>> getManagers()
throws MyTimeException {
List<Employee> employeesRoles = new ArrayList<>();
if (userService.getEmployeeRoles() != null) {
employeesRoles = userService.getEmployeeRoles().stream()
if (userService.getActiveEmployees() != null) {
employeesRoles = userService.getActiveEmployees().stream()
.sorted((o1, o2) -> o1.getEmployeeName()
.compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
......@@ -301,7 +301,7 @@ public class ProjectTeamController {
.collect(Collectors.toList());
}
if (employeeIds != null && !employeeIds.isEmpty()) {
List<Employee> emps = userService.getEmployeeRoles();
List<Employee> emps = userService.getActiveEmployees();
for (Employee emp : emps) {
if (employeeIds.contains(emp.getEmployeeId())) {
employees.add(emp);
......@@ -311,8 +311,8 @@ public class ProjectTeamController {
return new ResponseEntity<>(employees, HttpStatus.OK);
} else {
//List<EmployeeRoles> employees = new ArrayList<>();
if (userService.getEmployeeRoles() != null) {
employees = userService.getEmployeeRoles().stream()
if (userService.getActiveEmployees() != null) {
employees = userService.getActiveEmployees().stream()
.sorted((o1, o2) -> o1.getEmployeeName()
.compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
......
......@@ -41,18 +41,18 @@ import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.model.ReportSeriesRecord;
import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.repository.TeamMatesBillingRepo;
import com.nisum.mytime.service.ProjectService;
import com.nisum.mytime.service.UserService;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IEmployeeService;
@RestController
@RequestMapping("/reports")
public class ReportsController {
@Autowired
private UserService userService;
private IEmployeeService userService;
@Autowired
private ProjectService projectService;
private IProjectService projectService;
@Autowired
private EmployeeVisaRepo employeeVisaRepo;
......
package com.nisum.mytime.controller;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Shift;
import com.nisum.mytime.service.impl.ShiftService;
@RestController
public class ShiftController {
@Autowired
ShiftService shiftService;
// @RequestMapping(value = "/getAllShifts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/shifts/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllShifts() throws MyTimeException {
List<String> shifts = shiftService.getAllShifts().stream().filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Shift::getShiftName).sorted().collect(Collectors.toList());
return new ResponseEntity<>(shifts, HttpStatus.OK);
}
}
package com.nisum.mytime.controller;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Skill;
import com.nisum.mytime.service.impl.SkillService;
@RestController
public class SkillController {
@Autowired
SkillService skillService;
// @RequestMapping(value = "/getSkills", method = RequestMethod.GET,
// produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/skills/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getTechnologies() throws MyTimeException {
List<String> technologies = skillService.getTechnologies().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Skill::getSkillName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
}
}
package com.nisum.mytime.controller;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.AccountInfo;
import com.nisum.mytime.model.Designation;
import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.model.Shift;
import com.nisum.mytime.model.Skill;
import com.nisum.mytime.service.RoleMappingService;
import com.nisum.mytime.service.UserService;
import lombok.extern.slf4j.Slf4j;
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleMappingService roleMappingService;
@RequestMapping(value = "/employee", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRole(
@RequestParam("emailId") String emailId) throws MyTimeException {
Employee employeesRole = userService.getEmployeesRole(emailId);
if (employeesRole != null) {
if (employeesRole.getRole() != null
&& employeesRole.getRole().equalsIgnoreCase("Admin")) {
employeesRole.setRole("Admin");
} else {
String roleName = roleMappingService
.getEmployeeRole(employeesRole.getEmployeeId());
if (roleName != null) {
employeesRole.setRole(roleName);
}
}
}
System.out.println("emailId" + emailId + "result" + employeesRole);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> assigingEmployeeRole(
@RequestBody Employee employeeRoles, @RequestParam(value="empId") String loginEmpId) throws MyTimeException {
Employee employeeRole = userService
.assigingEmployeeRole(employeeRoles,loginEmpId);
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> updateEmployeeRole(
@RequestBody Employee employeeRoles,
@RequestParam(value="empId") String loginEmpId) throws MyTimeException {
Employee employeeRole = userService
.updateEmployeeRole(employeeRoles,loginEmpId);
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE,
produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> deleteEmployee(
@RequestParam("empId") String empId) throws MyTimeException {
userService.deleteEmployee(empId);
return new ResponseEntity<>("Success", HttpStatus.OK);
}
@RequestMapping(value = "/getUserRoles", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getUserRoles()
throws MyTimeException {
List<Employee> employeesRoles = userService.getEmployeeRoles();
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRoleData(
@RequestParam("empId") String empId) throws MyTimeException {
Employee employeesRole = userService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeLocations", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeLocationDetails>> getEmployeeLocations(
@RequestParam("employeeId") String empId) throws MyTimeException {
List<EmployeeLocationDetails> employeeLocationDetails = userService
.getEmployeeLocationDetails(empId);
return new ResponseEntity<>(employeeLocationDetails, HttpStatus.OK);
}
@RequestMapping(value = "/getManagers", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getManagers()
throws MyTimeException {
List<Employee> employeesRoles = userService.getEmployeeRoles();
List<Employee> managers = employeesRoles.stream()
.filter(e -> ("Director".equalsIgnoreCase(e.getRole())
|| "Delivery Manager".equalsIgnoreCase(e.getRole())
|| "Manager".equalsIgnoreCase(e.getRole())
|| "HR Manager".equalsIgnoreCase(e.getRole())
|| "Lead".equalsIgnoreCase(e.getRole())))
.sorted(Comparator.comparing(Employee::getEmployeeName))
.collect(Collectors.toList());
return new ResponseEntity<>(managers, HttpStatus.OK);
}
@RequestMapping(value = "/getAllShifts", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllShifts() throws MyTimeException {
List<String> shifts = userService.getAllShifts().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Shift::getShiftName).sorted().collect(Collectors.toList());
return new ResponseEntity<>(shifts, HttpStatus.OK);
}
@RequestMapping(value = "/getAllDesignations", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllDesignations()
throws MyTimeException {
List<String> designations = userService.getAllDesignations().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Designation::getDesignationName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(designations, HttpStatus.OK);
}
@RequestMapping(value = "/getSkills", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getTechnologies()
throws MyTimeException {
List<String> technologies = userService.getTechnologies().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Skill::getSkillName).sorted().collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
}
@RequestMapping(value = "/getLocations", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getLocations() throws MyTimeException {
System.out.println(
" userService.getLocations()" + userService.getLocations());
List<String> locations = userService.getLocations().stream()
.filter(e -> (e.isActiveStatus() == true))
.map(Location::getLocation).sorted()
.collect(Collectors.toList());
System.out.println("getLocations################ " + locations);
return new ResponseEntity<>(locations, HttpStatus.OK);
}
@RequestMapping(value = "/updateProfile", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> updateProfile(
@RequestBody Employee employeeRoles) throws MyTimeException {
Employee employeeRole = userService.updateProfile(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/getAccounts", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Account>> getAccounts() throws MyTimeException {
List<Account> technologies = userService.getAccounts().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getStatus()))
//.filter(a -> !("Nisum India".equalsIgnoreCase(a.getAccountName())))
// .map(Account::getAccountName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeRoleDataForSearchCriteria",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRoleDataForSearchCriteria(
@RequestParam("searchId") String searchId,
@RequestParam("searchAttribute") String searchAttribute)
throws MyTimeException {
Employee employeesRole = userService
.getEmployeeRoleDataForSearchCriteria(searchId,
searchAttribute);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeDetailsForAutocomplete",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getEmployeeDetailsForAutocomplete()
throws MyTimeException {
List<String> details = userService.getEmployeeDetailsForAutocomplete();
return new ResponseEntity<>(details, HttpStatus.OK);
}
@RequestMapping(value = "/getMasterData", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, List<String>>> getMasterData()
throws MyTimeException {
Map<String, List<String>> masterDataMap = new HashMap<>();
Map<String, List<MasterData>> result = userService.getMasterData()
.stream().filter(e -> (e.isActiveStatus() == true))
.collect(Collectors.groupingBy(MasterData::getMasterDataType));
for (String key : result.keySet()) {
List<MasterData> valueList = result.get(key);
List<String> technologies = valueList.stream()
.map(MasterData::getMasterDataName).sorted()
.collect(Collectors.toList());
masterDataMap.put(key, technologies);
}
return new ResponseEntity<>(masterDataMap, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeByStatus", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getEmployeeByStatus(
@RequestParam("status") String status) {
List<Employee> employeesRoles = userService
.getEmployeesByStatus(status);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
@RequestMapping(value = "/getDeliveryLeads", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<HashMap<String, String>>> getDeliveryLeads(
@RequestParam("domainId") String domainId) throws MyTimeException {
List<HashMap<String, String>> managers = userService
.getDeliveryLeads(domainId);
return new ResponseEntity<>(managers, HttpStatus.OK);
}
@RequestMapping(value = "/getAccountsInfo", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<AccountInfo>> getAccountsInfo()
throws MyTimeException {
List<AccountInfo> technologies = userService.getAccountsInfo().stream()
.filter(e -> "Active".equalsIgnoreCase(e.getStatus()))
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
}
@RequestMapping(value = "/getDomains", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Domain>> getDomains(
@RequestParam("accountId") String accountId)
throws MyTimeException {
List<Domain> domains = userService.getDomains(accountId).stream()
.filter(e -> "Active".equalsIgnoreCase(e.getStatus()))
.collect(Collectors.toList());
return new ResponseEntity<>(domains, HttpStatus.OK);
}
@RequestMapping(value = "/fileUpload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> exportDataFromFile(@RequestParam(value = "file") MultipartFile file, @RequestParam(value="empId") String loginEmpId)
throws MyTimeException {
log.info("Uploaded file: {} with size: {}", file.getOriginalFilename(), file.getSize());
String result = userService.importDataFromExcelFile(file,loginEmpId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
\ No newline at end of file
......@@ -15,14 +15,14 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmployeeVisa;
import com.nisum.mytime.model.TravelRequest;
import com.nisum.mytime.model.Visa;
import com.nisum.mytime.service.VisaService;
import com.nisum.mytime.service.IVisaService;
@RestController
@RequestMapping("/visa")
public class VisaController {
@Autowired
private VisaService visaService;
private IVisaService visaService;
@RequestMapping(value = "/getAllVisas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Visa>> getAllVisas() throws MyTimeException {
......
......@@ -23,7 +23,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Accounts")
@Document(collection = "accounts")
public class Account implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -17,7 +17,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Designations")
@Document(collection = "designations")
public class Designation implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -22,7 +22,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Domains")
@Document(collection = "domains")
public class Domain implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -19,7 +19,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "EmployeeDetails")
@Document(collection = "employees")
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -17,7 +17,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "MasterData")
@Document(collection = "masterData")
public class MasterData implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -21,7 +21,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Teams")
@Document(collection = "projects")
public class Project extends AuditFields implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -17,8 +17,8 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Role")
public class RoleInfo implements Serializable {
@Document(collection = "roles")
public class Role implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -17,7 +17,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Shifts")
@Document(collection = "shifts")
public class Shift implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -17,7 +17,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Skills")
@Document(collection = "skills")
public class Skill implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -7,7 +7,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Employee;
public interface EmployeeRolesRepo
public interface EmployeeRepo
extends MongoRepository<Employee, String> {
Employee findByEmailId(String emailId);
......
......@@ -2,11 +2,11 @@ package com.nisum.mytime.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.RoleInfo;
import com.nisum.mytime.model.Role;
public interface RoleInfoRepo extends MongoRepository<RoleInfo, String> {
public interface RoleInfoRepo extends MongoRepository<Role, String> {
RoleInfo findByRoleName(String roleName);
Role findByRoleName(String roleName);
RoleInfo findByRoleId(String roleId);
Role findByRoleId(String roleId);
}
\ No newline at end of file
......@@ -5,6 +5,6 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Skill;
public interface TechnologyRepo extends MongoRepository<Skill, String> {
public interface SkillRepo extends MongoRepository<Skill, String> {
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.service.EmployeeDataService;
import com.nisum.mytime.service.impl.EmployeeDataService;
import com.nisum.mytime.utils.MyTimeLogger;
@DisallowConcurrentExecution
......
......@@ -11,8 +11,6 @@ import com.nisum.mytime.model.Account;
@Service
public interface IAccountService {
Account createAccount(Account account) throws MyTimeException;
Account updateAccount(Account account) throws MyTimeException;
......
......@@ -8,7 +8,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.AttendenceData;
import com.nisum.mytime.model.EmpLoginData;
public interface AttendanceService {
public interface IAttendanceService {
List<AttendenceData> getAttendanciesReport(String reportDate,String shift) throws MyTimeException, SQLException;
......
package com.nisum.mytime.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Designation;
@Service
public interface IDesignationService {
List<Designation> getAllDesignations() throws MyTimeException;
}
......@@ -30,4 +30,6 @@ public interface IDomainService {
List<Domain> getDomainsList() throws MyTimeException;
Set<String> accountsAssignedToDeliveryLead(String empId) throws MyTimeException;
List<Domain> getDomainsUnderAccount(String accountId)throws MyTimeException;
}
package com.nisum.mytime.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeLocationDetails;
@Service
public interface IEmployeeLocationService {
public void saveEmployeeLocationDetails(Employee employee) ;
public List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId);
}
......@@ -4,6 +4,8 @@ import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.nisum.mytime.exception.handler.MyTimeException;
......@@ -19,17 +21,20 @@ import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.model.Shift;
import com.nisum.mytime.model.Skill;
public interface UserService {
@Service
public interface IEmployeeService {
List<Employee> getManagers()throws MyTimeException;
Boolean fetchEmployeesData(String perticularDate, boolean resynchFlag)
throws MyTimeException;
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException;
List<Employee> getEmployeeRoles() throws MyTimeException;
List<Employee> getActiveEmployees() throws MyTimeException;
Employee assigingEmployeeRole(Employee employeeRoles, String empId)
Employee createEmployee(Employee employeeRoles, String empId)
throws MyTimeException;
List generatePdfReport(long id, String fromDate, String toDate)
......@@ -38,7 +43,7 @@ public interface UserService {
List generatePdfReport(long id, String fromDate, String toDate,String fromTime,String toTime)
throws MyTimeException, ParseException;
Employee getEmployeesRole(String emailId);
Employee getEmployeeByEmaillId(String emailId);
void deleteEmployee(String empId);
......@@ -47,31 +52,31 @@ public interface UserService {
void updateEmployeeLocationDetails(Employee employeeRoles,
boolean delete);
void saveEmployeeLocationDetails(Employee employeeRoles);
//void saveEmployeeLocationDetails(Employee employeeRoles);
Employee getEmployeesRoleData(String empId);
List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId);
//List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId);
List<Shift> getAllShifts() throws MyTimeException;
// List<Shift> getAllShifts() throws MyTimeException;
List<Designation> getAllDesignations() throws MyTimeException;
// List<Designation> getAllDesignations() throws MyTimeException;
List<Skill> getTechnologies() throws MyTimeException;
//List<Skill> getTechnologies() throws MyTimeException;
public Employee updateProfile(Employee employeeRoles)
throws MyTimeException;
public List<Account> getAccounts() throws MyTimeException;
List<Location> getLocations() throws MyTimeException;
//List<Location> getLocations() throws MyTimeException;
Employee getEmployeeRoleDataForSearchCriteria(String searchId,
String searchAttribute);
List<String> getEmployeeDetailsForAutocomplete();
List<MasterData> getMasterData() throws MyTimeException;
//List<MasterData> getMasterData() throws MyTimeException;
List<Employee> getEmployeesByFunctionalGrp(String functionalGrp);
......
......@@ -9,7 +9,7 @@ import com.nisum.mytime.model.EmailDomain;
* @author nisum
*
*/
public interface MailService {
public interface IMailService {
public String sendEmailWithAttachment(EmailDomain emailObj);
......
package com.nisum.mytime.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.MasterData;
@Service
public interface IMasterDataService {
List<MasterData> getMasterData() throws MyTimeException;
}
package com.nisum.mytime.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Location;
@Service
public interface IOrgLocationService {
List<Location> getLocations() throws MyTimeException;
}
......@@ -14,8 +14,11 @@ import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate;
public interface ProjectService {
public interface IProjectService {
public ProjectTeamMate addNewBeanchAllocation(Employee employee,String loginEmpId);
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException;
......
package com.nisum.mytime.service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.RoleInfo;
import com.nisum.mytime.model.Role;
public interface RoleInfoService {
public interface IRoleInfoService {
public RoleInfo addRole(RoleInfo roleInfo) throws MyTimeException;
public Role addRole(Role roleInfo) throws MyTimeException;
public String getRole(String roleName) throws MyTimeException;
}
......@@ -6,7 +6,7 @@ import java.util.Set;
import com.mongodb.WriteResult;
import com.nisum.mytime.exception.handler.MyTimeException;
public interface RoleMappingService {
public interface IRoleMappingService {
void addEmployeeRole(String employeeId, String roleId) throws MyTimeException;
......
package com.nisum.mytime.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Shift;
@Service
public interface IShiftService {
List<Shift> getAllShifts() throws MyTimeException;
}
package com.nisum.mytime.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Skill;
@Service
public interface ISkillService {
List<Skill> getTechnologies() throws MyTimeException;
}
......@@ -16,7 +16,7 @@ import com.nisum.mytime.model.Visa;
* @author nisum
*
*/
public interface VisaService {
public interface IVisaService {
List<Visa> getAllVisas();
......
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import java.util.ArrayList;
import java.util.Collections;
......@@ -21,6 +21,9 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.service.IAccountService;
import com.nisum.mytime.service.IRoleInfoService;
import com.nisum.mytime.service.IRoleMappingService;
import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeUtils;
......@@ -34,10 +37,10 @@ public class AccountService implements IAccountService {
private MongoTemplate mongoTemplate;
@Autowired
private RoleInfoService roleInfoService;
private IRoleInfoService roleInfoService;
@Autowired
private RoleMappingService roleMappingService;
private IRoleMappingService roleMappingService;
private static final Logger logger = LoggerFactory.getLogger(AccountService.class);
......
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import java.sql.Connection;
import java.sql.ResultSet;
......@@ -23,13 +23,14 @@ import com.nisum.mytime.model.AttendenceData;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.repository.ProjectTeamMatesRepo;
import com.nisum.mytime.service.IAttendanceService;
import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeLogger;
import com.nisum.mytime.utils.MyTimeUtils;
import com.nisum.mytime.utils.PdfReportGenerator;
@Service
public class AttendanceServiceImpl implements AttendanceService {
public class AttendanceService implements IAttendanceService {
@Autowired
private EmployeeDataService employeeDataBaseService;
......
package com.nisum.mytime.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Designation;
import com.nisum.mytime.repository.DesignationRepo;
import com.nisum.mytime.service.IDesignationService;
@Service
public class DesignationService implements IDesignationService {
@Autowired
private DesignationRepo designationRepo;
@Override
public List<Designation> getAllDesignations() throws MyTimeException {
return designationRepo.findAll();
}
}
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import java.util.ArrayList;
import java.util.Collections;
......@@ -21,6 +21,9 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.repository.DomainRepo;
import com.nisum.mytime.service.IDomainService;
import com.nisum.mytime.service.IRoleInfoService;
import com.nisum.mytime.service.IRoleMappingService;
import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeUtils;
......@@ -38,10 +41,10 @@ public class DomainService implements IDomainService {
private MongoTemplate mongoTemplate;
@Autowired
private RoleInfoService roleInfoService;
private IRoleInfoService roleInfoService;
@Autowired
private RoleMappingService roleMappingService;
private IRoleMappingService roleMappingService;
private static final Logger logger = LoggerFactory.getLogger(DomainService.class);
......@@ -96,7 +99,7 @@ public class DomainService implements IDomainService {
private void updateRoleIdsForDMs(Domain domainReq, String roleId) throws MyTimeException {
Domain domainDAO = getDomainById(domainReq.getDomainId());
Domain domainDAO = getDomainByStatusActive(domainReq.getDomainId());
List dmssListDAO = domainDAO.getDeliveryManagers();
List dmsListReq = domainReq.getDeliveryManagers();
List<String> managersAddedByUser = managersAddedByUser = CommomUtil.getAddedManagersListForDM(dmssListDAO,
......@@ -108,7 +111,7 @@ public class DomainService implements IDomainService {
private void deleteRoleIdsForDMs(Domain domainUpdating, String roleId) throws MyTimeException {
Map<String, Integer> managersDomainCount = new HashMap<String, Integer>();
Domain domainDAO = getDomainById(domainUpdating.getDomainId());
Domain domainDAO = getDomainByStatusActive(domainUpdating.getDomainId());
List dmsListDAO = domainDAO.getDeliveryManagers();
List dmsListReq = domainUpdating.getDeliveryManagers();
......@@ -191,7 +194,7 @@ public class DomainService implements IDomainService {
}
// Custom methods
private Domain getDomainById(String domainId) {
private Domain getDomainByStatusActive(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);
......@@ -200,6 +203,7 @@ public class DomainService implements IDomainService {
return null;
}
private boolean duplicateCheck(String domainName, String accountId, List<String> fromDB, List fromUser) {
boolean check = false;
int count = 0;
......@@ -226,5 +230,23 @@ public class DomainService implements IDomainService {
}
return accIdsSet;
}
public Domain getDomainById(String domainId) {
Domain domain = null;
if (domainId != null && domainId.length() > 0) {
domain = domainRepo.findByDomainId(domainId);
}
return domain;
}
@Override
public List<Domain> getDomainsUnderAccount(String accountId) throws MyTimeException {
List<Domain> domains = domainRepo.findByAccountId(accountId);
return domains;
}
}
\ No newline at end of file
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import java.sql.Connection;
import java.sql.ResultSet;
......@@ -20,6 +20,7 @@ import org.springframework.stereotype.Component;
import com.nisum.mytime.configuration.DbConnection;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.service.IEmployeeDataService;
import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeLogger;
import com.nisum.mytime.utils.MyTimeUtils;
......
package com.nisum.mytime.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.repository.EmployeeLocationDetailsRepo;
import com.nisum.mytime.service.IEmployeeLocationService;
@Service
public class EmployeeLocationService implements IEmployeeLocationService{
@Autowired
private EmployeeLocationDetailsRepo employeeLocationDetailsRepo;
@Override
public void saveEmployeeLocationDetails(Employee employee) {
EmployeeLocationDetails employeeLocationDetails = new EmployeeLocationDetails();
employeeLocationDetails.setActive(employee.getEmpStatus().equalsIgnoreCase("Active"));
employeeLocationDetails.setEmployeeId(employee.getEmployeeId());
employeeLocationDetails.setEmployeeName(employee.getEmployeeName());
employeeLocationDetails.setCreateDate(new Date());
employeeLocationDetails.setEndDate(new Date());
employeeLocationDetails.setUpdatedDate(new Date());
employeeLocationDetails.setStartDate(new Date());
employeeLocationDetails.setEmpLocation(employee.getEmpLocation());
employeeLocationDetailsRepo.save(employeeLocationDetails);
}
@Override
public List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId) {
return employeeLocationDetailsRepo.findByEmployeeId(empId);
}
}
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
......@@ -43,14 +43,17 @@ import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.repository.DesignationRepo;
import com.nisum.mytime.repository.DomainRepo;
import com.nisum.mytime.repository.EmployeeLocationDetailsRepo;
import com.nisum.mytime.repository.EmployeeRolesRepo;
import com.nisum.mytime.repository.EmployeeRepo;
import com.nisum.mytime.repository.LocationRepo;
import com.nisum.mytime.repository.MasterDataRepo;
import com.nisum.mytime.repository.ProjectRepo;
import com.nisum.mytime.repository.ProjectTeamMatesRepo;
import com.nisum.mytime.repository.ShiftRepo;
import com.nisum.mytime.repository.TeamMatesBillingRepo;
import com.nisum.mytime.repository.TechnologyRepo;
import com.nisum.mytime.service.IEmployeeService;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IRoleMappingService;
import com.nisum.mytime.repository.SkillRepo;
import com.nisum.mytime.utils.DataValidations;
import com.nisum.mytime.utils.MyTimeUtils;
import com.nisum.mytime.utils.PdfReportGenerator;
......@@ -62,34 +65,34 @@ import lombok.extern.slf4j.Slf4j;
@Service("userService")
@Slf4j
public class UserServiceImpl implements UserService {
public class EmployeeService implements IEmployeeService {
@Autowired
private EmployeeRolesRepo employeeRolesRepo;
private EmployeeRepo employeeRepo;
@Autowired
private ProjectRepo projectRepo;
@Autowired
private ProjectTeamMatesRepo projectTeamMatesRepo;
@Autowired
private ProjectService projectService;
@Autowired
private ShiftRepo shiftRepo;
@Autowired
private DesignationRepo designationRepo;
private IProjectService projectService;
// @Autowired
// private AccountRepo accountRepo;
@Autowired
private AccountRepo accountRepo;
@Autowired
private MasterDataRepo masterDataRepo;
DomainService domainService;
//@Autowired
//private MasterDataRepo masterDataRepo;
@Autowired
private TechnologyRepo technologyRepo;
//@Autowired
// private TechnologyRepo technologyRepo;
@Autowired
private LocationRepo locationRepo;
//@Autowired
// private LocationRepo locationRepo;
@Autowired
private EmployeeDataService employeeDataBaseService;
......@@ -100,11 +103,11 @@ public class UserServiceImpl implements UserService {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private EmployeeLocationDetailsRepo employeeLocationDetailsRepo;
// @Autowired
// private EmployeeLocationDetailsRepo employeeLocationDetailsRepo;
@Autowired
private DomainRepo domainRepo;
//@Autowired
// private DomainRepo domainRepo;
@Autowired
private AccountInfoRepo accountInfoRepo;
......@@ -113,8 +116,16 @@ public class UserServiceImpl implements UserService {
private TeamMatesBillingRepo teamMatesBillingRepo;
@Autowired
private RoleMappingService roleMappingService;
private IRoleMappingService roleMappingService;
@Autowired
EmployeeLocationService empLocationService;
@Autowired
AccountService accountService;
@Override
public Boolean fetchEmployeesData(String perticularDate,
......@@ -140,64 +151,47 @@ public class UserServiceImpl implements UserService {
}
@Override
public List<Employee> getEmployeeRoles() throws MyTimeException {
public List<Employee> getActiveEmployees() throws MyTimeException {
//return employeeRolesRepo.findAll();
return employeeRolesRepo.findByEmpStatus(MyTimeUtils.ACTIVE);
return employeeRepo.findByEmpStatus(MyTimeUtils.ACTIVE);
}
public List<Employee> getManagers() throws MyTimeException {
List<Employee> employeesList = getActiveEmployees();
List<Employee> managers = employeesList.stream()
.filter(e -> ("Director".equalsIgnoreCase(e.getRole())
|| "Delivery Manager".equalsIgnoreCase(e.getRole()) || "Manager".equalsIgnoreCase(e.getRole())
|| "HR Manager".equalsIgnoreCase(e.getRole()) || "Lead".equalsIgnoreCase(e.getRole())))
.sorted(Comparator.comparing(Employee::getEmployeeName)).collect(Collectors.toList());
return managers;
}
@Override
public Employee assigingEmployeeRole(Employee employeeRoles, String loginEmpId)
public Employee createEmployee(Employee employeeReq, String loginEmpId)
throws MyTimeException {
employeeRoles.setCreatedOn(new Date());
employeeRoles.setCreatedBy(loginEmpId);
employeeRoles.setModifiedBy(loginEmpId);
ProjectTeamMate newBenchAllocation = new ProjectTeamMate();
newBenchAllocation.setAccount(MyTimeUtils.BENCH_ACCOUNT);
newBenchAllocation.setBillableStatus(MyTimeUtils.BENCH_BILLABILITY_STATUS);
newBenchAllocation.setDesignation(employeeRoles.getDesignation());
newBenchAllocation.setEmailId(employeeRoles.getEmailId());
newBenchAllocation.setEmployeeId(employeeRoles.getEmployeeId());
newBenchAllocation.setMobileNumber(employeeRoles.getMobileNumber());
employeeReq.setCreatedOn(new Date());
employeeReq.setCreatedBy(loginEmpId);
employeeReq.setModifiedBy(loginEmpId);
newBenchAllocation.setEmployeeName(employeeRoles.getEmployeeName());
newBenchAllocation.setProjectId(MyTimeUtils.BENCH_PROJECT_ID);
newBenchAllocation.setStartDate(employeeRoles.getDateOfJoining() != null ? employeeRoles.getDateOfJoining() : new Date());
Project p = projectRepo.findByProjectId(MyTimeUtils.BENCH_PROJECT_ID);
newBenchAllocation.setProjectName(p.getProjectName());
newBenchAllocation.setAccountId(p.getAccountId());
newBenchAllocation.setDomainId(p.getDomainId());
newBenchAllocation.setShift(employeeRoles.getShift());
newBenchAllocation.setRole(employeeRoles.getRole());
if ( null != employeeRoles.getEmpStatus() && employeeRoles.getEmpStatus().trim().equalsIgnoreCase(MyTimeUtils.IN_ACTIVE_SPACE)) {
newBenchAllocation.setEndDate(employeeRoles.getEndDate());
newBenchAllocation.setActive(false);
} else {
employeeRoles.setEmpStatus(MyTimeUtils.ACTIVE);
newBenchAllocation.setEndDate(p.getProjectEndDate());
newBenchAllocation.setActive(true);
}
//adding new Bench Allocation
projectService.addNewBeanchAllocation( employeeReq, loginEmpId);
//Saving Location Details.
empLocationService.saveEmployeeLocationDetails(employeeReq);
try {
projectService.addProjectTeamMate(newBenchAllocation, loginEmpId);
} catch (MyTimeException e) {
e.printStackTrace();
}
saveEmployeeLocationDetails(employeeRoles);
return employeeRolesRepo.save(employeeRoles);
return employeeRepo.save(employeeReq);
}
@Override
public Employee getEmployeesRole(String emailId) {
return employeeRolesRepo.findByEmailId(emailId);
public Employee getEmployeeByEmaillId(String emailId) {
return employeeRepo.findByEmailId(emailId);
}
@Override
public void deleteEmployee(String employeeId) {
Employee role = employeeRolesRepo.findByEmployeeId(employeeId);
employeeRolesRepo.delete(role);
Employee role = employeeRepo.findByEmployeeId(employeeId);
employeeRepo.delete(role);
}
@Override
......@@ -230,7 +224,7 @@ public class UserServiceImpl implements UserService {
}
// update employee location
if (employeeRoles.getEmpLocation() != null && !employeeRoles.getEmpLocation().equals("")) {
Employee existingEmployee = employeeRolesRepo.findByEmployeeId(employeeRoles.getEmployeeId());
Employee existingEmployee = employeeRepo.findByEmployeeId(employeeRoles.getEmployeeId());
if (!existingEmployee.getEmpLocation().equals(employeeRoles.getEmpLocation())) {
updateEmployeeLocationDetails(employeeRoles, false);
}
......@@ -245,7 +239,7 @@ public class UserServiceImpl implements UserService {
try {
// update employee location
if (employeeRoles.getEmpLocation() != null && !employeeRoles.getEmpLocation().equals("")) {
Employee existingEmployee = employeeRolesRepo.findByEmployeeId(employeeRoles.getEmployeeId());
Employee existingEmployee = employeeRepo.findByEmployeeId(employeeRoles.getEmployeeId());
if (!existingEmployee.getEmpLocation().equals(employeeRoles.getEmpLocation())) {
updateEmployeeLocationDetails(employeeRoles, false);
}
......@@ -257,6 +251,7 @@ public class UserServiceImpl implements UserService {
if (employeeProfiles != null && !employeeProfiles.isEmpty()) {
for (ProjectTeamMate profile : employeeProfiles) {
profile.setRole(emp.getRole());
profile.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
projectTeamMatesRepo.save(profile);
}
}
......@@ -291,40 +286,48 @@ public class UserServiceImpl implements UserService {
@Override
public Employee getEmployeesRoleData(String employeeId) {
return employeeRolesRepo.findByEmployeeId(employeeId);
return employeeRepo.findByEmployeeId(employeeId);
}
@Override
/* @Override
public List<Shift> getAllShifts() throws MyTimeException {
return shiftRepo.findAll();
}
*/
@Override
/* @Override
public List<Designation> getAllDesignations() throws MyTimeException {
return designationRepo.findAll();
}
*/
@Override
public List<Account> getAccounts() throws MyTimeException {
return accountRepo.findAll();
return accountService.getAccounts();
}
/*
@Override
public List<Skill> getTechnologies() throws MyTimeException {
return technologyRepo.findAll();
}
*/
/*
@Override
public List<Location> getLocations() throws MyTimeException {
return locationRepo.findAll();
}
*/
@Override
public Employee updateProfile(Employee employeeRoles)
throws MyTimeException {
boolean mobileNumberChanged = false;
employeeRoles.setLastModifiedOn(new Date());
Employee existingEmployee = employeeRolesRepo
Employee existingEmployee = employeeRepo
.findByEmployeeId(employeeRoles.getEmployeeId());
String newMobileNumber = employeeRoles.getMobileNumber();
if (newMobileNumber != null && !newMobileNumber.equalsIgnoreCase("")) {
......@@ -341,7 +344,7 @@ public class UserServiceImpl implements UserService {
existingEmployee.setPersonalEmailId(employeeRoles.getPersonalEmailId());
existingEmployee.setBaseTechnology(employeeRoles.getBaseTechnology());
existingEmployee.setTechnologyKnown(employeeRoles.getTechnologyKnown());
Employee employeeRolesDB = employeeRolesRepo.save(existingEmployee);
Employee employeeRolesDB = employeeRepo.save(existingEmployee);
if (mobileNumberChanged) {
try {
List<ProjectTeamMate> employeeProfiles = projectTeamMatesRepo
......@@ -370,9 +373,9 @@ public class UserServiceImpl implements UserService {
public Employee getEmployeeRoleDataForSearchCriteria(String searchId,
String searchAttribute) {
if (MyTimeUtils.EMPLOYEE_NAME.equals(searchAttribute)) {
return employeeRolesRepo.findByEmployeeName(searchId);
return employeeRepo.findByEmployeeName(searchId);
} else if (MyTimeUtils.EMAIL_ID.equals(searchAttribute)) {
return employeeRolesRepo.findByEmailId(searchId);
return employeeRepo.findByEmailId(searchId);
}
return null;
......@@ -386,7 +389,7 @@ public class UserServiceImpl implements UserService {
*/
@Override
public List<String> getEmployeeDetailsForAutocomplete() {
List<Employee> roles = employeeRolesRepo.findAll();
List<Employee> roles = employeeRepo.findAll();
List<String> details = new ArrayList<>();
roles.stream()
.sorted(java.util.Comparator
......@@ -409,11 +412,13 @@ public class UserServiceImpl implements UserService {
return details;
}
/*
@Override
public List<MasterData> getMasterData() throws MyTimeException {
return masterDataRepo.findAll();
}
*/
@Override
public void updateEmployeeLocationDetails(Employee employeeRoles,
boolean delete) {
......@@ -434,51 +439,59 @@ public class UserServiceImpl implements UserService {
mongoTemplate.save(existingLocation);
}
if (!delete)
saveEmployeeLocationDetails(employeeRoles);
empLocationService.saveEmployeeLocationDetails(employeeRoles);
} catch (Exception ex) {
System.out.println(ex);
}
}
/*
@Override
public void saveEmployeeLocationDetails(Employee employeeRoles) {
public void saveEmployeeLocationDetails(Employee employee) {
EmployeeLocationDetails employeeLocationDetails = new EmployeeLocationDetails();
employeeLocationDetails.setActive(employeeRoles.getEmpStatus().equalsIgnoreCase("Active"));
employeeLocationDetails.setEmployeeId(employeeRoles.getEmployeeId());
employeeLocationDetails.setEmployeeName(employeeRoles.getEmployeeName());
employeeLocationDetails.setActive(employee.getEmpStatus().equalsIgnoreCase("Active"));
employeeLocationDetails.setEmployeeId(employee.getEmployeeId());
employeeLocationDetails.setEmployeeName(employee.getEmployeeName());
employeeLocationDetails.setCreateDate(new Date());
employeeLocationDetails.setEndDate(new Date());
employeeLocationDetails.setUpdatedDate(new Date());
employeeLocationDetails.setStartDate(new Date());
employeeLocationDetails.setEmpLocation(employeeRoles.getEmpLocation());
employeeLocationDetails.setEmpLocation(employee.getEmpLocation());
employeeLocationDetailsRepo.save(employeeLocationDetails);
}
*/
/*
@Override
public List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId) {
return employeeLocationDetailsRepo.findByEmployeeId(empId);
}
*/
@Override
public List<Employee> getEmployeesByFunctionalGrp(
String functionalGrp) {
return employeeRolesRepo.findByEmpStatusAndFunctionalGroup("Active", functionalGrp);
return employeeRepo.findByEmpStatusAndFunctionalGroup("Active", functionalGrp);
}
@Override
public List<Employee> getEmployeesByStatus(String status) {
if (status.equals("both")) {
return employeeRolesRepo.findAll(new Sort(Sort.Direction.ASC, "employeeName"));
return employeeRepo.findAll(new Sort(Sort.Direction.ASC, "employeeName"));
} else {
return employeeRolesRepo.findByEmpStatusOrderByEmployeeNameAsc(status);
return employeeRepo.findByEmpStatusOrderByEmployeeNameAsc(status);
}
}
@Override
public List<HashMap<String, String>> getDeliveryLeads(String domainId) {
List<HashMap<String, String>> EmployeeList = null;
Domain domains= domainRepo.findByDomainId(domainId);
Domain domains =domainService.getDomainById(domainId);
EmployeeList=getEmployeeData(domains.getDeliveryManagers());
return EmployeeList;
}
......@@ -501,9 +514,8 @@ public class UserServiceImpl implements UserService {
}
@Override
public List<Domain> getDomains(String accountId)throws MyTimeException {
List<Domain> domains= domainRepo.findByAccountId(accountId);
return domains;
public List<Domain> getDomains(String accountId) throws MyTimeException {
return domainService.getDomainsUnderAccount(accountId);
}
......@@ -614,7 +626,7 @@ public class UserServiceImpl implements UserService {
employee.setGender(MyTimeUtils.FEMALE);
}
}
assigingEmployeeRole(employee,empId);
createEmployee(employee,empId);
} catch (MyTimeException e) {
e.printStackTrace();
}
......@@ -629,7 +641,7 @@ public class UserServiceImpl implements UserService {
Set<String> empIdsSet = employees.stream().map(Employee :: getEmployeeId).collect(Collectors.toSet());
List<Employee> existingEmployess = employeeRolesRepo.findByEmployeeIdIn(empIdsSet);
List<Employee> existingEmployess = employeeRepo.findByEmployeeIdIn(empIdsSet);
if(existingEmployess.size() > MyTimeUtils.INT_ZERO) {
result = "Below employee records already existed : \n" + existingEmployess.stream().map(Employee :: getEmployeeId).collect(Collectors.toSet()).toString();
employees.removeAll(existingEmployess);
......@@ -720,31 +732,33 @@ public class UserServiceImpl implements UserService {
private boolean importExcelMandatoryColumnsValidation(Employee emp) {
boolean mandatoryFlag = true;
if(! DataValidations.validateNumber(emp.getEmployeeId())) {
mandatoryFlag = false;
}else if(! DataValidations.validateName(emp.getEmployeeName())) {
mandatoryFlag = false;
}else if(! DataValidations.isValidGender(emp.getGender())) {
mandatoryFlag = false;
}else if(! DataValidations.isValidDate(emp.getDateOfJoining())) {
mandatoryFlag = false;
}else if(! DataValidations.isValidFunctionalGroup(emp.getFunctionalGroup(),masterDataRepo)) {
mandatoryFlag = false;
}else if(! DataValidations.isValidDesignation(emp.getDesignation(),masterDataRepo)) {
mandatoryFlag = false;
}else if(! DataValidations.isValidWorkLocation(emp.getEmpLocation(), locationRepo)) {
mandatoryFlag = false;
}else if(! DataValidations.isValidEmploymentType(emp.getEmploymentType(),masterDataRepo)) {
mandatoryFlag = false;
}else if(! DataValidations.isValidRole(emp.getRole(),masterDataRepo)) {
mandatoryFlag = false;
}else if(! DataValidations.isYesOrNo(emp.getHasPassort())) {
mandatoryFlag = false;
}else if(! DataValidations.isYesOrNo(emp.getHasB1())) {
mandatoryFlag = false;
}else if(!DataValidations.isValidEmail(emp.getEmailId())) {
mandatoryFlag = false;
}
// if(! DataValidations.validateNumber(emp.getEmployeeId())) {
// mandatoryFlag = false;
// }else if(! DataValidations.validateName(emp.getEmployeeName())) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidGender(emp.getGender())) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidDate(emp.getDateOfJoining())) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidFunctionalGroup(emp.getFunctionalGroup(),masterDataRepo)) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidDesignation(emp.getDesignation(),masterDataRepo)) {
// mandatoryFlag = false;
// }
// //else if(! DataValidations.isValidWorkLocation(emp.getEmpLocation(), locationRepo)) {
// //mandatoryFlag = false;
// // }
// else if(! DataValidations.isValidEmploymentType(emp.getEmploymentType(),masterDataRepo)) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidRole(emp.getRole(),masterDataRepo)) {
// mandatoryFlag = false;
// }else if(! DataValidations.isYesOrNo(emp.getHasPassort())) {
// mandatoryFlag = false;
// }else if(! DataValidations.isYesOrNo(emp.getHasB1())) {
// mandatoryFlag = false;
// }else if(!DataValidations.isValidEmail(emp.getEmailId())) {
// mandatoryFlag = false;
// }
return mandatoryFlag;
}
......
/**
*
*/
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import java.io.File;
import java.io.IOException;
......@@ -20,15 +20,16 @@ import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.EmailDomain;
import com.nisum.mytime.service.IMailService;
/**
* @author nisum
*
*/
@Service
public class MailServiceImpl implements MailService {
public class MailService implements IMailService {
private static final Logger logger = LoggerFactory.getLogger(MailServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(MailService.class);
@Autowired
JavaMailSender emailSender;
......
package com.nisum.mytime.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.repository.MasterDataRepo;
import com.nisum.mytime.service.IMasterDataService;
public class MasterDataService implements IMasterDataService {
@Autowired
private MasterDataRepo masterDataRepo;
@Override
public List<MasterData> getMasterData() throws MyTimeException {
return masterDataRepo.findAll();
}
}
package com.nisum.mytime.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.repository.LocationRepo;
import com.nisum.mytime.service.IOrgLocationService;
@Service
public class OrgLocationService implements IOrgLocationService {
@Autowired
private LocationRepo locationRepo;
@Override
public List<Location> getLocations() throws MyTimeException {
return locationRepo.findAll();
}
}
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -39,19 +39,23 @@ import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.repository.DomainRepo;
import com.nisum.mytime.repository.EmpShiftDetailsRepo;
import com.nisum.mytime.repository.EmployeeRolesRepo;
import com.nisum.mytime.repository.EmployeeRepo;
import com.nisum.mytime.repository.ProjectRepo;
import com.nisum.mytime.repository.ProjectTeamMatesRepo;
import com.nisum.mytime.repository.TeamMatesBillingRepo;
import com.nisum.mytime.service.IDomainService;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IRoleInfoService;
import com.nisum.mytime.service.IRoleMappingService;
import com.nisum.mytime.utils.MyTeamResultDTO;
import com.nisum.mytime.utils.MyTimeUtils;
import com.nisum.mytime.utils.PdfReportGenerator;
@Service("projectService")
public class ProjectServiceImpl implements ProjectService {
public class ProjectService implements IProjectService {
@Autowired
private EmployeeRolesRepo employeeRolesRepo;
private EmployeeRepo employeeRolesRepo;
@Autowired
private ProjectRepo projectRepo;
......@@ -78,10 +82,10 @@ public class ProjectServiceImpl implements ProjectService {
private DomainController domainController;
@Autowired
private RoleInfoService roleInfoService;
private IRoleInfoService roleInfoService;
@Autowired
private RoleMappingService roleMappingService;
private IRoleMappingService roleMappingService;
@Autowired
private AccountRepo accountRepo;
......@@ -92,6 +96,48 @@ public class ProjectServiceImpl implements ProjectService {
@Autowired
private IDomainService domainService;
public ProjectTeamMate addNewBeanchAllocation(Employee employee,String loginEmpId)
{
ProjectTeamMate teamatePersisted=null;
ProjectTeamMate newBenchAllocation = new ProjectTeamMate();
newBenchAllocation.setAccount(MyTimeUtils.BENCH_ACCOUNT);
newBenchAllocation.setBillableStatus(MyTimeUtils.BENCH_BILLABILITY_STATUS);
newBenchAllocation.setDesignation(employee.getDesignation());
newBenchAllocation.setEmailId(employee.getEmailId());
newBenchAllocation.setEmployeeId(employee.getEmployeeId());
newBenchAllocation.setMobileNumber(employee.getMobileNumber());
newBenchAllocation.setEmployeeName(employee.getEmployeeName());
newBenchAllocation.setProjectId(MyTimeUtils.BENCH_PROJECT_ID);
newBenchAllocation.setStartDate(employee.getDateOfJoining() != null ? employee.getDateOfJoining() : new Date());
Project p = projectRepo.findByProjectId(MyTimeUtils.BENCH_PROJECT_ID);
newBenchAllocation.setProjectName(p.getProjectName());
newBenchAllocation.setAccountId(p.getAccountId());
newBenchAllocation.setDomainId(p.getDomainId());
newBenchAllocation.setShift(employee.getShift());
newBenchAllocation.setRole(employee.getRole());
if ( null != employee.getEmpStatus() && employee.getEmpStatus().trim().equalsIgnoreCase(MyTimeUtils.IN_ACTIVE_SPACE)) {
newBenchAllocation.setEndDate(employee.getEndDate());
newBenchAllocation.setActive(false);
} else {
employee.setEmpStatus(MyTimeUtils.ACTIVE);
newBenchAllocation.setEndDate(p.getProjectEndDate());
newBenchAllocation.setActive(true);
}
try {
teamatePersisted= addProjectTeamMate(newBenchAllocation, loginEmpId);
} catch (MyTimeException e) {
e.printStackTrace();
}
return teamatePersisted;
}
@Override
public List<EmpLoginData> employeeLoginsBasedOnDate(long id,
String fromDate, String toDate) throws MyTimeException {
......
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.RoleInfo;
import com.nisum.mytime.model.Role;
import com.nisum.mytime.repository.RoleInfoRepo;
import com.nisum.mytime.service.IRoleInfoService;
@Service
public class RoleInfoServiceImpl implements RoleInfoService {
public class RoleInfoService implements IRoleInfoService {
@Autowired
RoleInfoRepo roleInfoRepo;
@Override
public RoleInfo addRole(RoleInfo roleInfo) throws MyTimeException {
public Role addRole(Role roleInfo) throws MyTimeException {
return roleInfoRepo.save(roleInfo);
}
......
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import java.util.HashSet;
import java.util.LinkedHashMap;
......@@ -19,10 +19,11 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.RoleMappingInfo;
import com.nisum.mytime.repository.RoleInfoRepo;
import com.nisum.mytime.repository.RoleMappingInfoRepo;
import com.nisum.mytime.service.IRoleMappingService;
import com.nisum.mytime.utils.MyTimeUtils;
@Service
public class RoleMappingServiceImpl implements RoleMappingService {
public class RoleMappingService implements IRoleMappingService {
@Autowired
private RoleMappingInfoRepo roleMappingInfoRepo;
......@@ -69,21 +70,20 @@ public class RoleMappingServiceImpl implements RoleMappingService {
@Override
public String getEmployeeRole(String employeeId) {
Map<Integer, String> roleInfoMap = new LinkedHashMap<Integer, String>();
List<RoleMappingInfo> listOfEmployeeRoles = roleMappingInfoRepo.findByEmployeeId(employeeId);
for (RoleMappingInfo employee : listOfEmployeeRoles) {
roleInfoMap.put((roleInfoRepo.findByRoleId(employee.getRoleId())).getPriority(), employee.getRoleId());
}
roleInfoMap = roleInfoMap.entrySet().stream().sorted(Map.Entry.comparingByKey()).collect(Collectors
.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
String roleName = null;
if (!roleInfoMap.isEmpty()) {
Map.Entry<Integer, String> entry = roleInfoMap.entrySet().iterator().next();
roleName = roleInfoRepo.findByRoleId(entry.getValue()).getRoleName();
} else {
roleName = null;
List<RoleMappingInfo> listOfEmployeeRoles = roleMappingInfoRepo.findByEmployeeId(employeeId).stream()
.filter(e -> ("N".equalsIgnoreCase(e.getIsActive()))).collect(Collectors.toList());
if (listOfEmployeeRoles != null && listOfEmployeeRoles.size() > 0) {
for (RoleMappingInfo employee : listOfEmployeeRoles) {
roleInfoMap.put((roleInfoRepo.findByRoleId(employee.getRoleId())).getPriority(), employee.getRoleId());
}
roleInfoMap = roleInfoMap.entrySet().stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toMap(
Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
if (!roleInfoMap.isEmpty()) {
Map.Entry<Integer, String> entry = roleInfoMap.entrySet().iterator().next();
roleName = roleInfoRepo.findByRoleId(entry.getValue()).getRoleName();
}
}
return roleName;
}
......@@ -92,7 +92,8 @@ public class RoleMappingServiceImpl implements RoleMappingService {
@Override
public Set<String> empRolesMapInfoByEmpId(String employeeId) {
Set<String> roleSet = new HashSet<String>();
List<RoleMappingInfo> listOfEmployeeRoles = roleMappingInfoRepo.findByEmployeeId(employeeId);
List<RoleMappingInfo> listOfEmployeeRoles = roleMappingInfoRepo.findByEmployeeId(employeeId).stream().filter(e->(
"N".equalsIgnoreCase(e.getIsActive()))).collect(Collectors.toList());
if(null != listOfEmployeeRoles && !listOfEmployeeRoles.isEmpty() && MyTimeUtils.INT_ZERO < listOfEmployeeRoles.size()) {
for(RoleMappingInfo obj : listOfEmployeeRoles) {
......
package com.nisum.mytime.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Shift;
import com.nisum.mytime.repository.ShiftRepo;
import com.nisum.mytime.service.IShiftService;
@Service
public class ShiftService implements IShiftService{
@Autowired
private ShiftRepo shiftRepo;
// @Override
public List<Shift> getAllShifts() throws MyTimeException {
return shiftRepo.findAll();
}
}
package com.nisum.mytime.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Skill;
import com.nisum.mytime.repository.SkillRepo;
import com.nisum.mytime.service.ISkillService;
@Service
public class SkillService implements ISkillService {
@Autowired
private SkillRepo technologyRepo;
@Override
public List<Skill> getTechnologies() throws MyTimeException {
return technologyRepo.findAll();
}
}
/**
*
*/
package com.nisum.mytime.service;
package com.nisum.mytime.service.impl;
import java.util.List;
......@@ -11,17 +11,19 @@ import org.springframework.stereotype.Service;
import com.nisum.mytime.model.EmployeeVisa;
import com.nisum.mytime.model.TravelRequest;
import com.nisum.mytime.model.Visa;
import com.nisum.mytime.repository.EmployeeRolesRepo;
import com.nisum.mytime.repository.EmployeeRepo;
import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.repository.TravelRepo;
import com.nisum.mytime.repository.VisaRepo;
import com.nisum.mytime.service.IEmployeeService;
import com.nisum.mytime.service.IVisaService;
/**
* @author nisum
*
*/
@Service
public class VisaServiceImpl implements VisaService {
public class VisaService implements IVisaService {
@Autowired
private VisaRepo visaRepo;
......@@ -32,10 +34,10 @@ public class VisaServiceImpl implements VisaService {
private EmployeeVisaRepo employeeVisaRepo;
@Autowired
private UserService userService;
private IEmployeeService userService;
@Autowired
private EmployeeRolesRepo employeeRolesRepo;
private EmployeeRepo employeeRolesRepo;
@Override
......
......@@ -25,8 +25,8 @@ import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.service.AttendanceService;
import com.nisum.mytime.service.EmployeeDataService;
import com.nisum.mytime.service.IAttendanceService;
import com.nisum.mytime.service.impl.EmployeeDataService;
@Component
public class PdfReportGenerator {
......@@ -38,7 +38,7 @@ public class PdfReportGenerator {
private EmployeeDataService employeeDataBaseService;
@Autowired
private AttendanceService attendanceService;
private IAttendanceService attendanceService;
public List generateEmployeeReport(long employeeId, String startDate, String endDate) throws MyTimeException {
String fileName = employeeId + "_" + startDate + "_" + endDate + ".pdf";
......
......@@ -48,7 +48,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
$scope.getAccountDetails = function(){
$http({
method : "GET",
url : appConfig.appUri + "account/accounts"
url : appConfig.appUri + "accounts"
}).then(function mySuccess(response) {
if(response.data.length > 10){
$scope.gridOptions.enablePaginationControls = true;
......@@ -112,7 +112,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
function deleteAccountRole(accountId){
var req = {
method : 'DELETE',
url : appConfig.appUri+ "account/accounts?accountId="+accountId
url : appConfig.appUri+ "accounts?accountId="+accountId
}
$http(req).then(function mySuccess(response) {
$scope.result = "Success";
......
......@@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.nisum.mytime.controller.AccountController;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.service.IAccountService;
import com.nisum.mytime.service.AccountService;
import com.nisum.mytime.service.impl.AccountService;
public class AccountControllerTest {
......
......@@ -20,16 +20,16 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.nisum.mytime.controller.AttendanceController;
import com.nisum.mytime.model.AttendenceData;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.service.AttendanceService;
import com.nisum.mytime.service.UserService;
import com.nisum.mytime.service.IAttendanceService;
import com.nisum.mytime.service.IEmployeeService;
public class AttendanceControllerTest {
@Mock
UserService userService;
IEmployeeService userService;
@Mock
AttendanceService attendanceService;
IAttendanceService attendanceService;
@InjectMocks
AttendanceController attendanceController;
......
......@@ -17,12 +17,12 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nisum.mytime.controller.EmailController;
import com.nisum.mytime.model.EmailDomain;
import com.nisum.mytime.service.MailService;
import com.nisum.mytime.service.IMailService;
public class EmailControllerTest {
@Mock
MailService mailService;
IMailService mailService;
@InjectMocks
EmailController emailController;
......
......@@ -29,7 +29,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nisum.mytime.controller.UserController;
import com.nisum.mytime.controller.EmployeeController;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Designation;
import com.nisum.mytime.model.Domain;
......@@ -39,26 +39,50 @@ import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.model.Shift;
import com.nisum.mytime.model.Skill;
import com.nisum.mytime.service.RoleMappingService;
import com.nisum.mytime.service.UserService;
import com.nisum.mytime.service.IRoleMappingService;
import com.nisum.mytime.service.impl.DesignationService;
import com.nisum.mytime.service.impl.EmployeeLocationService;
import com.nisum.mytime.service.impl.MasterDataService;
import com.nisum.mytime.service.impl.OrgLocationService;
import com.nisum.mytime.service.impl.ShiftService;
import com.nisum.mytime.service.impl.SkillService;
import com.nisum.mytime.service.IEmployeeService;
public class UserControllerTest {
public class EmployeeControllerTest {
@Mock
UserService userService;
IEmployeeService employeeService;
@Mock
RoleMappingService roleMappingService;
IRoleMappingService roleMappingService;
@InjectMocks
UserController userController;
EmployeeController employeeController;
@InjectMocks
EmployeeLocationService empLocationService;
@InjectMocks
ShiftService shiftService;
@InjectMocks
DesignationService designationService;
@InjectMocks
SkillService skillService;
@InjectMocks
OrgLocationService orgLocationService;
@InjectMocks
MasterDataService masterDataService;
private MockMvc mockMvc;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.standaloneSetup(userController).build();
mockMvc = MockMvcBuilders.standaloneSetup(employeeController).build();
}
@Test
......@@ -69,10 +93,10 @@ public class UserControllerTest {
"Male", null, new Date(2020 - 01 - 01), null, new Date(2018 - 01 - 01), new Date(2018 - 02 - 15),
new Date(2018 - 02 - 15), null, "Mahesh", "Mahesh");
;
when(userService.getEmployeesRole("mdeekonda@nisum.com")).thenReturn(employeesRole);
when(employeeService.getEmployeeByEmaillId("mdeekonda@nisum.com")).thenReturn(employeesRole);
mockMvc.perform(get("/user/employee").param("emailId", "mdeekonda@nisum.com"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeesRole("mdeekonda@nisum.com");
verify(employeeService).getEmployeeByEmaillId("mdeekonda@nisum.com");
}
@Test
......@@ -82,11 +106,11 @@ public class UserControllerTest {
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),
new Date(2018 - 02 - 15), null, "Mahesh", "Mahesh");
when(userService.getEmployeesRole("mdeekonda@nisum.com")).thenReturn(employeesRole);
when(employeeService.getEmployeeByEmaillId("mdeekonda@nisum.com")).thenReturn(employeesRole);
when(roleMappingService.getEmployeeRole(employeesRole.getEmployeeId())).thenReturn("Delivery Lead");
mockMvc.perform(get("/user/employee").param("emailId", "mdeekonda@nisum.com"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeesRole("mdeekonda@nisum.com");
verify(employeeService).getEmployeeByEmaillId("mdeekonda@nisum.com");
verify(roleMappingService).getEmployeeRole("16694");
}
......@@ -98,11 +122,11 @@ public class UserControllerTest {
new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh");
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole);
when(userService.assigingEmployeeRole(anyObject(), anyObject())).thenReturn(employeeRole);
when(employeeService.createEmployee(anyObject(), anyObject())).thenReturn(employeeRole);
mockMvc.perform(post("/user/assignEmployeeRole").param("empId", "16999")
.contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).assigingEmployeeRole(anyObject(), anyObject());
verify(employeeService).createEmployee(anyObject(), anyObject());
}
@Test
......@@ -113,27 +137,27 @@ public class UserControllerTest {
new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), "Mahesh", "Mahesh");
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole2);
when(userService.updateEmployeeRole(anyObject(), anyObject())).thenReturn(employeeRole2);
when(employeeService.updateEmployeeRole(anyObject(), anyObject())).thenReturn(employeeRole2);
mockMvc.perform(post("/user/updateEmployeeRole").param("empId", "16999")
.contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).updateEmployeeRole(anyObject(), anyObject());
verify(employeeService).updateEmployeeRole(anyObject(), anyObject());
}
@Test
public void testdeleteEmployee() throws Exception {
mockMvc.perform(delete("/user/deleteEmployee").param("empId", "16127"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).deleteEmployee("16127");
verify(employeeService).deleteEmployee("16127");
}
@Test
public void testgetUserRoles() throws Exception {
List<Employee> employeesRole3 = CreateUserRoles();
when(userService.getEmployeeRoles()).thenReturn(employeesRole3);
when(employeeService.getActiveEmployees()).thenReturn(employeesRole3);
mockMvc.perform(get("/user/getUserRoles").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeeRoles();
verify(employeeService).getActiveEmployees();
}
@Test
......@@ -143,12 +167,12 @@ public class UserControllerTest {
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),
new Date(2018 - 02 - 15), null, "Mahesh", "Mahesh");
when(userService.getEmployeesRoleData("16694")).thenReturn(employeesRole);
when(employeeService.getEmployeesRoleData("16694")).thenReturn(employeesRole);
mockMvc.perform(
get("/user/getEmployeeRoleData").param("empId", "16694").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$.employeeId", is("16694")))
.andDo(print());
verify(userService).getEmployeesRoleData("16694");
verify(employeeService).getEmployeesRoleData("16694");
}
@Test
......@@ -159,11 +183,11 @@ public class UserControllerTest {
"16090", "Dharmendra Kumar Jampana", "Hyderabad", new Date(2020 - 01 - 01), new Date(2018 - 01 - 01),
new Date(2018 - 02 - 15), new Date(2018 - 02 - 15), true);
empLocList.add(empLocation);
when(userService.getEmployeeLocationDetails("16090")).thenReturn(empLocList);
when(empLocationService.getEmployeeLocationDetails("16090")).thenReturn(empLocList);
mockMvc.perform(get("/user/getEmployeeLocations").param("employeeId", "16090")
.contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeeLocationDetails("16090");
verify(empLocationService).getEmployeeLocationDetails("16090");
}
@Test
......@@ -173,12 +197,12 @@ public class UserControllerTest {
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),
new Date(2018 - 02 - 15), "Mahesh", "Mahesh");
when(userService.getEmployeeRoleDataForSearchCriteria("dummy@nisum.com", "emailId")).thenReturn(employeesRole);
when(employeeService.getEmployeeRoleDataForSearchCriteria("dummy@nisum.com", "emailId")).thenReturn(employeesRole);
mockMvc.perform(get("/user/getEmployeeRoleDataForSearchCriteria").param("searchId", "dummy@nisum.com")
.param("searchAttribute", "emailId").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$.employeeId", is("16209")))
.andDo(print());
verify(userService).getEmployeeRoleDataForSearchCriteria("dummy@nisum.com", "emailId");
verify(employeeService).getEmployeeRoleDataForSearchCriteria("dummy@nisum.com", "emailId");
}
@Test
......@@ -189,13 +213,13 @@ public class UserControllerTest {
null, null, new Date(2020 - 01 - 01), new Date(2018 - 01 - 01), new Date(2018 - 02 - 15),
new Date(2018 - 02 - 15), "Mahesh", "Mahesh");
when(userService.getEmployeeRoleDataForSearchCriteria("Mahesh Kumar Gutam", "employeeName"))
when(employeeService.getEmployeeRoleDataForSearchCriteria("Mahesh Kumar Gutam", "employeeName"))
.thenReturn(employeesRole);
mockMvc.perform(get("/user/getEmployeeRoleDataForSearchCriteria").param("searchId", "Mahesh Kumar Gutam")
.param("searchAttribute", "employeeName").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$.employeeId", is("16209")))
.andDo(print());
verify(userService).getEmployeeRoleDataForSearchCriteria("Mahesh Kumar Gutam", "employeeName");
verify(employeeService).getEmployeeRoleDataForSearchCriteria("Mahesh Kumar Gutam", "employeeName");
}
@Test
......@@ -216,51 +240,51 @@ public class UserControllerTest {
details.add("16111");
details.add("Mahesh Mudrakolu");
details.add("mmahesh@nisum.com");
when(userService.getEmployeeDetailsForAutocomplete()).thenReturn(details);
when(employeeService.getEmployeeDetailsForAutocomplete()).thenReturn(details);
mockMvc.perform(get("/user/getEmployeeDetailsForAutocomplete").contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(MockMvcResultMatchers.status().isOk()).andDo(print());
verify(userService).getEmployeeDetailsForAutocomplete();
verify(employeeService).getEmployeeDetailsForAutocomplete();
}
@Test
public void testgetManagers() throws Exception {
List<Employee> employeesRole4 = CreateUserRoles();
System.out.println(employeesRole4);
when(userService.getEmployeeRoles()).thenReturn(employeesRole4);
when(employeeService.getActiveEmployees()).thenReturn(employeesRole4);
mockMvc.perform(get("/user/getManagers")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeeRoles();
verify(employeeService).getActiveEmployees();
}
@Test
public void testgetAllShifts() throws Exception {
List<Shift> shifts = CreateShifts();
when(userService.getAllShifts()).thenReturn(shifts);
when(shiftService.getAllShifts()).thenReturn(shifts);
mockMvc.perform(get("/user/getAllShifts")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getAllShifts();
verify(shiftService).getAllShifts();
}
@Test
public void testgetAllDesignations() throws Exception {
List<Designation> designation = CreateDesignations();
when(userService.getAllDesignations()).thenReturn(designation);
when(designationService.getAllDesignations()).thenReturn(designation);
mockMvc.perform(get("/user/getAllDesignations")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getAllDesignations();
verify(designationService).getAllDesignations();
}
@Test
public void testgetTechnologies() throws Exception {
List<Skill> skills = CreateSkill();
System.out.println(skills);
when(userService.getTechnologies()).thenReturn(skills);
when(skillService.getTechnologies()).thenReturn(skills);
mockMvc.perform(get("/user/getSkills")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getTechnologies();
verify(skillService).getTechnologies();
}
@Test
public void testgetLocations() throws Exception {
when(userService.getLocations()).thenReturn(locations());
when(orgLocationService.getLocations()).thenReturn(locations());
mockMvc.perform(get("/user/getLocations")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService, atLeastOnce()).getLocations();
verify(orgLocationService, atLeastOnce()).getLocations();
}
@Test
......@@ -273,45 +297,45 @@ public class UserControllerTest {
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole);
System.out.println(jsonString);
when(userService.updateProfile(anyObject())).thenReturn(employeeRole);
when(employeeService.updateProfile(anyObject())).thenReturn(employeeRole);
mockMvc.perform(post("/user/updateProfile").contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).updateProfile(anyObject());
verify(employeeService).updateProfile(anyObject());
}
@Test
public void getAccounts() throws Exception {
List<Account> account = CreateAccount();
System.out.println(account);
when(userService.getAccounts()).thenReturn(account);
when(employeeService.getAccounts()).thenReturn(account);
mockMvc.perform(get("/user/getAccounts")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getAccounts();
verify(employeeService).getAccounts();
}
@Test
public void testGetMasterData() throws Exception {
List<MasterData> masterDataMap = masterData();
when(userService.getMasterData()).thenReturn(masterDataMap);
when(masterDataService.getMasterData()).thenReturn(masterDataMap);
mockMvc.perform(get("/user/getMasterData")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getMasterData();
verify(masterDataService).getMasterData();
}
@Test
public void testGetEmployeeByStatus() throws Exception {
List<Employee> empRolesList = employeeRoles();
when(userService.getEmployeesByStatus("Active")).thenReturn(empRolesList);
when(employeeService.getEmployeesByStatus("Active")).thenReturn(empRolesList);
mockMvc.perform(get("/user/getEmployeeByStatus").param("status", "Active"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getEmployeesByStatus("Active");
verify(employeeService).getEmployeesByStatus("Active");
}
@Test
public void testgetdomains() throws Exception {
when(userService.getDomains("Acc001")).thenReturn(domains());
when(employeeService.getDomains("Acc001")).thenReturn(domains());
mockMvc.perform(get("/user/getDomains").param("accountId", "Acc001"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getDomains("Acc001");
verify(employeeService).getDomains("Acc001");
}
......@@ -331,10 +355,10 @@ public class UserControllerTest {
dlList.add(dl1);
dlList.add(dl2);
when(userService.getDeliveryLeads("DOM001")).thenReturn(dlList);
when(employeeService.getDeliveryLeads("DOM001")).thenReturn(dlList);
mockMvc.perform(get("/user/getDeliveryLeads").param("domainId", "DOM001"))
.andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).getDeliveryLeads("DOM001");
verify(employeeService).getDeliveryLeads("DOM001");
}
......
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