Commit fed165ca authored by Vijay Akula's avatar Vijay Akula

Modified code for all operations in resources as per new db design

parent 3ff7c67b
package com.nisum.myteam.controller; package com.nisum.myteam.controller;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -12,11 +11,9 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -12,11 +11,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.Billing; import com.nisum.myteam.model.dao.Billing;
import com.nisum.myteam.service.IBillingService; import com.nisum.myteam.service.IBillingService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@RestController @RestController
...@@ -50,6 +47,8 @@ public class BillingController { ...@@ -50,6 +47,8 @@ public class BillingController {
return new ResponseEntity<>(null, HttpStatus.OK); return new ResponseEntity<>(null, HttpStatus.OK);
} }
// @RequestMapping(value = "/getEmployeeBillingDetailsAll" // @RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping(value = "/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Billing>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId) public ResponseEntity<List<Billing>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
......
...@@ -8,6 +8,8 @@ import java.util.stream.Collectors; ...@@ -8,6 +8,8 @@ import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.nisum.myteam.model.dao.EmployeeVisa;
import com.nisum.myteam.repository.EmployeeVisaRepo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -38,6 +40,10 @@ public class EmployeeController { ...@@ -38,6 +40,10 @@ public class EmployeeController {
@Autowired @Autowired
private IEmployeeRoleService employeeRoleService; private IEmployeeRoleService employeeRoleService;
@Autowired
private EmployeeVisaRepo employeeVisaRepo;
@RequestMapping(value = "/employees/{empId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/employees/{empId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> createEmployee( @RequestBody Employee employeeReq, public ResponseEntity<?> createEmployee( @RequestBody Employee employeeReq,
@PathVariable(value = "empId") String loginEmpId, HttpServletRequest request) throws MyTeamException { @PathVariable(value = "empId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
...@@ -227,6 +233,43 @@ public class EmployeeController { ...@@ -227,6 +233,43 @@ public class EmployeeController {
return new ResponseEntity<>(employeesList, HttpStatus.OK); return new ResponseEntity<>(employeesList, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeesHavingVisa", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getEmployeesHavingVisa(@RequestParam("visa") String passport,HttpServletRequest request)
throws MyTeamException {
List<Employee> employees = new ArrayList<>();
if (passport != null && !"passport".equalsIgnoreCase(passport)) {
List<EmployeeVisa> employeeVisas = employeeVisaRepo.findByVisaName(passport);
List<String> employeeIds = null;
if (employeeVisas != null) {
employeeIds = employeeVisas.stream().map(EmployeeVisa::getEmployeeId).collect(Collectors.toList());
}
if (employeeIds != null && !employeeIds.isEmpty()) {
List<Employee> emps = empService.getActiveEmployees();
for (Employee emp : emps) {
if (employeeIds.contains(emp.getEmployeeId())) {
employees.add(emp);
}
}
}
} else {
if (empService.getActiveEmployees() != null) {
employees = empService.getActiveEmployees().stream()
.sorted((o1, o2) -> o1.getEmployeeName().compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
}
}
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
"List of Resources who has visa", employees, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
} }
\ No newline at end of file
...@@ -7,7 +7,6 @@ import com.nisum.myteam.model.dao.Project; ...@@ -7,7 +7,6 @@ import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.service.IEmployeeService; import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IProjectService; import com.nisum.myteam.service.IProjectService;
import com.nisum.myteam.statuscodes.ProjectStatus; import com.nisum.myteam.statuscodes.ProjectStatus;
import com.nisum.myteam.utils.MyTeamUtils;
import com.nisum.myteam.utils.constants.ApplicationRole; import com.nisum.myteam.utils.constants.ApplicationRole;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -38,7 +37,7 @@ public class ProjectController { ...@@ -38,7 +37,7 @@ public class ProjectController {
public ResponseEntity<?> createProject(@Valid @RequestBody Project projectReq, public ResponseEntity<?> createProject(@Valid @RequestBody Project projectReq,
@RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException { @RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
if (!projectService.isProjectExists(projectReq.getProjectName())) { if (!projectService.isProjectExistsByName(projectReq.getProjectName())) {
String accountName = ""; String accountName = "";
Account account = projectService.getProjectAccount(projectReq.getAccountId()); Account account = projectService.getProjectAccount(projectReq.getAccountId());
...@@ -80,7 +79,7 @@ public class ProjectController { ...@@ -80,7 +79,7 @@ public class ProjectController {
@RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException { @RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
if (projectService.isProjectExistsById(projectId)) { if (projectService.isProjectExistsById(projectId)) {
if (projectService.isProjectExists(project.getProjectName())) { if (projectService.isProjectExistsByName(project.getProjectName())) {
Project updatedProject = projectService.updateProject(project, loginEmpId); Project updatedProject = projectService.updateProject(project, loginEmpId);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), ProjectStatus.UPDATE.getCode(), ResponseDetails getRespDetails = new ResponseDetails(new Date(), ProjectStatus.UPDATE.getCode(),
ProjectStatus.UPDATE.getMessage(), "Project Updation Description", null, ProjectStatus.UPDATE.getMessage(), "Project Updation Description", null,
...@@ -183,21 +182,7 @@ public class ProjectController { ...@@ -183,21 +182,7 @@ public class ProjectController {
} }
@RequestMapping(value = "/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getMyProjectAllocations(
@RequestParam("employeeId") String employeeId, HttpServletRequest request) throws MyTeamException {
if (employeeId != null && !"".equalsIgnoreCase(employeeId)) {
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 604, "Retrieved the project allocations successfully",
"Projects allocations for an employee", projectService.getProjectsForEmployee(employeeId), request.getRequestURI(), "Project details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 606, "Please Provide valid employee id",
"Project allocations for an employee", null, request.getRequestURI(), "Project details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
} }
......
...@@ -42,6 +42,7 @@ public class ResourceController { ...@@ -42,6 +42,7 @@ public class ResourceController {
private IResourceService resourceService; private IResourceService resourceService;
@RequestMapping(value = "/resources", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> createResource(@RequestBody Resource resourceReq, public ResponseEntity<?> createResource(@RequestBody Resource resourceReq,
@RequestParam(value = "loginEmpId", required = true) String loginEmpId, HttpServletRequest request) throws MyTeamException { @RequestParam(value = "loginEmpId", required = true) String loginEmpId, HttpServletRequest request) throws MyTeamException {
...@@ -190,63 +191,27 @@ public class ResourceController { ...@@ -190,63 +191,27 @@ public class ResourceController {
} }
@RequestMapping(value = "resources/unAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) // @RequestMapping(value = "resources/unAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getUnAssignedEmployees(HttpServletRequest request) throws MyTeamException { // public ResponseEntity<?> getUnAssignedEmployees(HttpServletRequest request) throws MyTeamException {
List<Employee> employeesList = projectService.getUnAssignedEmployees(); // List<Employee> employeesList = projectService.getUnAssignedEmployees();
//
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully", // ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
"List of Resources who are not assigned to project", employeesList, request.getRequestURI(), "Resource details", null); // "List of Resources who are not assigned to project", employeesList, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK); // return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
} // }
//
//
@RequestMapping(value = "/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) // @RequestMapping(value = "/resources/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getEmployeesDashBoard(HttpServletRequest request) throws MyTeamException { // public ResponseEntity<?> getEmployeesDashBoard(HttpServletRequest request) throws MyTeamException {
List<EmployeeDashboardVO> employeeDashBoardList = projectService.getEmployeesDashBoard(); // List<EmployeeDashboardVO> employeeDashBoardList = projectService.getEmployeesDashBoard();
//
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully", // ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
"List of Resources for dashboard", employeeDashBoardList, request.getRequestURI(), "Resource details", null); // "List of Resources for dashboard", employeeDashBoardList, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK); // return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
} // }
@RequestMapping(value = "/getEmployeesHavingVisa", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getEmployeesHavingVisa(@RequestParam("visa") String passport,HttpServletRequest request) @RequestMapping(value = "resources/addEmployeeToTeamWithCheck", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
throws MyTeamException {
List<Employee> employees = new ArrayList<>();
if (passport != null && !"passport".equalsIgnoreCase(passport)) {
List<EmployeeVisa> employeeVisas = employeeVisaRepo.findByVisaName(passport);
List<String> employeeIds = null;
if (employeeVisas != null) {
employeeIds = employeeVisas.stream().map(EmployeeVisa::getEmployeeId).collect(Collectors.toList());
}
if (employeeIds != null && !employeeIds.isEmpty()) {
List<Employee> emps = employeeService.getActiveEmployees();
for (Employee emp : emps) {
if (employeeIds.contains(emp.getEmployeeId())) {
employees.add(emp);
}
}
}
} else {
if (employeeService.getActiveEmployees() != null) {
employees = employeeService.getActiveEmployees().stream()
.sorted((o1, o2) -> o1.getEmployeeName().compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
}
}
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
"List of Resources who has visa", employees, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
@RequestMapping(value = "/addEmployeeToTeamWithCheck", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addEmployeeToTeamWithCheck(@RequestBody Resource resourceReq, public ResponseEntity<?> addEmployeeToTeamWithCheck(@RequestBody Resource resourceReq,
@RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException { @RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
......
...@@ -7,6 +7,7 @@ import javax.validation.constraints.NotNull; ...@@ -7,6 +7,7 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import org.bson.types.ObjectId;
import org.hibernate.validator.constraints.Email; import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
...@@ -31,7 +32,7 @@ public class Employee implements Serializable { ...@@ -31,7 +32,7 @@ public class Employee implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
private String id; private ObjectId id;
@NotBlank(message="Employee Id cannot be blank") @NotBlank(message="Employee Id cannot be blank")
......
...@@ -32,7 +32,6 @@ public class Project extends AuditFields implements Serializable { ...@@ -32,7 +32,6 @@ public class Project extends AuditFields implements Serializable {
private String projectId; private String projectId;
private String projectName; private String projectName;
private String domainId; private String domainId;
private String domain;
private String accountId; private String accountId;
private String status; private String status;
private List<String> employeeIds; private List<String> employeeIds;
......
...@@ -27,28 +27,20 @@ public class ResourceAllocation extends AuditFields implements Serializable { ...@@ -27,28 +27,20 @@ public class ResourceAllocation extends AuditFields implements Serializable {
private String employeeId; private String employeeId;
private String projectId; private String projectId;
private String projectName; //private String projectName;
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
private String billableStatus; private String billableStatus;
@DateTimeFormat(iso = ISO.DATE)
@DateTimeFormat(iso = ISO.DATE, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSX")
private Date billingStartDate; private Date billingStartDate;
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSX")
private Date billingEndDate; private Date billingEndDate;
// private boolean active;
//private boolean active; private String resourceRole;
// private String role;
// @DateTimeFormat(iso = ISO.DATE)
// private Date projectStartDate;
//
// @DateTimeFormat(iso = ISO.DATE)
// private Date projectEndDate;
} }
...@@ -11,13 +11,13 @@ import java.util.List; ...@@ -11,13 +11,13 @@ import java.util.List;
public interface ResourceAllocationRepo public interface ResourceAllocationRepo
extends MongoRepository<ResourceAllocation, String> { extends MongoRepository<ResourceAllocation, String> {
List<Resource> findByProjectId(String projectId); List<ResourceAllocation> findByProjectId(String projectId);
List<Resource> findByEmployeeId(String employeeId); List<ResourceAllocation> findByEmployeeId(String employeeId);
Resource findById(ObjectId id); ResourceAllocation findById(ObjectId id);
Resource findByEmployeeIdAndProjectId(String employeeId, String projectId); List<ResourceAllocation> findByEmployeeIdAndProjectId(String employeeId, String projectId);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status); // List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
......
package com.nisum.myteam.service; package com.nisum.myteam.service;
public class IDashboardService { import com.nisum.myteam.model.vo.EmployeeDashboardVO;
import java.util.List;
public interface IDashboardService {
public List<EmployeeDashboardVO> getEmployeesDashBoard();
} }
package com.nisum.myteam.service; package com.nisum.myteam.service;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.springframework.stereotype.Service;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.Account; import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
@Service @Service
public interface IEmployeeService { public interface IEmployeeService {
boolean isEmployeeExistsById(String employeeId); boolean isEmployeeExistsById(String employeeId);
Employee createEmployee(Employee employeeRoles, String empId) throws MyTeamException;
Employee updateEmployee(Employee employeeRoles, String empId);
Employee createEmployee(Employee employeeRoles, String empId) throws MyTeamException; Employee deleteEmployee(String empId);
Employee updateEmployee(Employee employeeRoles, String empId); Employee updateProfile(Employee employeeRoles) throws MyTeamException;
Employee deleteEmployee(String empId); Employee getEmployeeById(String empId);
Employee updateProfile(Employee employeeRoles) throws MyTeamException; Employee getEmployeeByEmaillId(String emailId);
Employee getEmployeeById(String empId); List<Employee> getManagers() throws MyTeamException;
Employee getEmployeeByEmaillId(String emailId); List<Employee> getActiveEmployees() throws MyTeamException;
List<Employee> getManagers() throws MyTeamException; List<Employee> getEmployeesByStatus(String status);
List<Employee> getActiveEmployees() throws MyTeamException; List<Account> getAccounts() throws MyTeamException;
List<Employee> getEmployeesByStatus(String status); Employee getEmployeeRoleDataForSearchCriteria(String searchId, String searchAttribute);
List<Account> getAccounts() throws MyTeamException; List<String> getEmployeeDetailsForAutocomplete();
Employee getEmployeeRoleDataForSearchCriteria(String searchId, String searchAttribute); List<HashMap<String, String>> getDeliveryLeads(String domainId);
List<String> getEmployeeDetailsForAutocomplete(); List<Employee> getEmployeesByFunctionalGrp(String functionalGrp);
List<HashMap<String, String>> getDeliveryLeads(String domainId); boolean verifyEmployeeRole(String empId, String roleName);
List<Employee> getEmployeesByFunctionalGrp(String functionalGrp); List<Employee> getEmployeesFromList(Set<String> empIdsSet);
boolean verifyEmployeeRole(String empId, String roleName); List<HashMap<String, String>> getDeliveryManagerMap(List deliveryManagerIdsList);
List<Employee> getEmployeesFromList(Set<String> empIdsSet); public List<Employee> getAllEmployees();
List<HashMap<String, String>> getDeliveryManagerMap(List deliveryManagerIdsList);
public List<Employee> getAllEmployees();
} }
...@@ -16,10 +16,22 @@ public interface IProjectService { ...@@ -16,10 +16,22 @@ public interface IProjectService {
void deleteProject(String projectId); void deleteProject(String projectId);
List<Project> getProjectsUnderDomain(String domainId); public boolean isProjectExistsByName(String projectName);
public boolean isProjectExistsById(String projectId);
public Project getProjectByProjectId(String projectId);
public long getProjectsCount();
public List<Project> getAllProjects();
List<HashMap<Object, Object>> getProjects() throws MyTeamException; List<HashMap<Object, Object>> getProjects() throws MyTeamException;
public List<Project> getOnlyActiveProjects();
List<Project> getProjectsUnderDomain(String domainId);
List<Project> getProjectsUnderDeliveryLead(String managerId) throws MyTeamException; List<Project> getProjectsUnderDeliveryLead(String managerId) throws MyTeamException;
public Resource addNewBeanchAllocation(Employee employee, String loginEmpId); public Resource addNewBeanchAllocation(Employee employee, String loginEmpId);
...@@ -28,37 +40,23 @@ public interface IProjectService { ...@@ -28,37 +40,23 @@ public interface IProjectService {
String generatePdfReport(long id, String fromDate, String toDate) throws MyTeamException; String generatePdfReport(long id, String fromDate, String toDate) throws MyTeamException;
List<Resource> getResourcesUnderProject(String empId);
List<Employee> getUnAssignedEmployees();
public List<EmployeeDashboardVO> getEmployeesDashBoard();
public List<HashMap<Object, Object>> getProjectsForEmployee(String empId); //public List<HashMap<Object, Object>> getProjectsForEmployee(String empId);
public Set<String> accountsAssignedToDl(String empId); public Set<String> accountsAssignedToDl(String empId);
public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTeamException; public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTeamException;
public List<Project> getAllProjects();
public boolean isProjectExists(String projectName);
public boolean isProjectExistsById(String projectId);
public long getProjectsCount();
public Account getProjectAccount(String accountId); public Account getProjectAccount(String accountId);
public Account updateProjSeqinAccount(Account account) throws MyTeamException; public Account updateProjSeqinAccount(Account account) throws MyTeamException;
public List<HashMap<Object, Object>> getRoleBasedProjects(String empId) throws MyTeamException; public List<HashMap<Object, Object>> getRoleBasedProjects(String empId) throws MyTeamException;
public List<HashMap<Object, Object>> getProjectsInsteadOfRole() throws MyTeamException; public List<HashMap<Object, Object>> getProjectsInsteadOfRole() throws MyTeamException;
public List<Project> getProjectsForDeliveryLead(String deliveryLeadId);
public Project getProjectByProjectId(String projectId); List<Resource> getResourcesUnderProject(String empId);
} }
...@@ -4,6 +4,8 @@ import com.nisum.myteam.exception.handler.MyTeamException; ...@@ -4,6 +4,8 @@ import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Resource; import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.dao.ResourceAllocation; import com.nisum.myteam.model.dao.ResourceAllocation;
import com.nisum.myteam.model.vo.MyProjectAllocationVO;
import com.nisum.myteam.model.vo.ResourceVO;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import java.util.HashMap; import java.util.HashMap;
...@@ -11,31 +13,54 @@ import java.util.List; ...@@ -11,31 +13,54 @@ import java.util.List;
public interface IResourceAllocationService { public interface IResourceAllocationService {
ResourceAllocation addResourceAllocation(ResourceAllocation resourceAllocation, String loginEmpId) throws MyTeamException; ResourceAllocation addResourceAllocation(ResourceAllocation resourceAllocation, String loginEmpId) throws MyTeamException;
HashMap<String,Object> updateResource(ResourceAllocation resourceAllocation, String loginEmpId) throws MyTeamException; void updateResource(ResourceAllocation resourceAllocation, String loginEmpId) throws MyTeamException;
void deleteResource(ResourceAllocation resource, String loginEmpId);
List<ResourceAllocation> getAllResourcesForAllActiveProjects();
// Resource save(Resource resource);
// void addResources(Employee employee, String loginEmpId);
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
List<ResourceAllocation> getResourcesSortByBillingStartDate(String employeeId);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId);
// List<Resource> getAllResourcesForProject(String projectId);
List<ResourceAllocation> getActiveResources(String empId);
// List<Resource> getResourcesForShift(String shift);
public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag);
public List<ResourceAllocation> getResourcesUnderDeliveryLead(String empId);
Resource deleteResource(String empId, String projectId, ObjectId id, String loginEmpId);
// Resource save(Resource resource); public List<ResourceAllocation> getBillingsForEmployee(String empId);
// void addResources(Employee employee, String loginEmpId);
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId); public List<ResourceAllocation> getBillingsForProject(String empId, String projectId);
List<ResourceAllocation> getResourcesSortByProjectStartDate(String employeeId);
// List<Resource> getResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId); public List<MyProjectAllocationVO> getWorkedProjectsForResource(String empId);
// List<Resource> getResourcesForProject(String projectId);
// List<Resource> getActiveResources(String empId); public List<Employee> getUnAssignedEmployees();
// List<Resource> getResourcesForActiveProjects(); public List<ResourceAllocation> getAllResources();
// List<Resource> getResourcesForShift(String shift);
// public List<Resource> getResourcesUnderDeliveryLead(String empId);
} }
...@@ -61,7 +61,7 @@ public class ResourceService implements IResourceService { ...@@ -61,7 +61,7 @@ public class ResourceService implements IResourceService {
private ProjectService projectService; private ProjectService projectService;
@Autowired @Autowired
private EmployeeRepo employeeRoleRepo; private EmployeeRepo employeeRepo;
public Resource save(Resource resource) { public Resource save(Resource resource) {
return resourceRepo.save(resource); return resourceRepo.save(resource);
...@@ -306,11 +306,11 @@ public class ResourceService implements IResourceService { ...@@ -306,11 +306,11 @@ public class ResourceService implements IResourceService {
empShiftService.updateEmployeeShift(existingResource, loginEmpId); empShiftService.updateEmployeeShift(existingResource, loginEmpId);
existingResource.setShift(resourceReq.getShift()); existingResource.setShift(resourceReq.getShift());
Employee employeeDB = employeeRoleRepo.findByEmployeeId(resourceReq.getEmployeeId()); Employee employeeDB = employeeRepo.findByEmployeeId(resourceReq.getEmployeeId());
employeeDB.setShift(resourceReq.getShift()); employeeDB.setShift(resourceReq.getShift());
employeeDB.setModifiedBy(loginEmpId); employeeDB.setModifiedBy(loginEmpId);
employeeDB.setLastModifiedOn(new Date()); employeeDB.setLastModifiedOn(new Date());
employeeRoleRepo.save(employeeDB); employeeRepo.save(employeeDB);
} }
existingResource.setAuditFields(loginEmpId, MyTeamUtils.UPDATE);// Setting existingResource.setAuditFields(loginEmpId, MyTeamUtils.UPDATE);// Setting
// audit // audit
...@@ -335,15 +335,6 @@ public class ResourceService implements IResourceService { ...@@ -335,15 +335,6 @@ public class ResourceService implements IResourceService {
return response; return response;
} }
private String validateAgainstDOJ(Resource resource) {
String response = null;
Date empDoj = employeeRoleRepo.findByEmployeeId(resource.getEmployeeId()).getDateOfJoining();
if (resource.getNewBillingStartDate().compareTo(empDoj) < 0) {
response = "Resource Start Date (" + resource.getNewBillingStartDate() + " ) in "
+ resource.getProjectName() + " project should not be before Date of Joining ( " + empDoj + ").";
}
return response;
}
@Override @Override
public Resource deleteResource(String empId, String projectId, ObjectId id, String loginEmpId) { public Resource deleteResource(String empId, String projectId, ObjectId id, String loginEmpId) {
...@@ -668,17 +659,28 @@ public class ResourceService implements IResourceService { ...@@ -668,17 +659,28 @@ public class ResourceService implements IResourceService {
} }
private String validateNewProjectAssignmentStartDate(List<Resource> teamMateList, Resource projectTeamMate) { private String validateNewProjectAssignmentStartDate(List<Resource> resourceList, Resource resourceReq) {
String response = null; String response = null;
if (teamMateList != null && teamMateList.size() > 0) { if (resourceList != null && resourceList.size() > 0) {
Resource ptMate = teamMateList.get(0); Resource resource = resourceList.get(0);
if (projectTeamMate.getNewBillingStartDate().compareTo(ptMate.getEndDate()) <= 0) { if (resourceReq.getNewBillingStartDate().compareTo(resource.getEndDate()) <= 0) {
response = "Resource Start Date (" + projectTeamMate.getNewBillingStartDate() +" ) in " + projectTeamMate.getProjectName() response = "Resource Start Date (" + resourceReq.getNewBillingStartDate() +" ) in " + resourceReq.getProjectName()
+ " project should be after " + ptMate.getProjectName() + " project End Date ( " + ptMate.getEndDate() + ")."; + " project should be after " + resource.getProjectName() + " project End Date ( " + resource.getEndDate() + ").";
} }
} else { } else {
response = validateAgainstDOJ(projectTeamMate); response = validateAgainstDOJ(resourceReq);
}
return response;
}
private String validateAgainstDOJ(Resource resource) {
String response = null;
Date empDoj = employeeRepo.findByEmployeeId(resource.getEmployeeId()).getDateOfJoining();
if (resource.getNewBillingStartDate().compareTo(empDoj) < 0) {
response = "Resource Start Date (" + resource.getNewBillingStartDate() + " ) in "
+ resource.getProjectName() + " project should not be before Date of Joining ( " + empDoj + ").";
} }
return response; return response;
} }
} }
package com.nisum.myteam.statuscodes; package com.nisum.myteam.statuscodes;
public class ResourceStatus { public enum ResourceStatus {
ACTIVE("Active"), IN_ACTIVE("InActive");
private String status;
private ResourceStatus(String status) {
this.status = status;
}
public String getStatus() {
return this.status;
}
} }
...@@ -155,8 +155,8 @@ public class MyTeamUtils { ...@@ -155,8 +155,8 @@ public class MyTeamUtils {
public final static String PROJECT_START_DATE="ProjectStartDate"; public final static String PROJECT_START_DATE="ProjectStartDate";
public final static String PROJECT_END_DATE="ProjectEndDate"; public final static String PROJECT_END_DATE="ProjectEndDate";
public final static String BILLING_START_DATE="BillingStartDate"; public final static String BILLING_START_DATE="billingStartDate";
public final static String BILLING_END_DATE="BillingEndDate"; public final static String BILLING_END_DATE="billingEndDate";
} }
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