Commit 01fb8bfb authored by Vijay Akula's avatar Vijay Akula

Commented the ResourceController in order to take requests from new controller

parent fed165ca
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;
import org.springframework.http.ResponseEntity; //import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; //import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; //import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; //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
@Slf4j //@Slf4j
public class BillingController { //public class BillingController {
//
@Autowired // @Autowired
private IBillingService billingService; // private IBillingService billingService;
//
// @RequestMapping(value = "/addEmployeeBilling" // // @RequestMapping(value = "/addEmployeeBilling"
@RequestMapping(value = "/billing", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) // @RequestMapping(value = "/billing", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> addEmployeeBilling(@RequestBody Billing billing, // public ResponseEntity<Billing> addEmployeeBilling(@RequestBody Billing billing,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTeamException { // @RequestParam(value = "loginEmpId") String loginEmpId) throws MyTeamException {
Billing billingList = billingService.addBilling(billing, loginEmpId); // Billing billingList = billingService.addBilling(billing, loginEmpId);
//
return new ResponseEntity<>(billingList, HttpStatus.OK); // return new ResponseEntity<>(billingList, HttpStatus.OK);
} // }
//
// @RequestMapping(value = "/updateEmployeeBilling", // // @RequestMapping(value = "/updateEmployeeBilling",
@RequestMapping(value = "/billing", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) // @RequestMapping(value = "/billing", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> updateEmployeeBilling(@RequestBody Billing billing, // public ResponseEntity<Billing> updateEmployeeBilling(@RequestBody Billing billing,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTeamException { // @RequestParam(value = "loginEmpId") String loginEmpId) throws MyTeamException {
Billing billingList = billingService.updateBilling(billing, loginEmpId); // Billing billingList = billingService.updateBilling(billing, loginEmpId);
return new ResponseEntity<>(billingList, HttpStatus.OK); // return new ResponseEntity<>(billingList, HttpStatus.OK);
} // }
//
// @RequestMapping(value = "/deleteEmployeeBilling" // // @RequestMapping(value = "/deleteEmployeeBilling"
@RequestMapping(value = "/billing", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) // @RequestMapping(value = "/billing", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> deleteEmployeeBilling(@RequestBody Billing billing) throws MyTeamException { // public ResponseEntity<Billing> deleteEmployeeBilling(@RequestBody Billing billing) throws MyTeamException {
billingService.deleteBilling(billing); // billingService.deleteBilling(billing);
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)
throws MyTeamException { // throws MyTeamException {
List<Billing> billingList = billingService.getBillingsForEmployee(employeeId); // List<Billing> billingList = billingService.getBillingsForEmployee(employeeId);
return new ResponseEntity<>(billingList, HttpStatus.OK); // return new ResponseEntity<>(billingList, HttpStatus.OK);
} // }
//
// @RequestMapping(value = "/getEmployeeBillingDetails" // // @RequestMapping(value = "/getEmployeeBillingDetails"
@RequestMapping(value = "/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) // @RequestMapping(value = "/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Billing>> getBillingsForProject(@PathVariable("projectId") String projectId, // public ResponseEntity<List<Billing>> getBillingsForProject(@PathVariable("projectId") String projectId,
@RequestParam("employeeId") String employeeId) throws MyTeamException { // @RequestParam("employeeId") String employeeId) throws MyTeamException {
List<Billing> billingList = billingService.getBillingsForProject(employeeId, projectId); // List<Billing> billingList = billingService.getBillingsForProject(employeeId, projectId);
return new ResponseEntity<>(billingList, HttpStatus.OK); // return new ResponseEntity<>(billingList, HttpStatus.OK);
} // }
//
} //}
...@@ -25,7 +25,7 @@ public class DashboardController { ...@@ -25,7 +25,7 @@ public class DashboardController {
@Autowired @Autowired
private IDashboardService dashboardService; private IDashboardService dashboardService;
@RequestMapping(value = "/resourceAllocation/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 = dashboardService.getEmployeesDashBoard(); List<EmployeeDashboardVO> employeeDashBoardList = dashboardService.getEmployeesDashBoard();
......
...@@ -41,7 +41,7 @@ public class ResourceAllocationController { ...@@ -41,7 +41,7 @@ public class ResourceAllocationController {
private ResourceAllocationService resourceAllocService; private ResourceAllocationService resourceAllocService;
//tested in all the cases.ok //tested in all the cases.ok
@RequestMapping(value = "/resourceAllocation", 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 ResourceAllocation 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)) {
...@@ -73,7 +73,7 @@ public class ResourceAllocationController { ...@@ -73,7 +73,7 @@ public class ResourceAllocationController {
} }
//tested in all the cases.ok //tested in all the cases.ok
@RequestMapping(value = "/resourceAllocation", 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 ResourceAllocation resourceAllocationReq,
@RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException { @RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
...@@ -95,7 +95,7 @@ public class ResourceAllocationController { ...@@ -95,7 +95,7 @@ public class ResourceAllocationController {
} }
//Tested Ok //Tested Ok
@RequestMapping(value = "/resourceAllocation", 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 ResourceAllocation 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)) {
...@@ -115,7 +115,7 @@ public class ResourceAllocationController { ...@@ -115,7 +115,7 @@ public class ResourceAllocationController {
//Ok Tested in all of the cases //Ok Tested in all of the cases
@RequestMapping(value = "/resourceAllocation/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesForProject(@PathVariable(value = "projectId", required = true) String projectId, public ResponseEntity<?> getResourcesForProject(@PathVariable(value = "projectId", required = true) String projectId,
@RequestParam(value = "status", required = false, defaultValue = MyTeamUtils.ACTIVE) String status, @RequestParam(value = "status", required = false, defaultValue = MyTeamUtils.ACTIVE) String status,
HttpServletRequest request) HttpServletRequest request)
...@@ -135,7 +135,7 @@ public class ResourceAllocationController { ...@@ -135,7 +135,7 @@ public class ResourceAllocationController {
//ok //ok
///getMyProjectAllocations ///getMyProjectAllocations
@RequestMapping(value = "/resourceAllocation/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getMyProjectAllocations( public ResponseEntity<?> getMyProjectAllocations(
@RequestParam("employeeId") String employeeId, HttpServletRequest request) throws MyTeamException { @RequestParam("employeeId") String employeeId, HttpServletRequest request) throws MyTeamException {
...@@ -155,7 +155,7 @@ public class ResourceAllocationController { ...@@ -155,7 +155,7 @@ public class ResourceAllocationController {
//ok //ok
///resourceAllocation/projects has to be changed to /resourceAllocation/activeProjects ///resourceAllocation/projects has to be changed to /resourceAllocation/activeProjects
@RequestMapping(value = "/resourceAllocation/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<ResourceAllocation> resourcesList = resourceAllocService.getAllResourcesForAllActiveProjects();
...@@ -167,7 +167,7 @@ public class ResourceAllocationController { ...@@ -167,7 +167,7 @@ public class ResourceAllocationController {
//ok //Getting Current active resource record //ok //Getting Current active resource record
@RequestMapping(value = "/resourceAllocation/employeeId/{employeeId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/employeeId/{employeeId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesSortByProjectStartDate(@PathVariable(value = "employeeId", required = true) String employeeId, HttpServletRequest request) public ResponseEntity<?> getResourcesSortByProjectStartDate(@PathVariable(value = "employeeId", required = true) String employeeId, HttpServletRequest request)
throws MyTeamException { throws MyTeamException {
...@@ -186,7 +186,7 @@ public class ResourceAllocationController { ...@@ -186,7 +186,7 @@ public class ResourceAllocationController {
//ok tested //ok tested
@RequestMapping(value = "/resourceAllocation/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
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)) {
...@@ -205,7 +205,7 @@ public class ResourceAllocationController { ...@@ -205,7 +205,7 @@ public class ResourceAllocationController {
//ok working //ok working
@RequestMapping(value = "/resourceAllocation/deliverylead/{deliveryLeadId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/deliverylead/{deliveryLeadId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getTeamDetails(@PathVariable(value = "deliveryLeadId", required = true) String deliveryLeadId, HttpServletRequest request) public ResponseEntity<?> getTeamDetails(@PathVariable(value = "deliveryLeadId", required = true) String deliveryLeadId, HttpServletRequest request)
throws MyTeamException { throws MyTeamException {
...@@ -224,7 +224,7 @@ public class ResourceAllocationController { ...@@ -224,7 +224,7 @@ public class ResourceAllocationController {
} }
//ok tested working //ok tested working
@RequestMapping(value = "/resourceAllocation/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 = resourceAllocService.getUnAssignedEmployees();
...@@ -235,7 +235,7 @@ public class ResourceAllocationController { ...@@ -235,7 +235,7 @@ public class ResourceAllocationController {
//@RequestMapping(value = "/getEmployeeBillingDetailsAll" //@RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping(value = "/resourceAllocation/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceAllocation>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId) public ResponseEntity<List<ResourceAllocation>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
throws MyTeamException { throws MyTeamException {
List<ResourceAllocation> resourceAllocList = resourceAllocService.getBillingsForEmployee(employeeId); List<ResourceAllocation> resourceAllocList = resourceAllocService.getBillingsForEmployee(employeeId);
...@@ -243,7 +243,7 @@ public class ResourceAllocationController { ...@@ -243,7 +243,7 @@ public class ResourceAllocationController {
} }
// @RequestMapping(value = "/getEmployeeBillingDetails" // @RequestMapping(value = "/getEmployeeBillingDetails"
@RequestMapping(value = "/resourceAllocation/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<ResourceAllocation>> 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<ResourceAllocation> resourceAllocList = resourceAllocService.getBillingsForProject(employeeId, projectId);
......
...@@ -24,6 +24,6 @@ public interface ResourceRepo ...@@ -24,6 +24,6 @@ public interface ResourceRepo
List<Resource> findByEmployeeIdAndProjectIdAndActive(String employeeId, String projectId, boolean status); List<Resource> findByEmployeeIdAndProjectIdAndActive(String employeeId, String projectId, boolean status);
List<Resource> findByAccountAndActiveAndBillableStatus( String account, boolean status, String billableStatus); List<Resource> findByAccountAndActiveAndBillableStatus( String account, boolean status, String billableStatus);
Optional<List<Resource>> findByActiveAndShiftLikeOrderByEmployeeIdDesc( boolean active, String shift); Optional<List<Resource>> findByActiveAndShiftLikeOrderByEmployeeIdDesc( boolean active, String shift);
} }
...@@ -76,7 +76,7 @@ public class ResourceService implements IResourceService { ...@@ -76,7 +76,7 @@ public class ResourceService implements IResourceService {
resourceReq.setAuditFields(loginEmpId, MyTeamUtils.CREATE); resourceReq.setAuditFields(loginEmpId, MyTeamUtils.CREATE);
Resource resourcePersisted = resourceRepo.save(resourceReq); Resource resourcePersisted = resourceRepo.save(resourceReq);
// Get Active billings for Nisum Bench Project. // Get Active billings for Nisum Bench Project.
List<Billing> listBD = billingService.getActiveBillings(resourcePersisted.getEmployeeId(), "Nisum0000"); List<Billing> listBD = billingService.getActiveBillings(resourcePersisted.getEmployeeId(), "Nisum0000");
...@@ -586,23 +586,23 @@ public class ResourceService implements IResourceService { ...@@ -586,23 +586,23 @@ public class ResourceService implements IResourceService {
return resourcesList; return resourcesList;
} }
@Override @Override
public List<Resource> getResourcesUnderDeliveryLead(String deliveryLeadId) { public List<Resource> getResourcesUnderDeliveryLead(String deliveryLeadId) {
List<String> projectIdsList = new ArrayList<>(); List<String> projectIdsList = new ArrayList<>();
List<Resource> resourcesList = new ArrayList<>(); List<Resource> resourcesList = new ArrayList<>();
List<Project> projectsList = projectRepo.findByDeliveryLeadIds(deliveryLeadId); List<Project> projectsList = projectRepo.findByDeliveryLeadIds(deliveryLeadId);
for (Project project : projectsList) for (Project project : projectsList)
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<Resource> resourcesListPersisted = mongoTemplate.find(query, Resource.class); List<Resource> resourcesListPersisted = mongoTemplate.find(query, Resource.class);
for (Resource resource : resourcesListPersisted) { for (Resource resource : resourcesListPersisted) {
if (!resource.getEmployeeId().equals(deliveryLeadId)) if (!resource.getEmployeeId().equals(deliveryLeadId))
resourcesList.add(resource); resourcesList.add(resource);
......
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