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

Mt 98 domain changes (#70)

* 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
parent 194ddb67
...@@ -55,7 +55,8 @@ public class DomainController { ...@@ -55,7 +55,8 @@ public class DomainController {
@RequestMapping(value = "/domains", method = RequestMethod.PUT, produces = MediaType.TEXT_PLAIN_VALUE) @RequestMapping(value = "/domains", method = RequestMethod.PUT, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> updateDomain(@RequestBody Domains domains) throws MyTimeException { public ResponseEntity<String> updateDomain(@RequestBody Domains domains) throws MyTimeException {
domainService.updateDomain(domains); String response=null;
return new ResponseEntity<>("Domain updated successfully", HttpStatus.OK); response=domainService.updateDomain(domains);
return new ResponseEntity<>(response, HttpStatus.OK);
} }
} }
\ No newline at end of file
...@@ -28,7 +28,7 @@ public class AttendanceServiceImpl implements AttendanceService { ...@@ -28,7 +28,7 @@ public class AttendanceServiceImpl implements AttendanceService {
public List getAttendanciesReport(String reportDate) throws MyTimeException, SQLException { public List getAttendanciesReport(String reportDate) throws MyTimeException, SQLException {
long start_ms = System.currentTimeMillis(); long start_ms = System.currentTimeMillis();
List listOfEmployees = new ArrayList<>(); List listOfEmployees = new ArrayList<>();
String querys=MyTimeUtils.ATTENDANCE_PRESENT_REPORT_QUERY +"'"+reportDate+"'"+ MyTimeUtils.UNION +MyTimeUtils.ATTENDANCE_ABSENT_REPORT_QUERY+"'"+reportDate+"'"; String querys=MyTimeUtils.ATTENDANCE_PRESENT_REPORT_QUERY +"'"+reportDate+"'"+ MyTimeUtils.UNION +MyTimeUtils.ATTENDANCE_ABSENT_REPORT_QUERY+"'"+reportDate+"')";
try(Connection connection = dbConnection.getDBConnection(); try(Connection connection = dbConnection.getDBConnection();
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(querys.toString())) ResultSet resultSet = statement.executeQuery(querys.toString()))
...@@ -47,8 +47,6 @@ public class AttendanceServiceImpl implements AttendanceService { ...@@ -47,8 +47,6 @@ public class AttendanceServiceImpl implements AttendanceService {
} }
return listOfEmployees; return listOfEmployees;
} }
} }
...@@ -51,11 +51,9 @@ public class DomainServiceImpl implements DomainService { ...@@ -51,11 +51,9 @@ 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;
List<Domains> domainList=domainRepo.findByDomainNameAndAccountId(d.getDomainName(), d.getAccountId()); boolean isDuplicate=duplicateCheck(d.getDomainName(), d.getAccountId());
if(isDuplicate) {
if(domainList.size()>0) { return response="Domain already exists";
response="Domain already exists";
return response;
} }
if (StringUtils.isEmpty(d.getDomainId()) && d.getId()==null) { if (StringUtils.isEmpty(d.getDomainId()) && d.getId()==null) {
...@@ -91,7 +89,7 @@ public class DomainServiceImpl implements DomainService { ...@@ -91,7 +89,7 @@ public class DomainServiceImpl implements DomainService {
Query accountInfoQuery = new Query(Criteria.where(MyTimeUtils.ACCOUNT_ID).in(domain.getAccountId())); Query accountInfoQuery = new Query(Criteria.where(MyTimeUtils.ACCOUNT_ID).in(domain.getAccountId()));
List<Account> accountList = mongoTemplate.find(accountInfoQuery, Account.class); List<Account> accountList = mongoTemplate.find(accountInfoQuery, Account.class);
if(accountList!=null) if(accountList!=null && accountList.size()>0)
domainMap.put(MyTimeUtils.ACCOUNT_NAME, accountList.get(0).getAccountName()); domainMap.put(MyTimeUtils.ACCOUNT_NAME, accountList.get(0).getAccountName());
updatedEmployeeList = new ArrayList<>(); updatedEmployeeList = new ArrayList<>();
...@@ -114,6 +112,10 @@ public class DomainServiceImpl implements DomainService { ...@@ -114,6 +112,10 @@ 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;
...@@ -190,4 +192,13 @@ public class DomainServiceImpl implements DomainService { ...@@ -190,4 +192,13 @@ public class DomainServiceImpl implements DomainService {
return selectedDomain.get(0); return selectedDomain.get(0);
return null; return null;
} }
private boolean duplicateCheck(String domainName,String accountId)
{
boolean check=false;
List<Domains> domainList=domainRepo.findByDomainNameAndAccountId(domainName, accountId);
if(domainList.size()>0)
check= true;
return check;
}
} }
\ No newline at end of file
...@@ -89,11 +89,13 @@ public class MyTimeUtils { ...@@ -89,11 +89,13 @@ public class MyTimeUtils {
" FROM Transactions as tr,EmployeeMaster as emp where tr.EmployeemasterID=emp.EmployeeMasterID and \n" + " FROM Transactions as tr,EmployeeMaster as emp where tr.EmployeemasterID=emp.EmployeeMasterID and \n" +
" replace(convert(varchar,tr.aDateTime, 111), '/', '-')= "; " replace(convert(varchar,tr.aDateTime, 111), '/', '-')= ";
public final static String UNION=" Union "; public final static String UNION=" Union ";
public final static String ATTENDANCE_ABSENT_REPORT_QUERY= " select distinct emp.EmployeeCode,emp.FirstName,'A' as AttStatus\n" + public final static String ATTENDANCE_ABSENT_REPORT_QUERY= "select distinct M.EmployeeCode,M.FirstName,'A' as AttStatus from [smartiSCC].[dbo].[EmployeeMaster] M \n" +
" FROM Transactions as tr,EmployeeMaster as emp where tr.EmployeemasterID!=emp.EmployeeMasterID and \n" + "where EmployeeControllerStatus=1 and M.EmployeeCode not in \n" +
" (select distinct emp.EmployeeCode \n" +
" FROM Transactions as tr,EmployeeMaster as emp \n" +
" where tr.EmployeemasterID=emp.EmployeeMasterID and EmployeeControllerStatus=1 and \n" +
" replace(convert(varchar,tr.aDateTime, 111), '/', '-')="; " replace(convert(varchar,tr.aDateTime, 111), '/', '-')=";
// Role Mapping Info // Role Mapping Info
public static final String ACCOUNT = "Delivery Manager"; public static final String ACCOUNT = "Delivery Manager";
public static final String DOMAIN = "Delivery Lead"; public static final String DOMAIN = "Delivery Lead";
......
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