Commit 68970794 authored by b v s satyanarayana's avatar b v s satyanarayana

MT-70 :SNS :: AuditFiledsAddedToTeams_ProjectTeamMates_BillingDetails_ShifTDetails

parent 3cd9ee2f
...@@ -37,6 +37,7 @@ public class ProjectController { ...@@ -37,6 +37,7 @@ public class ProjectController {
private AccountRepo accountRepo; private AccountRepo accountRepo;
@Autowired @Autowired
private ProjectRepo projectRepo; private ProjectRepo projectRepo;
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRole(@RequestParam("emailId") String emailId) public ResponseEntity<EmployeeRoles> getEmployeeRole(@RequestParam("emailId") String emailId)
throws MyTimeException { throws MyTimeException {
...@@ -45,22 +46,21 @@ public class ProjectController { ...@@ -45,22 +46,21 @@ public class ProjectController {
} }
@RequestMapping(value = "/addProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/addProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addProject(@RequestBody Project projectAdded) throws MyTimeException { public ResponseEntity<?> addProject(@RequestBody Project projectAdded,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
// checking project duplicateName // checking project duplicateName
int projectNameCount=0; int projectNameCount=0;
if (projectAdded.getAccountId() != null) { if (projectAdded.getAccountId() != null) {
List<Project> projects = projectRepo.findByDomainId(projectAdded.getDomainId()); List<Project> projects = projectRepo.findByDomainId(projectAdded.getDomainId());
for (Project existproject : projects) { for (Project existproject : projects) {
if (projectAdded.getProjectName().equalsIgnoreCase(existproject.getProjectName())) if (projectAdded.getProjectName().equalsIgnoreCase(existproject.getProjectName()))
projectNameCount++; } projectNameCount++;
}
} }
if (projectNameCount>0) if (projectNameCount > MyTimeUtils.INT_ZERO){
{
MyTimeException myTimeException= new MyTimeException("Project name already exist !!! try with new"); MyTimeException myTimeException= new MyTimeException("Project name already exist !!! try with new");
return new ResponseEntity<>(myTimeException, HttpStatus.OK); return new ResponseEntity<>(myTimeException, HttpStatus.OK);
} }else{
else
{
String accountName=""; String accountName="";
String accountId=projectAdded.getAccountId(); String accountId=projectAdded.getAccountId();
// String accountName=projectAdded.getAccount(); // String accountName=projectAdded.getAccount();
...@@ -69,16 +69,18 @@ public class ProjectController { ...@@ -69,16 +69,18 @@ public class ProjectController {
accountName=account.getAccountName(); accountName=account.getAccountName();
int sequenceNumber= account.getAccountProjectSequence(); int sequenceNumber= account.getAccountProjectSequence();
account.setAccountProjectSequence(sequenceNumber+1); account.setAccountProjectSequence(sequenceNumber+1);
//account.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
accountRepo.save(account); accountRepo.save(account);
String projectId= accountName+String.format("%04d", sequenceNumber+1); String projectId= accountName+String.format("%04d", sequenceNumber+1);
projectAdded.setProjectId(projectId); projectAdded.setProjectId(projectId);
Project project = projectService.addProject(projectAdded); Project project = projectService.addProject(projectAdded, loginEmpId);
return new ResponseEntity<>(project, HttpStatus.OK); return new ResponseEntity<>(project, HttpStatus.OK);
} }
} }
@RequestMapping(value = "/updateProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/updateProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateEmployeeRole(@RequestBody Project project) throws MyTimeException { public ResponseEntity<?> updateProject(@RequestBody Project project,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
// checking project duplicateName // checking project duplicateName
int projectNameCount=0; int projectNameCount=0;
if (project.getAccountId() != null) { if (project.getAccountId() != null) {
...@@ -95,7 +97,7 @@ public class ProjectController { ...@@ -95,7 +97,7 @@ public class ProjectController {
MyTimeException myTimeException= new MyTimeException("Project name already exist !!! try with new"); MyTimeException myTimeException= new MyTimeException("Project name already exist !!! try with new");
return new ResponseEntity<>(myTimeException, HttpStatus.OK); return new ResponseEntity<>(myTimeException, HttpStatus.OK);
} }
Project updatedProject = projectService.updateProject(project); Project updatedProject = projectService.updateProject(project, loginEmpId);
return new ResponseEntity<>(updatedProject, HttpStatus.OK); return new ResponseEntity<>(updatedProject, HttpStatus.OK);
} }
......
...@@ -40,9 +40,6 @@ public class ProjectTeamController { ...@@ -40,9 +40,6 @@ public class ProjectTeamController {
@Autowired @Autowired
private EmployeeVisaRepo employeeVisaRepo; private EmployeeVisaRepo employeeVisaRepo;
@Autowired
private ProjectController projectController;
@RequestMapping(value = "/employee", method = RequestMethod.GET, @RequestMapping(value = "/employee", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRole( public ResponseEntity<EmployeeRoles> getEmployeeRole(
...@@ -55,17 +52,17 @@ public class ProjectTeamController { ...@@ -55,17 +52,17 @@ public class ProjectTeamController {
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Project> addProject( public ResponseEntity<Project> addProject(
@RequestBody Project employeeRoles) throws MyTimeException { @RequestBody Project projectObj, @RequestParam(value="loginEmpId") String loginEmpId) throws MyTimeException {
Project project = projectService.addProject(employeeRoles); Project project = projectService.addProject(projectObj, loginEmpId);
return new ResponseEntity<>(project, HttpStatus.OK); return new ResponseEntity<>(project, HttpStatus.OK);
} }
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST, @RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> updateEmployeeRole(@RequestBody EmployeeRoles employeeRoles, public ResponseEntity<EmployeeRoles> updateEmployeeRole(@RequestBody EmployeeRoles emp,
@RequestParam(value="empId") String loginEmpId) throws MyTimeException { @RequestParam(value="empId") String loginEmpId) throws MyTimeException {
EmployeeRoles employeeRole = userService.updateEmployeeRole(employeeRoles, loginEmpId); EmployeeRoles employeeRole = userService.updateEmployeeRole(emp, loginEmpId);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
...@@ -124,29 +121,20 @@ public class ProjectTeamController { ...@@ -124,29 +121,20 @@ public class ProjectTeamController {
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ProjectTeamMate> addEmployeeToTeam( public ResponseEntity<ProjectTeamMate> addEmployeeToTeam(
@RequestBody ProjectTeamMate teamMate) throws MyTimeException { @RequestBody ProjectTeamMate teamMate, @RequestParam(value="loginEmpId", required = false) String loginEmpId) throws MyTimeException {
teamMate.setActive(true); teamMate.setActive(true);
// teamMate.setStartDate(new Date()); teamMate.setAuditFields(loginEmpId, MyTimeUtils.CREATE);
/*if (teamMate.getRole()!= null && teamMate.getRole().equals("Lead")) { ProjectTeamMate teamMateDB = projectService.addProjectTeamMate(teamMate, loginEmpId);
Project project = new Project();
project.setProjectName(teamMate.getProjectName());
project.setManagerIds(Arrays.asList(teamMate.getEmployeeId()));
project.setAccountId(teamMate.getAccountId());
project.setDomainId(teamMate.getDomainId());
project.setStatus("Active");
projectController.addProject(project);
}*/
ProjectTeamMate teamMateDB = projectService.addProjectTeamMate(teamMate);
return new ResponseEntity<>(teamMateDB, HttpStatus.OK); return new ResponseEntity<>(teamMateDB, HttpStatus.OK);
} }
@RequestMapping(value = "/updateTeammate", method = RequestMethod.POST, @RequestMapping(value = "/updateTeammate", method = RequestMethod.POST,
produces = MediaType.TEXT_PLAIN_VALUE, produces = MediaType.TEXT_PLAIN_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> updateTeammate(@RequestBody ProjectTeamMate projectTeamMate) public ResponseEntity<String> updateTeammate(@RequestBody ProjectTeamMate projectTeamMate, @RequestParam(value = "loginEmpId") String loginEmpId)
throws MyTimeException { throws MyTimeException {
String response = projectService.updateTeammate(projectTeamMate); projectTeamMate.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
String response = projectService.updateTeammate(projectTeamMate, loginEmpId);
return new ResponseEntity<>(response, HttpStatus.OK); return new ResponseEntity<>(response, HttpStatus.OK);
} }
...@@ -154,10 +142,10 @@ public class ProjectTeamController { ...@@ -154,10 +142,10 @@ public class ProjectTeamController {
produces = MediaType.TEXT_PLAIN_VALUE, produces = MediaType.TEXT_PLAIN_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteTeammate( public ResponseEntity<String> deleteTeammate(
@RequestBody ProjectTeamMate projectTeamMate) @RequestBody ProjectTeamMate projectTeamMate, @RequestParam(value = "loginEmpId") String loginEmpId)
throws MyTimeException { throws MyTimeException {
projectService.deleteTeammate(projectTeamMate.getEmployeeId(), projectService.deleteTeammate(projectTeamMate.getEmployeeId(),
projectTeamMate.getProjectId(), projectTeamMate.getId()); projectTeamMate.getProjectId(), projectTeamMate.getId(), loginEmpId);
return new ResponseEntity<>("Success", HttpStatus.OK); return new ResponseEntity<>("Success", HttpStatus.OK);
} }
...@@ -259,9 +247,9 @@ public class ProjectTeamController { ...@@ -259,9 +247,9 @@ public class ProjectTeamController {
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BillingDetails> addEmployeeBilling( public ResponseEntity<BillingDetails> addEmployeeBilling(
@RequestBody BillingDetails teamMate) throws MyTimeException { @RequestBody BillingDetails billingDetails, @RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
BillingDetails billings = projectService BillingDetails billings = projectService
.addEmployeeBillingDetails(teamMate); .addEmployeeBillingDetails(billingDetails, loginEmpId);
return new ResponseEntity<>(billings, HttpStatus.OK); return new ResponseEntity<>(billings, HttpStatus.OK);
} }
...@@ -271,9 +259,9 @@ public class ProjectTeamController { ...@@ -271,9 +259,9 @@ public class ProjectTeamController {
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BillingDetails> updateEmployeeBilling( public ResponseEntity<BillingDetails> updateEmployeeBilling(
@RequestBody BillingDetails teamMate) throws MyTimeException { @RequestBody BillingDetails billingDetails, @RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
BillingDetails billings = projectService BillingDetails billings = projectService
.updateEmployeeBilling(teamMate); .updateEmployeeBilling(billingDetails, loginEmpId);
return new ResponseEntity<>(billings, HttpStatus.OK); return new ResponseEntity<>(billings, HttpStatus.OK);
} }
...@@ -301,12 +289,12 @@ public class ProjectTeamController { ...@@ -301,12 +289,12 @@ public class ProjectTeamController {
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getEmployeesHavingVisa( public ResponseEntity<List<EmployeeRoles>> getEmployeesHavingVisa(
@RequestParam("visa") String visa) throws MyTimeException { @RequestParam("visa") String passport) throws MyTimeException {
if (visa != null && !"passport".equalsIgnoreCase(visa)) { List<EmployeeRoles> employees = new ArrayList<>();
if (passport != null && !"passport".equalsIgnoreCase(passport)) {
List<EmployeeVisa> employeeVisas = employeeVisaRepo List<EmployeeVisa> employeeVisas = employeeVisaRepo
.findByVisaName(visa); .findByVisaName(passport);
List<String> employeeIds = null; List<String> employeeIds = null;
List<EmployeeRoles> employeesRoles = new ArrayList<>();
if (employeeVisas != null) { if (employeeVisas != null) {
employeeIds = employeeVisas.stream() employeeIds = employeeVisas.stream()
.map(EmployeeVisa::getEmployeeId) .map(EmployeeVisa::getEmployeeId)
...@@ -314,22 +302,22 @@ public class ProjectTeamController { ...@@ -314,22 +302,22 @@ public class ProjectTeamController {
} }
if (employeeIds != null && !employeeIds.isEmpty()) { if (employeeIds != null && !employeeIds.isEmpty()) {
List<EmployeeRoles> emps = userService.getEmployeeRoles(); List<EmployeeRoles> emps = userService.getEmployeeRoles();
for (EmployeeRoles e : emps) { for (EmployeeRoles emp : emps) {
if (employeeIds.contains(e.getEmployeeId())) { if (employeeIds.contains(emp.getEmployeeId())) {
employeesRoles.add(e); employees.add(emp);
} }
} }
} }
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employees, HttpStatus.OK);
} else { } else {
List<EmployeeRoles> employeesRoles = new ArrayList<>(); //List<EmployeeRoles> employees = new ArrayList<>();
if (userService.getEmployeeRoles() != null) { if (userService.getEmployeeRoles() != null) {
employeesRoles = userService.getEmployeeRoles().stream() employees = userService.getEmployeeRoles().stream()
.sorted((o1, o2) -> o1.getEmployeeName() .sorted((o1, o2) -> o1.getEmployeeName()
.compareTo(o2.getEmployeeName())) .compareTo(o2.getEmployeeName()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employees, HttpStatus.OK);
} }
} }
...@@ -338,10 +326,8 @@ public class ProjectTeamController { ...@@ -338,10 +326,8 @@ public class ProjectTeamController {
produces = MediaType.TEXT_PLAIN_VALUE, produces = MediaType.TEXT_PLAIN_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> addEmployeeToTeamWithCheck( public ResponseEntity<String> addEmployeeToTeamWithCheck(
@RequestBody ProjectTeamMate teamMate) throws MyTimeException { @RequestBody ProjectTeamMate teamMate, @RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
String response = projectService.addProjectTeamMateWithCheck(teamMate); String response = projectService.addProjectTeamMateWithCheck(teamMate, loginEmpId);
return new ResponseEntity<>(response, HttpStatus.OK); return new ResponseEntity<>(response, HttpStatus.OK);
} }
} }
\ No newline at end of file
package com.nisum.mytime.model;
import java.util.Date;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class AuditFields {
String createdBy;
String modifiedBy;
Date createdOn;
Date lastModifiedOn;
public void setAuditFields(String loginEmpId, String action) {
Date currentDate = new Date();
if (MyTimeUtils.CREATE.equals(action)) {
this.createdBy = loginEmpId;
this.createdOn = currentDate;
}
this.modifiedBy = loginEmpId;
this.lastModifiedOn = currentDate;
}
}
...@@ -21,7 +21,7 @@ import lombok.ToString; ...@@ -21,7 +21,7 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "BillingDetails") @Document(collection = "BillingDetails")
public class BillingDetails implements Serializable { public class BillingDetails extends AuditFields implements Serializable {
public Date getBillingEndDate() { public Date getBillingEndDate() {
return billingEndDate; return billingEndDate;
...@@ -43,7 +43,7 @@ public class BillingDetails implements Serializable { ...@@ -43,7 +43,7 @@ public class BillingDetails implements Serializable {
private Date billingEndDate; private Date billingEndDate;
private String comments; private String comments;
private boolean active; private boolean active;
@DateTimeFormat(pattern = "dd-MM-yyyy") //@DateTimeFormat(pattern = "dd-MM-yyyy")
private Date createDate; // private Date createDate;
} }
package com.nisum.mytime.model; package com.nisum.mytime.model;
import java.util.Date;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
...@@ -17,15 +15,15 @@ import lombok.ToString; ...@@ -17,15 +15,15 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "EmpShiftDetails") @Document(collection = "EmpShiftDetails")
public class EmpShiftDetails { public class EmpShiftDetails extends AuditFields {
@Id @Id
private String id; private String id;
private String employeeId; private String employeeId;
private String employeeName; private String employeeName;
private String shift; private String shift;
private Date createDate; //private Date createDate;
private Date updatedDate; //private Date updatedDate;
private boolean active; private boolean active;
} }
...@@ -22,7 +22,7 @@ import lombok.ToString; ...@@ -22,7 +22,7 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "Teams") @Document(collection = "Teams")
public class Project implements Serializable { public class Project extends AuditFields implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -30,12 +30,7 @@ public class Project implements Serializable { ...@@ -30,12 +30,7 @@ public class Project implements Serializable {
private ObjectId id; private ObjectId id;
private String projectId; private String projectId;
private String projectName; private String projectName;
/*
* After Ui Integration this below commented code will be removed
*/
//private String managerId;
// private String managerName;
// private String account;
private String domain; private String domain;
private String status; private String status;
private List<String> employeeIds; private List<String> employeeIds;
...@@ -47,5 +42,4 @@ public class Project implements Serializable { ...@@ -47,5 +42,4 @@ public class Project implements Serializable {
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
private Date projectEndDate; private Date projectEndDate;
private List<String> deliveryLeadIds; private List<String> deliveryLeadIds;
} }
...@@ -21,7 +21,7 @@ import lombok.ToString; ...@@ -21,7 +21,7 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "TeamDetails") @Document(collection = "TeamDetails")
public class ProjectTeamMate implements Serializable { public class ProjectTeamMate extends AuditFields implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -35,8 +35,7 @@ public class ProjectTeamMate implements Serializable { ...@@ -35,8 +35,7 @@ public class ProjectTeamMate implements Serializable {
private String projectId; private String projectId;
private String projectName; private String projectName;
private String account; private String account;
//private String managerId;
//private String managerName;
private String experience; private String experience;
private String designation; private String designation;
private String billableStatus; private String billableStatus;
...@@ -48,8 +47,7 @@ public class ProjectTeamMate implements Serializable { ...@@ -48,8 +47,7 @@ public class ProjectTeamMate implements Serializable {
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
private Date newBillingStartDate; private Date newBillingStartDate;
private boolean active; private boolean active;
//private List<String> managerIds;
private String accountId; private String accountId;
private String domainId; private String domainId;
} }
...@@ -21,7 +21,7 @@ public interface ProjectService { ...@@ -21,7 +21,7 @@ public interface ProjectService {
List<HashMap<Object, Object>> getProjects() throws MyTimeException; List<HashMap<Object, Object>> getProjects() throws MyTimeException;
Project addProject(Project project) throws MyTimeException; Project addProject(Project project, String loginEmpId) throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate) String generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException; throws MyTimeException;
...@@ -30,7 +30,7 @@ public interface ProjectService { ...@@ -30,7 +30,7 @@ public interface ProjectService {
void deleteProject(String projectId); void deleteProject(String projectId);
Project updateProject(Project project)throws MyTimeException; Project updateProject(Project project, String loginEmpId)throws MyTimeException;
EmployeeRoles getEmployeesRoleData(String empId); EmployeeRoles getEmployeesRoleData(String empId);
...@@ -39,12 +39,12 @@ public interface ProjectService { ...@@ -39,12 +39,12 @@ public interface ProjectService {
//MT-72 //MT-72
List<ProjectTeamMate> getProjectInfo(String empId); List<ProjectTeamMate> getProjectInfo(String empId);
public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate) public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate, String loginEmpId)
throws MyTimeException; throws MyTimeException;
String updateTeammate(ProjectTeamMate projectTeamMate) throws MyTimeException; String updateTeammate(ProjectTeamMate projectTeamMate, String loginEmpId) throws MyTimeException;
void deleteTeammate(String empId, String projectId, ObjectId id); void deleteTeammate(String empId, String projectId, ObjectId id, String loginEmpId);
List<Project> getProjects(String managerId) throws MyTimeException; List<Project> getProjects(String managerId) throws MyTimeException;
...@@ -63,9 +63,9 @@ public interface ProjectService { ...@@ -63,9 +63,9 @@ public interface ProjectService {
List<BillingDetails> getEmployeeBillingDetails(String empId, List<BillingDetails> getEmployeeBillingDetails(String empId,
String projectId); String projectId);
BillingDetails addEmployeeBillingDetails(BillingDetails teamMate); BillingDetails addEmployeeBillingDetails(BillingDetails billingDetails, String loginEmpId);
BillingDetails updateEmployeeBilling(BillingDetails teamMate); BillingDetails updateEmployeeBilling(BillingDetails billingDetails, String loginEmpId);
void deleteEmployeeBilling(BillingDetails teamMate); void deleteEmployeeBilling(BillingDetails teamMate);
...@@ -78,14 +78,14 @@ public interface ProjectService { ...@@ -78,14 +78,14 @@ public interface ProjectService {
List<BillingDetails> getEmployeeBillingDetailsAll(String empId); List<BillingDetails> getEmployeeBillingDetailsAll(String empId);
public void updateShiftDetails(ProjectTeamMate existingTeammate); public void updateShiftDetails(ProjectTeamMate existingTeammate, String loginEmpId);
public void addShiftDetails(ProjectTeamMate projectTeamMate); public void addShiftDetails(ProjectTeamMate projectTeamMate, String loginEmpId);
List<ProjectTeamMate> findByAccountAndActiveAndBillableStatus( List<ProjectTeamMate> findByAccountAndActiveAndBillableStatus(
String account, boolean status, String billableStatus); String account, boolean status, String billableStatus);
public String addProjectTeamMateWithCheck(ProjectTeamMate projectTeamMate) public String addProjectTeamMateWithCheck(ProjectTeamMate projectTeamMate, String loginEmpId)
throws MyTimeException; throws MyTimeException;
public List<HashMap<Object, Object>> projectsInfoByEmpId(String empId); public List<HashMap<Object, Object>> projectsInfoByEmpId(String empId);
......
...@@ -146,11 +146,11 @@ public class UserServiceImpl implements UserService { ...@@ -146,11 +146,11 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles, String empId) public EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles, String loginEmpId)
throws MyTimeException { throws MyTimeException {
employeeRoles.setCreatedOn(new Date()); employeeRoles.setCreatedOn(new Date());
employeeRoles.setCreatedBy(empId); employeeRoles.setCreatedBy(loginEmpId);
employeeRoles.setModifiedBy(empId); employeeRoles.setModifiedBy(loginEmpId);
ProjectTeamMate newBenchAllocation = new ProjectTeamMate(); ProjectTeamMate newBenchAllocation = new ProjectTeamMate();
newBenchAllocation.setAccount(MyTimeUtils.BENCH_ACCOUNT); newBenchAllocation.setAccount(MyTimeUtils.BENCH_ACCOUNT);
...@@ -180,7 +180,7 @@ public class UserServiceImpl implements UserService { ...@@ -180,7 +180,7 @@ public class UserServiceImpl implements UserService {
} }
try { try {
projectService.addProjectTeamMate(newBenchAllocation); projectService.addProjectTeamMate(newBenchAllocation, loginEmpId);
} catch (MyTimeException e) { } catch (MyTimeException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -201,7 +201,7 @@ public class UserServiceImpl implements UserService { ...@@ -201,7 +201,7 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles, String empId) { public EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles, String loginEmpId) {
// update all emp details to inactive if employee is inactive // update all emp details to inactive if employee is inactive
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();
...@@ -223,7 +223,7 @@ public class UserServiceImpl implements UserService { ...@@ -223,7 +223,7 @@ public class UserServiceImpl implements UserService {
update.set("passportExpiryDate", employeeRoles.getPassportExpiryDate()); update.set("passportExpiryDate", employeeRoles.getPassportExpiryDate());
update.set("b1ExpiryDate", employeeRoles.getB1ExpiryDate()); update.set("b1ExpiryDate", employeeRoles.getB1ExpiryDate());
update.set("modifiedBy", empId); update.set("modifiedBy", loginEmpId);
if(employeeRoles.getEmpStatus().equalsIgnoreCase(MyTimeUtils.IN_ACTIVE_SPACE)) { if(employeeRoles.getEmpStatus().equalsIgnoreCase(MyTimeUtils.IN_ACTIVE_SPACE)) {
update.set("endDate", employeeRoles.getEndDate()); update.set("endDate", employeeRoles.getEndDate());
...@@ -278,8 +278,9 @@ public class UserServiceImpl implements UserService { ...@@ -278,8 +278,9 @@ public class UserServiceImpl implements UserService {
billingDetailsExisting.setActive(false); billingDetailsExisting.setActive(false);
teamMatesBillingRepo.save(billingDetailsExisting); teamMatesBillingRepo.save(billingDetailsExisting);
} }
teamMate.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
projectTeamMatesRepo.save(teamMate); projectTeamMatesRepo.save(teamMate);
updateShiftDetails(teamMate); updateShiftDetails(teamMate, loginEmpId);
} }
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -522,7 +523,7 @@ public class UserServiceImpl implements UserService { ...@@ -522,7 +523,7 @@ public class UserServiceImpl implements UserService {
return billingsSorted; return billingsSorted;
} }
public void updateShiftDetails(ProjectTeamMate existingTeammate) { public void updateShiftDetails(ProjectTeamMate existingTeammate, String loginEmpId) {
Query getQuery = new Query(); Query getQuery = new Query();
getQuery.addCriteria(new Criteria().andOperator(Criteria.where("active").is(true), getQuery.addCriteria(new Criteria().andOperator(Criteria.where("active").is(true),
Criteria.where("employeeId").is(existingTeammate.getEmployeeId()))); Criteria.where("employeeId").is(existingTeammate.getEmployeeId())));
...@@ -531,7 +532,8 @@ public class UserServiceImpl implements UserService { ...@@ -531,7 +532,8 @@ public class UserServiceImpl implements UserService {
EmpShiftDetails existingShift = mongoTemplate.findOne(getQuery, EmpShiftDetails.class); EmpShiftDetails existingShift = mongoTemplate.findOne(getQuery, EmpShiftDetails.class);
if (existingShift != null) { if (existingShift != null) {
existingShift.setActive(false); existingShift.setActive(false);
existingShift.setUpdatedDate(new Date()); //existingShift.setUpdatedDate(new Date());// Commented as added common audit fields
existingShift.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
mongoTemplate.save(existingShift); mongoTemplate.save(existingShift);
} }
} }
......
...@@ -148,4 +148,7 @@ public class MyTimeUtils { ...@@ -148,4 +148,7 @@ public class MyTimeUtils {
public final static String FULL_TIME ="Full Time"; public final static String FULL_TIME ="Full Time";
public final static String CAMA = ","; public final static String CAMA = ",";
public final static String CREATE ="CREATE";
public final static String UPDATE ="UPDATE";
} }
...@@ -288,8 +288,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -288,8 +288,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
function deleteTeam(record){ function deleteTeam(record){
var urlRequest = ""; var urlRequest = "";
var loginEmpId = myFactory.getEmpId();
urlRequest = appConfig.appUri+ "/projectTeam/deleteTeammate"; urlRequest = appConfig.appUri+ "/projectTeam/deleteTeammate?loginEmpId="+loginEmpId;
var req = { var req = {
method : 'POST', method : 'POST',
url : urlRequest, url : urlRequest,
...@@ -1436,8 +1436,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -1436,8 +1436,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
function addRecord(record, action){ function addRecord(record, action){
var urlRequest = ""; var urlRequest = "";
var loginEmpId = myFactory.getEmpId();
urlRequest = appConfig.appUri+ "projectTeam/addEmployeeToTeamWithCheck"; urlRequest = appConfig.appUri+ "projectTeam/addEmployeeToTeamWithCheck?loginEmpId="+loginEmpId;
var req = { var req = {
method : 'POST', method : 'POST',
url : urlRequest, url : urlRequest,
...@@ -1494,8 +1494,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -1494,8 +1494,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
} }
function updateTeamRecord(record, action){ function updateTeamRecord(record, action){
var urlRequest = ""; var urlRequest = "";
var loginEmpId = myFactory.getEmpId();
urlRequest = appConfig.appUri+ "/projectTeam/updateTeammate"; urlRequest = appConfig.appUri+ "/projectTeam/updateTeammate?loginEmpId="+loginEmpId;
var req = { var req = {
method : 'POST', method : 'POST',
url : urlRequest, url : urlRequest,
...@@ -1529,10 +1529,11 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -1529,10 +1529,11 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
function addOrUpdateProject(record, action) { function addOrUpdateProject(record, action) {
var urlRequest = ""; var urlRequest = "";
var loginEmpId = myFactory.getEmpId();
if (action == "Assign") { if (action == "Assign") {
urlRequest = appConfig.appUri + "project/addProject"; urlRequest = appConfig.appUri + "project/addProject?loginEmpId="+loginEmpId;
} else if (action == "Update") { } else if (action == "Update") {
urlRequest = appConfig.appUri + "project/updateProject"; urlRequest = appConfig.appUri + "project/updateProject?loginEmpId="+loginEmpId;
} }
var req = { var req = {
method: 'POST', method: 'POST',
......
...@@ -386,8 +386,9 @@ myApp.controller("projectMyTeamController",function($scope, myFactory, $mdDialog ...@@ -386,8 +386,9 @@ myApp.controller("projectMyTeamController",function($scope, myFactory, $mdDialog
function addOrUpdateRole(record, action){ function addOrUpdateRole(record, action){
var urlRequest = ""; var urlRequest = "";
var loginEmpId = myFactory.getEmpId();
if(action == "Assign"){ if(action == "Assign"){
urlRequest = appConfig.appUri+ "projectTeam/addEmployeeToTeam"; urlRequest = appConfig.appUri+ "projectTeam/addEmployeeToTeam?loginEmpId="+loginEmpId;
}else if(action == "Update"){ }else if(action == "Update"){
urlRequest = appConfig.appUri+ "user/updateEmployeeRole"; urlRequest = appConfig.appUri+ "user/updateEmployeeRole";
} }
......
...@@ -24,6 +24,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -24,6 +24,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
}; };
$scope.employees = []; $scope.employees = [];
$scope.projects = []; $scope.projects = [];
var getCellTemplate = '<p class="col-lg-12"><i class="fa fa-pencil-square-o fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Update\')"></i>'+ var getCellTemplate = '<p class="col-lg-12"><i class="fa fa-pencil-square-o fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Update\')"></i>'+
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-minus-circle fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Delete\')"></i></p>'; '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-minus-circle fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Delete\')"></i></p>';
var getCellTemplate1='<div ng-show="COL_FIELD!=\'Employee\' && COL_FIELD!=\'HR\' "><p class="col-lg-12">{{COL_FIELD}} <i class="fa fa-sitemap fa-2x" aria-hidden="true" style="font-size:1.5em;color:blue;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'ViewTeamDetail\')"></i></p></div><div ng-show="COL_FIELD==\'Employee\' || COL_FIELD==\'HR\'"><p class="col-lg-12">{{COL_FIELD}}</p></div>' var getCellTemplate1='<div ng-show="COL_FIELD!=\'Employee\' && COL_FIELD!=\'HR\' "><p class="col-lg-12">{{COL_FIELD}} <i class="fa fa-sitemap fa-2x" aria-hidden="true" style="font-size:1.5em;color:blue;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'ViewTeamDetail\')"></i></p></div><div ng-show="COL_FIELD==\'Employee\' || COL_FIELD==\'HR\'"><p class="col-lg-12">{{COL_FIELD}}</p></div>'
...@@ -256,7 +257,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -256,7 +257,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
var record = {"id":id,"employeeId":empId,"projectId":projectId}; var record = {"id":id,"employeeId":empId,"projectId":projectId};
var req = { var req = {
method : 'POST', method : 'POST',
url : appConfig.appUri+ "projectTeam/deleteTeammate", var loginEmpId = myFactory.getEmpId();
url : appConfig.appUri+ "projectTeam/deleteTeammate?loginEmpId="+loginEmpId,
headers : { headers : {
"Content-type" : "application/json" "Content-type" : "application/json"
}, },
...@@ -445,10 +447,11 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -445,10 +447,11 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
}; };
function addOrUpdateBilling(record, action){ function addOrUpdateBilling(record, action){
var urlRequest = ""; var urlRequest = "";
var loginEmpId = myFactory.getEmpId();
if(action == "Add"){ if(action == "Add"){
urlRequest = appConfig.appUri+ "projectTeam/addEmployeeBilling"; urlRequest = appConfig.appUri+ "projectTeam/addEmployeeBilling?loginEmpId="+loginEmpId;
}else if(action == "Update"){ }else if(action == "Update"){
urlRequest = appConfig.appUri+ "projectTeam/updateEmployeeBilling"; urlRequest = appConfig.appUri+ "projectTeam/updateEmployeeBilling?loginEmpId="+loginEmpId;
} }
else if(action == "Delete"){ else if(action == "Delete"){
...@@ -829,10 +832,11 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -829,10 +832,11 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
function addOrUpdateRole(record, action){ function addOrUpdateRole(record, action){
var urlRequest = ""; var urlRequest = "";
var loginEmpId = myFactory.getEmpId();
if(action == "Add"){ if(action == "Add"){
urlRequest = appConfig.appUri+ "projectTeam/addEmployeeToTeam"; urlRequest = appConfig.appUri+ "projectTeam/addEmployeeToTeam?loginEmpId="+loginEmpId;
}else if(action == "Update"){ }else if(action == "Update"){
urlRequest = appConfig.appUri+ "projectTeam/updateTeammate"; urlRequest = appConfig.appUri+ "projectTeam/updateTeammate?loginEmpId="+loginEmpId;
} }
var req = { var req = {
method : 'POST', method : 'POST',
......
...@@ -533,10 +533,11 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid ...@@ -533,10 +533,11 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid
function addOrUpdateProject(record, action){ function addOrUpdateProject(record, action){
var urlRequest = ""; var urlRequest = "";
var loginEmpId = myFactory.getEmpId();
if(action == "Assign"){ if(action == "Assign"){
urlRequest = appConfig.appUri+ "project/addProject"; urlRequest = appConfig.appUri+ "project/addProject?loginEmpId="+loginEmpId;
}else if(action == "Update"){ }else if(action == "Update"){
urlRequest = appConfig.appUri+ "project/updateProject"; urlRequest = appConfig.appUri+ "project/updateProject?loginEmpId="+loginEmpId;
} }
var req = { var req = {
method : 'POST', method : 'POST',
......
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