Commit cf947c85 authored by Vijay Akula's avatar Vijay Akula

[vijay.A] Refactored the code for Employee Controller Service and

repositories
parent a6abbc45
......@@ -4,6 +4,7 @@ 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;
......@@ -18,6 +19,7 @@ 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.mytime.exception.handler.MyTimeException;
......@@ -25,21 +27,22 @@ import com.nisum.mytime.exception.handler.ResponseDetails;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.service.IAccountService;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@RestController
public class AccountController {
@Autowired
private IAccountService accountService;
private static final Logger logger = LoggerFactory.getLogger(AccountController.class);
@RequestMapping(value = "/accounts", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> createAccount(@Valid @RequestBody Account account, HttpServletRequest request)
throws MyTimeException {
logger.info("Serving the Account Creation action");
log.info("Serving the Account Creation action");
boolean isAccountExists = accountService.isAccountExists(account);
logger.info("is Account exists with the name " + account.getAccountName() + ":::" + isAccountExists);
log.info("is Account exists with the name " + account.getAccountName() + ":::" + isAccountExists);
if (!isAccountExists) {
Account accountPersisted = accountService.createAccount(account);
......@@ -57,7 +60,7 @@ public class AccountController {
@RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateAccount(@RequestBody Account account, @PathVariable String accountId,
HttpServletRequest request) throws MyTimeException {
logger.info("Updating the account with details::"+account);
log.info("Updating the account with details::"+account);
boolean isAccountExists = accountService.isAccountExists(account);
if (isAccountExists == true) {
Account accountPersisted = accountService.updateAccount(account);
......@@ -75,10 +78,26 @@ public class AccountController {
}
@RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deleteAccount(@PathVariable String accountId, HttpServletRequest request)
throws MyTimeException {
log.info("Deleting account with accountId:" + accountId);
Account accountDeleted = accountService.deleteAccount(accountId);
ResponseDetails deleteRespDetails = new ResponseDetails(new Date(), 604,
"Account has been deleted successfully", "status description", null,request.getRequestURI(), "details",
accountDeleted);
return new ResponseEntity<ResponseDetails>(deleteRespDetails, HttpStatus.OK);
}
@RequestMapping(value = "/accounts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAccounts(HttpServletRequest request) throws MyTimeException {
List<Map<Object, Object>> accountsList = accountService.getAccountsList();
logger.info("The accounts list::" + accountsList);
log.info("The accounts list::" + accountsList);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 604, "Retrieved the accounts successfully",
"Accounts list", accountsList, request.getRequestURI(), "details", null);
......@@ -87,6 +106,7 @@ public class AccountController {
}
@RequestMapping(value = "/accounts/names", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAccountNames(HttpServletRequest request) throws MyTimeException {
List<Account> acountsList = accountService.getAccounts();
......@@ -95,7 +115,7 @@ public class AccountController {
for (Account account : acountsList) {
accountNamesList.add(account.getAccountName());
}
logger.info("The account names list::" + accountNamesList);
log.info("The account names list::" + accountNamesList);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 604,
"Retrieved the account names successfully", "Account names list", accountNamesList,
......@@ -105,16 +125,13 @@ public class AccountController {
}
@RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deleteAccount(@PathVariable String accountId, HttpServletRequest request)
throws MyTimeException {
logger.info("Deleting account with accountId:" + accountId);
Account accountDeleted = accountService.deleteAccount(accountId);
ResponseDetails deleteRespDetails = new ResponseDetails(new Date(), 604,
"Account has been deleted successfully", "status description", null,request.getRequestURI(), "details",
accountDeleted);
return new ResponseEntity<ResponseDetails>(deleteRespDetails, HttpStatus.OK);
//get the accounts based on status(Active or inactive)
@RequestMapping(value = "/accounts/status", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Account>> getAccounts(@RequestParam("status")String status) throws MyTimeException {
List<Account> accountsList = accountService.getAccountsAll().stream()
.filter(e -> "Active".equalsIgnoreCase(e.getStatus())).collect(Collectors.toList());
return new ResponseEntity<>(accountsList, HttpStatus.OK);
}
}
\ No newline at end of file
......@@ -25,76 +25,56 @@ import com.nisum.mytime.service.IEmployeeService;
@RequestMapping("/attendance")
public class AttendanceController {
@Autowired
private IEmployeeService userService;
@Autowired
private IAttendanceService attendanceService;
@Autowired
private IAttendanceService attendanceService;
@RequestMapping(value = "employeeLoginsBasedOnDate", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmpLoginData>> employeeLoginsBasedOnDate(@RequestParam("empId") long id,
@RequestParam("fromDate") String fromDate, @RequestParam("toDate") String toDate) throws MyTimeException {
List<EmpLoginData> message = new ArrayList<>();
try {
message = attendanceService.employeeLoginsBasedOnDate(id, fromDate, toDate);
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseEntity<>(message, HttpStatus.OK);
}
@RequestMapping(value = "employeeLoginsBasedOnDate",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmpLoginData>> employeeLoginsBasedOnDate(
@RequestParam("empId") long id,
@RequestParam("fromDate") String fromDate,
@RequestParam("toDate") String toDate) throws MyTimeException {
List<EmpLoginData> message = new ArrayList<>();
try {
message = userService.employeeLoginsBasedOnDate(id, fromDate, toDate);
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseEntity<>(message, HttpStatus.OK);
}
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List> generatePdfReport(@PathVariable("id") long id,
@PathVariable("fromDate") String fromDate, @PathVariable("toDate") String toDate) throws MyTimeException {
List result = attendanceService.generatePdfReport(id, fromDate, toDate);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}",
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List> generatePdfReport(@PathVariable("id") long id,
@PathVariable("fromDate") String fromDate,
@PathVariable("toDate") String toDate) throws MyTimeException {
List result = userService.generatePdfReport(id, fromDate, toDate);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}/{fromTime}/{toTime}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List> generatePdfReport(@PathVariable("id") long id,
@PathVariable("fromDate") String fromDate, @PathVariable("toDate") String toDate,
@PathVariable("fromTime") String fromTime, @PathVariable("toTime") String toTime)
throws MyTimeException, ParseException {
List result = attendanceService.generatePdfReport(id, fromDate, toDate, fromTime, toTime);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}/{fromTime}/{toTime}",
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List> generatePdfReport(@PathVariable("id") long id,
@PathVariable("fromDate") String fromDate,
@PathVariable("toDate") String toDate,
@PathVariable("fromTime") String fromTime,
@PathVariable("toTime") String toTime) throws MyTimeException, ParseException {
List result = userService.generatePdfReport(id, fromDate, toDate,fromTime,toTime);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "attendanciesReport/{reportDate}",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<AttendenceData>> attendanciesReport(
@PathVariable("reportDate") String reportDate
,@RequestParam(value= "shift", required = false, defaultValue ="All") String shift)
throws MyTimeException, SQLException {
List<AttendenceData> lisOfAttendenceData = attendanceService.getAttendanciesReport(reportDate,shift);
return new ResponseEntity<>(lisOfAttendenceData, HttpStatus.OK);
}
@RequestMapping(value = "attendanciesReport/{reportDate}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<AttendenceData>> attendanciesReport(@PathVariable("reportDate") String reportDate,
@RequestParam(value = "shift", required = false, defaultValue = "All") String shift)
throws MyTimeException, SQLException {
List<AttendenceData> lisOfAttendenceData = attendanceService.getAttendanciesReport(reportDate, shift);
return new ResponseEntity<>(lisOfAttendenceData, HttpStatus.OK);
}
@RequestMapping(value = "employeesDataSave/{searchDate}",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> employeesDataSave(
@PathVariable("searchDate") String searchDate)
throws MyTimeException {
Boolean result = userService.fetchEmployeesData(searchDate, false);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "employeesDataSave/{searchDate}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> employeesDataSave(@PathVariable("searchDate") String searchDate)
throws MyTimeException {
Boolean result = attendanceService.fetchEmployeesData(searchDate, false);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "resyncMonthData/{fromDate}",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> resyncMonthData(
@PathVariable("fromDate") String fromDate) throws MyTimeException {
Boolean result = userService.fetchEmployeesData(fromDate, true);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "resyncMonthData/{fromDate}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> resyncMonthData(@PathVariable("fromDate") String fromDate) throws MyTimeException {
Boolean result = attendanceService.fetchEmployeesData(fromDate, true);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
\ No newline at end of file
package com.nisum.mytime.controller;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
......@@ -12,23 +15,27 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.exception.handler.ResponseDetails;
import com.nisum.mytime.model.Designation;
import com.nisum.mytime.service.IDesignationService;
import com.nisum.mytime.service.impl.DesignationService;
@RestController
public class DesignationController {
@Autowired
DesignationService designationService;
IDesignationService designationService;
// @RequestMapping(value = "/getAllDesignations", method =
// RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// @RequestMapping(value = "/getAllDesignations"
@RequestMapping(value = "/employees/designations/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllDesignations() throws MyTimeException {
public ResponseEntity<?> getAllDesignations(HttpServletRequest request) throws MyTimeException {
List<String> designations = designationService.getAllDesignations().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Designation::getDesignationName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(designations, HttpStatus.OK);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 908, "Retrieved Designations successfully",
"Designations list", designations, request.getRequestURI(), "Employee Designation Details", null);
return new ResponseEntity<>(getRespDetails, HttpStatus.OK);
}
}
......@@ -3,6 +3,7 @@ package com.nisum.mytime.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
......@@ -29,23 +30,24 @@ import com.nisum.mytime.service.IDomainService;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
/**
* @author Vijay
*
*/
@RestController
@Slf4j
public class DomainController {
@Autowired
private IDomainService domainService;
private static final Logger logger = LoggerFactory.getLogger(DomainController.class);
@RequestMapping(value = "/domains", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> createDomain(@RequestBody Domain domain, HttpServletRequest request)
throws MyTimeException {
logger.info("Domain Creation");
log.info("Domain Creation");
if (!domainService.isDomainExists(domain)) {
Domain domainPeristed = domainService.create(domain);
......@@ -54,7 +56,7 @@ public class DomainController {
"Domain Creation", null, "", "details", domainPeristed);
return new ResponseEntity<ResponseDetails>(createRespDetails, HttpStatus.OK);
}
logger.info("A domain is already existed with the requested name" + domain.getDomainName());
log.info("A domain is already existed with the requested name" + domain.getDomainName());
ResponseDetails responseDetails = new ResponseDetails(new Date(), 802, "Domain is already existed",
"Choose the different domain name", null, request.getRequestURI(), "Domain details", domain);
......@@ -102,4 +104,13 @@ public class DomainController {
}
//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 MyTimeException {
List<Domain> domains = domainService.getDomainsUnderAccount(accountId).stream()
.filter(e -> "Active".equalsIgnoreCase(e.getStatus())).collect(Collectors.toList());
return new ResponseEntity<>(domains, HttpStatus.OK);
}
}
\ No newline at end of file
package com.nisum.mytime.controller;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
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.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.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.exception.handler.ResponseDetails;
import com.nisum.mytime.model.EmployeeLocation;
import com.nisum.mytime.service.IEmployeeLocationService;
import com.nisum.mytime.service.impl.EmployeeLocationService;
@RestController
public class EmployeeLocationController {
@Autowired
EmployeeLocationService empLocationService;
@RequestMapping(value = "/getEmployeeLocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeLocationDetails>> getEmployeeLocations(@RequestParam("employeeId") String empId)
IEmployeeLocationService empLocationService;
@RequestMapping(value = "/employees/locations/{employeeId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getEmployeeLocations(@PathVariable("employeeId") String empId,HttpServletRequest request)
throws MyTimeException {
List<EmployeeLocationDetails> employeeLocationDetails = empLocationService.getEmployeeLocationDetails(empId);
return new ResponseEntity<>(employeeLocationDetails, HttpStatus.OK);
List<EmployeeLocation> employeeLocationDetails = empLocationService.getEmployeeLocations(empId);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 701, "Retrieved Employee Locations successfylly",
"Employee Locations", employeeLocationDetails, request.getRequestURI(), "Employee Location Details", null);
return new ResponseEntity<>(getRespDetails, HttpStatus.OK);
}
}
......@@ -17,7 +17,10 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.service.IMasterDataService;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class MasterDataController {
@Autowired
......
package com.nisum.mytime.controller;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -14,26 +17,34 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.exception.handler.ResponseDetails;
import com.nisum.mytime.model.OrgLocation;
import com.nisum.mytime.service.IOrgLocationService;
import com.nisum.mytime.service.impl.OrgLocationService;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class OrgLocationController {
@Autowired
OrgLocationService orgLocationService;
private static final Logger logger = LoggerFactory.getLogger(OrgLocationController.class);
// @RequestMapping(value = "/getLocations", method = RequestMethod.GET,
// produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/locations/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getLocations() throws MyTimeException {
// System.out.println(" userService.getLocations()" +
// orgLocationService.getLocations());
List<String> locations = orgLocationService.getLocations().stream().filter(e -> (e.isActiveStatus() == true))
.map(Location::getLocation).sorted().collect(Collectors.toList());
logger.info("getLocations " + locations);
return new ResponseEntity<>(locations, HttpStatus.OK);
IOrgLocationService orgLocationService;
// @RequestMapping(value = "/getLocations"
@RequestMapping(value = "/organization/locations/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getLocations(HttpServletRequest request) throws MyTimeException {
List<String> locationsList = orgLocationService.getLocations().stream()
.filter(e -> (e.isActiveStatus() == true)).map(OrgLocation::getLocation).sorted()
.collect(Collectors.toList());
log.info("getLocations " + locationsList);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905,
"Retrieved Organization Locations successfully", "Organization Locations List", locationsList,
request.getRequestURI(), "Organization Location Details", null);
return new ResponseEntity<>(getRespDetails, HttpStatus.OK);
}
}
......@@ -113,7 +113,7 @@ public class ProjectController {
List<HashMap<Object, Object>> projects = null;
if(!"undefined".equalsIgnoreCase(empId) ) {
boolean isDl = userService.verifyRole(empId,MyTimeUtils.DL) ;
boolean isDl = userService.verifyEmployeeRole(empId,MyTimeUtils.DL) ;
if( isDl ){
projects = projectService.deliveryLeadProjects(empId);
}
......@@ -126,7 +126,7 @@ public class ProjectController {
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRoleData(@RequestParam("empId") String empId)
throws MyTimeException {
Employee employeesRole = userService.getEmployeesRoleData(empId);
Employee employeesRole = userService.getEmployeeById(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
......
......@@ -33,14 +33,14 @@ import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.model.ColumnChartData;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.GroupByCount;
import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.model.Resource;
import com.nisum.mytime.model.ReportSeriesRecord;
import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.repository.TeamMatesBillingRepo;
import com.nisum.mytime.repository.BillingRepo;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IEmployeeService;
......@@ -56,11 +56,12 @@ public class ReportsController {
@Autowired
private EmployeeVisaRepo employeeVisaRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private TeamMatesBillingRepo teamMatesBillingRepo;
private BillingRepo teamMatesBillingRepo;
@RequestMapping(value = "/getEmployeesByFunctionalGroup1",
method = RequestMethod.GET,
......@@ -137,7 +138,7 @@ public class ReportsController {
// Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults = mongoTemplate
.aggregate(aggregate, BillingDetails.class,
.aggregate(aggregate, Billing.class,
ColumnChartData.class);
List<ColumnChartData> result = groupResults.getMappedResults();
List<String> statusList = new ArrayList();
......@@ -248,7 +249,7 @@ public class ReportsController {
// Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults1 = mongoTemplate
.aggregate(agg1, BillingDetails.class,
.aggregate(agg1, Billing.class,
ColumnChartData.class);
List<ColumnChartData> result1 = groupResults1.getMappedResults();
......@@ -326,11 +327,11 @@ public class ReportsController {
@RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> fetchEmployeeDetailsByAccountBillability(
public ResponseEntity<List<Resource>> fetchEmployeeDetailsByAccountBillability(
@RequestParam("account") String account,
@RequestParam("billabilityStatus") String billabilityStatus)
throws MyTimeException {
List<ProjectTeamMate> empList = new ArrayList<>();
List<Resource> empList = new ArrayList<>();
if (account != null && !account.isEmpty()) {
empList = projectService.findByAccountAndActiveAndBillableStatus(
account, true, billabilityStatus);
......@@ -341,11 +342,11 @@ public class ReportsController {
@RequestMapping(value = "/fetchEmployeeDetailsByDateBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<BillingDetails>> fetchEmployeeDetailsByDateBillability(
public ResponseEntity<List<Billing>> fetchEmployeeDetailsByDateBillability(
@RequestParam("billabilityStatus") String billabilityStatus,
@RequestParam("reportDate") String reportDateString)
throws MyTimeException {
List<BillingDetails> empList = new ArrayList<>();
List<Billing> empList = new ArrayList<>();
if (reportDateString != null && !reportDateString.isEmpty()) {
String pattern = "MM-dd-yyyy";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
......@@ -368,7 +369,7 @@ public class ReportsController {
criteriaV1.orOperator(criteriaV21, criteriaV22));
Query query = new Query();
query.addCriteria(criteriaV221);
empList = mongoTemplate.find(query, BillingDetails.class);
empList = mongoTemplate.find(query, Billing.class);
}
return new ResponseEntity<>(empList, HttpStatus.OK);
}
......
package com.nisum.mytime.controller;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
......@@ -12,23 +15,32 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.exception.handler.ResponseDetails;
import com.nisum.mytime.model.Shift;
import com.nisum.mytime.service.IShiftService;
import com.nisum.mytime.service.impl.ShiftService;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class ShiftController {
@Autowired
ShiftService shiftService;
// @RequestMapping(value = "/getAllShifts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
IShiftService shiftService;
// @RequestMapping(value = "/getAllShifts"
@RequestMapping(value = "/employees/shifts/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllShifts() throws MyTimeException {
List<String> shifts = shiftService.getAllShifts().stream().filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Shift::getShiftName).sorted().collect(Collectors.toList());
return new ResponseEntity<>(shifts, HttpStatus.OK);
public ResponseEntity<?> getAllShifts(HttpServletRequest request) throws MyTimeException {
List<String> shiftsList = shiftService.getAllShifts().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Shift::getShiftName).sorted()
.collect(Collectors.toList());
log.info("The Active shift names:" + shiftsList);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905, "Retrieved Employee Shifts successfully",
"Employee Shifts List", shiftsList, request.getRequestURI(), "Employee Shifts Details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
}
package com.nisum.mytime.controller;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
......@@ -12,23 +15,31 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.exception.handler.ResponseDetails;
import com.nisum.mytime.model.Skill;
import com.nisum.mytime.service.ISkillService;
import com.nisum.mytime.service.impl.SkillService;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class SkillController {
@Autowired
SkillService skillService;
ISkillService skillService;
// @RequestMapping(value = "/getSkills", method = RequestMethod.GET,
// produces = MediaType.APPLICATION_JSON_VALUE)
// @RequestMapping(value = "/getSkills"
@RequestMapping(value = "/employees/skills/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getTechnologies() throws MyTimeException {
List<String> technologies = skillService.getTechnologies().stream()
public ResponseEntity<?> getTechnologies(HttpServletRequest request) throws MyTimeException {
List<String> skillsList = skillService.getTechnologies().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Skill::getSkillName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
log.info("The Employee skills Lis::" + skillsList);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905, "Retrieved Employee Skills successfully",
"Employee Skills List", skillsList, request.getRequestURI(), "Employee Skills Details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
}
package com.nisum.mytime.controller;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.service.IUploadXLService;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class UploadXLController {
@Autowired
private IUploadXLService uploadService;
@RequestMapping(value = "/employee/fileUpload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> exportDataFromFile(@RequestParam(value = "file") MultipartFile file,
@RequestParam(value = "empId") String loginEmpId) throws MyTimeException {
log.info("Uploaded file: {} with size: {}", file.getOriginalFilename(), file.getSize());
String result = uploadService.importDataFromExcelFile(file, loginEmpId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
package com.nisum.mytime.exception.handler;
public class EmployeeNotFoundException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
public EmployeeNotFoundException(String message) {
super(message);
}
}
......@@ -17,11 +17,15 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import lombok.extern.slf4j.Slf4j;
@RestControllerAdvice
@RestController
@Slf4j
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
// private static final Logger log =
// LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler(DataAccessException.class)
public String handleDataAccessExceptions(DataAccessException ex) {
......@@ -40,15 +44,26 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(AccountNotFoundException.class)
public final ResponseEntity<Object> handleUserNotFoundException(AccountNotFoundException ex, WebRequest request) {
log.error("Exception occured due to::", ex);
ResponseDetails errorDetails = new ResponseDetails(new Date(), 602,
"The Account you are looking for is not found", ex.getMessage(), null, request.getContextPath(),
request.getDescription(false), null);
return new ResponseEntity<Object>(errorDetails, HttpStatus.NOT_FOUND);
}
@ExceptionHandler(EmployeeNotFoundException.class)
public final ResponseEntity<Object> handleEmployeeNotFoundException(EmployeeNotFoundException ex, WebRequest request) {
log.error("Exception occured due to::", ex);
ResponseDetails errorDetails = new ResponseDetails(new Date(), 902,
"The Employee you are looking for is not found", ex.getMessage(), null, request.getContextPath(),
request.getDescription(false), null);
return new ResponseEntity<Object>(errorDetails, HttpStatus.NOT_FOUND);
}
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex,
HttpHeaders headers, HttpStatus status, WebRequest request) {
log.error("The exception is occured due to ::", ex);
ResponseDetails errorDetails = new ResponseDetails(new Date(), 702, "Method Arguement is not validated",
"Validation Failed", null, request.getContextPath(), ex.getBindingResult().toString(), null);
return new ResponseEntity<Object>(errorDetails, HttpStatus.BAD_REQUEST);
......
......@@ -20,8 +20,8 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "BillingDetails")
public class BillingDetails extends AuditFields implements Serializable {
@Document(collection = "billing")
public class Billing extends AuditFields implements Serializable {
public Date getBillingEndDate() {
return billingEndDate;
......
......@@ -14,7 +14,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "EmpShiftDetails")
@Document(collection = "employeeShifts")
public class EmpShiftDetails extends AuditFields {
@Id
......
......@@ -3,6 +3,12 @@ package com.nisum.mytime.model;
import java.io.Serializable;
import java.util.Date;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
......@@ -15,7 +21,7 @@ import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
......@@ -26,24 +32,33 @@ public class Employee implements Serializable {
@Id
private String id;
@NotBlank(message="Employee Id cannot be blank")
//@Pattern(regexp = "^\\d{6}", message = "Invalid Employee code, It should be 5 digit")
@ExcelCellName("Employee ID")
private String employeeId;
@NotBlank(message="Employee name should not be empty")
@Size(min = 2, max = 80, message = "Employee Name should have atlast 2 and less than 200 characters")
@ExcelCellName("Employee Name")
private String employeeName;
@Email(message = "Invalid email id")
@ExcelCellName("Email ID")
private String emailId;
@ExcelCellName("Role")
private String role;
@ExcelCellName("Shift")
private String shift;
@NotBlank(message="Designation cannot be blank")
@ExcelCellName("Designation")
private String designation;
@ExcelCellName("Shift")
private String shift;
@ExcelCellName("Primary Skill")
private String baseTechnology;
......@@ -57,12 +72,17 @@ public class Employee implements Serializable {
@ExcelCellName("Skills")
private String technologyKnown;
@NotBlank
@Pattern(regexp="(^$|[0-9]{10})",message="Invalid mobile number")
@ExcelCellName("Primary Mobile")
private String mobileNumber;
@NotBlank
@Pattern(regexp="(^$|[0-9]{10})",message="Invalid alternate mobile number")
@ExcelCellName("Alternate Mobile")
private String alternateMobileNumber;
@Email(message = "Invalid personal email id")
@ExcelCellName("Personal Email")
private String personalEmailId;
......@@ -75,9 +95,11 @@ public class Employee implements Serializable {
@ExcelCellName("Employment Type")
private String employmentType;
@NotNull
@ExcelCellName("Date Of Joining")
private Date dateOfJoining;
@ExcelCellName("Date Of Birth")
private Date dateOfBirth;
......
package com.nisum.mytime.model;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import com.poiji.annotation.ExcelCellName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
......@@ -18,19 +21,20 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "AccountInfo")
public class AccountInfo implements Serializable {
@Document(collection = "employeeLocations")
public class EmployeeLocation implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private ObjectId id;
private String accountId;
private String accountName;
private String status;
private String clientAddress;
private String industryType;
List<String> deliveryManagers;
private String employeeId;
private String employeeName;
private String empLocation;
private Date startDate;
private Date endDate;
private Date createDate;
private Date updatedDate;
private boolean active;
}
package com.nisum.mytime.model;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import com.poiji.annotation.ExcelCellName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "EmployeeLocationDetails")
public class EmployeeLocationDetails implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private ObjectId id;
private String employeeId;
private String employeeName;
private String empLocation;
private Date startDate;
private Date endDate;
private Date createDate;
private Date updatedDate;
private boolean active;
}
......@@ -16,8 +16,9 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "EmpAssignedRoleMappingInfo")
public class RoleMappingInfo implements Serializable {
//@Document(collection = "EmpAssignedRoleMappingInfo")
@Document(collection = "employeeRoles")
public class EmployeeRole implements Serializable {
private static final long serialVersionUID = 1L;
@Id
......
......@@ -17,8 +17,8 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Locations")
public class Location implements Serializable {
@Document(collection = "orgLocations")
public class OrgLocation implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -20,8 +20,8 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "TeamDetails")
public class ProjectTeamMate extends AuditFields implements Serializable {
@Document(collection = "resources")
public class Resource extends AuditFields implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -35,7 +35,6 @@ public class ProjectTeamMate extends AuditFields implements Serializable {
private String projectId;
private String projectName;
private String account;
private String experience;
private String designation;
private String billableStatus;
......
package com.nisum.mytime.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.AccountInfo;
public interface AccountInfoRepo extends MongoRepository<AccountInfo, String> {
AccountInfo findByAccountName(String accontName);
}
\ No newline at end of file
......@@ -5,16 +5,16 @@ import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.Billing;
public interface TeamMatesBillingRepo extends MongoRepository<BillingDetails, String> {
public interface BillingRepo extends MongoRepository<Billing, String> {
List<BillingDetails> findByProjectId(String projectId);
List<Billing> findByProjectId(String projectId);
List<BillingDetails> findByEmployeeId(String employeeId);
List<Billing> findByEmployeeId(String employeeId);
BillingDetails findById(ObjectId id);
Billing findById(ObjectId id);
List<BillingDetails> findByEmployeeIdAndProjectId(String employeeId, String projectId);
List<Billing> findByEmployeeIdAndProjectId(String employeeId, String projectId);
}
......@@ -4,12 +4,11 @@ import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.model.EmployeeLocation;
public interface EmployeeLocationDetailsRepo extends MongoRepository<EmployeeLocationDetails, String> {
public interface EmployeeLocationRepo extends MongoRepository<EmployeeLocation, String> {
List<EmployeeLocationDetails> findByEmployeeId(String employeeId);
List<EmployeeLocation> findByEmployeeId(String employeeId);
EmployeeLocationDetails findByEmployeeName(String employeeName);
EmployeeLocation findByEmployeeName(String employeeName);
}
package com.nisum.mytime.repository;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Employee;
......@@ -24,5 +29,6 @@ public interface EmployeeRepo
List<Employee> findByEmpStatus(String status);
List<Employee> findByEmployeeIdIn(Set<String> empIdsSet);
}
\ No newline at end of file
......@@ -4,11 +4,11 @@ import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.RoleMappingInfo;
import com.nisum.mytime.model.EmployeeRole;
public interface RoleMappingInfoRepo extends MongoRepository<RoleMappingInfo, String> {
public interface EmployeeRoleRepo extends MongoRepository<EmployeeRole, String> {
RoleMappingInfo findByEmployeeIdAndRoleId(String employeeId, String roleId);
EmployeeRole findByEmployeeIdAndRoleId(String employeeId, String roleId);
List<RoleMappingInfo> findByEmployeeId(String employeeId);
List<EmployeeRole> findByEmployeeId(String employeeId);
}
\ No newline at end of file
......@@ -4,8 +4,8 @@ import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.OrgLocation;
public interface LocationRepo extends MongoRepository<Location, String> {
List<Location> findByLocationAndActiveStatus(String location, boolean activeStatus);
public interface OrgLocationRepo extends MongoRepository<OrgLocation, String> {
List<OrgLocation> findByLocationAndActiveStatus(String location, boolean activeStatus);
}
\ No newline at end of file
package com.nisum.mytime.repository;
import java.util.List;
import java.util.Optional;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.ProjectTeamMate;
public interface ProjectTeamMatesRepo
extends MongoRepository<ProjectTeamMate, String> {
List<ProjectTeamMate> findByProjectId(String projectId);
List<ProjectTeamMate> findByEmployeeId(String employeeId);
ProjectTeamMate findById(ObjectId id);
ProjectTeamMate findByEmployeeIdAndProjectId(String employeeId,String projectId);
List<ProjectTeamMate> findByEmployeeIdAndActive(String employeeId,boolean status);
List<ProjectTeamMate> findByEmployeeIdAndProjectIdAndActive(String employeeId, String projectId, boolean status);
List<ProjectTeamMate> findByAccountAndActiveAndBillableStatus( String account, boolean status, String billableStatus);
Optional<List<ProjectTeamMate>> findByActiveAndShiftLikeOrderByEmployeeIdDesc( boolean active, String shift);
}
package com.nisum.mytime.repository;
import java.util.List;
import java.util.Optional;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Resource;
public interface ResourceRepo
extends MongoRepository<Resource, String> {
List<Resource> findByProjectId(String projectId);
List<Resource> findByEmployeeId(String employeeId);
Resource findById(ObjectId id);
Resource findByEmployeeIdAndProjectId(String employeeId,String projectId);
List<Resource> findByEmployeeIdAndActive(String employeeId,boolean status);
List<Resource> findByEmployeeIdAndProjectIdAndActive(String employeeId, String projectId, boolean status);
List<Resource> findByAccountAndActiveAndBillableStatus( String account, boolean status, String billableStatus);
Optional<List<Resource>> findByActiveAndShiftLikeOrderByEmployeeIdDesc( boolean active, String shift);
}
......@@ -4,7 +4,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Role;
public interface RoleInfoRepo extends MongoRepository<Role, String> {
public interface RoleRepo extends MongoRepository<Role, String> {
Role findByRoleName(String roleName);
......
......@@ -23,4 +23,6 @@ public interface IAccountService {
Account deleteAccount(String accountId) throws MyTimeException;
public List<Account> getAccountsAll() throws MyTimeException;
}
......@@ -10,10 +10,20 @@ import com.nisum.mytime.model.EmpLoginData;
public interface IAttendanceService {
List<AttendenceData> getAttendanciesReport(String reportDate,String shift) throws MyTimeException, SQLException;
List<AttendenceData> getAttendanciesReport(String reportDate, String shift) throws MyTimeException, SQLException;
List generatePdfReport(long id, String fromDate, String toDate, String fromTime, String toTime) throws MyTimeException;
List generatePdfReport(long id, String fromDate, String toDate, String fromTime, String toTime)
throws MyTimeException;
List<EmpLoginData> employeeLoginReportBasedOnDateTime(long id, String fromDate, String toDate, String fromTime,
String toTime) throws MyTimeException, ParseException;
Boolean fetchEmployeesData(String perticularDate, boolean resynchFlag) throws MyTimeException;
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) throws MyTimeException;
List generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException;
List<EmpLoginData> employeeLoginReportBasedOnDateTime(long id, String fromDate,
String toDate,String fromTime,String toTime) throws MyTimeException, ParseException;
}
package com.nisum.mytime.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.model.Employee;
@Service
public interface IBillingService {
public Billing addBillingtoResource(Billing billing, Employee employee, String loginEmpId);
public List<Billing> getEmployeeActiveBillingDetails(String empId, String projectId);
}
......@@ -32,4 +32,10 @@ public interface IDomainService {
Set<String> accountsAssignedToDeliveryLead(String empId) throws MyTimeException;
List<Domain> getDomainsUnderAccount(String accountId)throws MyTimeException;
Domain getDomainById(String domainId);
}
......@@ -5,13 +5,14 @@ import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.model.EmployeeLocation;
@Service
public interface IEmployeeLocationService {
public void saveEmployeeLocationDetails(Employee employee) ;
public List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId);
public void save(Employee employee);
public List<EmployeeLocation> getEmployeeLocations(String empId);
void update(Employee employee, boolean delete);
}
......@@ -3,11 +3,17 @@ package com.nisum.mytime.service;
import java.util.List;
import java.util.Set;
import org.springframework.stereotype.Service;
import com.mongodb.WriteResult;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmployeeRole;
public interface IRoleMappingService {
@Service
public interface IEmployeeRoleService {
List<EmployeeRole> findByEmployeeId(String employeeId);
void addEmployeeRole(String employeeId, String roleId) throws MyTimeException;
void saveUniqueEmployeeAndRole(List<String> employeeIds, String roleId) throws MyTimeException;
......
package com.nisum.mytime.service;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import org.springframework.http.ResponseEntity;
import java.util.Set;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.AccountInfo;
import com.nisum.mytime.model.Designation;
import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.model.Shift;
import com.nisum.mytime.model.Skill;
@Service
public interface IEmployeeService {
List<Employee> getManagers()throws MyTimeException;
Boolean fetchEmployeesData(String perticularDate, boolean resynchFlag)
throws MyTimeException;
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException;
List<Employee> getActiveEmployees() throws MyTimeException;
Employee createEmployee(Employee employeeRoles, String empId)
throws MyTimeException;
List generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException;
List generatePdfReport(long id, String fromDate, String toDate,String fromTime,String toTime)
throws MyTimeException, ParseException;
Employee getEmployeeByEmaillId(String emailId);
boolean isEmployeeExistsById(String employeeId);
void deleteEmployee(String empId);
Employee createEmployee(Employee employeeRoles, String empId) throws MyTimeException;
Employee updateEmployeeRole(Employee employeeRoles,String empId);
Employee updateEmployee(Employee employeeRoles, String empId);
void updateEmployeeLocationDetails(Employee employeeRoles,
boolean delete);
Employee deleteEmployee(String empId);
//void saveEmployeeLocationDetails(Employee employeeRoles);
Employee updateProfile(Employee employeeRoles) throws MyTimeException;
Employee getEmployeesRoleData(String empId);
Employee getEmployeeById(String empId);
//List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId);
Employee getEmployeeByEmaillId(String emailId);
// List<Shift> getAllShifts() throws MyTimeException;
List<Employee> getManagers() throws MyTimeException;
// List<Designation> getAllDesignations() throws MyTimeException;
List<Employee> getActiveEmployees() throws MyTimeException;
//List<Skill> getTechnologies() throws MyTimeException;
List<Employee> getEmployeesByStatus(String status);
public Employee updateProfile(Employee employeeRoles)
throws MyTimeException;
List<Account> getAccounts() throws MyTimeException;
public List<Account> getAccounts() throws MyTimeException;
Employee getEmployeeRoleDataForSearchCriteria(String searchId, String searchAttribute);
//List<Location> getLocations() throws MyTimeException;
List<String> getEmployeeDetailsForAutocomplete();
Employee getEmployeeRoleDataForSearchCriteria(String searchId,
String searchAttribute);
List<HashMap<String, String>> getDeliveryLeads(String domainId);
List<String> getEmployeeDetailsForAutocomplete();
List<Employee> getEmployeesByFunctionalGrp(String functionalGrp);
//List<MasterData> getMasterData() throws MyTimeException;
boolean verifyEmployeeRole(String empId, String roleName);
List<Employee> getEmployeesByFunctionalGrp(String functionalGrp);
List<Employee> getEmployeesFromList(Set<String> empIdsSet);
List<Employee> getEmployeesByStatus(String status);
List<HashMap<String, String>> getDeliveryLeads(String domainId);
public List<AccountInfo> getAccountsInfo() throws MyTimeException;
public List<Domain> getDomains(String accountId)throws MyTimeException;
public boolean verifyRole(String empId, String roleName);
String importDataFromExcelFile(MultipartFile file, String empId) throws MyTimeException;
}
package com.nisum.mytime.service;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.Resource;
@Service
public interface IEmployeeShiftService {
void updateShiftDetails(Resource existingTeammate, String loginEmpId);
}
......@@ -11,4 +11,7 @@ import com.nisum.mytime.model.MasterData;
public interface IMasterDataService {
List<MasterData> getMasterData() throws MyTimeException;
List<MasterData> findByMasterDataTypeAndMasterDataNameAndActiveStatus(String masterDataType, String masterDataName,
boolean activeStatus);
}
......@@ -5,10 +5,12 @@ import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.model.OrgLocation;
@Service
public interface IOrgLocationService {
List<Location> getLocations() throws MyTimeException;
List<OrgLocation> getLocations() throws MyTimeException;
List<OrgLocation> findByLocationAndActiveStatus(String location, boolean activeStatus);
}
......@@ -7,17 +7,17 @@ import java.util.Set;
import org.bson.types.ObjectId;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.model.Resource;
public interface IProjectService {
public ProjectTeamMate addNewBeanchAllocation(Employee employee,String loginEmpId);
public Resource addNewBeanchAllocation(Employee employee,String loginEmpId);
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException;
......@@ -37,58 +37,58 @@ public interface IProjectService {
Employee getEmployeesRoleData(String empId);
List<ProjectTeamMate> getTeamDetails(String empId);
List<Resource> getTeamDetails(String empId);
//MT-72
List<ProjectTeamMate> getProjectInfo(String empId);
List<Resource> getProjectInfo(String empId);
public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate, String loginEmpId)
public Resource addProjectTeamMate(Resource projectTeamMate, String loginEmpId)
throws MyTimeException;
String updateTeammate(ProjectTeamMate projectTeamMate, String loginEmpId) throws MyTimeException;
String updateTeammate(Resource projectTeamMate, String loginEmpId) throws MyTimeException;
void deleteTeammate(String empId, String projectId, ObjectId id, String loginEmpId);
List<Project> getProjects(String managerId) throws MyTimeException;
List<ProjectTeamMate> getMyTeamDetails(String empId);
List<Resource> getMyTeamDetails(String empId);
List<Employee> getUnAssignedEmployees();
List<ProjectTeamMate> getShiftDetails(String shift);
List<Resource> getShiftDetails(String shift);
List<ProjectTeamMate> getAllProjectDetails();
List<Resource> getAllProjectDetails();
List<ProjectTeamMate> getProjectDetails(String projectId,String status);
List<Resource> getProjectDetails(String projectId,String status);
public List<ProjectTeamMate> getMyProjectAllocations(String empId);
public List<Resource> getMyProjectAllocations(String empId);
List<BillingDetails> getEmployeeBillingDetails(String empId,
List<Billing> getEmployeeBillingDetails(String empId,
String projectId);
BillingDetails addEmployeeBillingDetails(BillingDetails billingDetails, String loginEmpId);
Billing addEmployeeBillingDetails(Billing billingDetails, String loginEmpId);
BillingDetails updateEmployeeBilling(BillingDetails billingDetails, String loginEmpId);
Billing updateEmployeeBilling(Billing billingDetails, String loginEmpId);
void deleteEmployeeBilling(BillingDetails teamMate);
void deleteEmployeeBilling(Billing teamMate);
public List<EmployeeDashboardVO> getEmployeesDashBoard();
List<BillingDetails> getEmployeeActiveBillingDetails(String empId,
List<Billing> getEmployeeActiveBillingDetails(String empId,
String projectId);
List<BillingDetails> getEmployeeActiveNisumBench(String empId);
List<Billing> getEmployeeActiveNisumBench(String empId);
List<BillingDetails> getEmployeeBillingDetailsAll(String empId);
List<Billing> getEmployeeBillingDetailsAll(String empId);
public void updateShiftDetails(ProjectTeamMate existingTeammate, String loginEmpId);
public void updateShiftDetails(Resource existingTeammate, String loginEmpId);
public void addShiftDetails(ProjectTeamMate projectTeamMate, String loginEmpId);
public void addShiftDetails(Resource projectTeamMate, String loginEmpId);
List<ProjectTeamMate> findByAccountAndActiveAndBillableStatus(
List<Resource> findByAccountAndActiveAndBillableStatus(
String account, boolean status, String billableStatus);
public String addProjectTeamMateWithCheck(ProjectTeamMate projectTeamMate, String loginEmpId)
public String addProjectTeamMateWithCheck(Resource projectTeamMate, String loginEmpId)
throws MyTimeException;
public List<HashMap<Object, Object>> projectsInfoByEmpId(String empId);
......
package com.nisum.mytime.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Resource;
@Service
public interface IResourceService {
public Resource save(Resource resource);
void addResources(Employee employee, String loginEmpId);
void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
public List<Resource> getResources(String empId);
}
package com.nisum.mytime.service;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Role;
public interface IRoleInfoService {
@Service
public interface IRoleService {
public Role addRole(Role roleInfo) throws MyTimeException;
......
package com.nisum.mytime.service;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.nisum.mytime.exception.handler.MyTimeException;
@Service
public interface IUploadXLService {
String importDataFromExcelFile(MultipartFile file, String empId) throws MyTimeException;
}
......@@ -22,12 +22,15 @@ import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.service.IAccountService;
import com.nisum.mytime.service.IRoleInfoService;
import com.nisum.mytime.service.IRoleMappingService;
import com.nisum.mytime.service.IRoleService;
import com.nisum.mytime.service.IEmployeeRoleService;
import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class AccountService implements IAccountService {
@Autowired
......@@ -37,12 +40,11 @@ public class AccountService implements IAccountService {
private MongoTemplate mongoTemplate;
@Autowired
private IRoleInfoService roleInfoService;
private IRoleService roleInfoService;
@Autowired
private IRoleMappingService roleMappingService;
private IEmployeeRoleService roleMappingService;
private static final Logger logger = LoggerFactory.getLogger(AccountService.class);
@Override
public Account createAccount(Account accountReq) throws MyTimeException {
......@@ -50,16 +52,16 @@ public class AccountService implements IAccountService {
accountReq.setAccountId(generateAccountId());
accountReq.setStatus(MyTimeUtils.STRING_Y);
Account accountPersisted = accountRepo.save(accountReq);
if (logger.isInfoEnabled()) {
logger.info("Account has been persisted in database with account details::" + accountPersisted);
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(MyTimeUtils.ACCOUNT);
logger.info("Going to add DM role id for account delivery managers::::" + accountDmsList);
log.info("Going to add DM role id for account delivery managers::::" + accountDmsList);
roleMappingService.saveUniqueEmployeeAndRole(accountDmsList, roleId);
logger.info("Added roleids for delivery managers in rolemapping collection");
log.info("Added roleids for delivery managers in rolemapping collection");
}
}
......@@ -73,15 +75,15 @@ public class AccountService implements IAccountService {
accountUpdating.setStatus(accountBeforeUpdate.getStatus());
accountUpdating.setAccountName(accountUpdating.getAccountName().trim());
logger.info("Updating the roleids of DeliveryManagers in RoleMapping Collection");
log.info("Updating the roleids of DeliveryManagers in RoleMapping Collection");
final String roleId = roleInfoService.getRole(MyTimeUtils.ACCOUNT);
updateRoleIdsForDeliveryManager(accountUpdating, roleId);
logger.info("Deleting the roleids of DeliveryManagers in RoleMapping Collection");
log.info("Deleting the roleids of DeliveryManagers in RoleMapping Collection");
deleteRoleIdsForDeliveryManager(accountUpdating, roleId);
Account accountUpdated = accountRepo.save(accountUpdating);
logger.info("Account updated::"+accountUpdated);
log.info("Account updated::"+accountUpdated);
return accountUpdated;
}
......@@ -105,8 +107,8 @@ public class AccountService implements IAccountService {
List<Map<String, String>> updatedEmployeeList = null;
for (Account account : accountRepo.findAll()) {
updatedEmployeeList = new ArrayList<>();
for (Employee employeesRole : getEmployeeDetails(account)) {
updatedEmployeeList.add(getEmployeeDetails(employeesRole));
for (Employee employee : getEmployeeDetails(account)) {
updatedEmployeeList.add(getEmployeeDetails(employee));
}
updatedAccountList.add(getAccuntDetails(account, updatedEmployeeList));
}
......@@ -117,7 +119,7 @@ public class AccountService implements IAccountService {
public Account deleteAccount(String accountId) throws MyTimeException {
// delete the documents for deliveryManagers in rolemapping collection.
logger.info("After updation:: Deleting the Roleids for DeliveryManagers in RoleMapping collection");
log.info("After updation:: Deleting the Roleids for DeliveryManagers in RoleMapping collection");
deleteRoleidsForDeliveryManagers(accountId);
// updating the status to "InActive".
......@@ -128,7 +130,7 @@ public class AccountService implements IAccountService {
options.upsert(true);
Account updatedAccount = mongoTemplate.findAndModify(query, update, options, Account.class);
logger.info("The account updated::" + updatedAccount);
log.info("The account updated::" + updatedAccount);
return updatedAccount;
}
......@@ -236,5 +238,12 @@ public class AccountService implements IAccountService {
}
}
}
@Override
public List<Account> getAccountsAll() throws MyTimeException {
return accountRepo.findAll();
}
}
......@@ -21,8 +21,8 @@ import com.nisum.mytime.configuration.DbConnection;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.AttendenceData;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.repository.ProjectTeamMatesRepo;
import com.nisum.mytime.model.Resource;
import com.nisum.mytime.repository.ResourceRepo;
import com.nisum.mytime.service.IAttendanceService;
import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeLogger;
......@@ -39,7 +39,7 @@ public class AttendanceService implements IAttendanceService {
DbConnection dbConnection;
@Autowired
ProjectTeamMatesRepo projectTeamMatesRepo;
ResourceRepo projectTeamMatesRepo;
@Autowired
private PdfReportGenerator pdfReportGenerator;
......@@ -66,12 +66,15 @@ public class AttendanceService implements IAttendanceService {
throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
}
private List<AttendenceData> getEmpsAttendenceByShiftWise(String reportDate, String shift) throws MyTimeException {
List<AttendenceData> listOfEmployees = new ArrayList<AttendenceData>();
Optional<List<ProjectTeamMate>> list = findEmpIdsByShiftWise(shift);
Optional<List<Resource>> list = findEmpIdsByShiftWise(shift);
if(list.isPresent()) {
List<String> empIdList = list.get().stream().map(ProjectTeamMate::getEmployeeId).collect(Collectors.toList());
List<String> empIdList = list.get().stream().map(Resource::getEmployeeId).collect(Collectors.toList());
if(null != empIdList && empIdList.size() > MyTimeUtils.INT_ZERO) {
String query = buildSqlQuery(reportDate,empIdList.toString().substring(1, empIdList.toString().length()-1), MyTimeUtils.PRESENT);
listOfEmployees.addAll(getAttendenceData(query, MyTimeUtils.PRESENT));
......@@ -87,8 +90,8 @@ public class AttendanceService implements IAttendanceService {
return listOfEmployees;
}
private Optional<List<ProjectTeamMate>> findEmpIdsByShiftWise(String shift) {
Optional<List<ProjectTeamMate>> list = null;
private Optional<List<Resource>> findEmpIdsByShiftWise(String shift) {
Optional<List<Resource>> list = null;
if(MyTimeUtils.ALL.equalsIgnoreCase(shift)) {
list = projectTeamMatesRepo.findByActiveAndShiftLikeOrderByEmployeeIdDesc( true, MyTimeUtils.SHIFT);
}else {
......@@ -129,6 +132,27 @@ public class AttendanceService implements IAttendanceService {
}
return listOfEmployees;
}
// @Override
public Boolean fetchEmployeesData(String perticularDate, boolean resynchFlag) throws MyTimeException {
return true;
}
// @Override
public List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate)
throws MyTimeException {
return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates(id, fromDate, toDate);
}
@Override
public List generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
}
}
package com.nisum.mytime.service.impl;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
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.stereotype.Service;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.repository.BillingRepo;
import com.nisum.mytime.service.IBillingService;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class BillingService implements IBillingService {
@Autowired
private BillingRepo billingRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Override
public List<Billing> getEmployeeActiveBillingDetails(String empId, String projectId) {
Query query4 = new Query();
query4.addCriteria(Criteria.where("active").is(new Boolean(true)));
query4.addCriteria(Criteria.where("employeeId").is(empId));
query4.addCriteria(Criteria.where("projectId").is(projectId));
List<Billing> billings = mongoTemplate.find(query4, Billing.class);
List<Billing> billingsSorted = billings;
try {
billingsSorted = (billings == null || billings.size() == 0) ? billings
: billings.stream().sorted(Comparator.comparing(Billing::getBillingStartDate).reversed())
.collect(Collectors.toList());
} catch (Exception e) {
e.printStackTrace();
}
return billingsSorted;
}
public Billing addBillingtoResource(Billing billing, Employee employee, String loginEmpId) {
billing.setBillingEndDate(employee.getEndDate());
billing.setActive(false);
billing.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
return billingRepo.save(billing);
}
}
......@@ -9,6 +9,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Designation;
import com.nisum.mytime.repository.DesignationRepo;
import com.nisum.mytime.service.IDesignationService;
@Service
public class DesignationService implements IDesignationService {
......
......@@ -22,16 +22,19 @@ import com.nisum.mytime.model.Domain;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.repository.DomainRepo;
import com.nisum.mytime.service.IDomainService;
import com.nisum.mytime.service.IRoleInfoService;
import com.nisum.mytime.service.IRoleMappingService;
import com.nisum.mytime.service.IRoleService;
import com.nisum.mytime.service.IEmployeeRoleService;
import com.nisum.mytime.utils.CommomUtil;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
/**
* @author Vijay
*
*/
@Service
@Slf4j
public class DomainService implements IDomainService {
@Autowired
......@@ -41,12 +44,12 @@ public class DomainService implements IDomainService {
private MongoTemplate mongoTemplate;
@Autowired
private IRoleInfoService roleInfoService;
private IRoleService roleInfoService;
@Autowired
private IRoleMappingService roleMappingService;
private IEmployeeRoleService roleMappingService;
private static final Logger logger = LoggerFactory.getLogger(DomainService.class);
public boolean isDomainExists(Domain domainReq) {
boolean isDomainExists = false;
......@@ -83,16 +86,16 @@ public class DomainService implements IDomainService {
@Override
public Domain update(Domain domainReq) throws MyTimeException {
logger.info("updating the roles for DeliveryManager in EmployeeRoleMapping collection");
log.info("updating the roles for DeliveryManager in EmployeeRoleMapping collection");
final String roleId = roleInfoService.getRole(MyTimeUtils.DOMAIN);
updateRoleIdsForDMs(domainReq, roleId);
logger.info("deleting roleids for DeliveryManagers in EmployeeRoleMapping collection");
log.info("deleting roleids for DeliveryManagers in EmployeeRoleMapping collection");
deleteRoleIdsForDMs(domainReq, roleId);
logger.info("updating the domain details");
log.info("updating the domain details");
domainReq.setStatus(MyTimeUtils.ACTIVE);
Domain domainPersisted = domainRepo.save(domainReq);
logger.info("After update the domain details::" + domainPersisted);
log.info("After update the domain details::" + domainPersisted);
return domainPersisted;
}
......
package com.nisum.mytime.service.impl;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
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.stereotype.Service;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeLocationDetails;
import com.nisum.mytime.repository.EmployeeLocationDetailsRepo;
import com.nisum.mytime.model.EmployeeLocation;
import com.nisum.mytime.repository.EmployeeLocationRepo;
import com.nisum.mytime.service.IEmployeeLocationService;
import lombok.extern.slf4j.Slf4j;
@Service
public class EmployeeLocationService implements IEmployeeLocationService{
@Slf4j
public class EmployeeLocationService implements IEmployeeLocationService {
@Autowired
private EmployeeLocationDetailsRepo employeeLocationDetailsRepo;
@Override
public void saveEmployeeLocationDetails(Employee employee) {
EmployeeLocationDetails employeeLocationDetails = new EmployeeLocationDetails();
employeeLocationDetails.setActive(employee.getEmpStatus().equalsIgnoreCase("Active"));
employeeLocationDetails.setEmployeeId(employee.getEmployeeId());
employeeLocationDetails.setEmployeeName(employee.getEmployeeName());
employeeLocationDetails.setCreateDate(new Date());
employeeLocationDetails.setEndDate(new Date());
employeeLocationDetails.setUpdatedDate(new Date());
employeeLocationDetails.setStartDate(new Date());
employeeLocationDetails.setEmpLocation(employee.getEmpLocation());
employeeLocationDetailsRepo.save(employeeLocationDetails);
}
@Override
public List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId) {
return employeeLocationDetailsRepo.findByEmployeeId(empId);
}
@Autowired
private EmployeeLocationRepo employeeLocationRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Override
public void save(Employee employee) {
EmployeeLocation employeeLocation = new EmployeeLocation();
employeeLocation.setActive(employee.getEmpStatus().equalsIgnoreCase("Active"));
employeeLocation.setEmployeeId(employee.getEmployeeId());
employeeLocation.setEmployeeName(employee.getEmployeeName());
employeeLocation.setCreateDate(new Date());
employeeLocation.setEndDate(new Date());
employeeLocation.setUpdatedDate(new Date());
employeeLocation.setStartDate(new Date());
employeeLocation.setEmpLocation(employee.getEmpLocation());
employeeLocationRepo.save(employeeLocation);
}
@Override
public List<EmployeeLocation> getEmployeeLocations(String empId) {
List<EmployeeLocation> empLocationList = employeeLocationRepo.findByEmployeeId(empId);
log.info("The Employee Locations: findByEmployeeId" + empLocationList);
return empLocationList;
}
@Override
public void update(Employee employee, boolean delete) {
try {
Query getQuery = new Query();
getQuery.addCriteria(new Criteria().andOperator(Criteria.where("active").is(true),
Criteria.where("employeeId").is(employee.getEmployeeId())));
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
EmployeeLocation existingLocation = mongoTemplate.findOne(getQuery, EmployeeLocation.class);
if (existingLocation != null) {
existingLocation.setActive(false);
existingLocation.setEndDate(cal.getTime());
existingLocation.setUpdatedDate(new Date());
mongoTemplate.save(existingLocation);
}
if (!delete)
save(employee);
} catch (Exception ex) {
System.out.println(ex);
}
}
}
......@@ -16,24 +16,25 @@ import org.springframework.stereotype.Service;
import com.mongodb.WriteResult;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.RoleMappingInfo;
import com.nisum.mytime.repository.RoleInfoRepo;
import com.nisum.mytime.repository.RoleMappingInfoRepo;
import com.nisum.mytime.service.IRoleMappingService;
import com.nisum.mytime.model.EmployeeRole;
import com.nisum.mytime.repository.RoleRepo;
import com.nisum.mytime.repository.EmployeeRoleRepo;
import com.nisum.mytime.service.IEmployeeRoleService;
import com.nisum.mytime.utils.MyTimeUtils;
@Service
public class RoleMappingService implements IRoleMappingService {
public class EmployeeRoleService implements IEmployeeRoleService {
@Autowired
private RoleMappingInfoRepo roleMappingInfoRepo;
private EmployeeRoleRepo employeeRoleRepo;
@Autowired
private RoleInfoRepo roleInfoRepo;
private RoleRepo roleRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Override
public void saveUniqueEmployeeAndRole(List<String> employeeIds, String roleId) throws MyTimeException {
for (String employeeId : employeeIds) {
......@@ -42,10 +43,10 @@ public class RoleMappingService implements IRoleMappingService {
}
public void addEmployeeRole(String employeeId, String roleId) throws MyTimeException {
RoleMappingInfo roleMappingInfo = roleMappingInfoRepo.findByEmployeeIdAndRoleId(employeeId, roleId);
EmployeeRole roleMappingInfo = employeeRoleRepo.findByEmployeeIdAndRoleId(employeeId, roleId);
boolean isChanged = false;
if (roleMappingInfo == null) {
roleMappingInfo = new RoleMappingInfo();
roleMappingInfo = new EmployeeRole();
roleMappingInfo.setEmployeeId(employeeId);
roleMappingInfo.setRoleId(roleId);
roleMappingInfo.setIsActive("Y");
......@@ -55,16 +56,22 @@ public class RoleMappingService implements IRoleMappingService {
isChanged = true;
}
if (isChanged) {
roleMappingInfoRepo.save(roleMappingInfo);
employeeRoleRepo.save(roleMappingInfo);
}
}
@Override
public List<EmployeeRole> findByEmployeeId(String employeeId)
{
return employeeRoleRepo.findByEmployeeId(employeeId);
}
@Override
public WriteResult deleteRole(String employeeId, String roleId) throws MyTimeException {
Query query = new Query(Criteria.where("employeeId").is(employeeId).and("roleId").is(roleId));
Update update = new Update();
update.set(MyTimeUtils.IS_ACTIVE, "N");
return mongoTemplate.upsert(query, update, RoleMappingInfo.class);
return mongoTemplate.upsert(query, update, EmployeeRole.class);
}
@Override
......@@ -72,17 +79,17 @@ public class RoleMappingService implements IRoleMappingService {
Map<Integer, String> roleInfoMap = new LinkedHashMap<Integer, String>();
String roleName = null;
List<RoleMappingInfo> listOfEmployeeRoles = roleMappingInfoRepo.findByEmployeeId(employeeId).stream()
List<EmployeeRole> listOfEmployeeRoles = employeeRoleRepo.findByEmployeeId(employeeId).stream()
.filter(e -> ("N".equalsIgnoreCase(e.getIsActive()))).collect(Collectors.toList());
if (listOfEmployeeRoles != null && listOfEmployeeRoles.size() > 0) {
for (RoleMappingInfo employee : listOfEmployeeRoles) {
roleInfoMap.put((roleInfoRepo.findByRoleId(employee.getRoleId())).getPriority(), employee.getRoleId());
for (EmployeeRole employee : listOfEmployeeRoles) {
roleInfoMap.put((roleRepo.findByRoleId(employee.getRoleId())).getPriority(), employee.getRoleId());
}
roleInfoMap = roleInfoMap.entrySet().stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toMap(
Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
if (!roleInfoMap.isEmpty()) {
Map.Entry<Integer, String> entry = roleInfoMap.entrySet().iterator().next();
roleName = roleInfoRepo.findByRoleId(entry.getValue()).getRoleName();
roleName = roleRepo.findByRoleId(entry.getValue()).getRoleName();
}
}
return roleName;
......@@ -92,11 +99,11 @@ public class RoleMappingService implements IRoleMappingService {
@Override
public Set<String> empRolesMapInfoByEmpId(String employeeId) {
Set<String> roleSet = new HashSet<String>();
List<RoleMappingInfo> listOfEmployeeRoles = roleMappingInfoRepo.findByEmployeeId(employeeId).stream().filter(e->(
List<EmployeeRole> listOfEmployeeRoles = employeeRoleRepo.findByEmployeeId(employeeId).stream().filter(e->(
"N".equalsIgnoreCase(e.getIsActive()))).collect(Collectors.toList());
if(null != listOfEmployeeRoles && !listOfEmployeeRoles.isEmpty() && MyTimeUtils.INT_ZERO < listOfEmployeeRoles.size()) {
for(RoleMappingInfo obj : listOfEmployeeRoles) {
for(EmployeeRole obj : listOfEmployeeRoles) {
roleSet.add(obj.getRoleId());
}
}
......
package com.nisum.mytime.service.impl;
import java.util.Calendar;
import org.springframework.beans.factory.annotation.Autowired;
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.stereotype.Service;
import com.nisum.mytime.model.EmpShiftDetails;
import com.nisum.mytime.model.Resource;
import com.nisum.mytime.service.IEmployeeShiftService;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class EmployeeShiftService implements IEmployeeShiftService{
@Autowired
private MongoTemplate mongoTemplate;
public void updateShiftDetails(Resource existingTeammate, String loginEmpId) {
Query getQuery = new Query();
getQuery.addCriteria(new Criteria().andOperator(Criteria.where("active").is(true),
Criteria.where("employeeId").is(existingTeammate.getEmployeeId())));
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
EmpShiftDetails existingShift = mongoTemplate.findOne(getQuery, EmpShiftDetails.class);
if (existingShift != null) {
existingShift.setActive(false);
// existingShift.setUpdatedDate(new Date());// Commented as added
// common audit fields
existingShift.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
mongoTemplate.save(existingShift);
}
}
}
......@@ -9,15 +9,23 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.repository.MasterDataRepo;
import com.nisum.mytime.service.IMasterDataService;
import com.nisum.mytime.utils.MyTimeUtils;
@Service("masterDataService")
public class MasterDataService implements IMasterDataService {
@Autowired
private MasterDataRepo masterDataRepo;
private MasterDataRepo masterDataRepo;
@Override
public List<MasterData> getMasterData() throws MyTimeException {
return masterDataRepo.findAll();
}
@Override
public List<MasterData> findByMasterDataTypeAndMasterDataNameAndActiveStatus(String masterDataType, String masterDataName,
boolean activeStatus) {
return masterDataRepo.findByMasterDataTypeAndMasterDataNameAndActiveStatus(masterDataType, masterDataName,
activeStatus);
}
}
......@@ -6,18 +6,30 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Location;
import com.nisum.mytime.repository.LocationRepo;
import com.nisum.mytime.model.OrgLocation;
import com.nisum.mytime.repository.OrgLocationRepo;
import com.nisum.mytime.service.IOrgLocationService;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class OrgLocationService implements IOrgLocationService {
@Autowired
private LocationRepo locationRepo;
private OrgLocationRepo orgLocationRepo;
@Override
public List<OrgLocation> getLocations() throws MyTimeException {
List<OrgLocation> orgLocationList = orgLocationRepo.findAll();
log.info("The Organization Location Details::" + orgLocationList);
return orgLocationList;
}
@Override
public List<Location> getLocations() throws MyTimeException {
return locationRepo.findAll();
public List<OrgLocation> findByLocationAndActiveStatus(String location, boolean activeStatus) {
return orgLocationRepo.findByLocationAndActiveStatus(location, activeStatus);
}
}
package com.nisum.mytime.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Resource;
import com.nisum.mytime.repository.ResourceRepo;
import com.nisum.mytime.service.IResourceService;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class ResourceService implements IResourceService {
@Autowired
private BillingService billingService;
@Autowired
private EmployeeShiftService empShiftService;
@Autowired
private ResourceRepo resourceRepo;
public Resource save(Resource resource) {
return resourceRepo.save(resource);
}
public void addResources(Employee employee, String loginEmpId) {
List<Resource> resourceList = resourceRepo.findByEmployeeId(employee.getEmployeeId());
if (resourceList != null && !resourceList.isEmpty()) {
for (Resource resource : resourceList) {
resource.setRole(employee.getRole());
resource.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
resourceRepo.save(resource);
}
}
// return null;
}
public void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId) {
// inactive the employee from the assigned project
if (employeeReq.getEmpStatus().equals(MyTimeUtils.IN_ACTIVE_SPACE) && employeeReq.getEndDate() != null
&& employeeReq.getEndDate().compareTo(new Date()) <= 0) {
List<Resource> resourcesList = resourceRepo.findByEmployeeIdAndActive(employeeReq.getEmployeeId(), true);
if (resourcesList.size() == 1) {
Resource resource = resourcesList.get(0);
resource.setActive(false);
resource.setEndDate(employeeReq.getEndDate());
List<Billing> billingList = billingService.getEmployeeActiveBillingDetails(resource.getEmployeeId(),
resource.getProjectId());
if (billingList != null && !billingList.isEmpty()) {
billingService.addBillingtoResource(billingList.get(0), employeeUpdated, loginEmpId);
}
resource.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
resourceRepo.save(resource);
empShiftService.updateShiftDetails(resource, loginEmpId);
}
}
}
public List<Resource> getResources(String empId) {
return resourceRepo.findByEmployeeId(empId);
}
}
......@@ -5,25 +5,28 @@ import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Role;
import com.nisum.mytime.repository.RoleInfoRepo;
import com.nisum.mytime.service.IRoleInfoService;
import com.nisum.mytime.repository.RoleRepo;
import com.nisum.mytime.service.IRoleService;
import lombok.extern.slf4j.Slf4j;
@Service
public class RoleInfoService implements IRoleInfoService {
@Slf4j
public class RoleService implements IRoleService {
@Autowired
RoleInfoRepo roleInfoRepo;
RoleRepo roleRepo;
@Override
public Role addRole(Role roleInfo) throws MyTimeException {
return roleInfoRepo.save(roleInfo);
return roleRepo.save(roleInfo);
}
@Override
public String getRole(String roleName) throws MyTimeException {
return roleInfoRepo.findByRoleName(roleName).getRoleId();
return roleRepo.findByRoleName(roleName).getRoleId();
}
}
......@@ -10,14 +10,19 @@ import com.nisum.mytime.model.Shift;
import com.nisum.mytime.repository.ShiftRepo;
import com.nisum.mytime.service.IShiftService;
import lombok.extern.slf4j.Slf4j;
@Service
public class ShiftService implements IShiftService{
@Slf4j
public class ShiftService implements IShiftService {
@Autowired
private ShiftRepo shiftRepo;
@Autowired
private ShiftRepo shiftRepo;
// @Override
public List<Shift> getAllShifts() throws MyTimeException {
return shiftRepo.findAll();
}
@Override
public List<Shift> getAllShifts() throws MyTimeException {
List<Shift> shiftsList = shiftRepo.findAll();
log.info("The shift list details::" + shiftsList);
return shiftsList;
}
}
......@@ -10,7 +10,10 @@ import com.nisum.mytime.model.Skill;
import com.nisum.mytime.repository.SkillRepo;
import com.nisum.mytime.service.ISkillService;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class SkillService implements ISkillService {
@Autowired
......
......@@ -5,15 +5,21 @@ import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.MasterData;
import com.nisum.mytime.repository.LocationRepo;
import com.nisum.mytime.repository.MasterDataRepo;
import com.nisum.mytime.service.IMasterDataService;
import com.nisum.mytime.service.impl.OrgLocationService;
@Service
public class DataValidations {
@Autowired
static IMasterDataService masterDataService;
@Autowired
static OrgLocationService orgLocationService;
public static boolean validateNumber(String number) {
boolean flag = false;
number = number.trim();
......@@ -72,46 +78,46 @@ public class DataValidations {
return flag;
}
public static boolean isValidFunctionalGroup(String functionalGroup,MasterDataRepo masterDataRepo) {
public static boolean isValidFunctionalGroup(String functionalGroup) {
boolean flag = false;
functionalGroup = functionalGroup.trim();
if(!MyTimeUtils.EMPTY_STRING.equals(functionalGroup)) {
List<MasterData> fsData = masterDataRepo.findByMasterDataTypeAndMasterDataNameAndActiveStatus(MyTimeUtils.MASTERDATA_FG, functionalGroup, true);
List<MasterData> fsData = masterDataService.findByMasterDataTypeAndMasterDataNameAndActiveStatus(MyTimeUtils.MASTERDATA_FG, functionalGroup, true);
flag = fsData.size() > MyTimeUtils.INT_ZERO;
}
return flag;
}
public static boolean isValidDesignation(String designation, MasterDataRepo masterDataRepo) {
public static boolean isValidDesignation(String designation) {
boolean flag = false;
designation = designation.trim();
if( !MyTimeUtils.EMPTY_STRING.equals(designation)) {
List<MasterData> designationData = masterDataRepo.findByMasterDataTypeAndMasterDataNameAndActiveStatus(MyTimeUtils.MASTERDATA_DESIGNATION, designation, true);
List<MasterData> designationData = masterDataService.findByMasterDataTypeAndMasterDataNameAndActiveStatus(MyTimeUtils.MASTERDATA_DESIGNATION, designation, true);
flag = designationData.size() > MyTimeUtils.INT_ZERO;
}
return flag;
}
public static boolean isValidEmploymentType(String employmentType, MasterDataRepo masterDataRepo) {
public static boolean isValidEmploymentType(String employmentType) {
boolean flag = false;
employmentType = employmentType.trim();
if(MyTimeUtils.EMPTY_STRING.equals(employmentType)){
flag = true;
}else if( !MyTimeUtils.EMPTY_STRING.equals(employmentType)) {
List<MasterData> empTypeData = masterDataRepo.findByMasterDataTypeAndMasterDataNameAndActiveStatus(MyTimeUtils.MASTERDATAD_EMLOYMENT_TYPE, employmentType, true);
List<MasterData> empTypeData = masterDataService.findByMasterDataTypeAndMasterDataNameAndActiveStatus(MyTimeUtils.MASTERDATAD_EMLOYMENT_TYPE, employmentType, true);
flag = empTypeData.size() > MyTimeUtils.INT_ZERO ;
}
return flag;
}
public static boolean isValidRole(String role,MasterDataRepo masterDataRepo) {
public static boolean isValidRole(String role) {
boolean flag = false;
role = role.trim();
if( MyTimeUtils.EMPTY_STRING.equals(role)){
flag = true;
}else if(!MyTimeUtils.EMPTY_STRING.equals(role)) {
List<MasterData> roleData = masterDataRepo.findByMasterDataTypeAndMasterDataNameAndActiveStatus(MyTimeUtils.MASTERDATA_ROLES, role, true);
List<MasterData> roleData = masterDataService.findByMasterDataTypeAndMasterDataNameAndActiveStatus(MyTimeUtils.MASTERDATA_ROLES, role, true);
flag = roleData.size() > MyTimeUtils.INT_ZERO;
}
return flag;
......@@ -144,11 +150,11 @@ public class DataValidations {
}
public static boolean isValidWorkLocation(String workLocation, LocationRepo locationRepo) {
public static boolean isValidWorkLocation(String workLocation) {
boolean flag = false;
workLocation = workLocation.trim();
if(!MyTimeUtils.EMPTY_STRING.equals(workLocation)) {
flag= locationRepo.findByLocationAndActiveStatus(workLocation, true). size() > MyTimeUtils.INT_ZERO ;
flag= orgLocationService.findByLocationAndActiveStatus(workLocation, true). size() > MyTimeUtils.INT_ZERO ;
}
return flag;
}
......
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