Exemplo n.º 1
0
 private void populateEmployeeForm(EmployeeForm employeeForm, Employee employee) {
   employeeForm.setId(employee.getId());
   employeeForm.setName(employee.getName());
   employeeForm.setSurname(employee.getSurname());
   employeeForm.setPhoneNumber(employee.getPhoneNumber());
   employeeForm.setDateOfBirth(employee.getDateOfBirth());
   employeeForm.setPosition(employee.getPosition());
   employeeForm.setSalary(employee.getSalary());
 }
Exemplo n.º 2
0
  private EmployeeForm convertEmployeeToEmployeeForm(Employee employee) {

    EmployeeForm employeeForm = new EmployeeForm();

    if (employee.getPosition() == Position.Cook) {
      Cook cook = (Cook) employee;
      List<String> cookedDishesIdList = new ArrayList<>();
      List<CookedDishes> cookedDishes = cook.getCookedDishes();

      cookedDishes.forEach(dish -> cookedDishesIdList.add(dish.getId().toString()));
      String cookedDishesString = convertListToDelimitedString(cookedDishesIdList);
      employeeForm.setCookedDishes(cookedDishesString);
      populateEmployeeForm(employeeForm, cook);

      if ("".equals(employeeForm.getCookedDishes())) {
        employeeForm.setCookedDishes("No cooked dishes");
      }

      return employeeForm;

    } else if (employee.getPosition() == Position.Waiter) {
      Waiter waiter = (Waiter) employee;
      List<String> ordersIdList = new ArrayList<>();
      List<Orders> orders = waiter.getOrders();

      orders.forEach(order -> ordersIdList.add(order.getId().toString()));
      String ordersString = convertListToDelimitedString(ordersIdList);

      employeeForm.setOrders(ordersString);
      populateEmployeeForm(employeeForm, waiter);

      if ("".equals(employeeForm.getOrders())) {
        employeeForm.setOrders("No orders");
      }

      return employeeForm;

    } else {
      populateEmployeeForm(employeeForm, employee);

      return employeeForm;
    }
  }