@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;
  }
 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());
 }
 private void validNumberOfEmployees(WorkPlace workPlace, Hairdressers hairdressersDB)
     throws IllegalNumberOfMaxEmployyesException {
   int newMaxEmployees = workPlace.getMaxEmployees();
   int currentEmployees = hairdressersDB.getCurrentEmployees();
   if (newMaxEmployees < currentEmployees) {
     throw new IllegalNumberOfMaxEmployyesException();
   }
 }
  @Override
  public void saveChanges(WorkPlace workPlaceOld, WorkPlace workPlace) throws PlaceException {
    if (CommonUtils.needSaveChangesToDB(workPlaceOld, workPlace)) {
      long placeID = workPlaceOld.getId();
      Hairdressers hairdressersDB = hairdressersDAO.load(placeID);

      try {
        Object synchoObj = SynchronizationProvider.getSynchoObj(Hairdressers.class, placeID);

        synchronized (synchoObj) {
          validChanges(workPlace, hairdressersDB);
          applyChanges(hairdressersDB, workPlace);
          hairdressersDAO.update(hairdressersDB);
        }
      } finally {
        SynchronizationProvider.relaseSynchoObj(Hairdressers.class, placeID);
      }
    }
  }