Commit 773f36fc authored by Vijay Akula's avatar Vijay Akula

Provided the details required for MyTeam Page

parent bc7eee70
......@@ -190,7 +190,7 @@ public class ResourceAllocationController {
public ResponseEntity<?> getActiveResources(@RequestParam(value = "employeeId", required = false) String employeeId, HttpServletRequest request)
throws MyTeamException {
if (StringUtils.isNotBlank(employeeId)) {
List<ResourceAllocation> employeesRoles = resourceAllocService.getActiveResources(employeeId);
List<ResourceVO> employeesRoles = resourceAllocService.getActiveResources(employeeId);
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);
......
......@@ -35,4 +35,6 @@ public class ResourceVO {
private String resourceStatus;
private String resourceRole;
private String mobileNo;
}
......@@ -36,7 +36,7 @@ public interface IResourceAllocationService {
// List<Resource> getAllResourcesForProject(String projectId);
List<ResourceAllocation> getActiveResources(String empId);
List<ResourceVO> getActiveResources(String empId);
......
......@@ -207,17 +207,53 @@ public class ResourceAllocationService implements IResourceAllocationService {
}
@Override
public List<ResourceAllocation> getActiveResources(String empId) {
List<ResourceAllocation> resourcesList = new ArrayList<>();
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> resourcesList = new ArrayList<>();
for (ResourceAllocation resource : resourceAllocationRepo.findByEmployeeId(empId)) {
//if (resource.isActive()) {
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
resourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
resourcesList.addAll(prepareProjectTeamMembersList(resource.getProjectId()));
}
}
return resourcesList;
}
public List<ResourceVO> prepareProjectTeamMembersList(String projectId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null;
for (ResourceAllocation resource : getAllResourcesForProject(projectId)) {
ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId());
resourceVO.setEmployeeId(resource.getEmployeeId());
employee = employeeService.getEmployeeById(resource.getEmployeeId());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate());
resourceVO.setResourceRole(resource.getResourceRole());
if(resource.getBillingEndDate().compareTo(new Date())>0)
{
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
}else
{
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
}
finalResourcesList.add(resourceVO);
}
return finalResourcesList;
}
public List<ResourceAllocation> getAllResourcesForProject(String projectId) {
return resourceAllocationRepo.findByProjectId(projectId);
}
......@@ -400,3 +436,56 @@ public class ResourceAllocationService implements IResourceAllocationService {
}
// @Override
// public List<ResourceVO> getActiveResources(String empId) {
// List<ResourceVO> finalResourcesList = new ArrayList<>();
//
// List<ResourceAllocation> resourceList = resourceAllocationRepo.findByEmployeeId(empId);
// if (resourceList != null && resourceList.size() > 0) {
//
// ResourceAllocation resourceAlloc=resourceList.get(0);
//
//
//
//
// }
//
// for (ResourceAllocation resource : resourceAllocationRepo.findByEmployeeId(empId)) {
//
// ResourceVO resourceVO=new ResourceVO();
// resourceVO.setEmployeeId(resource.getEmployeeId());
//
// Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
// resourceVO.setEmployeeName(employee.getEmployeeName());
// resourceVO.setDesignation(employee.getDesignation());
// resourceVO.setEmailId(employee.getEmailId());
// resourceVO.setMobileNo(employee.getMobileNumber());
//
// resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
//
//
// if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
// finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
// }
//
//
// }
// return finalResourcesList;
// }
// @Override
// public List<ResourceVO> getActiveResources(String empId) {
// List<ResourceVO> finalResourcesList = new ArrayList<>();
// Employee employee = null;
//
// List<ResourceAllocation> resourceList = resourceAllocationRepo.findByEmployeeId(empId);
// Optional<ResourceAllocation> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
// if (optionalResource.isPresent()) {
// finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
// }
// return finalResourcesList;
// }
\ No newline at end of file
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