@Override public WorkPlace getWorkPlaceDetails(long id) { Hairdressers hairdressers = hairdressersDAO.findOne(id); List<Employee> employees = hairdressers.getEmployees(); WorkPlace place = new WorkPlace(hairdressers); float placeAvgRate = CommonUtils.calcPlaceAvgRate(employees); place.setRate(placeAvgRate); return place; }
@Override public List<WorkPlace> getAllWorkPlaceWithAvailableVacancy() { List<Hairdressers> hairdressersDB = hairdressersDAO.getAllWithAvailableVacancy(); List<WorkPlace> allPlaces = Lists.newArrayListWithCapacity(hairdressersDB.size()); for (Hairdressers hairdressers : hairdressersDB) { allPlaces.add(new WorkPlace(hairdressers.getId(), hairdressers.getName())); } return allPlaces; }
@Override public List<EmployeeTO> getAllEmployees(long placeID) { Hairdressers hairdressers = hairdressersDAO.load(placeID); List<Employee> employeesDB = hairdressers.getEmployees(); List<EmployeeTO> employees = Lists.newArrayListWithCapacity(employeesDB.size()); for (Employee employee : employeesDB) { employees.add(new EmployeeTO(employee)); } return employees; }
private void validNumberOfEmployees(WorkPlace workPlace, Hairdressers hairdressersDB) throws IllegalNumberOfMaxEmployyesException { int newMaxEmployees = workPlace.getMaxEmployees(); int currentEmployees = hairdressersDB.getCurrentEmployees(); if (newMaxEmployees < currentEmployees) { throw new IllegalNumberOfMaxEmployyesException(); } }
private void applyChanges(Hairdressers hairdressersDB, WorkPlace workPlace) { hairdressersDB.getAddress().setBuildingNumber(workPlace.getBuildingNumber()); hairdressersDB.getAddress().setCity(workPlace.getCity()); hairdressersDB.getAddress().setDoorNumber(workPlace.getDoorNumber()); hairdressersDB.getAddress().setPostCode(workPlace.getPostCode()); hairdressersDB.getAddress().setStreet(workPlace.getStreet()); hairdressersDB.setMaxEmployees(workPlace.getMaxEmployees()); hairdressersDB.setName(workPlace.getName()); hairdressersDB.setOpenFrom(workPlace.getOpenFrom()); hairdressersDB.setOpenTo(workPlace.getOpenTo()); }