/** * Removes the {@link Location} from the local database after it was removed on the server * * @param request {@link Request} performed * @param response {@link Response} received */ private void removeLocationPerformed(Request<Location> request, Response<Void> response) { boolean success = locHome.remove(request.getData()); if (!success) { Log.i(TAG, "removal of location " + request.getData() + " failed"); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") public void onRequestPerformed(Request<?> request, Response<?> response, RemoteEntityHome rHome) { switch (request.getAction()) { case getLocation: getLocationPerformed((Request<Measurement>) request, (Response<Location>) response); break; case getLocationList: getLocationListPerformed((Request<Void>) request, (Response<List<Location>>) response); break; case removeLocation: removeLocationPerformed((Request<Location>) request, (Response<Void>) response); break; case updateLocation: updateLocationPerformed((Request<Location>) request, (Response<Void>) response); break; default: throw new IllegalArgumentException( getClass().getName() + " can't handle action " + request.getAction()); } }
/** * Updates the local database after the location was updated on the server * * @param request {@link Request} performed * @param response {@link Response} received */ private void updateLocationPerformed(Request<Location> request, Response<Void> response) { Location l = request.getData(); if (l == null) { return; } Location dbLoc = locHome.get(l); if (!l.equals(dbLoc)) { boolean success = locHome.update(l); if (!success) { Log.i(TAG, "update of location " + l + " failed"); } } }