コード例 #1
0
 @Override
 public EmployeeDTO getEmployeeDtoByEmail(String email) {
   Optional<Employee> employee = employeeRepository.findOneByEmail(email);
   if (employee.isPresent()) {
     return mapEmployeeToEmployeeDtoObject(employee.get());
   } else {
     throw new IllegalArgumentException(
         "there is no employee found with email ' " + email + " '.");
   }
 }
コード例 #2
0
 public void updateEmployee(EmployeeDTO employeeDTO) {
   Employee employee = employeeRepository.findOneByEmail(employeeDTO.getEmail()).get();
   if (checkIfValidEntity(employee)) {
     employee.setFunctionalLevel(employeeDTO.getFunctionalLevel());
     employee.setActive(employeeDTO.getActive());
     if (employeeDTO.getActive() == false && employee.getCurrentCar() != null) {
       moveCurrentCarToCarHistory(employee);
     }
     employeeRepository.save(employee);
   }
 }
コード例 #3
0
  @Override
  public CarDTO assignPoolCarToEmployee(EmployeeDTO employeeDTO, CarDTO carDTO) {
    Employee employee = employeeRepository.findOneByEmail(employeeDTO.getEmail()).get();

    updatePoolCar(carRepository.findOne(carDTO.getId()));
    Car currentCar = employee.getCurrentCar();

    if (currentCar != null) {
      Set<Car> carHistory = employee.getCarHistory();
      currentCar.setEndLeasing(LocalDate.now());
      carHistory.add(currentCar);
    }
    employee.setCurrentCar(carRepository.findOne(carDTO.getId()));
    employee.setReceivedMailForNewCar(false);
    employeeRepository.save(employee);
    return carDTO;
  }
コード例 #4
0
 @Override
 public Optional<Employee> getOptionalEmployeeByEmail(String email) {
   return employeeRepository.findOneByEmail(email);
 }