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