Commit 1828c372 authored by Vijay Akula's avatar Vijay Akula

Provided the validation messages for Projects

parent 7a8ddf80
package com.nisum.myteam.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
\ No newline at end of file
...@@ -27,7 +27,7 @@ import com.nisum.myteam.service.IResourceService; ...@@ -27,7 +27,7 @@ import com.nisum.myteam.service.IResourceService;
import com.nisum.myteam.utils.MyTeamUtils; import com.nisum.myteam.utils.MyTeamUtils;
@RestController @RestController
@RequestMapping("/projectTeam") @RequestMapping
public class ResourceController { public class ResourceController {
@Autowired @Autowired
...@@ -70,15 +70,12 @@ public class ResourceController { ...@@ -70,15 +70,12 @@ public class ResourceController {
resourceService.deleteResource(resource.getEmployeeId(), resource.getProjectId(), resource.getId(), loginEmpId); resourceService.deleteResource(resource.getEmployeeId(), resource.getProjectId(), resource.getId(), loginEmpId);
return new ResponseEntity<>("Success", HttpStatus.OK); return new ResponseEntity<>("Success", HttpStatus.OK);
} }
// @RequestMapping(value = "/getEmployeeProjectInfo" // @RequestMapping(value = "/getEmployeeProjectInfo"
@RequestMapping(value = "/resources", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/employeeId/{employeeId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesSortByStartDate(@RequestParam("empId") String empId) public ResponseEntity<List<Resource>> getResourcesSortByStartDate(@PathVariable(value = "employeeId",required = true) String employeeId)
throws MyTeamException { throws MyTeamException {
List<Resource> projectInfo = resourceService.getResourcesSortByStartDate(empId); List<Resource> projectInfo = resourceService.getResourcesSortByStartDate(employeeId);
return new ResponseEntity<>(projectInfo, HttpStatus.OK); return new ResponseEntity<>(projectInfo, HttpStatus.OK);
} }
...@@ -93,7 +90,7 @@ public class ResourceController { ...@@ -93,7 +90,7 @@ public class ResourceController {
// @RequestMapping(value = "/getShiftDetails" // @RequestMapping(value = "/getShiftDetails"
@RequestMapping(value = "/resources/{shift}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/resources/shifts/{shift}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesForShift(@PathVariable("shift") String shift) public ResponseEntity<List<Resource>> getResourcesForShift(@PathVariable("shift") String shift)
throws MyTeamException { throws MyTeamException {
List<Resource> resourcesList = resourceService.getResourcesForShift(shift); List<Resource> resourcesList = resourceService.getResourcesForShift(shift);
...@@ -101,7 +98,7 @@ public class ResourceController { ...@@ -101,7 +98,7 @@ public class ResourceController {
} }
// @RequestMapping(value = "/getProjectAllocations" // @RequestMapping(value = "/getProjectAllocations"
@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<List<Resource>> getResourcesAllocatedForAllProjects() throws MyTeamException { public ResponseEntity<List<Resource>> getResourcesAllocatedForAllProjects() throws MyTeamException {
List<Resource> resourcesList = resourceService.getResourcesForActiveProjects(); List<Resource> resourcesList = resourceService.getResourcesForActiveProjects();
return new ResponseEntity<>(resourcesList, HttpStatus.OK); return new ResponseEntity<>(resourcesList, HttpStatus.OK);
...@@ -127,16 +124,13 @@ public class ResourceController { ...@@ -127,16 +124,13 @@ public class ResourceController {
@RequestMapping(value = "/getUnAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "resources/unAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getUnAssignedEmployees() throws MyTeamException { public ResponseEntity<List<Employee>> getUnAssignedEmployees() throws MyTeamException {
List<Employee> employeesList = projectService.getUnAssignedEmployees(); List<Employee> employeesList = projectService.getUnAssignedEmployees();
return new ResponseEntity<>(employeesList, HttpStatus.OK); return new ResponseEntity<>(employeesList, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeDashboardVO>> getEmployeesDashBoard() throws MyTeamException { public ResponseEntity<List<EmployeeDashboardVO>> getEmployeesDashBoard() throws MyTeamException {
......
...@@ -30,13 +30,13 @@ public class Project extends AuditFields implements Serializable { ...@@ -30,13 +30,13 @@ public class Project extends AuditFields implements Serializable {
private ObjectId id; private ObjectId id;
private String projectId; private String projectId;
private String projectName; private String projectName;
private String domainId;
private String domain; private String domain;
private String accountId;
private String status; private String status;
private List<String> employeeIds; private List<String> employeeIds;
private List<String> managerIds; private List<String> managerIds;
private String accountId;
private String domainId;
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
private Date projectStartDate; private Date projectStartDate;
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
......
...@@ -11,6 +11,8 @@ public interface ProjectRepo extends MongoRepository<Project, String> { ...@@ -11,6 +11,8 @@ public interface ProjectRepo extends MongoRepository<Project, String> {
Project findByProjectId(String projectId); Project findByProjectId(String projectId);
Project findByProjectName(String projectName);
List<Project> findByDeliveryLeadIds(String empId); List<Project> findByDeliveryLeadIds(String empId);
// List<Project> findByManagerId(String managerId); // List<Project> findByManagerId(String managerId);
......
...@@ -5,11 +5,7 @@ import java.util.List; ...@@ -5,11 +5,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.EmpLoginData; import com.nisum.myteam.model.*;
import com.nisum.myteam.model.Employee;
import com.nisum.myteam.model.EmployeeDashboardVO;
import com.nisum.myteam.model.Project;
import com.nisum.myteam.model.Resource;
public interface IProjectService { public interface IProjectService {
...@@ -46,4 +42,17 @@ public interface IProjectService { ...@@ -46,4 +42,17 @@ public interface IProjectService {
public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTeamException; public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTeamException;
public List<Project> getAllProjects(); public List<Project> getAllProjects();
public boolean isProjectExists(String projectName);
public boolean isProjectExistsById(String projectId);
public long getProjectsCount();
public Account getProjectAccount(String accountId);
public Account updateProjSeqinAccount(Account account) throws MyTeamException;
} }
package com.nisum.myteam.service.impl; package com.nisum.myteam.service.impl;
import java.util.ArrayList; import com.nisum.myteam.exception.handler.MyTeamException;
import java.util.Comparator; import com.nisum.myteam.model.*;
import java.util.Date; import com.nisum.myteam.repository.*;
import java.util.HashMap; import com.nisum.myteam.service.IAccountService;
import java.util.HashSet; import com.nisum.myteam.service.IDomainService;
import java.util.List; import com.nisum.myteam.service.IEmployeeService;
import java.util.Map; import com.nisum.myteam.service.IProjectService;
import java.util.Set; import com.nisum.myteam.utils.MyTeamUtils;
import java.util.stream.Collectors; import com.nisum.myteam.utils.PdfReportGenerator;
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;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
...@@ -20,27 +19,8 @@ import org.springframework.data.mongodb.core.query.Query; ...@@ -20,27 +19,8 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update; import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.nisum.myteam.exception.handler.MyTeamException; import java.util.*;
import com.nisum.myteam.model.Account; import java.util.stream.Collectors;
import com.nisum.myteam.model.Billing;
import com.nisum.myteam.model.Domain;
import com.nisum.myteam.model.EmpLoginData;
import com.nisum.myteam.model.Employee;
import com.nisum.myteam.model.EmployeeDashboardVO;
import com.nisum.myteam.model.Project;
import com.nisum.myteam.model.Resource;
import com.nisum.myteam.repository.AccountRepo;
import com.nisum.myteam.repository.DomainRepo;
import com.nisum.myteam.repository.EmployeeRepo;
import com.nisum.myteam.repository.ProjectRepo;
import com.nisum.myteam.repository.ResourceRepo;
import com.nisum.myteam.service.IDomainService;
import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IProjectService;
import com.nisum.myteam.utils.MyTeamUtils;
import com.nisum.myteam.utils.PdfReportGenerator;
import lombok.extern.slf4j.Slf4j;
@Service("projectService") @Service("projectService")
@Slf4j @Slf4j
...@@ -51,7 +31,8 @@ public class ProjectService implements IProjectService { ...@@ -51,7 +31,8 @@ public class ProjectService implements IProjectService {
@Autowired @Autowired
private ProjectRepo projectRepo; private ProjectRepo projectRepo;
@Autowired @Autowired
private ResourceRepo resourceRepo; private ResourceRepo resourceRepo;
...@@ -88,7 +69,10 @@ public class ProjectService implements IProjectService { ...@@ -88,7 +69,10 @@ public class ProjectService implements IProjectService {
@Autowired @Autowired
private IEmployeeService employeeService; private IEmployeeService employeeService;
@Autowired
private IAccountService accountService;
...@@ -96,25 +80,47 @@ public class ProjectService implements IProjectService { ...@@ -96,25 +80,47 @@ public class ProjectService implements IProjectService {
public List<Project> getProjectsUnderDomain(String domainId) { public List<Project> getProjectsUnderDomain(String domainId) {
return projectRepo.findByDomainId(domainId); return projectRepo.findByDomainId(domainId);
} }
public boolean isProjectExists(String projectName) {
boolean isProjectExists = false;
if (projectName != null && !"".equalsIgnoreCase(projectName)) {
Project project = projectRepo.findByProjectName(projectName);
isProjectExists = (project == null) ? false : true;
}
return isProjectExists;
}
public boolean isProjectExistsById(String projectId) {
boolean isProjectExists = false;
if (projectId != null && !"".equalsIgnoreCase(projectId)) {
Project project = projectRepo.findByProjectId(projectId);
isProjectExists = (project == null) ? false : true;
}
return isProjectExists;
}
public long getProjectsCount() {
return projectRepo.count();
}
public Account getProjectAccount(String accountId) {
Account account = null;
if (accountId != null && !"".equalsIgnoreCase(accountId)) {
return accountService.getAccountById(accountId);
}
return account;
}
public Account updateProjSeqinAccount(Account account) throws MyTeamException {
return accountService.updateAccount(account);
}
@Override @Override
public Project createProject(Project project, String loginEmpId) throws MyTeamException { public Project createProject(Project project, String loginEmpId) throws MyTeamException {
if (project.getDomainId() == null) { if (project.getDomainId() == null) {
// Domain domain = new Domain();
// domain.setAccountId(project.getAccountId());
// domain.setDomainName(project.getDomain());
// domain.setDeliveryManagers(project.getManagerIds());
// domain.setStatus(project.getStatus());
// domainController.createDomain(domain,null);
List<Domain> domainsList = domainRepo List<Domain> domainsList = domainRepo
.findByAccountId(project.getAccountId()); .findByAccountId(project.getAccountId());
Domain savedDomain = domainsList.get(0); Domain savedDomain = domainsList.get(0);
...@@ -667,4 +673,6 @@ public class ProjectService implements IProjectService { ...@@ -667,4 +673,6 @@ public class ProjectService implements IProjectService {
} }
return projectsList; return projectsList;
} }
} }
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