Unverified Commit 3a919a10 authored by rsayannagari-nisum-com's avatar rsayannagari-nisum-com Committed by GitHub

Merge pull request #2 from nisum-inc/MT-43

MT-43[Rajeshekar]: Added work location feature
parents 00b2f4e0 1b5f9eab
...@@ -18,6 +18,7 @@ import com.nisum.mytime.exception.handler.MyTimeException; ...@@ -18,6 +18,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account; import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Designation; import com.nisum.mytime.model.Designation;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.Shift; import com.nisum.mytime.model.Shift;
import com.nisum.mytime.model.Skill; import com.nisum.mytime.model.Skill;
import com.nisum.mytime.service.UserService; import com.nisum.mytime.service.UserService;
...@@ -29,92 +30,135 @@ public class UserController { ...@@ -29,92 +30,135 @@ public class UserController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/employee", method = RequestMethod.GET,
public ResponseEntity<EmployeeRoles> getEmployeeRole(@RequestParam("emailId") String emailId) produces = MediaType.APPLICATION_JSON_VALUE)
throws MyTimeException { public ResponseEntity<EmployeeRoles> getEmployeeRole(
@RequestParam("emailId") String emailId) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId); EmployeeRoles employeesRole = userService.getEmployeesRole(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
@RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST,
public ResponseEntity<EmployeeRoles> assigingEmployeeRole(@RequestBody EmployeeRoles employeeRoles) produces = MediaType.APPLICATION_JSON_VALUE,
throws MyTimeException { consumes = MediaType.APPLICATION_JSON_VALUE)
EmployeeRoles employeeRole = userService.assigingEmployeeRole(employeeRoles); public ResponseEntity<EmployeeRoles> assigingEmployeeRole(
@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService
.assigingEmployeeRole(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST,
public ResponseEntity<EmployeeRoles> updateEmployeeRole(@RequestBody EmployeeRoles employeeRoles) produces = MediaType.APPLICATION_JSON_VALUE,
throws MyTimeException { consumes = MediaType.APPLICATION_JSON_VALUE)
EmployeeRoles employeeRole = userService.updateEmployeeRole(employeeRoles); public ResponseEntity<EmployeeRoles> updateEmployeeRole(
@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService
.updateEmployeeRole(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
@RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE) @RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE,
public ResponseEntity<String> deleteEmployee(@RequestParam("empId") String empId) throws MyTimeException { produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> deleteEmployee(
@RequestParam("empId") String empId) throws MyTimeException {
userService.deleteEmployee(empId); userService.deleteEmployee(empId);
return new ResponseEntity<>("Success", HttpStatus.OK); return new ResponseEntity<>("Success", HttpStatus.OK);
} }
@RequestMapping(value = "/getUserRoles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getUserRoles", method = RequestMethod.GET,
public ResponseEntity<List<EmployeeRoles>> getUserRoles() throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getUserRoles()
throws MyTimeException {
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles(); List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles();
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET,
public ResponseEntity<EmployeeRoles> getEmployeeRoleData(@RequestParam("empId") String empId) produces = MediaType.APPLICATION_JSON_VALUE)
throws MyTimeException { public ResponseEntity<EmployeeRoles> getEmployeeRoleData(
@RequestParam("empId") String empId) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId); EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
@RequestMapping(value = "/getManagers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getManagers", method = RequestMethod.GET,
public ResponseEntity<List<EmployeeRoles>> getManagers() throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getManagers()
throws MyTimeException {
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles(); List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles();
List<EmployeeRoles> managers = employeesRoles.stream() List<EmployeeRoles> managers = employeesRoles.stream()
.filter(e -> ("Director".equalsIgnoreCase(e.getRole()) .filter(e -> ("Director".equalsIgnoreCase(e.getRole())
|| "Delivery Manager".equalsIgnoreCase(e.getRole()) || "Manager".equalsIgnoreCase(e.getRole()) || "Delivery Manager".equalsIgnoreCase(e.getRole())
|| "HR Manager".equalsIgnoreCase(e.getRole()) || "Lead".equalsIgnoreCase(e.getRole()))) || "Manager".equalsIgnoreCase(e.getRole())
.sorted(Comparator.comparing(EmployeeRoles::getEmployeeName)).collect(Collectors.toList()); || "HR Manager".equalsIgnoreCase(e.getRole())
|| "Lead".equalsIgnoreCase(e.getRole())))
.sorted(Comparator.comparing(EmployeeRoles::getEmployeeName))
.collect(Collectors.toList());
return new ResponseEntity<>(managers, HttpStatus.OK); return new ResponseEntity<>(managers, HttpStatus.OK);
} }
@RequestMapping(value = "/getAllShifts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getAllShifts", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllShifts() throws MyTimeException { public ResponseEntity<List<String>> getAllShifts() throws MyTimeException {
List<String> shifts = userService.getAllShifts().stream().filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())) List<String> shifts = userService.getAllShifts().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Shift::getShiftName).sorted().collect(Collectors.toList()); .map(Shift::getShiftName).sorted().collect(Collectors.toList());
return new ResponseEntity<>(shifts, HttpStatus.OK); return new ResponseEntity<>(shifts, HttpStatus.OK);
} }
@RequestMapping(value = "/getAllDesignations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getAllDesignations", method = RequestMethod.GET,
public ResponseEntity<List<String>> getAllDesignations() throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllDesignations()
throws MyTimeException {
List<String> designations = userService.getAllDesignations().stream() List<String> designations = userService.getAllDesignations().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Designation::getDesignationName).sorted() .filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Designation::getDesignationName).sorted()
.collect(Collectors.toList()); .collect(Collectors.toList());
return new ResponseEntity<>(designations, HttpStatus.OK); return new ResponseEntity<>(designations, HttpStatus.OK);
} }
@RequestMapping(value = "/getSkills", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getSkills", method = RequestMethod.GET,
public ResponseEntity<List<String>> getTechnologies() throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getTechnologies()
throws MyTimeException {
List<String> technologies = userService.getTechnologies().stream() List<String> technologies = userService.getTechnologies().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Skill::getSkillName).sorted() .filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.collect(Collectors.toList()); .map(Skill::getSkillName).sorted().collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK); return new ResponseEntity<>(technologies, HttpStatus.OK);
} }
@RequestMapping(value = "/updateProfile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getLocations", method = RequestMethod.GET,
public ResponseEntity<EmployeeRoles> updateProfile(@RequestBody EmployeeRoles employeeRoles) produces = MediaType.APPLICATION_JSON_VALUE)
throws MyTimeException { 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<EmployeeRoles> updateProfile(
@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService.updateProfile(employeeRoles); EmployeeRoles employeeRole = userService.updateProfile(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
@RequestMapping(value = "/getAccounts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getAccounts", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAccounts() throws MyTimeException { public ResponseEntity<List<String>> getAccounts() throws MyTimeException {
List<String> technologies = userService.getAccounts().stream().filter(e -> "Y".equalsIgnoreCase(e.getStatus())) List<String> technologies = userService.getAccounts().stream()
.map(Account::getAccountName).sorted().collect(Collectors.toList()); .filter(e -> "Y".equalsIgnoreCase(e.getStatus()))
.map(Account::getAccountName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK); return new ResponseEntity<>(technologies, HttpStatus.OK);
} }
} }
\ No newline at end of file
...@@ -34,6 +34,7 @@ public class EmployeeRoles implements Serializable { ...@@ -34,6 +34,7 @@ public class EmployeeRoles implements Serializable {
private String designation; private String designation;
private String shift; private String shift;
private String baseTechnology; private String baseTechnology;
private String empLocation;
private String technologyKnown; private String technologyKnown;
private String mobileNumber; private String mobileNumber;
private String alternateMobileNumber; private String alternateMobileNumber;
......
package com.nisum.mytime.model;
import java.io.Serializable;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Locations")
public class Location implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private ObjectId id;
private String locationCode;
private String location;
private String country;
private String state;
private String city;
private boolean activeStatus;
private String comments;
}
package com.nisum.mytime.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Location;
public interface LocationRepo extends MongoRepository<Location, String> {
}
\ No newline at end of file
...@@ -7,20 +7,25 @@ import com.nisum.mytime.model.Account; ...@@ -7,20 +7,25 @@ import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Designation; import com.nisum.mytime.model.Designation;
import com.nisum.mytime.model.EmpLoginData; import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.Shift; import com.nisum.mytime.model.Shift;
import com.nisum.mytime.model.Skill; import com.nisum.mytime.model.Skill;
public interface UserService { public interface UserService {
Boolean fetchEmployeesData(String perticularDate,boolean resynchFlag) throws MyTimeException; Boolean fetchEmployeesData(String perticularDate, boolean resynchFlag)
throws MyTimeException;
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) throws MyTimeException; List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException;
List<EmployeeRoles> getEmployeeRoles() throws MyTimeException; List<EmployeeRoles> getEmployeeRoles() throws MyTimeException;
EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles) throws MyTimeException; EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles)
throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException; String generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException;
EmployeeRoles getEmployeesRole(String emailId); EmployeeRoles getEmployeesRole(String emailId);
...@@ -36,7 +41,10 @@ public interface UserService { ...@@ -36,7 +41,10 @@ public interface UserService {
List<Skill> getTechnologies() throws MyTimeException; List<Skill> getTechnologies() throws MyTimeException;
public EmployeeRoles updateProfile(EmployeeRoles employeeRoles) throws MyTimeException; public EmployeeRoles updateProfile(EmployeeRoles employeeRoles)
throws MyTimeException;
public List<Account> getAccounts() throws MyTimeException; public List<Account> getAccounts() throws MyTimeException;
List<Location> getLocations() throws MyTimeException;
} }
...@@ -16,12 +16,14 @@ import com.nisum.mytime.model.Account; ...@@ -16,12 +16,14 @@ import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Designation; import com.nisum.mytime.model.Designation;
import com.nisum.mytime.model.EmpLoginData; import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.model.Shift; import com.nisum.mytime.model.Shift;
import com.nisum.mytime.model.Skill; import com.nisum.mytime.model.Skill;
import com.nisum.mytime.repository.AccountRepo; import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.repository.DesignationRepo; import com.nisum.mytime.repository.DesignationRepo;
import com.nisum.mytime.repository.EmployeeRolesRepo; import com.nisum.mytime.repository.EmployeeRolesRepo;
import com.nisum.mytime.repository.LocationRepo;
import com.nisum.mytime.repository.ProjectTeamMatesRepo; import com.nisum.mytime.repository.ProjectTeamMatesRepo;
import com.nisum.mytime.repository.ShiftRepo; import com.nisum.mytime.repository.ShiftRepo;
import com.nisum.mytime.repository.TechnologyRepo; import com.nisum.mytime.repository.TechnologyRepo;
...@@ -48,6 +50,9 @@ public class UserServiceImpl implements UserService { ...@@ -48,6 +50,9 @@ public class UserServiceImpl implements UserService {
@Autowired @Autowired
private TechnologyRepo technologyRepo; private TechnologyRepo technologyRepo;
@Autowired
private LocationRepo locationRepo;
@Autowired @Autowired
private EmployeeDataService employeeDataBaseService; private EmployeeDataService employeeDataBaseService;
...@@ -58,18 +63,22 @@ public class UserServiceImpl implements UserService { ...@@ -58,18 +63,22 @@ public class UserServiceImpl implements UserService {
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Override @Override
public Boolean fetchEmployeesData(String perticularDate,boolean resynchFlag) throws MyTimeException { public Boolean fetchEmployeesData(String perticularDate,
return employeeDataBaseService.fetchEmployeesData(perticularDate,resynchFlag); boolean resynchFlag) throws MyTimeException {
return employeeDataBaseService.fetchEmployeesData(perticularDate,
resynchFlag);
} }
@Override @Override
public List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) public List<EmpLoginData> employeeLoginsBasedOnDate(long id,
throws MyTimeException { String fromDate, String toDate) throws MyTimeException {
return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates(id, fromDate, toDate); return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates(id,
fromDate, toDate);
} }
@Override @Override
public String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException { public String generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate); return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
} }
...@@ -79,7 +88,8 @@ public class UserServiceImpl implements UserService { ...@@ -79,7 +88,8 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles) throws MyTimeException { public EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles)
throws MyTimeException {
employeeRoles.setCreatedOn(new Date()); employeeRoles.setCreatedOn(new Date());
return employeeRolesRepo.save(employeeRoles); return employeeRolesRepo.save(employeeRoles);
} }
...@@ -98,7 +108,8 @@ public class UserServiceImpl implements UserService { ...@@ -98,7 +108,8 @@ public class UserServiceImpl implements UserService {
@Override @Override
public EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles) { public EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles) {
Query query = new Query(Criteria.where("employeeId").is(employeeRoles.getEmployeeId())); Query query = new Query(
Criteria.where("employeeId").is(employeeRoles.getEmployeeId()));
Update update = new Update(); Update update = new Update();
update.set("employeeName", employeeRoles.getEmployeeName()); update.set("employeeName", employeeRoles.getEmployeeName());
update.set("emailId", employeeRoles.getEmailId()); update.set("emailId", employeeRoles.getEmailId());
...@@ -107,15 +118,20 @@ public class UserServiceImpl implements UserService { ...@@ -107,15 +118,20 @@ public class UserServiceImpl implements UserService {
FindAndModifyOptions options = new FindAndModifyOptions(); FindAndModifyOptions options = new FindAndModifyOptions();
options.returnNew(true); options.returnNew(true);
options.upsert(true); options.upsert(true);
EmployeeRoles emp= mongoTemplate.findAndModify(query, update, options, EmployeeRoles.class); EmployeeRoles emp = mongoTemplate.findAndModify(query, update, options,
EmployeeRoles.class);
try { try {
List<ProjectTeamMate> employeeProfiles= projectTeamMatesRepo.findByEmployeeId(emp.getEmployeeId()); List<ProjectTeamMate> employeeProfiles = projectTeamMatesRepo
if(employeeProfiles!=null&&!employeeProfiles.isEmpty()) { .findByEmployeeId(emp.getEmployeeId());
for(ProjectTeamMate profile:employeeProfiles){ if (employeeProfiles != null && !employeeProfiles.isEmpty()) {
profile.setRole(emp.getRole());; for (ProjectTeamMate profile : employeeProfiles) {
profile.setRole(emp.getRole());
;
projectTeamMatesRepo.save(profile); projectTeamMatesRepo.save(profile);
} }
}}catch(Exception e) {} }
} catch (Exception e) {
}
return emp; return emp;
} }
...@@ -145,40 +161,62 @@ public class UserServiceImpl implements UserService { ...@@ -145,40 +161,62 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public EmployeeRoles updateProfile(EmployeeRoles employeeRoles) throws MyTimeException { public List<Location> getLocations() throws MyTimeException {
boolean mobileNumberChnaged=false; return locationRepo.findAll();
boolean designationChnaged=false;
employeeRoles.setLastModifiedOn(new Date());
EmployeeRoles existingEmployee=employeeRolesRepo.findByEmployeeId(employeeRoles.getEmployeeId());
String newMobileNumber=employeeRoles.getMobileNumber();
String designation=employeeRoles.getDesignation();
if(newMobileNumber!=null&&!newMobileNumber.equalsIgnoreCase("")) {
if((existingEmployee!=null&&existingEmployee.getMobileNumber()!=null&&!existingEmployee.getMobileNumber().equalsIgnoreCase(newMobileNumber) )|| (existingEmployee.getMobileNumber()==null )){
mobileNumberChnaged=true;
} }
}
if(designation!=null&&!designation.equalsIgnoreCase("")) { @Override
if((existingEmployee!=null&&existingEmployee.getDesignation()!=null&&!existingEmployee.getDesignation().equalsIgnoreCase(newMobileNumber) )|| (existingEmployee.getDesignation()==null )){ public EmployeeRoles updateProfile(EmployeeRoles employeeRoles)
designationChnaged=true; throws MyTimeException {
boolean mobileNumberChnaged = false;
boolean designationChnaged = false;
employeeRoles.setLastModifiedOn(new Date());
EmployeeRoles existingEmployee = employeeRolesRepo
.findByEmployeeId(employeeRoles.getEmployeeId());
String newMobileNumber = employeeRoles.getMobileNumber();
String designation = employeeRoles.getDesignation();
if (newMobileNumber != null && !newMobileNumber.equalsIgnoreCase("")) {
if ((existingEmployee != null
&& existingEmployee.getMobileNumber() != null
&& !existingEmployee.getMobileNumber()
.equalsIgnoreCase(newMobileNumber))
|| (existingEmployee.getMobileNumber() == null)) {
mobileNumberChnaged = true;
}
}
if (designation != null && !designation.equalsIgnoreCase("")) {
if ((existingEmployee != null
&& existingEmployee.getDesignation() != null
&& !existingEmployee.getDesignation()
.equalsIgnoreCase(newMobileNumber))
|| (existingEmployee.getDesignation() == null)) {
designationChnaged = true;
} }
} }
existingEmployee.setDesignation(employeeRoles.getDesignation()); existingEmployee.setDesignation(employeeRoles.getDesignation());
existingEmployee.setMobileNumber(employeeRoles.getMobileNumber()); existingEmployee.setMobileNumber(employeeRoles.getMobileNumber());
existingEmployee.setAlternateMobileNumber(employeeRoles.getAlternateMobileNumber()); existingEmployee.setAlternateMobileNumber(
employeeRoles.getAlternateMobileNumber());
existingEmployee.setPersonalEmailId(employeeRoles.getPersonalEmailId()); existingEmployee.setPersonalEmailId(employeeRoles.getPersonalEmailId());
existingEmployee.setBaseTechnology(employeeRoles.getBaseTechnology()); existingEmployee.setBaseTechnology(employeeRoles.getBaseTechnology());
existingEmployee.setTechnologyKnown(employeeRoles.getTechnologyKnown()); existingEmployee.setTechnologyKnown(employeeRoles.getTechnologyKnown());
EmployeeRoles employeeRolesDB= employeeRolesRepo.save(existingEmployee); EmployeeRoles employeeRolesDB = employeeRolesRepo
if(mobileNumberChnaged || designationChnaged) { .save(existingEmployee);
if (mobileNumberChnaged || designationChnaged) {
try { try {
List<ProjectTeamMate> employeeProfiles= projectTeamMatesRepo.findByEmployeeId(employeeRoles.getEmployeeId()); List<ProjectTeamMate> employeeProfiles = projectTeamMatesRepo
if(employeeProfiles!=null&&!employeeProfiles.isEmpty()) { .findByEmployeeId(employeeRoles.getEmployeeId());
for(ProjectTeamMate profile:employeeProfiles){ if (employeeProfiles != null && !employeeProfiles.isEmpty()) {
profile.setDesignation(employeeRolesDB.getDesignation()); for (ProjectTeamMate profile : employeeProfiles) {
profile.setMobileNumber(employeeRolesDB.getMobileNumber()); profile.setDesignation(
employeeRolesDB.getDesignation());
profile.setMobileNumber(
employeeRolesDB.getMobileNumber());
projectTeamMatesRepo.save(profile); projectTeamMatesRepo.save(profile);
} }
}}catch(Exception e) {} }
} catch (Exception e) {
}
} }
return employeeRolesDB; return employeeRolesDB;
......
...@@ -11,6 +11,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -11,6 +11,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
getAllShifts(); getAllShifts();
getAllDesignations(); getAllDesignations();
getAllTechnologies(); getAllTechnologies();
getAllLocations();
getAllAccounts(); getAllAccounts();
$("#start").trigger("click"); $("#start").trigger("click");
} }
...@@ -86,6 +87,16 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -86,6 +87,16 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
}); });
}; };
function getAllLocations(){
$http({
method : "GET",
url : appConfig.appUri + "user/getLocations"
}).then(function mySuccess(response) {
myFactory.setLocations(response.data);
}, function myError(response) {
});
};
function getAllAccounts(){ function getAllAccounts(){
$http({ $http({
method : "GET", method : "GET",
...@@ -125,7 +136,8 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -125,7 +136,8 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
$scope.empName = dataToPass.getName(); $scope.empName = dataToPass.getName();
$scope.empEmail = dataToPass.getEmail(); $scope.empEmail = dataToPass.getEmail();
$scope.empShift; $scope.empShift;
$scope.shifts = myFactory.getTechnologies(); //["Shift 1(09:00 AM - 06:00 PM)","Shift 2(03:30 PM - 12:30 PM)", "Shift 3(09:00 PM - 06:00 AM)"]; $scope.shifts = myFactory.getTechnologies();
$scope.locations = myFactory.getLocations();//["Shift 1(09:00 AM - 06:00 PM)","Shift 2(03:30 PM - 12:30 PM)", "Shift 3(09:00 PM - 06:00 AM)"];
$scope.getSelectedShift = function(){ $scope.getSelectedShift = function(){
if ($scope.empShift !== undefined) { if ($scope.empShift !== undefined) {
...@@ -134,6 +146,13 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -134,6 +146,13 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
return "Please select primary skill"; return "Please select primary skill";
} }
}; };
$scope.getSelectedLocation = function(){
if ($scope.empLocation !== undefined) {
return $scope.empLocation;
} else {
return "Please select work location";
}
};
$scope.validateEmpId = function(){ $scope.validateEmpId = function(){
var searchId = $scope.empId; var searchId = $scope.empId;
...@@ -171,6 +190,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -171,6 +190,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
var searchId = $scope.empId; var searchId = $scope.empId;
var empName = $scope.empName; var empName = $scope.empName;
var empShift = $scope.empShift; var empShift = $scope.empShift;
var empLocation = $scope.empLocation;
var mobileNumber = $scope.mobileNumber; var mobileNumber = $scope.mobileNumber;
if(searchId == ""){ if(searchId == ""){
...@@ -191,9 +211,13 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -191,9 +211,13 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
}else if(empShift == undefined){ }else if(empShift == undefined){
$scope.alertMsg = "Please select a primary skill"; $scope.alertMsg = "Please select a primary skill";
document.getElementById('empShift').focus(); document.getElementById('empShift').focus();
}
else if(empLocation == undefined){
$scope.alertMsg = "Please select a work location";
document.getElementById('empLocation').focus();
}else{ }else{
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "emailId": $scope.empEmail, "role": "Employee", "shift": "Shift 1(09:00 AM - 06:00 PM)","mobileNumber":$scope.mobileNumber,"baseTechnology": $scope.empShift}; var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "emailId": $scope.empEmail, "role": "Employee", "shift": "Shift 1(09:00 AM - 06:00 PM)","mobileNumber":$scope.mobileNumber,"baseTechnology": $scope.empShift,"empLocation": $scope.empLocation};
addEmployee(record); addEmployee(record);
} }
}; };
...@@ -313,7 +337,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -313,7 +337,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
auth2.disconnect(); auth2.disconnect();
//Clear if any values set to factory //Clear if any values set to factory
var menuItems = [], designations = [], accounts = [], technologies = [], shifts = []; var menuItems = [], designations = [], accounts = [], technologies = [], shifts = [],locations=[];
myFactory.setEmpId(""); myFactory.setEmpId("");
myFactory.setEmpName(""); myFactory.setEmpName("");
myFactory.setEmpEmailId(""); myFactory.setEmpEmailId("");
...@@ -325,7 +349,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -325,7 +349,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
myFactory.setAccounts(accounts); myFactory.setAccounts(accounts);
myFactory.setTechnologies(technologies); myFactory.setTechnologies(technologies);
myFactory.setShifts(shifts); myFactory.setShifts(shifts);
myFactory.setLocations(locations);
var element = document.getElementById('home'); var element = document.getElementById('home');
var path = "'templates/login.html'"; var path = "'templates/login.html'";
element.setAttribute("src", path); element.setAttribute("src", path);
......
...@@ -35,6 +35,7 @@ myApp.factory('myFactory', function() { ...@@ -35,6 +35,7 @@ myApp.factory('myFactory', function() {
var profileUrl = ""; var profileUrl = "";
var designations=""; var designations="";
var technologies=""; var technologies="";
var locations="";
var shifts=""; var shifts="";
var accounts=""; var accounts="";
function setEmpId(id) { function setEmpId(id) {
...@@ -95,6 +96,12 @@ myApp.factory('myFactory', function() { ...@@ -95,6 +96,12 @@ myApp.factory('myFactory', function() {
function getTechnologies() { function getTechnologies() {
return technologies; return technologies;
} }
function setLocations(locations1) {
locations = locations1;
}
function getLocations() {
return locations;
}
function setShifts(shifts1) { function setShifts(shifts1) {
shifts = shifts1; shifts = shifts1;
} }
...@@ -135,6 +142,8 @@ myApp.factory('myFactory', function() { ...@@ -135,6 +142,8 @@ myApp.factory('myFactory', function() {
getAccounts : getAccounts, getAccounts : getAccounts,
setTechnologies : setTechnologies, setTechnologies : setTechnologies,
getTechnologies : getTechnologies, getTechnologies : getTechnologies,
setLocations : setLocations,
getLocations : getLocations,
setShifts : setShifts, setShifts : setShifts,
getShifts : getShifts, getShifts : getShifts,
setTemplateUrl : setTemplateUrl, setTemplateUrl : setTemplateUrl,
......
...@@ -158,6 +158,20 @@ ...@@ -158,6 +158,20 @@
</div> </div>
</div>
<div class="row col-lg-12 col-xs-12">
<div class="col-lg-5 col-xs-6">
<p>
<b>Work Location</b>
</p>
</div>
<div class="col-lg-7 col-xs-6">
<p>
<b>:</b> {{profile.empLocation}}
</p>
</div>
</div> </div>
</div> </div>
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
<md-select ng-model="empShift" md-selected-text="getSelectedShift()" id="empShift"> <md-select ng-model="empShift" md-selected-text="getSelectedShift()" id="empShift">
<md-optgroup label="skills"> <md-option ng-value="shift" <md-optgroup label="skills"> <md-option ng-value="shift"
ng-repeat="shift in shifts">{{shift}}</md-option> </md-optgroup> </md-select> ng-repeat="shift in shifts">{{shift}}</md-option> </md-optgroup> </md-select>
<md-select ng-model="empLocation" md-selected-text="getSelectedLocation()" id="empLocation">
<md-optgroup label="locations"> <md-option ng-value="location"
ng-repeat="location in locations">{{location}}</md-option> </md-optgroup> </md-select>
<div role="alert"> <div role="alert">
<span class="error" style="color: red;">{{alertMsg}}</span> <span class="error" style="color: red;">{{alertMsg}}</span>
</div> </div>
......
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