/** * Method saving a poi and all the associated foreign collections without transaction management. * * <p>Do not call the DAO directly to save a poi, use this method. * * @param poi The poi to save * @return The saved poi * @see #savePoi(Poi) */ private Poi savePoiNoTransaction(Poi poi) { List<PoiTag> poiTagsToRemove = poiTagDao.queryByPoiId(poi.getId()); poiTagsToRemove.removeAll(poi.getTags()); for (PoiTag poiTag : poiTagsToRemove) { poiTagDao.delete(poiTag); } List<PoiNodeRef> poiNodeRefsToRemove = poiNodeRefDao.queryByPoiId(poi.getId()); poiNodeRefsToRemove.removeAll(poi.getNodeRefs()); for (PoiNodeRef poiNodeRef : poiNodeRefsToRemove) { poiNodeRefDao.delete(poiNodeRef); } poiDao.createOrUpdate(poi); if (poi.getTags() != null) { for (PoiTag poiTag : poi.getTags()) { poiTag.setPoi(poi); poiTagDao.createOrUpdate(poiTag); } } if (poi.getNodeRefs() != null) { for (PoiNodeRef poiNodeRef : poi.getNodeRefs()) { poiNodeRef.setPoi(poi); poiNodeRefDao.createOrUpdate(poiNodeRef); } } return poi; }
/** * Get the backup data and put it back in the active NodeRefPoi * * @param poiNodeRefId The Id of the PoiNodeRef to revert. */ private void revertPoiNodeRef(Long poiNodeRefId) { PoiNodeRef poiNodeRef = poiNodeRefDao.queryForId(poiNodeRefId); PoiNodeRef backup; Long oldId = poiNodeRef.getOldPoiId(); if (oldId != null) { backup = poiNodeRefDao.queryForId(oldId); poiNodeRef.setLatitude(backup.getLatitude()); poiNodeRef.setLongitude(backup.getLongitude()); poiNodeRefDao.deleteById(oldId); } poiNodeRef.setUpdated(false); poiNodeRef.setOld(false); poiNodeRef.setOldPoiId(null); poiNodeRefDao.createOrUpdate(poiNodeRef); }