Commit 93d1721d authored by ssathu-nisum-com's avatar ssathu-nisum-com Committed by tdutta-nisum-com

MT-106_Addrole_option_in_addteammatescreen_Issues (#63)

parent 9eae800a
...@@ -40,10 +40,12 @@ public class ProjectController { ...@@ -40,10 +40,12 @@ public class ProjectController {
@RequestMapping(value = "/addProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/addProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Project> addProject(@RequestBody Project projectAdded) throws MyTimeException { public ResponseEntity<Project> addProject(@RequestBody Project projectAdded) throws MyTimeException {
String accountName="";
String accountId=projectAdded.getAccountId(); String accountId=projectAdded.getAccountId();
// String accountName=projectAdded.getAccount(); // String accountName=projectAdded.getAccount();
Account account= accountRepo.findByAccountId(accountId); Account account= accountRepo.findByAccountId(accountId);
String accountName=account.getAccountName(); if(account!=null)
accountName=account.getAccountName();
int sequenceNumber= account.getAccountProjectSequence(); int sequenceNumber= account.getAccountProjectSequence();
account.setAccountProjectSequence(sequenceNumber+1); account.setAccountProjectSequence(sequenceNumber+1);
accountRepo.save(account); accountRepo.save(account);
......
...@@ -127,7 +127,7 @@ public class ProjectTeamController { ...@@ -127,7 +127,7 @@ public class ProjectTeamController {
@RequestBody ProjectTeamMate teamMate) throws MyTimeException { @RequestBody ProjectTeamMate teamMate) throws MyTimeException {
teamMate.setActive(true); teamMate.setActive(true);
// teamMate.setStartDate(new Date()); // teamMate.setStartDate(new Date());
if (teamMate.getRole().equals("Lead")) { if (teamMate.getRole()!= null && teamMate.getRole().equals("Lead")) {
Project project = new Project(); Project project = new Project();
project.setProjectName(teamMate.getProjectName()); project.setProjectName(teamMate.getProjectName());
project.setManagerIds(Arrays.asList(teamMate.getEmployeeId())); project.setManagerIds(Arrays.asList(teamMate.getEmployeeId()));
......
...@@ -37,6 +37,7 @@ import com.nisum.mytime.model.EmployeeRoles; ...@@ -37,6 +37,7 @@ import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.repository.AccountRepo; import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.repository.DomainRepo;
import com.nisum.mytime.repository.EmpShiftDetailsRepo; import com.nisum.mytime.repository.EmpShiftDetailsRepo;
import com.nisum.mytime.repository.EmployeeRolesRepo; import com.nisum.mytime.repository.EmployeeRolesRepo;
import com.nisum.mytime.repository.ProjectRepo; import com.nisum.mytime.repository.ProjectRepo;
...@@ -80,6 +81,9 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -80,6 +81,9 @@ public class ProjectServiceImpl implements ProjectService {
@Autowired @Autowired
private AccountRepo accountRepo; private AccountRepo accountRepo;
@Autowired
private DomainRepo domainRepo;
@Override @Override
public List<EmpLoginData> employeeLoginsBasedOnDate(long id, public List<EmpLoginData> employeeLoginsBasedOnDate(long id,
...@@ -110,7 +114,11 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -110,7 +114,11 @@ public class ProjectServiceImpl implements ProjectService {
projectMap.put("projectId", p.getProjectId()); projectMap.put("projectId", p.getProjectId());
projectMap.put("projectName", p.getProjectName()); projectMap.put("projectName", p.getProjectName());
Account account= accountRepo.findByAccountId(p.getAccountId()); Account account= accountRepo.findByAccountId(p.getAccountId());
projectMap.put("account", account); Domains domain = domainRepo.findByDomainId(p.getDomainId());
if(domain!=null)
projectMap.put("domain", domain.getDomainName());
if(account!=null)
projectMap.put("account", account.getAccountName());
projectMap.put("accountId", p.getAccountId()); projectMap.put("accountId", p.getAccountId());
projectMap.put("domainId", p.getDomainId()); projectMap.put("domainId", p.getDomainId());
projectMap.put("status", p.getStatus()); projectMap.put("status", p.getStatus());
...@@ -200,8 +208,6 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -200,8 +208,6 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public List<ProjectTeamMate> getTeamDetails(String empId) { public List<ProjectTeamMate> getTeamDetails(String empId) {
// return projectTeamMatesRepo.findByManagerId(empId);
// MT-79:maintain the ManagerIds in List
List<String> projectsId = new ArrayList<>(); List<String> projectsId = new ArrayList<>();
Query query = new Query(Criteria.where("employeeId").is(empId).and("role").is("Lead")); Query query = new Query(Criteria.where("employeeId").is(empId).and("role").is("Lead"));
List<ProjectTeamMate> projectMatesList = mongoTemplate.find(query, ProjectTeamMate.class); List<ProjectTeamMate> projectMatesList = mongoTemplate.find(query, ProjectTeamMate.class);
...@@ -209,7 +215,10 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -209,7 +215,10 @@ public class ProjectServiceImpl implements ProjectService {
projectsId.add(projectMate.getProjectId()); projectsId.add(projectMate.getProjectId());
Query query1 = new Query(Criteria.where("projectId").in(projectsId)); Query query1 = new Query(Criteria.where("projectId").in(projectsId));
List<ProjectTeamMate> projectMateList = mongoTemplate.find(query1, ProjectTeamMate.class); List<ProjectTeamMate> projectMateList = mongoTemplate.find(query1, ProjectTeamMate.class);
// return projectTeamMatesRepo.findByManagerIds(empId); for (ProjectTeamMate projectTeamMate : projectMateList) {
if (projectTeamMate.getEmployeeId().equals(empId))
projectMateList.remove(projectTeamMate);
}
return projectMateList; return projectMateList;
} }
...@@ -269,7 +278,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -269,7 +278,7 @@ public class ProjectServiceImpl implements ProjectService {
} }
} }
} }
if (projectTeamMate.getRole().equals("Lead")) { if (projectTeamMate.getRole()!= null && projectTeamMate.getRole().equals("Lead")) {
Query query = new Query( Query query = new Query(
Criteria.where("employeeId").is(projectTeamMate.getEmployeeId()).and("role").ne("Lead")); Criteria.where("employeeId").is(projectTeamMate.getEmployeeId()).and("role").ne("Lead"));
List<ProjectTeamMate> projectMates = mongoTemplate.find(query, ProjectTeamMate.class); List<ProjectTeamMate> projectMates = mongoTemplate.find(query, ProjectTeamMate.class);
......
...@@ -475,8 +475,8 @@ public class UserServiceImpl implements UserService { ...@@ -475,8 +475,8 @@ public class UserServiceImpl implements UserService {
List<EmployeeRoles> employeeRoles = mongoTemplate.find(query, EmployeeRoles.class); List<EmployeeRoles> employeeRoles = mongoTemplate.find(query, EmployeeRoles.class);
for (EmployeeRoles employeesRole : employeeRoles) { for (EmployeeRoles employeesRole : employeeRoles) {
HashMap<String, String> managerMap = new HashMap<>(); HashMap<String, String> managerMap = new HashMap<>();
managerMap.put("id", employeesRole.getEmployeeId()); managerMap.put("employeeId", employeesRole.getEmployeeId());
managerMap.put("name", employeesRole.getEmployeeName()); managerMap.put("employeeName", employeesRole.getEmployeeName());
EmployeeList.add(managerMap); EmployeeList.add(managerMap);
} }
return EmployeeList; return EmployeeList;
......
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