Commit 49d725f8 authored by Vijay Akula's avatar Vijay Akula

Renamed the references of ResourceAlloc to resources in all other files

parent 066543e3
...@@ -4,12 +4,11 @@ import com.nisum.myteam.exception.handler.MyTeamException; ...@@ -4,12 +4,11 @@ import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.ColumnChartData; import com.nisum.myteam.model.ColumnChartData;
import com.nisum.myteam.model.GroupByCount; import com.nisum.myteam.model.GroupByCount;
import com.nisum.myteam.model.ReportSeriesRecord; import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.ResourceAllocation; import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.ResourceVO; import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.service.IEmployeeService; import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IResourceAllocationService; import com.nisum.myteam.service.IResourceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
...@@ -47,7 +46,7 @@ public class ReportsController { ...@@ -47,7 +46,7 @@ public class ReportsController {
private IEmployeeService employeeService; private IEmployeeService employeeService;
@Autowired @Autowired
private IResourceAllocationService resourceService; private IResourceService resourceService;
//Ok Response //Ok Response
@RequestMapping(value = "/getEmployeesByFunctionalGroup1", @RequestMapping(value = "/getEmployeesByFunctionalGroup1",
...@@ -132,7 +131,7 @@ public class ReportsController { ...@@ -132,7 +131,7 @@ public class ReportsController {
// Convert the aggregation result into a List // Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults = mongoTemplate.aggregate(aggregate, ResourceAllocation.class, AggregationResults<ColumnChartData> groupResults = mongoTemplate.aggregate(aggregate, Resource.class,
ColumnChartData.class); ColumnChartData.class);
List<ColumnChartData> result = groupResults.getMappedResults(); List<ColumnChartData> result = groupResults.getMappedResults();
List<String> statusList = new ArrayList(); List<String> statusList = new ArrayList();
...@@ -246,7 +245,7 @@ public class ReportsController { ...@@ -246,7 +245,7 @@ public class ReportsController {
// Convert the aggregation result into a List // Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults1 = mongoTemplate AggregationResults<ColumnChartData> groupResults1 = mongoTemplate
.aggregate(agg1, ResourceAllocation.class, .aggregate(agg1, Resource.class,
ColumnChartData.class); ColumnChartData.class);
List<ColumnChartData> result1 = groupResults1.getMappedResults(); List<ColumnChartData> result1 = groupResults1.getMappedResults();
...@@ -341,11 +340,11 @@ public class ReportsController { ...@@ -341,11 +340,11 @@ public class ReportsController {
@RequestMapping(value = "/fetchEmployeeDetailsByDateBillability", @RequestMapping(value = "/fetchEmployeeDetailsByDateBillability",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceAllocation>> fetchEmployeeDetailsByDateBillability( public ResponseEntity<List<Resource>> fetchEmployeeDetailsByDateBillability(
@RequestParam("billabilityStatus") String billabilityStatus, @RequestParam("billabilityStatus") String billabilityStatus,
@RequestParam("reportDate") String reportDateString) @RequestParam("reportDate") String reportDateString)
throws MyTeamException { throws MyTeamException {
List<ResourceAllocation> empList = new ArrayList<>(); List<Resource> empList = new ArrayList<>();
if (reportDateString != null && !reportDateString.isEmpty()) { if (reportDateString != null && !reportDateString.isEmpty()) {
String pattern = "MM-dd-yyyy"; String pattern = "MM-dd-yyyy";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
...@@ -368,7 +367,7 @@ public class ReportsController { ...@@ -368,7 +367,7 @@ public class ReportsController {
criteriaV1.orOperator(criteriaV21, criteriaV22)); criteriaV1.orOperator(criteriaV21, criteriaV22));
Query query = new Query(); Query query = new Query();
query.addCriteria(criteriaV221); query.addCriteria(criteriaV221);
empList = mongoTemplate.find(query, ResourceAllocation.class); empList = mongoTemplate.find(query, Resource.class);
} }
return new ResponseEntity<>(empList, HttpStatus.OK); return new ResponseEntity<>(empList, HttpStatus.OK);
} }
......
...@@ -4,13 +4,13 @@ package com.nisum.myteam.controller; ...@@ -4,13 +4,13 @@ package com.nisum.myteam.controller;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.exception.handler.ResponseDetails; import com.nisum.myteam.exception.handler.ResponseDetails;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.ResourceAllocation; import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.EmployeeShiftsVO; import com.nisum.myteam.model.vo.EmployeeShiftsVO;
import com.nisum.myteam.model.vo.ResourceVO; import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.repository.EmployeeVisaRepo; import com.nisum.myteam.repository.EmployeeVisaRepo;
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.service.impl.ResourceAllocationService; import com.nisum.myteam.service.impl.ResourceService;
import com.nisum.myteam.utils.MyTeamUtils; import com.nisum.myteam.utils.MyTeamUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -27,7 +27,7 @@ import java.util.List; ...@@ -27,7 +27,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping @RequestMapping
@Slf4j @Slf4j
public class ResourceAllocationController { public class ResourceController {
@Autowired @Autowired
private IEmployeeService employeeService; private IEmployeeService employeeService;
...@@ -39,19 +39,19 @@ public class ResourceAllocationController { ...@@ -39,19 +39,19 @@ public class ResourceAllocationController {
private EmployeeVisaRepo employeeVisaRepo; private EmployeeVisaRepo employeeVisaRepo;
@Autowired @Autowired
private ResourceAllocationService resourceAllocService; private ResourceService 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 ResourceAllocation resourceAllocationReq, public ResponseEntity<?> createResource(@RequestBody Resource resourceAllocationReq,
@RequestParam(value = "loginEmpId", required = true) String loginEmpId, HttpServletRequest request) throws MyTeamException { @RequestParam(value = "loginEmpId", required = true) String loginEmpId, HttpServletRequest request) throws MyTeamException {
if (StringUtils.isNotBlank(loginEmpId)) { if (StringUtils.isNotBlank(loginEmpId)) {
resourceAllocationReq.setAuditFields(loginEmpId, MyTeamUtils.CREATE); resourceAllocationReq.setAuditFields(loginEmpId, MyTeamUtils.CREATE);
if (resourceAllocService.validateBillingStartEndDateAgainstProjectStartEndDate(resourceAllocationReq, loginEmpId)) { if (resourceService.validateBillingStartEndDateAgainstProjectStartEndDate(resourceAllocationReq, loginEmpId)) {
if (resourceAllocService.validateBillingStartDateAgainstDOJ(resourceAllocationReq)) { if (resourceService.validateBillingStartDateAgainstDOJ(resourceAllocationReq)) {
if (!resourceAllocService.isResourceAssignedToAnyProject(resourceAllocationReq)) { if (!resourceService.isResourceAssignedToAnyProject(resourceAllocationReq)) {
if(!resourceAllocService.isResourceExistsForProject(resourceAllocationReq.getEmployeeId(),resourceAllocationReq.getProjectId())) { if(!resourceService.isResourceExistsForProject(resourceAllocationReq.getEmployeeId(),resourceAllocationReq.getProjectId())) {
ResourceAllocation resourcePersisted = resourceAllocService.addResourceAllocation(resourceAllocationReq, loginEmpId); Resource resourcePersisted = resourceService.addResource(resourceAllocationReq, loginEmpId);
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), 800, "Resource has been created", ResponseDetails createResponseDetails = new ResponseDetails(new Date(), 800, "Resource has been created",
"Resource description", null, request.getContextPath(), "details", resourcePersisted); "Resource description", null, request.getContextPath(), "details", resourcePersisted);
...@@ -61,7 +61,7 @@ public class ResourceAllocationController { ...@@ -61,7 +61,7 @@ public class ResourceAllocationController {
} }
} }
ResponseDetails responseDetails = new ResponseDetails(new Date(), Integer.parseInt(resourceAllocService.respMap.get("statusCode").toString()), resourceAllocService.respMap.get("message").toString(), ResponseDetails responseDetails = new ResponseDetails(new Date(), Integer.parseInt(resourceService.respMap.get("statusCode").toString()), resourceService.respMap.get("message").toString(),
"Error message desc", null, request.getRequestURI(), "Resource details", resourceAllocationReq); "Error message desc", null, request.getRequestURI(), "Resource details", resourceAllocationReq);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
...@@ -73,21 +73,21 @@ public class ResourceAllocationController { ...@@ -73,21 +73,21 @@ public class ResourceAllocationController {
} }
@RequestMapping(value = "/resources", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateResource(@RequestBody ResourceAllocation resourceAllocationReq, public ResponseEntity<?> updateResource(@RequestBody Resource resourceAllocationReq,
@RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException { @RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
if (StringUtils.isNotBlank(loginEmpId)) { if (StringUtils.isNotBlank(loginEmpId)) {
resourceAllocationReq.setAuditFields(loginEmpId, MyTeamUtils.UPDATE); resourceAllocationReq.setAuditFields(loginEmpId, MyTeamUtils.UPDATE);
if (resourceAllocService.isResourceExistsForProject(resourceAllocationReq.getEmployeeId(), resourceAllocationReq.getProjectId())) { if (resourceService.isResourceExistsForProject(resourceAllocationReq.getEmployeeId(), resourceAllocationReq.getProjectId())) {
resourceAllocService.updateResourceDetails(resourceAllocationReq, loginEmpId); resourceService.updateResourceDetails(resourceAllocationReq, loginEmpId);
// resourceAllocService.insertNewResourceAllocWithNewStatus(resourceAllocationReq, loginEmpId); // resourceService.insertNewResourceWithNewStatus(resourceAllocationReq, loginEmpId);
} }
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), Integer.parseInt(resourceAllocService.respMap.get("statusCode").toString()), ResponseDetails createResponseDetails = new ResponseDetails(new Date(), Integer.parseInt(resourceService.respMap.get("statusCode").toString()),
resourceAllocService.respMap.get("message").toString(), "Resource description", null, request.getContextPath(), resourceService.respMap.get("message").toString(), "Resource description", null, request.getContextPath(),
"Resource details", resourceAllocationReq); "Resource details", resourceAllocationReq);
return new ResponseEntity<ResponseDetails>(createResponseDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(createResponseDetails, HttpStatus.OK);
} }
...@@ -97,10 +97,10 @@ public class ResourceAllocationController { ...@@ -97,10 +97,10 @@ public class ResourceAllocationController {
} }
@RequestMapping(value = "/resources", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deleteResource(@RequestBody ResourceAllocation resourceReq, public ResponseEntity<?> deleteResource(@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 {
if (StringUtils.isNotBlank(loginEmpId)) { if (StringUtils.isNotBlank(loginEmpId)) {
resourceAllocService.deleteResource(resourceReq, loginEmpId); resourceService.deleteResource(resourceReq, loginEmpId);
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), 601, "Resource has been deleted", ResponseDetails createResponseDetails = new ResponseDetails(new Date(), 601, "Resource has been deleted",
"Resource description", null, request.getContextPath(), "Resource details", resourceReq); "Resource description", null, request.getContextPath(), "Resource details", resourceReq);
...@@ -120,7 +120,7 @@ public class ResourceAllocationController { ...@@ -120,7 +120,7 @@ public class ResourceAllocationController {
throws MyTeamException { throws MyTeamException {
if (StringUtils.isNotBlank(projectId)) { if (StringUtils.isNotBlank(projectId)) {
List<ResourceVO> resourcesList = resourceAllocService.getResourcesForProject(projectId, status); List<ResourceVO> resourcesList = resourceService.getResourcesForProject(projectId, status);
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 a project", resourcesList, request.getRequestURI(), "Resource details", null); "List of Resources for a project", resourcesList, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
...@@ -137,7 +137,7 @@ public class ResourceAllocationController { ...@@ -137,7 +137,7 @@ public class ResourceAllocationController {
if (employeeId != null && !"".equalsIgnoreCase(employeeId)) { if (employeeId != null && !"".equalsIgnoreCase(employeeId)) {
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 604, "Retrieved the project allocations successfully", ResponseDetails getRespDetails = new ResponseDetails(new Date(), 604, "Retrieved the project allocations successfully",
"Projects allocations for an employee", resourceAllocService.getWorkedProjectsForResource(employeeId), request.getRequestURI(), "Project details", null); "Projects allocations for an employee", resourceService.getWorkedProjectsForResource(employeeId), request.getRequestURI(), "Project details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
} }
...@@ -154,7 +154,7 @@ public class ResourceAllocationController { ...@@ -154,7 +154,7 @@ public class ResourceAllocationController {
@RequestMapping(value = "/resources/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesAllocatedForAllProjects(HttpServletRequest request) throws MyTeamException { public ResponseEntity<?> getResourcesAllocatedForAllProjects(HttpServletRequest request) throws MyTeamException {
List<ResourceAllocation> resourcesList = resourceAllocService.getAllResourcesForAllActiveProjects(); List<Resource> resourcesList = resourceService.getAllResourcesForAllActiveProjects();
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 the projects", resourcesList, request.getRequestURI(), "Resource details", null); "List of Resources for the projects", resourcesList, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
...@@ -168,7 +168,7 @@ public class ResourceAllocationController { ...@@ -168,7 +168,7 @@ public class ResourceAllocationController {
throws MyTeamException { throws MyTeamException {
if (StringUtils.isNotBlank(employeeId)) { if (StringUtils.isNotBlank(employeeId)) {
List<ResourceAllocation> resourcesList = resourceAllocService.getResourcesSortByBillingStartDate(employeeId); List<Resource> resourcesList = resourceService.getResourcesSortByBillingStartDate(employeeId);
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 an employee", resourcesList, request.getRequestURI(), "Resource List details", null); "List of Resources for an employee", resourcesList, request.getRequestURI(), "Resource List details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
...@@ -185,7 +185,7 @@ public class ResourceAllocationController { ...@@ -185,7 +185,7 @@ public class ResourceAllocationController {
public ResponseEntity<?> getActiveResources(@RequestParam(value = "employeeId", required = false) String employeeId, HttpServletRequest request) public ResponseEntity<?> getActiveResources(@RequestParam(value = "employeeId", required = false) String employeeId, HttpServletRequest request)
throws MyTeamException { throws MyTeamException {
if (StringUtils.isNotBlank(employeeId)) { if (StringUtils.isNotBlank(employeeId)) {
List<ResourceVO> employeesRoles = resourceAllocService.getActiveResources(employeeId); List<ResourceVO> employeesRoles = resourceService.getActiveResources(employeeId);
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 active in the projects", employeesRoles, request.getRequestURI(), "Resource List details", null); "List of Resources who are active in the projects", employeesRoles, request.getRequestURI(), "Resource List details", null);
...@@ -204,7 +204,7 @@ public class ResourceAllocationController { ...@@ -204,7 +204,7 @@ public class ResourceAllocationController {
throws MyTeamException { throws MyTeamException {
if (StringUtils.isNotBlank(deliveryLeadId)) { if (StringUtils.isNotBlank(deliveryLeadId)) {
List<ResourceAllocation> resourcesList = resourceAllocService.getResourcesUnderDeliveryLead(deliveryLeadId); List<Resource> resourcesList = resourceService.getResourcesUnderDeliveryLead(deliveryLeadId);
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 a Delivery Lead", resourcesList, request.getRequestURI(), "Resource details", null); "List of Resources for a Delivery Lead", resourcesList, request.getRequestURI(), "Resource details", null);
...@@ -219,7 +219,7 @@ public class ResourceAllocationController { ...@@ -219,7 +219,7 @@ public class ResourceAllocationController {
@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 = resourceAllocService.getUnAssignedEmployees(); List<Employee> employeesList = resourceService.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);
...@@ -230,14 +230,14 @@ public class ResourceAllocationController { ...@@ -230,14 +230,14 @@ public class ResourceAllocationController {
@RequestMapping(value = "/resources/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceVO>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId) public ResponseEntity<List<ResourceVO>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
throws MyTeamException { throws MyTeamException {
List<ResourceVO> resourceAllocList = resourceAllocService.getBillingsForEmployee(employeeId); List<ResourceVO> resourceAllocList = resourceService.getBillingsForEmployee(employeeId);
return new ResponseEntity<>(resourceAllocList, HttpStatus.OK); return new ResponseEntity<>(resourceAllocList, HttpStatus.OK);
} }
@RequestMapping(value = "/resources/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceAllocation>> getBillingsForProject(@PathVariable("projectId") String projectId, public ResponseEntity<List<Resource>> getBillingsForProject(@PathVariable("projectId") String projectId,
@RequestParam("employeeId") String employeeId) throws MyTeamException { @RequestParam("employeeId") String employeeId) throws MyTeamException {
List<ResourceAllocation> resourceAllocList = resourceAllocService.getBillingsForProject(employeeId, projectId); List<Resource> resourceAllocList = resourceService.getBillingsForProject(employeeId, projectId);
return new ResponseEntity<>(resourceAllocList, HttpStatus.OK); return new ResponseEntity<>(resourceAllocList, HttpStatus.OK);
} }
...@@ -247,7 +247,7 @@ public class ResourceAllocationController { ...@@ -247,7 +247,7 @@ public class ResourceAllocationController {
throws MyTeamException { throws MyTeamException {
if (StringUtils.isNotBlank(shift)) { if (StringUtils.isNotBlank(shift)) {
List<EmployeeShiftsVO> resourcesList = resourceAllocService.getResourcesForShift(shift); List<EmployeeShiftsVO> resourcesList = resourceService.getResourcesForShift(shift);
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 the provided shift", resourcesList, request.getRequestURI(), "Resource List for shift", null); "List of Resources for the provided shift", resourcesList, request.getRequestURI(), "Resource List for shift", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
......
...@@ -17,7 +17,7 @@ import java.util.Date; ...@@ -17,7 +17,7 @@ import java.util.Date;
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "resourceAllocation") @Document(collection = "resourceAllocation")
public class ResourceAllocation extends AuditFields implements Serializable { public class Resource extends AuditFields implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -2,22 +2,21 @@ package com.nisum.myteam.repository; ...@@ -2,22 +2,21 @@ package com.nisum.myteam.repository;
import com.nisum.myteam.model.dao.Resource; import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.dao.ResourceAllocation;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List; import java.util.List;
public interface ResourceAllocationRepo public interface ResourceRepo
extends MongoRepository<ResourceAllocation, String> { extends MongoRepository<Resource, String> {
List<ResourceAllocation> findByProjectId(String projectId); List<Resource> findByProjectId(String projectId);
List<ResourceAllocation> findByEmployeeId(String employeeId); List<Resource> findByEmployeeId(String employeeId);
ResourceAllocation findById(ObjectId id); Resource findById(ObjectId id);
List<ResourceAllocation> findByEmployeeIdAndProjectId(String employeeId, String projectId); List<Resource> findByEmployeeIdAndProjectId(String employeeId, String projectId);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status); // List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
......
...@@ -4,7 +4,7 @@ import com.nisum.myteam.exception.handler.MyTeamException; ...@@ -4,7 +4,7 @@ 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.EmpLoginData; import com.nisum.myteam.model.dao.EmpLoginData;
import com.nisum.myteam.model.dao.Project; import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.model.dao.ResourceAllocation; import com.nisum.myteam.model.dao.Resource;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -58,7 +58,7 @@ public interface IProjectService { ...@@ -58,7 +58,7 @@ public interface IProjectService {
public List<Project> getProjectsForDeliveryLead(String deliveryLeadId); public List<Project> getProjectsForDeliveryLead(String deliveryLeadId);
List<ResourceAllocation> getResourcesUnderProject(String empId); List<Resource> getResourcesUnderProject(String empId);
} }
...@@ -2,40 +2,40 @@ package com.nisum.myteam.service; ...@@ -2,40 +2,40 @@ package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException; 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.ResourceAllocation; import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.EmployeeShiftsVO; import com.nisum.myteam.model.vo.EmployeeShiftsVO;
import com.nisum.myteam.model.vo.MyProjectAllocationVO; import com.nisum.myteam.model.vo.MyProjectAllocationVO;
import com.nisum.myteam.model.vo.ResourceVO; import com.nisum.myteam.model.vo.ResourceVO;
import java.util.List; import java.util.List;
public interface IResourceAllocationService { public interface IResourceService {
ResourceAllocation addResourceAllocation(ResourceAllocation resourceAllocation, String loginEmpId) throws MyTeamException; Resource addResource(Resource resourceAllocation, String loginEmpId) throws MyTeamException;
public void updateExistedResourceAlloc(ResourceAllocation resourceAlloc) throws MyTeamException; public void updateExistedResource(Resource resourceAlloc) throws MyTeamException;
public void insertNewResourceAllocWithNewStatus(ResourceAllocation resourceAllocReq, String loginEmpId) throws MyTeamException; public void insertNewResourceWithNewStatus(Resource resourceAllocReq, String loginEmpId) throws MyTeamException;
void deleteResource(ResourceAllocation resource, String loginEmpId); void deleteResource(Resource resource, String loginEmpId);
List<ResourceAllocation> getAllResourcesForAllActiveProjects(); List<Resource> getAllResourcesForAllActiveProjects();
List<ResourceAllocation> getResourcesSortByBillingStartDate(String employeeId); List<Resource> getResourcesSortByBillingStartDate(String employeeId);
List<ResourceVO> getActiveResources(String empId); List<ResourceVO> getActiveResources(String empId);
public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag); public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag);
public List<ResourceAllocation> getResourcesUnderDeliveryLead(String empId); public List<Resource> getResourcesUnderDeliveryLead(String empId);
public List<ResourceVO> getBillingsForEmployee(String empId); public List<ResourceVO> getBillingsForEmployee(String empId);
public List<ResourceAllocation> getBillingsForProject(String empId, String projectId); public List<Resource> getBillingsForProject(String empId, String projectId);
public List<MyProjectAllocationVO> getWorkedProjectsForResource(String empId); public List<MyProjectAllocationVO> getWorkedProjectsForResource(String empId);
...@@ -43,13 +43,13 @@ public interface IResourceAllocationService { ...@@ -43,13 +43,13 @@ public interface IResourceAllocationService {
public List<Employee> getUnAssignedEmployees(); public List<Employee> getUnAssignedEmployees();
public List<ResourceAllocation> getAllResources(); public List<Resource> getAllResources();
public List<ResourceVO> getAllResourcesVO(); public List<ResourceVO> getAllResourcesVO();
public void deleteResourcesUnderProject(String projectId); public void deleteResourcesUnderProject(String projectId);
public ResourceAllocation addResourceToBenchProject(Employee employee, String loginEmpId) throws MyTeamException; public Resource addResourceToBenchProject(Employee employee, String loginEmpId) throws MyTeamException;
public List<EmployeeShiftsVO> getResourcesForShift(String shift); public List<EmployeeShiftsVO> getResourcesForShift(String shift);
......
...@@ -2,13 +2,12 @@ package com.nisum.myteam.service.impl; ...@@ -2,13 +2,12 @@ package com.nisum.myteam.service.impl;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Project; import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.model.dao.ResourceAllocation;
import com.nisum.myteam.model.vo.EmployeeDashboardVO; import com.nisum.myteam.model.vo.EmployeeDashboardVO;
import com.nisum.myteam.model.vo.ResourceVO; import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.service.IDashboardService; import com.nisum.myteam.service.IDashboardService;
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.service.IResourceAllocationService; import com.nisum.myteam.service.IResourceService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -24,7 +23,7 @@ public class DashboardService implements IDashboardService { ...@@ -24,7 +23,7 @@ public class DashboardService implements IDashboardService {
private IEmployeeService employeeService; private IEmployeeService employeeService;
@Autowired @Autowired
private IResourceAllocationService resourceService; private IResourceService resourceService;
@Autowired @Autowired
private IProjectService projectService; private IProjectService projectService;
...@@ -39,7 +38,7 @@ public class DashboardService implements IDashboardService { ...@@ -39,7 +38,7 @@ public class DashboardService implements IDashboardService {
Map<String, Object> teamMatesStatusMap = new HashMap(); Map<String, Object> teamMatesStatusMap = new HashMap();
// Find all active employees // Find all active employees
//List<ResourceAllocation> resources = resourceService.getAllResources(); //List<Resource> resources = resourceService.getAllResources();
List<ResourceVO> resources = resourceService.getAllResourcesVO(); List<ResourceVO> resources = resourceService.getAllResourcesVO();
......
...@@ -49,7 +49,7 @@ public class EmployeeService implements IEmployeeService { ...@@ -49,7 +49,7 @@ public class EmployeeService implements IEmployeeService {
private IEmployeeLocationService empLocationService; private IEmployeeLocationService empLocationService;
@Autowired @Autowired
private IResourceAllocationService resourceService; private IResourceService resourceService;
@Override @Override
public Employee createEmployee(Employee employee, String loginEmpId) throws MyTeamException { public Employee createEmployee(Employee employee, String loginEmpId) throws MyTeamException {
......
...@@ -40,7 +40,7 @@ public class ProjectService implements IProjectService { ...@@ -40,7 +40,7 @@ public class ProjectService implements IProjectService {
private IDomainService domainService; private IDomainService domainService;
@Autowired @Autowired
private ResourceAllocationService resourceAllocService; private ResourceService resourceService;
@Autowired @Autowired
private IEmployeeService employeeService; private IEmployeeService employeeService;
...@@ -130,7 +130,7 @@ public class ProjectService implements IProjectService { ...@@ -130,7 +130,7 @@ public class ProjectService implements IProjectService {
Project project = projectRepo.findByProjectId(projectId); Project project = projectRepo.findByProjectId(projectId);
projectRepo.delete(project); projectRepo.delete(project);
resourceAllocService.deleteResourcesUnderProject(projectId); resourceService.deleteResourcesUnderProject(projectId);
} }
...@@ -198,19 +198,19 @@ public class ProjectService implements IProjectService { ...@@ -198,19 +198,19 @@ public class ProjectService implements IProjectService {
} }
@Override @Override
public List<ResourceAllocation> getResourcesUnderProject(String empId) { public List<Resource> getResourcesUnderProject(String empId) {
List<String> projectsIdsList = new ArrayList<>(); List<String> projectsIdsList = new ArrayList<>();
List<ResourceAllocation> resourcesList = new ArrayList<>(); List<Resource> resourcesList = new ArrayList<>();
List<Project> projectsList = projectRepo.findByDeliveryLeadIds(empId); List<Project> projectsList = projectRepo.findByDeliveryLeadIds(empId);
for (Project project : projectsList) for (Project project : projectsList)
projectsIdsList.add(project.getProjectId()); projectsIdsList.add(project.getProjectId());
Query query = new Query(Criteria.where("projectId").in(projectsIdsList)); Query query = new Query(Criteria.where("projectId").in(projectsIdsList));
List<ResourceAllocation> resourcesListPersisted = mongoTemplate.find(query, ResourceAllocation.class); List<Resource> resourcesListPersisted = mongoTemplate.find(query, Resource.class);
for (ResourceAllocation resource : resourcesListPersisted) { for (Resource resource : resourcesListPersisted) {
if (!resource.getEmployeeId().equals(empId)) if (!resource.getEmployeeId().equals(empId))
resourcesList.add(resource); resourcesList.add(resource);
} }
...@@ -247,7 +247,7 @@ public class ProjectService implements IProjectService { ...@@ -247,7 +247,7 @@ public class ProjectService implements IProjectService {
} }
private String validateAgainstDOJ(ResourceAllocation resource) { private String validateAgainstDOJ(Resource resource) {
String response = null; String response = null;
Date empDoj = employeeService.getEmployeeById(resource.getEmployeeId()).getDateOfJoining(); Date empDoj = employeeService.getEmployeeById(resource.getEmployeeId()).getDateOfJoining();
if (resource.getBillingStartDate().compareTo(empDoj) < 0) { if (resource.getBillingStartDate().compareTo(empDoj) < 0) {
...@@ -405,7 +405,7 @@ public class ProjectService implements IProjectService { ...@@ -405,7 +405,7 @@ public class ProjectService implements IProjectService {
// public Resource addNewBeanchAllocation(Employee employee, String loginEmpId) { // public Resource addNewBeanchAllocation(Employee employee, String loginEmpId) {
// ResourceAllocation resourcePersisted = null; // Resource resourcePersisted = null;
// Resource resourceBench = new Resource(); // Resource resourceBench = new Resource();
// resourceBench.setAccount(MyTeamUtils.BENCH_ACCOUNT); // resourceBench.setAccount(MyTeamUtils.BENCH_ACCOUNT);
// resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS); // resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
......
...@@ -5,7 +5,7 @@ import com.nisum.myteam.model.dao.*; ...@@ -5,7 +5,7 @@ import com.nisum.myteam.model.dao.*;
import com.nisum.myteam.model.vo.EmployeeShiftsVO; import com.nisum.myteam.model.vo.EmployeeShiftsVO;
import com.nisum.myteam.model.vo.MyProjectAllocationVO; import com.nisum.myteam.model.vo.MyProjectAllocationVO;
import com.nisum.myteam.model.vo.ResourceVO; import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.repository.ResourceAllocationRepo; import com.nisum.myteam.repository.ResourceRepo;
import com.nisum.myteam.service.*; import com.nisum.myteam.service.*;
import com.nisum.myteam.statuscodes.ResourceStatus; import com.nisum.myteam.statuscodes.ResourceStatus;
import com.nisum.myteam.utils.MyTeamDateUtils; import com.nisum.myteam.utils.MyTeamDateUtils;
...@@ -24,13 +24,13 @@ import java.util.stream.Collectors; ...@@ -24,13 +24,13 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class ResourceAllocationService implements IResourceAllocationService { public class ResourceService implements IResourceService {
@Autowired @Autowired
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Autowired @Autowired
private ResourceAllocationRepo resourceAllocationRepo; private ResourceRepo resourceRepo;
@Autowired @Autowired
private IAccountService accountService; private IAccountService accountService;
...@@ -50,15 +50,15 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -50,15 +50,15 @@ public class ResourceAllocationService implements IResourceAllocationService {
public HashMap<String, Object> respMap = new HashMap<>(); public HashMap<String, Object> respMap = new HashMap<>();
public ResourceAllocation addResourceAllocation(ResourceAllocation resourceAllocation, String loginEmpId) throws MyTeamException { public Resource addResource(Resource resource, String loginEmpId) throws MyTeamException {
return resourceAllocationRepo.save(resourceAllocation); return resourceRepo.save(resource);
} }
public boolean isResourceExistsForProject(String employeeId, String projectId) { public boolean isResourceExistsForProject(String employeeId, String projectId) {
boolean isExists = false; boolean isExists = false;
List<ResourceAllocation> resourceList = resourceAllocationRepo.findByEmployeeIdAndProjectId(employeeId, projectId); List<Resource> resourceList = resourceRepo.findByEmployeeIdAndProjectId(employeeId, projectId);
if (resourceList != null && resourceList.size() > 0) { if (resourceList != null && resourceList.size() > 0) {
isExists = true; isExists = true;
respMap.put("message", "Resourse is already in the project"); respMap.put("message", "Resourse is already in the project");
...@@ -72,40 +72,40 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -72,40 +72,40 @@ public class ResourceAllocationService implements IResourceAllocationService {
public void updateResourceDetails(ResourceAllocation resourceAllocReq, String loginEmpId) throws MyTeamException { public void updateResourceDetails(Resource resourceReq, String loginEmpId) throws MyTeamException {
List<ResourceAllocation> resourceAllocList = resourceAllocationRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId()); List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
List<ResourceAllocation> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList()); List<Resource> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) { if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) {
ResourceAllocation resourceAllocPrev = resourceListWithLatestRecord.get(0); //latest resource record. Resource resourcePrev = resourceListWithLatestRecord.get(0); //latest resource record.
log.info("Requsting Resource Allocation BillingStart Date::::"+resourceAllocReq.getBillingStartDate()); log.info("Requsting Resource Allocation BillingStart Date::::"+resourceReq.getBillingStartDate());
log.info("The before date is::" + MyTeamDateUtils.getDayLessThanDate(resourceAllocReq.getBillingStartDate())); log.info("The before date is::" + MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
if(!resourceAllocPrev.getBillableStatus().equals(resourceAllocReq.getBillableStatus())) { if(!resourcePrev.getBillableStatus().equals(resourceReq.getBillableStatus())) {
if (resourceAllocPrev.getBillingEndDate().compareTo(new Date()) == 0) { if (resourcePrev.getBillingEndDate().compareTo(new Date()) == 0) {
resourceAllocPrev.setBillingEndDate(new Date()); resourcePrev.setBillingEndDate(new Date());
} else { } else {
resourceAllocPrev.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceAllocReq.getBillingStartDate())); //adding resource. resourcePrev.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
} }
insertNewResourceAllocWithNewStatus(resourceAllocReq,loginEmpId); insertNewResourceWithNewStatus(resourceReq,loginEmpId);
}else { }else {
resourceAllocPrev.setResourceRole(resourceAllocReq.getResourceRole()); resourcePrev.setResourceRole(resourceReq.getResourceRole());
resourceAllocPrev.setBillingStartDate(resourceAllocReq.getBillingStartDate()); resourcePrev.setBillingStartDate(resourceReq.getBillingStartDate());
resourceAllocPrev.setBillingEndDate(resourceAllocReq.getBillingEndDate()); resourcePrev.setBillingEndDate(resourceReq.getBillingEndDate());
//resourceAllocPrev.setBillingEndDate(); //adding resource. //resourceAllocPrev.setBillingEndDate(); //adding resource.
} }
log.info("After setting the date:::before saving the Resource::" + resourceAllocPrev); log.info("After setting the date:::before saving the Resource::" + resourcePrev);
this.updateExistedResourceAlloc(resourceAllocPrev); this.updateExistedResource(resourcePrev);
} }
} }
public void updateExistedResourceAlloc(ResourceAllocation resourceAlloc) { public void updateExistedResource(Resource resource) {
if (resourceAlloc != null) { if (resource != null) {
ResourceAllocation resourcePers = resourceAllocationRepo.save(resourceAlloc); Resource resourcePers = resourceRepo.save(resource);
respMap.put("statusCode", 801); respMap.put("statusCode", 801);
respMap.put("message", "Resource updated successfully"); respMap.put("message", "Resource updated successfully");
respMap.put("resourceObj", resourcePers); respMap.put("resourceObj", resourcePers);
...@@ -114,53 +114,53 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -114,53 +114,53 @@ public class ResourceAllocationService implements IResourceAllocationService {
} }
public void insertNewResourceAllocWithNewStatus(ResourceAllocation resourceAllocReq, String loginEmpId) throws MyTeamException { public void insertNewResourceWithNewStatus(Resource resourceReq, String loginEmpId) throws MyTeamException {
resourceAllocReq.setId(null); resourceReq.setId(null);
ResourceAllocation resourceAllocationPers = resourceAllocationRepo.insert(resourceAllocReq); Resource resourcePers = resourceRepo.insert(resourceReq);
respMap.put("statusCode", 801); respMap.put("statusCode", 801);
respMap.put("message", "Resource updated successfully"); respMap.put("message", "Resource updated successfully");
respMap.put("resourceObj", resourceAllocationPers); respMap.put("resourceObj", resourcePers);
} }
public boolean validateBillingStartEndDateAgainstProjectStartEndDate(ResourceAllocation resourceAllocation, String loginEmpId) throws MyTeamException { public boolean validateBillingStartEndDateAgainstProjectStartEndDate(Resource resource, String loginEmpId) throws MyTeamException {
boolean isValid = true; boolean isValid = true;
Project project = projectService.getProjectByProjectId(resourceAllocation.getProjectId()); Project project = projectService.getProjectByProjectId(resource.getProjectId());
log.info("Project::" + project); log.info("Project::" + project);
if (!resourceAllocation.getBillingStartDate().after(project.getProjectStartDate())) { if (!resource.getBillingStartDate().after(project.getProjectStartDate())) {
log.info("Billing start date should be after Project start date"); log.info("Billing start date should be after Project start date");
respMap.put("statusCode", 811); respMap.put("statusCode", 811);
respMap.put("message", "Billing start date should be after Project start date"); respMap.put("message", "Billing start date should be after Project start date");
isValid = false; isValid = false;
} }
if (!resourceAllocation.getBillingStartDate().before(resourceAllocation.getBillingEndDate())) { if (!resource.getBillingStartDate().before(resource.getBillingEndDate())) {
log.info("Billing start date should be before Billing End Date."); log.info("Billing start date should be before Billing End Date.");
respMap.put("statusCode", 812); respMap.put("statusCode", 812);
respMap.put("message", "Billing start date should be before Billing End Date."); respMap.put("message", "Billing start date should be before Billing End Date.");
isValid = false; isValid = false;
} }
log.info("ResourceALloc Req::" + resourceAllocation); log.info("ResourceALloc Req::" + resource);
log.info("" + project.getProjectEndDate().toString()); log.info("" + project.getProjectEndDate().toString());
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) { //if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
if(!(resourceAllocation.getBillingEndDate().compareTo(project.getProjectEndDate())<=0)) { if(!(resource.getBillingEndDate().compareTo(project.getProjectEndDate())<=0)) {
log.info("Billing end date should be on or before Project End Date."); log.info("Billing end date should be on or before Project End Date.");
respMap.put("statusCode", 813); respMap.put("statusCode", 813);
respMap.put("message", "Billing end date should be before Project End Date."); respMap.put("message", "Billing end date should be before Project End Date.");
isValid = false; isValid = false;
} }
respMap.put("resourceObj", resourceAllocation); respMap.put("resourceObj", resource);
return isValid; return isValid;
} }
public boolean validateBillingStartDateAgainstDOJ(ResourceAllocation resource) { public boolean validateBillingStartDateAgainstDOJ(Resource resource) {
String message = ""; String message = "";
boolean isValid = true; boolean isValid = true;
...@@ -178,22 +178,22 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -178,22 +178,22 @@ public class ResourceAllocationService implements IResourceAllocationService {
} }
public boolean isResourceAssignedToAnyProject(ResourceAllocation resourceAllocReq) { public boolean isResourceAssignedToAnyProject(Resource resourceReq) {
boolean isAssigned = false; boolean isAssigned = false;
String message = ""; String message = "";
//List<ResourceAllocation> resourceAllocList = resourceAllocationRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId()); //List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
List<ResourceAllocation> resourceAllocList = resourceAllocationRepo.findByEmployeeId(resourceAllocReq.getEmployeeId()); List<Resource> resourceAllocList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
List<ResourceAllocation> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList()); List<Resource> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) { if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) {
ResourceAllocation resourceAllocPrev = resourceListWithLatestRecord.get(0);//latest resource record. Resource resourcePrev = resourceListWithLatestRecord.get(0);//latest resource record.
if (!resourceAllocPrev.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)) { if (!resourcePrev.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)) {
message = "Resource " + resourceAllocPrev.getEmployeeId() + " already Assigned to the " message = "Resource " + resourcePrev.getEmployeeId() + " already Assigned to the "
+ projectService.getProjectByProjectId(resourceAllocPrev.getProjectId()).getProjectName() + projectService.getProjectByProjectId(resourcePrev.getProjectId()).getProjectName()
+ " Project" + " from " + resourceAllocPrev.getBillingStartDate() + "to " + resourceAllocPrev.getBillingEndDate(); + " Project" + " from " + resourcePrev.getBillingStartDate() + "to " + resourcePrev.getBillingEndDate();
isAssigned = true; isAssigned = true;
respMap.put("statusCode", 815); respMap.put("statusCode", 815);
respMap.put("message", message); respMap.put("message", message);
...@@ -207,15 +207,15 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -207,15 +207,15 @@ public class ResourceAllocationService implements IResourceAllocationService {
public void deleteResource(ResourceAllocation resourceReq, String loginEmpId) { public void deleteResource(Resource resourceReq, String loginEmpId) {
List<ResourceAllocation> resourcesList = resourceAllocationRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId()); List<Resource> resourcesList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
resourcesList.forEach(resource -> resourceAllocationRepo.delete(resource)); resourcesList.forEach(resource -> resourceRepo.delete(resource));
} }
@Override @Override
public List<ResourceAllocation> getAllResources() { public List<Resource> getAllResources() {
return resourceAllocationRepo.findAll(); return resourceRepo.findAll();
} }
...@@ -267,9 +267,9 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -267,9 +267,9 @@ public class ResourceAllocationService implements IResourceAllocationService {
} }
public List<ResourceAllocation> getResourcesSortByBillingStartDate(String employeeId) { public List<Resource> getResourcesSortByBillingStartDate(String employeeId) {
Query query = prepareQuery(employeeId, MyTeamUtils.BILLING_START_DATE); Query query = prepareQuery(employeeId, MyTeamUtils.BILLING_START_DATE);
return mongoTemplate.find(query, ResourceAllocation.class); return mongoTemplate.find(query, Resource.class);
} }
private Query prepareQuery(String employeeId, String dateColumn) { private Query prepareQuery(String employeeId, String dateColumn) {
...@@ -283,7 +283,7 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -283,7 +283,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override @Override
public List<ResourceVO> getActiveResources(String empId) { public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> resourcesList = new ArrayList<>(); List<ResourceVO> resourcesList = new ArrayList<>();
for (ResourceAllocation resource : resourceAllocationRepo.findByEmployeeId(empId)) { for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
if (resource.getBillingEndDate().compareTo(new Date()) > 0) { if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
resourcesList.addAll(prepareProjectTeamMembersList(resource.getProjectId())); resourcesList.addAll(prepareProjectTeamMembersList(resource.getProjectId()));
} }
...@@ -296,7 +296,7 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -296,7 +296,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
List<ResourceVO> finalResourcesList = new ArrayList<>(); List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null; Employee employee = null;
for (ResourceAllocation resource : getAllResourcesForProject(projectId)) { for (Resource resource : getAllResourcesForProject(projectId)) {
ResourceVO resourceVO = new ResourceVO(); ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId()); resourceVO.setId(resource.getId());
...@@ -328,14 +328,14 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -328,14 +328,14 @@ public class ResourceAllocationService implements IResourceAllocationService {
return finalResourcesList; return finalResourcesList;
} }
public List<ResourceAllocation> getAllResourcesForProject(String projectId) { public List<Resource> getAllResourcesForProject(String projectId) {
return resourceAllocationRepo.findByProjectId(projectId); return resourceRepo.findByProjectId(projectId);
} }
@Override @Override
public List<ResourceAllocation> getAllResourcesForAllActiveProjects() { public List<Resource> getAllResourcesForAllActiveProjects() {
List<ResourceAllocation> resourceList = new ArrayList<>(); List<Resource> resourceList = new ArrayList<>();
for (Project activeProject : projectService.getOnlyActiveProjects()) { for (Project activeProject : projectService.getOnlyActiveProjects()) {
resourceList.addAll(getAllResourcesForProject(activeProject.getProjectId())); resourceList.addAll(getAllResourcesForProject(activeProject.getProjectId()));
...@@ -349,7 +349,7 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -349,7 +349,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag) { public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag) {
List<ResourceVO> resourcesList = new ArrayList<>(); List<ResourceVO> resourcesList = new ArrayList<>();
for (ResourceAllocation resource : resourceAllocationRepo.findByProjectId(projectId)) { for (Resource resource : resourceRepo.findByProjectId(projectId)) {
Date billingEndDate = resource.getBillingEndDate(); Date billingEndDate = resource.getBillingEndDate();
if (billingEndDate != null) { if (billingEndDate != null) {
...@@ -395,10 +395,10 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -395,10 +395,10 @@ public class ResourceAllocationService implements IResourceAllocationService {
Employee employee = null; Employee employee = null;
List<MyProjectAllocationVO> myProjectList = new ArrayList<>(); List<MyProjectAllocationVO> myProjectList = new ArrayList<>();
List<ResourceAllocation> resourcesAllocatedList = resourceAllocationRepo.findByEmployeeId(empId); List<Resource> resourcesAllocatedList = resourceRepo.findByEmployeeId(empId);
if (null != resourcesAllocatedList && !resourcesAllocatedList.isEmpty() && MyTeamUtils.INT_ZERO < resourcesAllocatedList.size()) { if (null != resourcesAllocatedList && !resourcesAllocatedList.isEmpty() && MyTeamUtils.INT_ZERO < resourcesAllocatedList.size()) {
for (ResourceAllocation resourceAlloc : resourcesAllocatedList) { for (Resource resourceAlloc : resourcesAllocatedList) {
project = projectService.getProjectByProjectId(resourceAlloc.getProjectId()); project = projectService.getProjectByProjectId(resourceAlloc.getProjectId());
account = accountService.getAccountById(project.getAccountId()); account = accountService.getAccountById(project.getAccountId());
...@@ -434,17 +434,17 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -434,17 +434,17 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override @Override
public List<ResourceAllocation> getResourcesUnderDeliveryLead(String deliveryLeadId) { public List<Resource> getResourcesUnderDeliveryLead(String deliveryLeadId) {
List<String> projectIdsList = new ArrayList<>(); List<String> projectIdsList = new ArrayList<>();
List<ResourceAllocation> resourcesList = new ArrayList<>(); List<Resource> resourcesList = new ArrayList<>();
for (Project project : projectService.getProjectsForDeliveryLead(deliveryLeadId)) for (Project project : projectService.getProjectsForDeliveryLead(deliveryLeadId))
projectIdsList.add(project.getProjectId()); projectIdsList.add(project.getProjectId());
Query query = new Query(Criteria.where("projectId").in(projectIdsList)); Query query = new Query(Criteria.where("projectId").in(projectIdsList));
List<ResourceAllocation> resourcesListPersisted = mongoTemplate.find(query, ResourceAllocation.class); List<Resource> resourcesListPersisted = mongoTemplate.find(query, Resource.class);
for (ResourceAllocation resourceAlloc : resourcesListPersisted) { for (Resource resourceAlloc : resourcesListPersisted) {
if (!resourceAlloc.getEmployeeId().equals(deliveryLeadId)) if (!resourceAlloc.getEmployeeId().equals(deliveryLeadId))
resourcesList.add(resourceAlloc); resourcesList.add(resourceAlloc);
} }
...@@ -456,11 +456,11 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -456,11 +456,11 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override @Override
public List<ResourceVO> getBillingsForEmployee(String empId) { public List<ResourceVO> getBillingsForEmployee(String empId) {
List<ResourceVO> finalList=new ArrayList<>(); List<ResourceVO> finalList=new ArrayList<>();
List<ResourceAllocation> resourcesList = resourceAllocationRepo.findByEmployeeId(empId); List<Resource> resourcesList = resourceRepo.findByEmployeeId(empId);
if (resourcesList != null && resourcesList.size() > 0) { if (resourcesList != null && resourcesList.size() > 0) {
log.info("The resources billing list before sorting::" + resourcesList); log.info("The resources billing list before sorting::" + resourcesList);
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList()); //return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
List<ResourceAllocation> sortedList = resourcesList.stream().sorted(Comparator.comparing(ResourceAllocation::getBillingStartDate).reversed()).collect(Collectors.toList()); List<Resource> sortedList = resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList());
finalList= convertResourcesToResourcesVO(sortedList); finalList= convertResourcesToResourcesVO(sortedList);
} }
...@@ -468,14 +468,14 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -468,14 +468,14 @@ public class ResourceAllocationService implements IResourceAllocationService {
} }
@Override @Override
public List<ResourceAllocation> getBillingsForProject(String empId, String projectId) { public List<Resource> getBillingsForProject(String empId, String projectId) {
List<ResourceAllocation> resourcesList = resourceAllocationRepo.findByEmployeeIdAndProjectId(empId, projectId); List<Resource> resourcesList = resourceRepo.findByEmployeeIdAndProjectId(empId, projectId);
if (resourcesList == null || resourcesList.size() == 0) { if (resourcesList == null || resourcesList.size() == 0) {
return resourcesList; return resourcesList;
} else { } else {
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList()); //return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return resourcesList.stream().sorted(Comparator.comparing(ResourceAllocation::getBillingStartDate).reversed()).collect(Collectors.toList()); return resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList());
} }
} }
...@@ -487,7 +487,7 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -487,7 +487,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
List<Employee> notAssignedEmployees = new ArrayList<>(); List<Employee> notAssignedEmployees = new ArrayList<>();
List<String> resourceIdsList = new ArrayList<>(); List<String> resourceIdsList = new ArrayList<>();
for (ResourceAllocation resource : this.getAllResources()) { for (Resource resource : this.getAllResources()) {
Project project = projectService.getProjectByProjectId(resource.getProjectId()); Project project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null && project.getStatus() != null && !"Completed".equalsIgnoreCase(project.getStatus())) { if (project != null && project.getStatus() != null && !"Completed".equalsIgnoreCase(project.getStatus())) {
resourceIdsList.add(resource.getEmployeeId()); resourceIdsList.add(resource.getEmployeeId());
...@@ -505,13 +505,13 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -505,13 +505,13 @@ public class ResourceAllocationService implements IResourceAllocationService {
public void deleteResourcesUnderProject(String projectId) { public void deleteResourcesUnderProject(String projectId) {
Query query = new Query(Criteria.where("projectId").is(projectId)); Query query = new Query(Criteria.where("projectId").is(projectId));
List<ResourceAllocation> list = mongoTemplate.find(query, ResourceAllocation.class); List<Resource> list = mongoTemplate.find(query, Resource.class);
resourceAllocationRepo.delete(list); resourceRepo.delete(list);
} }
private List<ResourceVO> convertResourcesToResourcesVO(List<ResourceAllocation> resourcesList) { private List<ResourceVO> convertResourcesToResourcesVO(List<Resource> resourcesList) {
List<ResourceVO> finalList = new ArrayList<>(); List<ResourceVO> finalList = new ArrayList<>();
if (resourcesList != null && resourcesList.size() > 0) { if (resourcesList != null && resourcesList.size() > 0) {
...@@ -565,10 +565,10 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -565,10 +565,10 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override @Override
public ResourceAllocation addResourceToBenchProject(Employee employee, String loginEmpId) throws MyTeamException { public Resource addResourceToBenchProject(Employee employee, String loginEmpId) throws MyTeamException {
ResourceAllocation resourcePersisted = null; Resource resourcePersisted = null;
ResourceAllocation resourceBench = new ResourceAllocation(); Resource resourceBench = new Resource();
resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID); resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID);
resourceBench.setEmployeeId(employee.getEmployeeId()); resourceBench.setEmployeeId(employee.getEmployeeId());
resourceBench.setResourceRole(employee.getRole()); resourceBench.setResourceRole(employee.getRole());
...@@ -576,7 +576,7 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -576,7 +576,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS); resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
resourceBench.setEmployeeId(employee.getEmployeeId()); resourceBench.setEmployeeId(employee.getEmployeeId());
resourceBench.setBillingEndDate(employee.getEndDate()); resourceBench.setBillingEndDate(employee.getEndDate());
resourcePersisted = addResourceAllocation(resourceBench, loginEmpId); resourcePersisted = addResource(resourceBench, loginEmpId);
return resourcePersisted; return resourcePersisted;
...@@ -585,7 +585,7 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -585,7 +585,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override @Override
public List<EmployeeShiftsVO> getResourcesForShift(String shift) { public List<EmployeeShiftsVO> getResourcesForShift(String shift) {
List<ResourceAllocation> resourcesListPers = null; List<Resource> resourcesListPers = null;
List<EmployeeShiftsVO> resourcesList = new ArrayList<>(); List<EmployeeShiftsVO> resourcesList = new ArrayList<>();
List<Project> projects = projectService.getAllProjects(); List<Project> projects = projectService.getAllProjects();
...@@ -593,7 +593,7 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -593,7 +593,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
if ("Active".equalsIgnoreCase(project.getStatus())) { if ("Active".equalsIgnoreCase(project.getStatus())) {
resourcesListPers = getAllResourcesForProject(project.getProjectId()); resourcesListPers = getAllResourcesForProject(project.getProjectId());
for (ResourceAllocation resource : resourcesListPers) { for (Resource resource : resourcesListPers) {
// EmployeeShift empShift = empShiftService.getEmployeeShift(resource.getEmployeeId()); // EmployeeShift empShift = empShiftService.getEmployeeShift(resource.getEmployeeId());
// if (empShift != null) { // if (empShift != null) {
...@@ -643,17 +643,17 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -643,17 +643,17 @@ public class ResourceAllocationService implements IResourceAllocationService {
// public List<ResourceVO> getActiveResources(String empId) { // public List<ResourceVO> getActiveResources(String empId) {
// List<ResourceVO> finalResourcesList = new ArrayList<>(); // List<ResourceVO> finalResourcesList = new ArrayList<>();
// //
// List<ResourceAllocation> resourceList = resourceAllocationRepo.findByEmployeeId(empId); // List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
// if (resourceList != null && resourceList.size() > 0) { // if (resourceList != null && resourceList.size() > 0) {
// //
// ResourceAllocation resourceAlloc=resourceList.get(0); // Resource resourceAlloc=resourceList.get(0);
// //
// //
// //
// //
// } // }
// //
// for (ResourceAllocation resource : resourceAllocationRepo.findByEmployeeId(empId)) { // for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
// //
// ResourceVO resourceVO=new ResourceVO(); // ResourceVO resourceVO=new ResourceVO();
// resourceVO.setEmployeeId(resource.getEmployeeId()); // resourceVO.setEmployeeId(resource.getEmployeeId());
...@@ -682,8 +682,8 @@ public class ResourceAllocationService implements IResourceAllocationService { ...@@ -682,8 +682,8 @@ public class ResourceAllocationService implements IResourceAllocationService {
// List<ResourceVO> finalResourcesList = new ArrayList<>(); // List<ResourceVO> finalResourcesList = new ArrayList<>();
// Employee employee = null; // Employee employee = null;
// //
// List<ResourceAllocation> resourceList = resourceAllocationRepo.findByEmployeeId(empId); // List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
// Optional<ResourceAllocation> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny(); // Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
// if (optionalResource.isPresent()) { // if (optionalResource.isPresent()) {
// finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId()); // finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
// } // }
......
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