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 {
@RequestMapping(value = "/domains", method = RequestMethod.PUT, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> updateDomain(@RequestBody Domains domains) throws MyTimeException {
domainService.updateDomain(domains);
return new ResponseEntity<>("Domain updated successfully", HttpStatus.OK);
String response=null;
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 {
public List getAttendanciesReport(String reportDate) throws MyTimeException, SQLException {
long start_ms = System.currentTimeMillis();
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();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(querys.toString()))
......@@ -47,8 +47,6 @@ public class AttendanceServiceImpl implements AttendanceService {
}
return listOfEmployees;
}
}
......@@ -51,11 +51,9 @@ public class DomainServiceImpl implements DomainService {
@Override
public String addDomains(Domains d) throws MyTimeException {
String response=null;
List<Domains> domainList=domainRepo.findByDomainNameAndAccountId(d.getDomainName(), d.getAccountId());
if(domainList.size()>0) {
response="Domain already exists";
return response;
boolean isDuplicate=duplicateCheck(d.getDomainName(), d.getAccountId());
if(isDuplicate) {
return response="Domain already exists";
}
if (StringUtils.isEmpty(d.getDomainId()) && d.getId()==null) {
......@@ -91,7 +89,7 @@ public class DomainServiceImpl implements DomainService {
Query accountInfoQuery = new Query(Criteria.where(MyTimeUtils.ACCOUNT_ID).in(domain.getAccountId()));
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());
updatedEmployeeList = new ArrayList<>();
......@@ -114,6 +112,10 @@ public class DomainServiceImpl implements DomainService {
@Override
public String updateDomain(Domains d) throws MyTimeException{
String response = null;
boolean isDuplicate=duplicateCheck(d.getDomainName(), d.getAccountId());
if(isDuplicate) {
return response="Domain already exists";
}
List<String> deliveryManagersListFromUser = null;
List<String> deliveryManagersListFromDb = null;
List<String> managersAddedByUser = null;
......@@ -190,4 +192,13 @@ public class DomainServiceImpl implements DomainService {
return selectedDomain.get(0);
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 {
" FROM Transactions as tr,EmployeeMaster as emp where tr.EmployeemasterID=emp.EmployeeMasterID and \n" +
" replace(convert(varchar,tr.aDateTime, 111), '/', '-')= ";
public final static String UNION=" Union ";
public final static String ATTENDANCE_ABSENT_REPORT_QUERY= " select distinct emp.EmployeeCode,emp.FirstName,'A' as AttStatus\n" +
" FROM Transactions as tr,EmployeeMaster as emp where tr.EmployeemasterID!=emp.EmployeeMasterID and \n" +
public final static String ATTENDANCE_ABSENT_REPORT_QUERY= "select distinct M.EmployeeCode,M.FirstName,'A' as AttStatus from [smartiSCC].[dbo].[EmployeeMaster] M \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), '/', '-')=";
// Role Mapping Info
public static final String ACCOUNT = "Delivery Manager";
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