public void incrementOrStoreLocation(Double latitude,
Double longitude) {
PersistenceManager pm = getPersistenceManager();
String key = latitude + ";" + longitude;
Location location = null;
try {
location = pm.getObjectById(Location.class, key);
if (location != null) {
location.setOccurrences(location.getOccurrences() + 1);
pm.makePersistent(location);
}
} catch (JDOObjectNotFoundException e) {
location = new Location(key, latitude, longitude);
pm.makePersistent(location);
} finally {
pm.close();
}
}