Commit 9b203e2a authored by ssathu-nisum-com's avatar ssathu-nisum-com Committed by tdutta-nisum-com

MT-106_Add_role_option_in_addteammate_screen (#57)

parent b46b0f61
...@@ -40,8 +40,10 @@ public class ProjectController { ...@@ -40,8 +40,10 @@ 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=projectAdded.getAccount(); String accountId=projectAdded.getAccountId();
Account account= accountRepo.findByAccountName(accountName); // String accountName=projectAdded.getAccount();
Account account= accountRepo.findByAccountId(accountId);
String 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);
......
package com.nisum.mytime.controller; package com.nisum.mytime.controller;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -37,6 +38,9 @@ public class ProjectTeamController { ...@@ -37,6 +38,9 @@ public class ProjectTeamController {
@Autowired @Autowired
private EmployeeVisaRepo employeeVisaRepo; private EmployeeVisaRepo employeeVisaRepo;
@Autowired
private ProjectController projectController;
@RequestMapping(value = "/employee", method = RequestMethod.GET, @RequestMapping(value = "/employee", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
...@@ -123,6 +127,16 @@ public class ProjectTeamController { ...@@ -123,6 +127,16 @@ 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")) {
Project project = new Project();
project.setProjectName(teamMate.getProjectName());
project.setManagerIds(Arrays.asList(teamMate.getEmployeeId()));
project.setAccountId(teamMate.getAccountId());
project.setDomainId(teamMate.getDomainId());
project.setStatus("Active");
projectController.addProject(project);
}
ProjectTeamMate teamMateDB = projectService ProjectTeamMate teamMateDB = projectService
.addProjectTeamMate(teamMate); .addProjectTeamMate(teamMate);
return new ResponseEntity<>(teamMateDB, HttpStatus.OK); return new ResponseEntity<>(teamMateDB, HttpStatus.OK);
......
...@@ -27,12 +27,17 @@ public class Project implements Serializable { ...@@ -27,12 +27,17 @@ public class Project implements Serializable {
private ObjectId id; private ObjectId id;
private String projectId; private String projectId;
private String projectName; private String projectName;
private String managerId; /*
private String managerName; * After Ui Integration this below commented code will be removed
private String account; */
private String domain; //private String managerId;
// private String managerName;
// private String account;
// private String domain;
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;
} }
...@@ -49,6 +49,8 @@ public class ProjectTeamMate implements Serializable { ...@@ -49,6 +49,8 @@ public class ProjectTeamMate implements Serializable {
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
private Date newBillingStartDate; private Date newBillingStartDate;
private boolean active; private boolean active;
private List<String> managerIds; //private List<String> managerIds;
private String accountId;
private String domainId;
} }
...@@ -7,5 +7,6 @@ import com.nisum.mytime.model.Account; ...@@ -7,5 +7,6 @@ import com.nisum.mytime.model.Account;
public interface AccountRepo extends MongoRepository<Account, String> { public interface AccountRepo extends MongoRepository<Account, String> {
Account findByAccountName(String accontName); Account findByAccountName(String accontName);
Account findByAccountId(String accountId);
Account findByAccountId(String accountId);
} }
\ No newline at end of file
...@@ -10,5 +10,5 @@ public interface ProjectRepo extends MongoRepository<Project, String> { ...@@ -10,5 +10,5 @@ public interface ProjectRepo extends MongoRepository<Project, String> {
Project findByProjectId(String projectId); Project findByProjectId(String projectId);
List<Project> findByManagerId(String managerId); //List<Project> findByManagerId(String managerId);
} }
\ No newline at end of file
...@@ -12,9 +12,9 @@ public interface ProjectTeamMatesRepo ...@@ -12,9 +12,9 @@ public interface ProjectTeamMatesRepo
List<ProjectTeamMate> findByProjectId(String projectId); List<ProjectTeamMate> findByProjectId(String projectId);
List<ProjectTeamMate> findByManagerId(String projectId); // List<ProjectTeamMate> findByManagerId(String projectId);
List<ProjectTeamMate> findByManagerIds(String managerId); // List<ProjectTeamMate> findByManagerIds(String managerId);
List<ProjectTeamMate> findByEmployeeId(String employeeId); List<ProjectTeamMate> findByEmployeeId(String employeeId);
......
...@@ -25,14 +25,18 @@ import org.springframework.util.CollectionUtils; ...@@ -25,14 +25,18 @@ import org.springframework.util.CollectionUtils;
import com.mongodb.BasicDBObject; import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection; import com.mongodb.DBCollection;
import com.nisum.mytime.controller.DomainController;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.BillingDetails; import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.Domains;
import com.nisum.mytime.model.EmpLoginData; import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmpShiftDetails; import com.nisum.mytime.model.EmpShiftDetails;
import com.nisum.mytime.model.EmployeeDashboardVO; import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.EmployeeRoles; 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.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;
...@@ -64,6 +68,18 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -64,6 +68,18 @@ public class ProjectServiceImpl implements ProjectService {
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Autowired @Autowired
private EmpShiftDetailsRepo empShiftDetailsRepo; private EmpShiftDetailsRepo empShiftDetailsRepo;
@Autowired
private DomainController domainController;
@Autowired
private RoleInfoService roleInfoService;
@Autowired
private RoleMappingService roleMappingService;
@Autowired
private AccountRepo accountRepo;
@Override @Override
public List<EmpLoginData> employeeLoginsBasedOnDate(long id, public List<EmpLoginData> employeeLoginsBasedOnDate(long id,
...@@ -93,14 +109,16 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -93,14 +109,16 @@ public class ProjectServiceImpl implements ProjectService {
projectMap.put("id", p.getId()); projectMap.put("id", p.getId());
projectMap.put("projectId", p.getProjectId()); projectMap.put("projectId", p.getProjectId());
projectMap.put("projectName", p.getProjectName()); projectMap.put("projectName", p.getProjectName());
projectMap.put("account", p.getAccount()); Account account= accountRepo.findByAccountId(p.getAccountId());
projectMap.put("domain", p.getDomain()); projectMap.put("account", account);
projectMap.put("accountId", p.getAccountId());
projectMap.put("domainId", p.getDomainId());
projectMap.put("status", p.getStatus()); projectMap.put("status", p.getStatus());
projectMap.put("employeeIds", p.getEmployeeIds()); projectMap.put("employeeIds", p.getEmployeeIds());
if (p.getManagerIds() == null && p.getManagerId() != null) { /*if (p.getManagerIds() == null && p.getManagerId() != null) {
EmployeeList = getEmployeeData(Arrays.asList(p.getManagerId())); EmployeeList = getEmployeeData(Arrays.asList(p.getManagerId()));
} else if (p.getManagerIds() != null) { } else*/ if (p.getManagerIds() != null) {
List<String> managerIds = p.getManagerIds(); List<String> managerIds = p.getManagerIds();
EmployeeList = getEmployeeData(managerIds); EmployeeList = getEmployeeData(managerIds);
...@@ -113,6 +131,14 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -113,6 +131,14 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public Project addProject(Project project) throws MyTimeException { public Project addProject(Project project) throws MyTimeException {
if(project.getDomainId()==null)
{
Domains domain=new Domains();
domain.setAccountId(project.getAccountId());
domain.setDomainId(project.getDomainId());
domain.setDeliveryManagers(project.getManagerIds());
domainController.addDomain(domain);
}
return projectRepo.save(project); return projectRepo.save(project);
} }
...@@ -141,10 +167,10 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -141,10 +167,10 @@ public class ProjectServiceImpl implements ProjectService {
if(project.getManagerIds()!= null) if(project.getManagerIds()!= null)
{ {
update.set("managerIds", project.getManagerIds()); update.set("managerIds", project.getManagerIds());
}else{ }/*else{
update.set("managerIds",Arrays.asList(project.getManagerId())); update.set("managerIds",Arrays.asList(project.getManagerId()));
} }*/
update.set("account", project.getAccount()); update.set("accountId", project.getAccountId());
update.set("status", project.getStatus()); update.set("status", project.getStatus());
FindAndModifyOptions options = new FindAndModifyOptions(); FindAndModifyOptions options = new FindAndModifyOptions();
options.returnNew(true); options.returnNew(true);
...@@ -157,10 +183,10 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -157,10 +183,10 @@ public class ProjectServiceImpl implements ProjectService {
for (ProjectTeamMate emp : employeeDetails) { for (ProjectTeamMate emp : employeeDetails) {
//emp.setManagerId(projectDB.getManagerId()); //emp.setManagerId(projectDB.getManagerId());
//emp.setManagerName(projectDB.getManagerName()); //emp.setManagerName(projectDB.getManagerName());
emp.setAccount(projectDB.getAccount()); emp.setaccountId(projectDB.getAccountId());
emp.setProjectName(projectDB.getProjectName()); emp.setProjectName(projectDB.getProjectName());
//MT-79:Maintatin the managerids in List //MT-79:Maintatin the managerids in List
emp.setManagerIds(projectDB.getManagerIds()); // emp.setManagerIds(projectDB.getManagerIds());
projectTeamMatesRepo.save(emp); projectTeamMatesRepo.save(emp);
} }
} }
...@@ -174,9 +200,17 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -174,9 +200,17 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public List<ProjectTeamMate> getTeamDetails(String empId) { public List<ProjectTeamMate> getTeamDetails(String empId) {
// return projectTeamMatesRepo.findByManagerId(empId); // return projectTeamMatesRepo.findByManagerId(empId);
// MT-79:maintain the ManagerIds in List // MT-79:maintain the ManagerIds in List
return projectTeamMatesRepo.findByManagerIds(empId); List<String> projectsId = new ArrayList<>();
Query query = new Query(Criteria.where("employeeId").is(empId).and("role").is("Lead"));
List<ProjectTeamMate> projectMatesList = mongoTemplate.find(query, ProjectTeamMate.class);
for (ProjectTeamMate projectMate : projectMatesList)
projectsId.add(projectMate.getProjectId());
Query query1 = new Query(Criteria.where("projectId").in(projectsId));
List<ProjectTeamMate> projectMateList = mongoTemplate.find(query1, ProjectTeamMate.class);
// return projectTeamMatesRepo.findByManagerIds(empId);
return projectMateList;
} }
...@@ -235,6 +269,15 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -235,6 +269,15 @@ public class ProjectServiceImpl implements ProjectService {
} }
} }
} }
if (projectTeamMate.getRole().equals("Lead")) {
Query query = new Query(
Criteria.where("employeeId").is(projectTeamMate.getEmployeeId()).and("role").ne("Lead"));
List<ProjectTeamMate> projectMates = mongoTemplate.find(query, ProjectTeamMate.class);
if (projectMates.size() == 0) {
String roleId = roleInfoService.getRole(MyTimeUtils.LEAD);
roleMappingService.saveUniqueEmployeeAndRole(Arrays.asList(projectTeamMate.getEmployeeId()), roleId);
}
}
return pT; return pT;
} }
...@@ -359,8 +402,8 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -359,8 +402,8 @@ public class ProjectServiceImpl implements ProjectService {
newBenchAllocation.setStartDate(new Date()); newBenchAllocation.setStartDate(new Date());
Project p = projectRepo.findByProjectId("Nisum0000"); Project p = projectRepo.findByProjectId("Nisum0000");
newBenchAllocation.setProjectName(p.getProjectName()); newBenchAllocation.setProjectName(p.getProjectName());
newBenchAllocation.setManagerId(p.getManagerId()); // newBenchAllocation.setManagerId(p.getManagerId());
newBenchAllocation.setManagerName(p.getManagerName()); //newBenchAllocation.setManagerName(p.getManagerName());
projectTeamMatesRepo.save(newBenchAllocation); projectTeamMatesRepo.save(newBenchAllocation);
updateShiftDetails(existingTeammate); updateShiftDetails(existingTeammate);
} }
...@@ -451,11 +494,11 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -451,11 +494,11 @@ public class ProjectServiceImpl implements ProjectService {
//return projectTeamMatesRepo.findByProjectId(projectId); //return projectTeamMatesRepo.findByProjectId(projectId);
//MT-79: adding the existing managerIds in List and sending them as response //MT-79: adding the existing managerIds in List and sending them as response
List<ProjectTeamMate> teamMates=projectTeamMatesRepo.findByProjectId(projectId); List<ProjectTeamMate> teamMates=projectTeamMatesRepo.findByProjectId(projectId);
for(ProjectTeamMate pt:teamMates) /* for(ProjectTeamMate pt:teamMates)
{ {
if(pt.getManagerIds()== null && pt.getManagerId()!= null) if(pt.getManagerIds()== null && pt.getManagerId()!= null)
pt.setManagerIds(Arrays.asList(pt.getManagerId())); pt.setManagerIds(Arrays.asList(pt.getManagerId()));
} }*/
return teamMates; return teamMates;
} }
......
...@@ -152,8 +152,8 @@ public class UserServiceImpl implements UserService { ...@@ -152,8 +152,8 @@ public class UserServiceImpl implements UserService {
: new Date()); : new Date());
Project p = projectRepo.findByProjectId("Nisum0000"); Project p = projectRepo.findByProjectId("Nisum0000");
newBenchAllocation.setProjectName(p.getProjectName()); newBenchAllocation.setProjectName(p.getProjectName());
newBenchAllocation.setManagerId(p.getManagerId()); // newBenchAllocation.setManagerId(p.getManagerId());
newBenchAllocation.setManagerName(p.getManagerName()); //newBenchAllocation.setManagerName(p.getManagerName());
try { try {
projectService.addProjectTeamMate(newBenchAllocation); projectService.addProjectTeamMate(newBenchAllocation);
} catch (MyTimeException e) { } catch (MyTimeException e) {
......
...@@ -96,5 +96,6 @@ public class MyTimeUtils { ...@@ -96,5 +96,6 @@ public class MyTimeUtils {
public static final String PROJECT = "Delivery Lead"; public static final String PROJECT = "Delivery Lead";
public static final String DOMAIN = "Delivery Manager"; public static final String DOMAIN = "Delivery Manager";
public static final String IS_ACTIVE = "isActive"; public static final String IS_ACTIVE = "isActive";
public static final String LEAD="Lead";
} }
\ 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