Commit c99aa775 authored by Vijay Chaitanya's avatar Vijay Chaitanya Committed by rbonthala-nisum-com

Mt 98 domain changes (#77)

* update code changes

* changes done for saving with Id and Name

* changes done for response for UI

* MT-79 code fix

* changes for defect fixing

* duplicate check in update domain

* defect fix changes
parent 2290c78c
...@@ -51,8 +51,8 @@ public class DomainServiceImpl implements DomainService { ...@@ -51,8 +51,8 @@ public class DomainServiceImpl implements DomainService {
@Override @Override
public String addDomains(Domains d) throws MyTimeException { public String addDomains(Domains d) throws MyTimeException {
String response=null; String response=null;
boolean isDuplicate=duplicateCheck(d.getDomainName(), d.getAccountId()); List<Domains> domainList=domainRepo.findByDomainNameAndAccountId(d.getDomainName(), d.getAccountId());
if(isDuplicate) { if(domainList.size()>0) {
return response="Domain already exists"; return response="Domain already exists";
} }
...@@ -62,9 +62,9 @@ public class DomainServiceImpl implements DomainService { ...@@ -62,9 +62,9 @@ public class DomainServiceImpl implements DomainService {
d.setStatus(MyTimeUtils.ACTIVE); d.setStatus(MyTimeUtils.ACTIVE);
if(d.getId()==null){ if(d.getId()==null){
response="Domain saved succesfully"; response="Domain saved successfully";
}else{ }else{
response="Domain updated succesfully"; response="Domain updated successfully";
} }
domainRepo.save(d); domainRepo.save(d);
String roleId = roleInfoService.getRole(MyTimeUtils.DOMAIN); String roleId = roleInfoService.getRole(MyTimeUtils.DOMAIN);
...@@ -112,10 +112,7 @@ public class DomainServiceImpl implements DomainService { ...@@ -112,10 +112,7 @@ public class DomainServiceImpl implements DomainService {
@Override @Override
public String updateDomain(Domains d) throws MyTimeException{ public String updateDomain(Domains d) throws MyTimeException{
String response = null; String response = null;
boolean isDuplicate=duplicateCheck(d.getDomainName(), d.getAccountId());
if(isDuplicate) {
return response="Domain already exists";
}
List<String> deliveryManagersListFromUser = null; List<String> deliveryManagersListFromUser = null;
List<String> deliveryManagersListFromDb = null; List<String> deliveryManagersListFromDb = null;
List<String> managersAddedByUser = null; List<String> managersAddedByUser = null;
...@@ -128,6 +125,13 @@ public class DomainServiceImpl implements DomainService { ...@@ -128,6 +125,13 @@ public class DomainServiceImpl implements DomainService {
if (null != domainDetailsFromDb) if (null != domainDetailsFromDb)
deliveryManagersListFromDb = domainDetailsFromDb.getDeliveryManagers(); deliveryManagersListFromDb = domainDetailsFromDb.getDeliveryManagers();
boolean isDuplicate=duplicateCheck(d.getDomainName(), d.getAccountId(),deliveryManagersListFromDb,d.getDeliveryManagers());
if(isDuplicate) {
return response="Domain already exists";
}else{
response="Domain updated successfully";
}
managersAddedByUser = CommomUtil.getAddedManagersList(deliveryManagersListFromDb, deliveryManagersListFromUser); managersAddedByUser = CommomUtil.getAddedManagersList(deliveryManagersListFromDb, deliveryManagersListFromUser);
managersDeletedByUser = CommomUtil.getDeletedManagersList(deliveryManagersListFromDb, deliveryManagersListFromUser); managersDeletedByUser = CommomUtil.getDeletedManagersList(deliveryManagersListFromDb, deliveryManagersListFromUser);
...@@ -193,11 +197,12 @@ public class DomainServiceImpl implements DomainService { ...@@ -193,11 +197,12 @@ public class DomainServiceImpl implements DomainService {
return null; return null;
} }
private boolean duplicateCheck(String domainName,String accountId) private boolean duplicateCheck(String domainName,String accountId,List<String> fromDB,List<String> fromUser)
{ {
boolean check=false; boolean check=false;
boolean deleveryManagersCheck=fromDB.toString().contentEquals(fromUser.toString());
List<Domains> domainList=domainRepo.findByDomainNameAndAccountId(domainName, accountId); List<Domains> domainList=domainRepo.findByDomainNameAndAccountId(domainName, accountId);
if(domainList.size()>0) if(domainList.size()>0 && deleveryManagersCheck)
check= true; check= true;
return check; return check;
} }
......
...@@ -307,7 +307,7 @@ myApp.controller("domainController", ...@@ -307,7 +307,7 @@ myApp.controller("domainController",
} }
function updatingGridBasedOnStatus(status, response,result) { function updatingGridBasedOnStatus(status, response,result) {
if (response == "Domain saved succesfully") { if (response == "Domain saved successfully") {
updateGrid("Add", result); updateGrid("Add", result);
} else if (response == "Domain updated successfully") { } else if (response == "Domain updated successfully") {
updateGrid("Update", result); updateGrid("Update", result);
......
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