Commit cf30e48e authored by bsatyanarayana-nisum-com's avatar bsatyanarayana-nisum-com Committed by rbonthala-nisum-com

MT-97_5 : SNS :: Update_RoleTable_While_Account_CRUD_operations (#81)

parent 5718d05f
...@@ -43,89 +43,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -43,89 +43,7 @@ public class AccountServiceImpl implements AccountService {
Account accountResult= null; Account accountResult= null;
String roleId = roleInfoService.getRole(MyTimeUtils.ACCOUNT); String roleId = roleInfoService.getRole(MyTimeUtils.ACCOUNT);
//List<Account> accounts = accountRepo.findAll();
/* if( action != null && action.equals(MyTimeUtils.STRING_N)) {//N means adding New Account
if( !accounts.isEmpty() && accounts.size() > 0){
response ="Account already exist";
}else {
List<String> accDms = account.getDeliveryManagers();
account.setAccountId(generateAccountId());
account.setStatus(MyTimeUtils.STRING_Y);
accountResult = accountRepo.save(account);
if(accDms != null && !accDms.isEmpty() && accDms.size() > 0) {
roleMappingService.saveUniqueEmployeeAndRole(accDms, roleId);
}
if(accountResult.getId() != null) {
response="Saved succesfully";
}else {
response = "Error occured while account creating";
}
}
}else if(action != null && action.equals("U")){//U means updating existing Account
if( !accounts.isEmpty() && accounts.size() > 0){
for(Account accObj : accounts) {
if(!accObj.getAccountId().equals(account.getAccountId()) && accObj.getAccountName().equalsIgnoreCase(account.getAccountName())){
response ="Account already exist with updated account name";
return response;
}
}
//response ="Account already exist";
}
List<String> employeeIds = null;
List<Account> accountList = null;
List<String> dmsAddedByUser = null;
List<String> dmsDeletedByUser = null;
Map<String, Integer> dmsCount = new HashMap<String,Integer>();
Account accountBeforeUpdate = accountRepo.findByAccountId(account.getAccountId());
List<String> updatedAccDms = account.getDeliveryManagers();
List<String> beforeAccUpdateDms = accountBeforeUpdate.getDeliveryManagers();
dmsAddedByUser = CommomUtil.getAddedManagersList(beforeAccUpdateDms, updatedAccDms);
dmsDeletedByUser = CommomUtil.getDeletedManagersList(beforeAccUpdateDms, updatedAccDms);
accountList = accountRepo.findAll();
if(accountList != null && !accountList.isEmpty() && accountList.size() >0) {
for (Account acc : accountList) {
employeeIds = acc.getDeliveryManagers();
if(employeeIds != null && !employeeIds.isEmpty() && employeeIds.size() >0) {
for(String eId:employeeIds) {
if(dmsCount.get(eId) != null)
dmsCount.put(eId, dmsCount.get(eId)+1);
else
dmsCount.put(eId, 1);
employeeIds = null;
}
}
}
}
for (String empId : dmsDeletedByUser) {
if(dmsCount.get(empId)==1) {
//Service call for RoleMapping
roleMappingService.deleteRole(empId,roleId);
}
}
//account.setStatus(MyTimeUtils.STRING_Y);
account.setStatus(accountBeforeUpdate.getStatus());
accountResult = accountRepo.save(account);
roleMappingService.saveUniqueEmployeeAndRole(dmsAddedByUser, roleId);
response="Updated succesfully";
}*/
if( action != null && action.equals(MyTimeUtils.STRING_N)) {//N means adding New Account if( action != null && action.equals(MyTimeUtils.STRING_N)) {//N means adding New Account
boolean flag = false; boolean flag = false;
...@@ -177,7 +95,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -177,7 +95,7 @@ public class AccountServiceImpl implements AccountService {
} }
if(flag) { if(flag) {
response ="Account Already exist with update account name"; response ="Account already exist";
return response; return response;
} }
......
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