@Override public GeoAddress find(GeoAddress geoAddress) { List<GeoAddress> executeMulti = Entity.query(GeoAddress.class).executeMulti(); for (GeoAddress ga : executeMulti) { if (ga.getLocation().equals(geoAddress.getLocation())) { Ln.d("GeoAddress:" + ga); return ga; } } return null; }
@Override public void saveGeoAddress(GeoAddress geoAddress) { GeoAddress geoaddressExistant = Entity.query(GeoAddress.class) .where(eql(GeoAddress.ADDRESS_COLUMN, geoAddress.getFormattedAddress())) .execute(); /*String state; if (geoaddressExistant!=null && geoaddressExistant.equals(geoAddress)) { state = "_same"; // Ln.d(placeExistant.getPlaceName()+": save_state="+state); // int oldId = placeExistant.getId(); // place.setId(oldId); // state = ""+place.save(); // do nothing } else { state = ""+geoAddress.save(); Ln.d(geoAddress.getFormattedAddress() +": save_state="+state); }*/ if (geoaddressExistant == null) { geoaddressExistant = geoAddress; Ln.d("inserted geoaddress: " + geoAddress); } else { // update Ln.d("updating geoaddress: " + geoaddressExistant); geoaddressExistant.setFormattedAddress(geoAddress.getFormattedAddress()); geoaddressExistant.setLocation(geoAddress.getLocation()); Ln.d("updated geoaddress: " + geoaddressExistant); } geoaddressExistant.save(); }