Commit 87dbd1f2 authored by Vijay Akula's avatar Vijay Akula

Added methods for Accounts and Domains

parent 1828c372
package com.nisum.myteam.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.exception.handler.ResponseDetails;
import com.nisum.myteam.model.Account;
import com.nisum.myteam.service.IAccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@RestController
......@@ -47,7 +37,7 @@ public class AccountController {
Account accountPersisted = accountService.createAccount(account);
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), 601, "Account has been created",
"status description",null, request.getContextPath(), "details", accountPersisted);
"Account description",null, request.getContextPath(), "details", accountPersisted);
return new ResponseEntity<ResponseDetails>(createResponseDetails, HttpStatus.OK);
}
......@@ -133,5 +123,36 @@ public class AccountController {
.filter(e -> "Active".equalsIgnoreCase(e.getStatus())).collect(Collectors.toList());
return new ResponseEntity<>(accountsList, HttpStatus.OK);
}
@RequestMapping(value = "/accounts/accountId/{accId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAccountName(@PathVariable("accId") String accountId, HttpServletRequest request) throws MyTeamException {
log.info("Serving the Account Name Get action: accountId:"+accountId);
if (accountId != null && !"".equalsIgnoreCase(accountId)) {
boolean isAccountExists = accountService.isAccountExists(accountId);
log.info("is Account exists with the name " + isAccountExists);
if (isAccountExists) {
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 604, "Retrieved the account Name successfully",
"Account Name", accountService.getAccountById(accountId), request.getRequestURI(), "details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 604, "Account Does Not Exists",
"Account Name", null, request.getRequestURI(), "details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 604, "Please provide Valid account Id",
"Account Name", null, request.getRequestURI(), "details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
}
\ No newline at end of file
......@@ -64,14 +64,6 @@ public class DomainController {
}
@RequestMapping(value = "/domains", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getDomains(HttpServletRequest request) throws MyTeamException {
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 804, "Retrieved the domains successfully",
"Domains list", domainService.getDomainsList(), request.getRequestURI(), "details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
@RequestMapping(value = "/domains", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateDomain(@RequestBody Domain domain, HttpServletRequest request)
......@@ -104,6 +96,16 @@ public class DomainController {
}
@RequestMapping(value = "/domains", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getDomains(HttpServletRequest request) throws MyTeamException {
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 804, "Retrieved the domains successfully",
"Domains list", domainService.getDomainsList(), request.getRequestURI(), "details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
//getting domains list under accountId which is an active.
@RequestMapping(value = "/domains/{accountId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Domain>> getDomains(@PathVariable("accountId") String accountId) throws MyTeamException {
......@@ -112,4 +114,7 @@ public class DomainController {
return new ResponseEntity<>(domains, HttpStatus.OK);
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.bson.types.ObjectId;
@Setter
@Getter
......@@ -28,10 +29,10 @@ public class Account implements Serializable {
private static final long serialVersionUID = 1L;
// private ObjectId id;
@Id
private ObjectId id;
@NotNull
private String accountId;
@NotNull
@Size(min=2,max=50,message="Name should have atlast 2 and less than 50 characters")
......
......@@ -15,6 +15,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.bson.types.ObjectId;
@Setter
@Getter
......@@ -26,7 +27,9 @@ public class Domain implements Serializable {
private static final long serialVersionUID = 1L;
// private ObjectId id;
//private ObjectId id;
@Id
private String domainId;
@NotNull
......
......@@ -15,4 +15,4 @@ public interface AccountRepo extends MongoRepository<Account, String> {
List<Account> findByaccountNameAndAccountId(String accountName,String accountId);
Account findByAccountNameIgnoreCase(String accountName);
}
\ No newline at end of file
}
......@@ -16,6 +16,10 @@ public interface IAccountService {
Account updateAccount(Account account) throws MyTeamException;
boolean isAccountExists(Account account);
boolean isAccountExists(String accountId);
public Account getAccountById(String accountId);
List<Account> getAccounts() throws MyTeamException;
......@@ -25,4 +29,7 @@ public interface IAccountService {
public List<Account> getAccountsAll() throws MyTeamException;
}
package com.nisum.myteam.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import com.nisum.myteam.controller.AccountController;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.Account;
import com.nisum.myteam.model.Employee;
......@@ -26,224 +9,259 @@ import com.nisum.myteam.service.IEmployeeRoleService;
import com.nisum.myteam.service.IRoleService;
import com.nisum.myteam.utils.CommomUtil;
import com.nisum.myteam.utils.MyTeamUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
@Slf4j
public class AccountService implements IAccountService {
@Autowired
private AccountRepo accountRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private IRoleService roleInfoService;
@Autowired
private IEmployeeRoleService roleMappingService;
@Override
public Account createAccount(Account accountReq) throws MyTeamException {
accountReq.setAccountId(generateAccountId());
accountReq.setStatus(MyTeamUtils.STRING_Y);
Account accountPersisted = accountRepo.save(accountReq);
if (log.isInfoEnabled()) {
log.info("Account has been persisted in database with account details::" + accountPersisted);
}
if (accountPersisted != null) {
List<String> accountDmsList = accountReq.getDeliveryManagers();
if (accountDmsList != null && !accountDmsList.isEmpty() && accountDmsList.size() > 0) {
String roleId = roleInfoService.getRole(MyTeamUtils.ACCOUNT);
log.info("Going to add DM role id for account delivery managers::::" + accountDmsList);
roleMappingService.saveUniqueEmployeeAndRole(accountDmsList, roleId);
log.info("Added roleids for delivery managers in rolemapping collection");
}
}
return accountPersisted;
}
@Override
public Account updateAccount(Account accountUpdating) throws MyTeamException {
Account accountBeforeUpdate = accountRepo.findByAccountId(accountUpdating.getAccountId());
accountUpdating.setStatus(accountBeforeUpdate.getStatus());
accountUpdating.setAccountName(accountUpdating.getAccountName().trim());
log.info("Updating the roleids of DeliveryManagers in RoleMapping Collection");
final String roleId = roleInfoService.getRole(MyTeamUtils.ACCOUNT);
updateRoleIdsForDeliveryManager(accountUpdating, roleId);
log.info("Deleting the roleids of DeliveryManagers in RoleMapping Collection");
deleteRoleIdsForDeliveryManager(accountUpdating, roleId);
Account accountUpdated = accountRepo.save(accountUpdating);
log.info("Account updated::"+accountUpdated);
return accountUpdated;
}
@Override
public boolean isAccountExists(Account account) {
Account accountFetched = accountRepo.findByAccountNameIgnoreCase(account.getAccountName());
return (accountFetched != null) ? true : false;
}
@Override
public List<Account> getAccounts() throws MyTeamException {
return accountRepo.findAll();
}
@Override
public List<Map<Object, Object>> getAccountsList() throws MyTeamException {
List<Map<Object, Object>> updatedAccountList = new ArrayList<>();
List<Map<String, String>> updatedEmployeeList = null;
for (Account account : accountRepo.findAll()) {
updatedEmployeeList = new ArrayList<>();
for (Employee employee : getEmployeeDetails(account)) {
updatedEmployeeList.add(getEmployeeDetails(employee));
}
updatedAccountList.add(getAccuntDetails(account, updatedEmployeeList));
}
return updatedAccountList;
}
@Override
public Account deleteAccount(String accountId) throws MyTeamException {
// delete the documents for deliveryManagers in rolemapping collection.
log.info("After updation:: Deleting the Roleids for DeliveryManagers in RoleMapping collection");
deleteRoleidsForDeliveryManagers(accountId);
// updating the status to "InActive".
Query query = new Query(Criteria.where(MyTeamUtils.ACCOUNT_ID).is(accountId));
Update update = new Update();
update.set(MyTeamUtils.STATUS, MyTeamUtils.STRING_N);
FindAndModifyOptions options = new FindAndModifyOptions();
options.upsert(true);
Account updatedAccount = mongoTemplate.findAndModify(query, update, options, Account.class);
log.info("The account updated::" + updatedAccount);
return updatedAccount;
}
// generating the account id.
// accountId format is "Acc001"
private String generateAccountId() throws MyTeamException {
return (MyTeamUtils.ACC + MyTeamUtils.ZERO_) + (getAccounts().size() + MyTeamUtils.ONE);
}
private void updateRoleIdsForDeliveryManager(Account accountReq, String roleId) throws MyTeamException {
List<String> updatingDmsList = accountReq.getDeliveryManagers();
List<String> persistedDmsList = accountRepo.findByAccountId(accountReq.getAccountId()).getDeliveryManagers();
List<String> dmsAddedByUser = CommomUtil.getAddedManagersList(persistedDmsList, updatingDmsList);
roleMappingService.saveUniqueEmployeeAndRole(dmsAddedByUser, roleId);
}
private void deleteRoleIdsForDeliveryManager(Account accountUpdating, String roleId) throws MyTeamException {
List<String> dmIdList = null;
Map<String, Integer> dmsCountMap = new HashMap<String, Integer>();
List<String> updatingDmsList = accountUpdating.getDeliveryManagers();
List<String> persistedDmsList = accountRepo.findByAccountId(accountUpdating.getAccountId())
.getDeliveryManagers();
List<String> dmsListDeletedByUser = CommomUtil.getDeletedManagersList(persistedDmsList, updatingDmsList);
List<Account> allAccountList = accountRepo.findAll();
if (allAccountList != null && !allAccountList.isEmpty() && allAccountList.size() > 0) {
for (Account acc : allAccountList) {
dmIdList = acc.getDeliveryManagers();
if (dmIdList != null && !dmIdList.isEmpty() && dmIdList.size() > 0) {
for (String dmId : dmIdList) {
if (dmsCountMap.get(dmId) != null)
dmsCountMap.put(dmId, dmsCountMap.get(dmId) + 1);
else
dmsCountMap.put(dmId, 1);
dmIdList = null;
}
}
}
}
for (String empId : dmsListDeletedByUser) {
if (dmsCountMap.get(empId) == 1) {
// Service call for RoleMapping
roleMappingService.deleteRole(empId, roleId);
}
}
}
// fetching the employee details using employeeId.
private List<Employee> getEmployeeDetails(Account account) {
List<Employee> employeeRoles = mongoTemplate.find(
new Query(Criteria.where(MyTeamUtils.EMPLOYEE_ID).in(account.getDeliveryManagers())),
Employee.class);
return employeeRoles;
}
private HashMap<String, String> getEmployeeDetails(Employee employeesRole) {
HashMap<String, String> employeeDetails = new HashMap<>();
employeeDetails.put(MyTeamUtils.EMPLOYEE_ID, employeesRole.getEmployeeId());
employeeDetails.put(MyTeamUtils.EMPLOYEE_NAME, employeesRole.getEmployeeName());
return employeeDetails;
}
private Map<Object, Object> getAccuntDetails(Account account, List<Map<String, String>> updatedEmployeeList) {
Map<Object, Object> accountDetails = new HashMap<>();
//accountDetails.put(MyTimeUtils.ID_, account.getId());
accountDetails.put(MyTeamUtils.ACCOUNT_ID, account.getAccountId());
accountDetails.put(MyTeamUtils.ACCOUNT_NAME, account.getAccountName());
accountDetails.put(MyTeamUtils.STATUS, account.getStatus());
accountDetails.put(MyTeamUtils.CLIENT_ADDRESS, account.getClientAddress());
accountDetails.put(MyTeamUtils.INDUSTRY_TYPE, account.getIndustryType());
accountDetails.put(MyTeamUtils.DELIVERY_MANAGERS, updatedEmployeeList);
return accountDetails;
}
private void deleteRoleidsForDeliveryManagers(String accountId) throws MyTeamException {
int occurrences = 0;
List<Account> allAccountsList = null;
List<String> accountDms = null;
List<String> tempDmsList = new ArrayList<String>();
String roleId = roleInfoService.getRole(MyTeamUtils.ACCOUNT);
allAccountsList = accountRepo.findAll();
List<String> accountDmsList = accountRepo.findByAccountId(accountId).getDeliveryManagers();
for (Account account : allAccountsList) {
accountDms = account.getDeliveryManagers();
for (String accountDm : accountDms)
tempDmsList.add(accountDm);
accountDms = null;
}
for (String dmId : accountDmsList) {
occurrences = Collections.frequency(tempDmsList, dmId);
if (occurrences == 1) {
// Service call for RoleMapping
roleMappingService.deleteRole(dmId, roleId);
}
}
}
@Override
public List<Account> getAccountsAll() throws MyTeamException {
return accountRepo.findAll();
}
@Autowired
private AccountRepo accountRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private IRoleService roleInfoService;
@Autowired
private IEmployeeRoleService roleMappingService;
@Override
public Account createAccount(Account accountReq) throws MyTeamException {
accountReq.setAccountId(generateAccountId());
accountReq.setStatus(MyTeamUtils.STRING_Y);
Account accountPersisted = accountRepo.save(accountReq);
if (log.isInfoEnabled()) {
log.info("Account has been persisted in database with account details::" + accountPersisted);
}
if (accountPersisted != null) {
List<String> accountDmsList = accountReq.getDeliveryManagers();
if (accountDmsList != null && !accountDmsList.isEmpty() && accountDmsList.size() > 0) {
String roleId = roleInfoService.getRole(MyTeamUtils.ACCOUNT);
log.info("Going to add DM role id for account delivery managers::::" + accountDmsList);
roleMappingService.saveUniqueEmployeeAndRole(accountDmsList, roleId);
log.info("Added roleids for delivery managers in rolemapping collection");
}
}
return accountPersisted;
}
@Override
public Account updateAccount(Account accountUpdating) throws MyTeamException {
Account accountBeforeUpdate = accountRepo.findByAccountId(accountUpdating.getAccountId());
accountUpdating.setStatus(accountBeforeUpdate.getStatus());
accountUpdating.setAccountName(accountUpdating.getAccountName().trim());
log.info("Updating the roleids of DeliveryManagers in RoleMapping Collection");
final String roleId = roleInfoService.getRole(MyTeamUtils.ACCOUNT);
updateRoleIdsForDeliveryManager(accountUpdating, roleId);
log.info("Deleting the roleids of DeliveryManagers in RoleMapping Collection");
deleteRoleIdsForDeliveryManager(accountUpdating, roleId);
Account accountUpdated = accountRepo.save(accountUpdating);
log.info("Account updated::" + accountUpdated);
return accountUpdated;
}
@Override
public boolean isAccountExists(Account account) {
Account accountFetched = accountRepo.findByAccountNameIgnoreCase(account.getAccountName());
return (accountFetched != null) ? true : false;
}
@Override
public boolean isAccountExists(String accountId) {
boolean isExists = false;
log.info("AccountId in Account Service::"+accountId);
if (accountId != null && !"".equalsIgnoreCase(accountId)) {
log.info("in condition");
Account account= accountRepo.findByAccountId(accountId);
log.info("Account details in Account Service::"+account);
isExists = ( account== null) ? false : true;
}
log.info("isExists:"+isExists);
return isExists;
}
@Override
public Account getAccountById(String accountId) {
Account account = null;
if (accountId != null && !"".equalsIgnoreCase(accountId)) {
return accountRepo.findByAccountId(accountId);
}
return account;
}
@Override
public List<Account> getAccounts() throws MyTeamException {
return accountRepo.findAll();
}
@Override
public List<Map<Object, Object>> getAccountsList() throws MyTeamException {
List<Map<Object, Object>> updatedAccountList = new ArrayList<>();
List<Map<String, String>> updatedEmployeeList = null;
for (Account account : accountRepo.findAll()) {
updatedEmployeeList = new ArrayList<>();
for (Employee employee : getEmployeeDetails(account)) {
updatedEmployeeList.add(getEmployeeDetails(employee));
}
updatedAccountList.add(getAccuntDetails(account, updatedEmployeeList));
}
return updatedAccountList;
}
@Override
public Account deleteAccount(String accountId) throws MyTeamException {
// delete the documents for deliveryManagers in rolemapping collection.
log.info("After updation:: Deleting the Roleids for DeliveryManagers in RoleMapping collection");
deleteRoleidsForDeliveryManagers(accountId);
// updating the status to "InActive".
Query query = new Query(Criteria.where(MyTeamUtils.ACCOUNT_ID).is(accountId));
Update update = new Update();
update.set(MyTeamUtils.STATUS, MyTeamUtils.STRING_N);
FindAndModifyOptions options = new FindAndModifyOptions();
options.upsert(true);
Account updatedAccount = mongoTemplate.findAndModify(query, update, options, Account.class);
log.info("The account updated::" + updatedAccount);
return updatedAccount;
}
// generating the account id.
// accountId format is "Acc001"
private String generateAccountId() throws MyTeamException {
return (MyTeamUtils.ACC + MyTeamUtils.ZERO_) + (getAccounts().size() + MyTeamUtils.ONE);
}
private void updateRoleIdsForDeliveryManager(Account accountReq, String roleId) throws MyTeamException {
List<String> updatingDmsList = accountReq.getDeliveryManagers();
List<String> persistedDmsList = accountRepo.findByAccountId(accountReq.getAccountId()).getDeliveryManagers();
List<String> dmsAddedByUser = CommomUtil.getAddedManagersList(persistedDmsList, updatingDmsList);
roleMappingService.saveUniqueEmployeeAndRole(dmsAddedByUser, roleId);
}
private void deleteRoleIdsForDeliveryManager(Account accountUpdating, String roleId) throws MyTeamException {
List<String> dmIdList = null;
Map<String, Integer> dmsCountMap = new HashMap<String, Integer>();
List<String> updatingDmsList = accountUpdating.getDeliveryManagers();
List<String> persistedDmsList = accountRepo.findByAccountId(accountUpdating.getAccountId())
.getDeliveryManagers();
List<String> dmsListDeletedByUser = CommomUtil.getDeletedManagersList(persistedDmsList, updatingDmsList);
List<Account> allAccountList = accountRepo.findAll();
if (allAccountList != null && !allAccountList.isEmpty() && allAccountList.size() > 0) {
for (Account acc : allAccountList) {
dmIdList = acc.getDeliveryManagers();
if (dmIdList != null && !dmIdList.isEmpty() && dmIdList.size() > 0) {
for (String dmId : dmIdList) {
if (dmsCountMap.get(dmId) != null)
dmsCountMap.put(dmId, dmsCountMap.get(dmId) + 1);
else
dmsCountMap.put(dmId, 1);
dmIdList = null;
}
}
}
}
for (String empId : dmsListDeletedByUser) {
if (dmsCountMap.get(empId) == 1) {
// Service call for RoleMapping
roleMappingService.deleteRole(empId, roleId);
}
}
}
// fetching the employee details using employeeId.
private List<Employee> getEmployeeDetails(Account account) {
List<Employee> employeeRoles = mongoTemplate.find(
new Query(Criteria.where(MyTeamUtils.EMPLOYEE_ID).in(account.getDeliveryManagers())),
Employee.class);
return employeeRoles;
}
private HashMap<String, String> getEmployeeDetails(Employee employeesRole) {
HashMap<String, String> employeeDetails = new HashMap<>();
employeeDetails.put(MyTeamUtils.EMPLOYEE_ID, employeesRole.getEmployeeId());
employeeDetails.put(MyTeamUtils.EMPLOYEE_NAME, employeesRole.getEmployeeName());
return employeeDetails;
}
private Map<Object, Object> getAccuntDetails(Account account, List<Map<String, String>> updatedEmployeeList) {
Map<Object, Object> accountDetails = new HashMap<>();
//accountDetails.put(MyTimeUtils.ID_, account.getId());
accountDetails.put(MyTeamUtils.ACCOUNT_ID, account.getAccountId());
accountDetails.put(MyTeamUtils.ACCOUNT_NAME, account.getAccountName());
accountDetails.put(MyTeamUtils.STATUS, account.getStatus());
accountDetails.put(MyTeamUtils.CLIENT_ADDRESS, account.getClientAddress());
accountDetails.put(MyTeamUtils.INDUSTRY_TYPE, account.getIndustryType());
accountDetails.put(MyTeamUtils.DELIVERY_MANAGERS, updatedEmployeeList);
return accountDetails;
}
private void deleteRoleidsForDeliveryManagers(String accountId) throws MyTeamException {
int occurrences = 0;
List<Account> allAccountsList = null;
List<String> accountDms = null;
List<String> tempDmsList = new ArrayList<String>();
String roleId = roleInfoService.getRole(MyTeamUtils.ACCOUNT);
allAccountsList = accountRepo.findAll();
List<String> accountDmsList = accountRepo.findByAccountId(accountId).getDeliveryManagers();
for (Account account : allAccountsList) {
accountDms = account.getDeliveryManagers();
for (String accountDm : accountDms)
tempDmsList.add(accountDm);
accountDms = null;
}
for (String dmId : accountDmsList) {
occurrences = Collections.frequency(tempDmsList, dmId);
if (occurrences == 1) {
// Service call for RoleMapping
roleMappingService.deleteRole(dmId, roleId);
}
}
}
@Override
public List<Account> getAccountsAll() throws MyTeamException {
return accountRepo.findAll();
}
}
......@@ -39,6 +39,8 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class EmployeeService implements IEmployeeService {
@Autowired
private EmployeeRepo employeeRepo;
......@@ -196,7 +198,11 @@ public class EmployeeService implements IEmployeeService {
@Override
public Employee getEmployeeById(String employeeId) {
return employeeRepo.findByEmployeeId(employeeId);
log.info("The employeeId::"+employeeId);
Employee employee=employeeRepo.findByEmployeeId(employeeId);
log.info("Employee Found in Repo::"+employee);
return employee;
}
@Override
......@@ -296,7 +302,14 @@ public class EmployeeService implements IEmployeeService {
@Override
public boolean verifyEmployeeRole(String empId, String roleName) {
boolean flag = false;
String role = getEmployeeById(empId).getRole();
log.info("The employeeId::"+empId);
Employee employee=getEmployeeById(empId);
log.info("Employee::::in EmployeeService::"+employee);
String role = employee.getRole();
log.info("The employee role::"+role);
if (null != role && "" != role && !"Admin".equalsIgnoreCase(role)) {
Set<String> roleSet = employeeRoleService.empRolesMapInfoByEmpId(empId);
if (null != roleSet && !roleSet.isEmpty() && MyTeamUtils.INT_ZERO < roleSet.size()) {
......
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