use of io.jawg.osmcontributor.model.events.PoisToUpdateLoadedEvent in project osm-contributor by jawg.
the class PoiManager method onPleaseLoadPoisToUpdateEvent.
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseLoadPoisToUpdateEvent(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) {
Long oldPoiId = p.getOldPoiId();
if (oldPoiId != null) {
allPois.add(new PoiUpdateWrapper(true, p, poiDao.queryForId(oldPoiId), 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));
}
Aggregations