Ejemplo n.º 1
0
  @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;
  }
Ejemplo n.º 2
0
  @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);
      }
    }
  }