public void onEventAsync(PleaseLoadPoisToUpdateEvent event) {
    List<Poi> updatedPois = poiDao.queryForAllUpdated();
    List<Poi> newPois = poiDao.queryForAllNew();
    List<Poi> toDeletePois = poiDao.queryToDelete();
    List<PoiNodeRef> wayPoiNodeRef = poiNodeRefDao.queryAllToUpdate();
    List<PoiUpdateWrapper> allPois = new ArrayList<>();

    for (Poi p : updatedPois) {
      allPois.add(
          new PoiUpdateWrapper(
              true,
              p,
              poiDao.queryForId(p.getOldPoiId()),
              null,
              PoiUpdateWrapper.PoiAction.UPDATE));
    }
    for (Poi p : newPois) {
      allPois.add(new PoiUpdateWrapper(true, p, null, null, PoiUpdateWrapper.PoiAction.CREATE));
    }
    for (Poi p : toDeletePois) {
      allPois.add(
          new PoiUpdateWrapper(
              true,
              p,
              poiDao.queryForId(p.getOldPoiId()),
              null,
              PoiUpdateWrapper.PoiAction.DELETED));
    }
    for (PoiNodeRef p : wayPoiNodeRef) {
      allPois.add(new PoiUpdateWrapper(false, null, null, p, PoiUpdateWrapper.PoiAction.UPDATE));
    }

    bus.post(new PoisToUpdateLoadedEvent(allPois));
  }
 public void deleteOldPoiAssociated(Poi poi) {
   Long oldId = poi.getOldPoiId();
   if (oldId != null) {
     Poi old = poiDao.queryForId(oldId);
     if (old != null) {
       deletePoi(old);
     }
     poi.setOldPoiId(null);
   }
 }
  /**
   * Get the backup data and put it back in the active Poi, at the end the backup Poi is deleted.
   *
   * @param poiId The Id of the Poi to revert.
   */
  private void revertPoi(Long poiId) {
    Poi poi = poiDao.queryForId(poiId);
    Poi backup;
    Long oldPoiId = poi.getOldPoiId();

    if (oldPoiId != null) {
      backup = poiDao.queryForId(oldPoiId);

      // we retrieve the backup data and put it back
      backup.setOld(false);
      backup.setId(poi.getId());
      savePoi(backup);

      // we prepare to delete the modifications
      poi.setId(oldPoiId);
    }

    deletePoi(poi);
  }