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;
...@@ -26,95 +27,138 @@ import com.nisum.mytime.service.UserService; ...@@ -26,95 +27,138 @@ import com.nisum.mytime.service.UserService;
@RequestMapping("/user") @RequestMapping("/user")
public class UserController { 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(
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId); @RequestParam("emailId") String emailId) throws MyTimeException {
return new ResponseEntity<>(employeesRole, HttpStatus.OK); EmployeeRoles employeesRole = userService.getEmployeesRole(emailId);
} return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> assigingEmployeeRole(@RequestBody EmployeeRoles employeeRoles) @RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST,
throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE,
EmployeeRoles employeeRole = userService.assigingEmployeeRole(employeeRoles); consumes = MediaType.APPLICATION_JSON_VALUE)
return new ResponseEntity<>(employeeRole, HttpStatus.OK); public ResponseEntity<EmployeeRoles> assigingEmployeeRole(
} @RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) .assigingEmployeeRole(employeeRoles);
public ResponseEntity<EmployeeRoles> updateEmployeeRole(@RequestBody EmployeeRoles employeeRoles) return new ResponseEntity<>(employeeRole, HttpStatus.OK);
throws MyTimeException { }
EmployeeRoles employeeRole = userService.updateEmployeeRole(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); @RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST,
} produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity<EmployeeRoles> updateEmployeeRole(
public ResponseEntity<String> deleteEmployee(@RequestParam("empId") String empId) throws MyTimeException { @RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
userService.deleteEmployee(empId); EmployeeRoles employeeRole = userService
return new ResponseEntity<>("Success", HttpStatus.OK); .updateEmployeeRole(employeeRoles);
} return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/getUserRoles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getUserRoles() throws MyTimeException { @RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE,
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles(); produces = MediaType.TEXT_PLAIN_VALUE)
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); public ResponseEntity<String> deleteEmployee(
} @RequestParam("empId") String empId) throws MyTimeException {
userService.deleteEmployee(empId);
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) return new ResponseEntity<>("Success", HttpStatus.OK);
public ResponseEntity<EmployeeRoles> getEmployeeRoleData(@RequestParam("empId") String empId) }
throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId); @RequestMapping(value = "/getUserRoles", method = RequestMethod.GET,
return new ResponseEntity<>(employeesRole, HttpStatus.OK); produces = MediaType.APPLICATION_JSON_VALUE)
} public ResponseEntity<List<EmployeeRoles>> getUserRoles()
throws MyTimeException {
@RequestMapping(value = "/getManagers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles();
public ResponseEntity<List<EmployeeRoles>> getManagers() throws MyTimeException { return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles(); }
List<EmployeeRoles> managers = employeesRoles.stream()
.filter(e -> ("Director".equalsIgnoreCase(e.getRole()) @RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET,
|| "Delivery Manager".equalsIgnoreCase(e.getRole()) || "Manager".equalsIgnoreCase(e.getRole()) produces = MediaType.APPLICATION_JSON_VALUE)
|| "HR Manager".equalsIgnoreCase(e.getRole()) || "Lead".equalsIgnoreCase(e.getRole()))) public ResponseEntity<EmployeeRoles> getEmployeeRoleData(
.sorted(Comparator.comparing(EmployeeRoles::getEmployeeName)).collect(Collectors.toList()); @RequestParam("empId") String empId) throws MyTimeException {
return new ResponseEntity<>(managers, HttpStatus.OK); EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId);
} return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/getAllShifts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllShifts() throws MyTimeException { @RequestMapping(value = "/getManagers", method = RequestMethod.GET,
List<String> shifts = userService.getAllShifts().stream().filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())) produces = MediaType.APPLICATION_JSON_VALUE)
.map(Shift::getShiftName).sorted().collect(Collectors.toList()); public ResponseEntity<List<EmployeeRoles>> getManagers()
return new ResponseEntity<>(shifts, HttpStatus.OK); throws MyTimeException {
} List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles();
List<EmployeeRoles> managers = employeesRoles.stream()
@RequestMapping(value = "/getAllDesignations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) .filter(e -> ("Director".equalsIgnoreCase(e.getRole())
public ResponseEntity<List<String>> getAllDesignations() throws MyTimeException { || "Delivery Manager".equalsIgnoreCase(e.getRole())
List<String> designations = userService.getAllDesignations().stream() || "Manager".equalsIgnoreCase(e.getRole())
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Designation::getDesignationName).sorted() || "HR Manager".equalsIgnoreCase(e.getRole())
.collect(Collectors.toList()); || "Lead".equalsIgnoreCase(e.getRole())))
return new ResponseEntity<>(designations, HttpStatus.OK); .sorted(Comparator.comparing(EmployeeRoles::getEmployeeName))
} .collect(Collectors.toList());
return new ResponseEntity<>(managers, 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() @RequestMapping(value = "/getAllShifts", method = RequestMethod.GET,
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Skill::getSkillName).sorted() produces = MediaType.APPLICATION_JSON_VALUE)
.collect(Collectors.toList()); public ResponseEntity<List<String>> getAllShifts() throws MyTimeException {
return new ResponseEntity<>(technologies, HttpStatus.OK); 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 = "/updateProfile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) }
public ResponseEntity<EmployeeRoles> updateProfile(@RequestBody EmployeeRoles employeeRoles)
throws MyTimeException { @RequestMapping(value = "/getAllDesignations", method = RequestMethod.GET,
EmployeeRoles employeeRole = userService.updateProfile(employeeRoles); produces = MediaType.APPLICATION_JSON_VALUE)
return new ResponseEntity<>(employeeRole, HttpStatus.OK); public ResponseEntity<List<String>> getAllDesignations()
} throws MyTimeException {
List<String> designations = userService.getAllDesignations().stream()
@RequestMapping(value = "/getAccounts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) .filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
public ResponseEntity<List<String>> getAccounts() throws MyTimeException { .map(Designation::getDesignationName).sorted()
List<String> technologies = userService.getAccounts().stream().filter(e -> "Y".equalsIgnoreCase(e.getStatus())) .collect(Collectors.toList());
.map(Account::getAccountName).sorted().collect(Collectors.toList()); return new ResponseEntity<>(designations, HttpStatus.OK);
return new ResponseEntity<>(technologies, 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<EmployeeRoles> updateProfile(
@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService.updateProfile(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/getAccounts", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAccounts() throws MyTimeException {
List<String> technologies = userService.getAccounts().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getStatus()))
.map(Account::getAccountName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
}
} }
\ No newline at end of file
...@@ -20,25 +20,26 @@ import lombok.ToString; ...@@ -20,25 +20,26 @@ import lombok.ToString;
@Document(collection = "EmployeeRoles") @Document(collection = "EmployeeRoles")
public class EmployeeRoles implements Serializable { public class EmployeeRoles implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id
private String id;
private String employeeId;
private String employeeName;
private String emailId;
private String role;
private String designation;
private String shift;
private String baseTechnology;
private String empLocation;
private String technologyKnown;
private String mobileNumber;
private String alternateMobileNumber;
private String personalEmailId;
private Date createdOn;
private Date lastModifiedOn;
@Id
private String id;
private String employeeId;
private String employeeName;
private String emailId;
private String role;
private String designation;
private String shift;
private String baseTechnology;
private String technologyKnown;
private String mobileNumber;
private String alternateMobileNumber;
private String personalEmailId;
private Date createdOn;
private Date lastModifiedOn;
} }
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,36 +7,44 @@ import com.nisum.mytime.model.Account; ...@@ -7,36 +7,44 @@ 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);
void deleteEmployee(String empId); void deleteEmployee(String empId);
EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles); EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles);
EmployeeRoles getEmployeesRoleData(String empId); EmployeeRoles getEmployeesRoleData(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 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;
...@@ -30,157 +32,193 @@ import com.nisum.mytime.utils.PdfReportGenerator; ...@@ -30,157 +32,193 @@ import com.nisum.mytime.utils.PdfReportGenerator;
@Service("userService") @Service("userService")
public class UserServiceImpl implements UserService { public class UserServiceImpl implements UserService {
@Autowired @Autowired
private EmployeeRolesRepo employeeRolesRepo; private EmployeeRolesRepo employeeRolesRepo;
@Autowired @Autowired
private ProjectTeamMatesRepo projectTeamMatesRepo; private ProjectTeamMatesRepo projectTeamMatesRepo;
@Autowired @Autowired
private ShiftRepo shiftRepo; private ShiftRepo shiftRepo;
@Autowired @Autowired
private DesignationRepo designationRepo; private DesignationRepo designationRepo;
@Autowired @Autowired
private AccountRepo accountRepo; private AccountRepo accountRepo;
@Autowired @Autowired
private TechnologyRepo technologyRepo; private TechnologyRepo technologyRepo;
@Autowired @Autowired
private EmployeeDataService employeeDataBaseService; private LocationRepo locationRepo;
@Autowired @Autowired
private PdfReportGenerator pdfReportGenerator; private EmployeeDataService employeeDataBaseService;
@Autowired @Autowired
private MongoTemplate mongoTemplate; private PdfReportGenerator pdfReportGenerator;
@Override @Autowired
public Boolean fetchEmployeesData(String perticularDate,boolean resynchFlag) throws MyTimeException { private MongoTemplate mongoTemplate;
return employeeDataBaseService.fetchEmployeesData(perticularDate,resynchFlag);
} @Override
public Boolean fetchEmployeesData(String perticularDate,
@Override boolean resynchFlag) throws MyTimeException {
public List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) return employeeDataBaseService.fetchEmployeesData(perticularDate,
throws MyTimeException { resynchFlag);
return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates(id, fromDate, toDate); }
}
@Override
@Override public List<EmpLoginData> employeeLoginsBasedOnDate(long id,
public String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException { String fromDate, String toDate) throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate); return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates(id,
} fromDate, toDate);
}
@Override
public List<EmployeeRoles> getEmployeeRoles() throws MyTimeException { @Override
return employeeRolesRepo.findAll(); public String generatePdfReport(long id, String fromDate, String toDate)
} throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
@Override }
public EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles) throws MyTimeException {
employeeRoles.setCreatedOn(new Date()); @Override
return employeeRolesRepo.save(employeeRoles); public List<EmployeeRoles> getEmployeeRoles() throws MyTimeException {
} return employeeRolesRepo.findAll();
}
@Override
public EmployeeRoles getEmployeesRole(String emailId) { @Override
return employeeRolesRepo.findByEmailId(emailId); public EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles)
throws MyTimeException {
} employeeRoles.setCreatedOn(new Date());
return employeeRolesRepo.save(employeeRoles);
@Override }
public void deleteEmployee(String employeeId) {
EmployeeRoles role = employeeRolesRepo.findByEmployeeId(employeeId); @Override
employeeRolesRepo.delete(role); public EmployeeRoles getEmployeesRole(String emailId) {
} return employeeRolesRepo.findByEmailId(emailId);
@Override }
public EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles) {
Query query = new Query(Criteria.where("employeeId").is(employeeRoles.getEmployeeId())); @Override
Update update = new Update(); public void deleteEmployee(String employeeId) {
update.set("employeeName", employeeRoles.getEmployeeName()); EmployeeRoles role = employeeRolesRepo.findByEmployeeId(employeeId);
update.set("emailId", employeeRoles.getEmailId()); employeeRolesRepo.delete(role);
update.set("role", employeeRoles.getRole()); }
update.set("lastModifiedOn", new Date());
FindAndModifyOptions options = new FindAndModifyOptions(); @Override
options.returnNew(true); public EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles) {
options.upsert(true); Query query = new Query(
EmployeeRoles emp= mongoTemplate.findAndModify(query, update, options, EmployeeRoles.class); Criteria.where("employeeId").is(employeeRoles.getEmployeeId()));
try { Update update = new Update();
List<ProjectTeamMate> employeeProfiles= projectTeamMatesRepo.findByEmployeeId(emp.getEmployeeId()); update.set("employeeName", employeeRoles.getEmployeeName());
if(employeeProfiles!=null&&!employeeProfiles.isEmpty()) { update.set("emailId", employeeRoles.getEmailId());
for(ProjectTeamMate profile:employeeProfiles){ update.set("role", employeeRoles.getRole());
profile.setRole(emp.getRole());; update.set("lastModifiedOn", new Date());
projectTeamMatesRepo.save(profile); FindAndModifyOptions options = new FindAndModifyOptions();
} options.returnNew(true);
}}catch(Exception e) {} options.upsert(true);
return emp; EmployeeRoles emp = mongoTemplate.findAndModify(query, update, options,
} EmployeeRoles.class);
try {
@Override List<ProjectTeamMate> employeeProfiles = projectTeamMatesRepo
public EmployeeRoles getEmployeesRoleData(String employeeId) { .findByEmployeeId(emp.getEmployeeId());
return employeeRolesRepo.findByEmployeeId(employeeId); if (employeeProfiles != null && !employeeProfiles.isEmpty()) {
} for (ProjectTeamMate profile : employeeProfiles) {
profile.setRole(emp.getRole());
@Override ;
public List<Shift> getAllShifts() throws MyTimeException { projectTeamMatesRepo.save(profile);
return shiftRepo.findAll(); }
} }
} catch (Exception e) {
@Override }
public List<Designation> getAllDesignations() throws MyTimeException { return emp;
return designationRepo.findAll(); }
}
@Override
@Override public EmployeeRoles getEmployeesRoleData(String employeeId) {
public List<Account> getAccounts() throws MyTimeException { return employeeRolesRepo.findByEmployeeId(employeeId);
return accountRepo.findAll(); }
}
@Override
@Override public List<Shift> getAllShifts() throws MyTimeException {
public List<Skill> getTechnologies() throws MyTimeException { return shiftRepo.findAll();
return technologyRepo.findAll(); }
}
@Override
@Override public List<Designation> getAllDesignations() throws MyTimeException {
public EmployeeRoles updateProfile(EmployeeRoles employeeRoles) throws MyTimeException { return designationRepo.findAll();
boolean mobileNumberChnaged=false; }
boolean designationChnaged=false;
employeeRoles.setLastModifiedOn(new Date()); @Override
EmployeeRoles existingEmployee=employeeRolesRepo.findByEmployeeId(employeeRoles.getEmployeeId()); public List<Account> getAccounts() throws MyTimeException {
String newMobileNumber=employeeRoles.getMobileNumber(); return accountRepo.findAll();
String designation=employeeRoles.getDesignation(); }
if(newMobileNumber!=null&&!newMobileNumber.equalsIgnoreCase("")) {
if((existingEmployee!=null&&existingEmployee.getMobileNumber()!=null&&!existingEmployee.getMobileNumber().equalsIgnoreCase(newMobileNumber) )|| (existingEmployee.getMobileNumber()==null )){ @Override
mobileNumberChnaged=true; public List<Skill> getTechnologies() throws MyTimeException {
} return technologyRepo.findAll();
} }
if(designation!=null&&!designation.equalsIgnoreCase("")) {
if((existingEmployee!=null&&existingEmployee.getDesignation()!=null&&!existingEmployee.getDesignation().equalsIgnoreCase(newMobileNumber) )|| (existingEmployee.getDesignation()==null )){ @Override
designationChnaged=true; public List<Location> getLocations() throws MyTimeException {
} return locationRepo.findAll();
} }
existingEmployee.setDesignation(employeeRoles.getDesignation());
existingEmployee.setMobileNumber(employeeRoles.getMobileNumber()); @Override
existingEmployee.setAlternateMobileNumber(employeeRoles.getAlternateMobileNumber()); public EmployeeRoles updateProfile(EmployeeRoles employeeRoles)
existingEmployee.setPersonalEmailId(employeeRoles.getPersonalEmailId()); throws MyTimeException {
existingEmployee.setBaseTechnology(employeeRoles.getBaseTechnology()); boolean mobileNumberChnaged = false;
existingEmployee.setTechnologyKnown(employeeRoles.getTechnologyKnown()); boolean designationChnaged = false;
EmployeeRoles employeeRolesDB= employeeRolesRepo.save(existingEmployee); employeeRoles.setLastModifiedOn(new Date());
if(mobileNumberChnaged || designationChnaged) { EmployeeRoles existingEmployee = employeeRolesRepo
try { .findByEmployeeId(employeeRoles.getEmployeeId());
List<ProjectTeamMate> employeeProfiles= projectTeamMatesRepo.findByEmployeeId(employeeRoles.getEmployeeId()); String newMobileNumber = employeeRoles.getMobileNumber();
if(employeeProfiles!=null&&!employeeProfiles.isEmpty()) { String designation = employeeRoles.getDesignation();
for(ProjectTeamMate profile:employeeProfiles){ if (newMobileNumber != null && !newMobileNumber.equalsIgnoreCase("")) {
profile.setDesignation(employeeRolesDB.getDesignation()); if ((existingEmployee != null
profile.setMobileNumber(employeeRolesDB.getMobileNumber()); && existingEmployee.getMobileNumber() != null
projectTeamMatesRepo.save(profile); && !existingEmployee.getMobileNumber()
} .equalsIgnoreCase(newMobileNumber))
}}catch(Exception e) {} || (existingEmployee.getMobileNumber() == null)) {
} mobileNumberChnaged = true;
return employeeRolesDB; }
}
} 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.setMobileNumber(employeeRoles.getMobileNumber());
existingEmployee.setAlternateMobileNumber(
employeeRoles.getAlternateMobileNumber());
existingEmployee.setPersonalEmailId(employeeRoles.getPersonalEmailId());
existingEmployee.setBaseTechnology(employeeRoles.getBaseTechnology());
existingEmployee.setTechnologyKnown(employeeRoles.getTechnologyKnown());
EmployeeRoles employeeRolesDB = employeeRolesRepo
.save(existingEmployee);
if (mobileNumberChnaged || designationChnaged) {
try {
List<ProjectTeamMate> employeeProfiles = projectTeamMatesRepo
.findByEmployeeId(employeeRoles.getEmployeeId());
if (employeeProfiles != null && !employeeProfiles.isEmpty()) {
for (ProjectTeamMate profile : employeeProfiles) {
profile.setDesignation(
employeeRolesDB.getDesignation());
profile.setMobileNumber(
employeeRolesDB.getMobileNumber());
projectTeamMatesRepo.save(profile);
}
}
} catch (Exception e) {
}
}
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