/**
  * Requests the latest (the closest before the "now") entry from the carparkload table for given
  * carpark id
  *
  * <p>Request example: GET http://localhost:8080/carparks/latestEntry/1
  *
  * @return
  */
 @RequestMapping(value = "/latestEntry/{idString}", method = RequestMethod.GET)
 public CarParkLoad getLatestEntry(@PathVariable final String idString) {
   LOGGER.infof("Entering getLatestEntry(%s)", idString);
   // TODO: add error handling when car park not found
   CarParkLoad latestEntry =
       carParkLoadRep.getLatestEntry(Long.valueOf(idString), createPageRequest(0, 1)).get(0);
   if (LOGGER.isTraceEnabled()) {
     LOGGER.tracef("Leaving getLatestEntry(): %s", latestEntry);
   } else {
     LOGGER.info("Leaving getLatestEntry()");
   }
   return latestEntry;
 }
 /**
  * Requests the latest (the closest before the "now") entries for all carparks from the
  * carparkload table
  *
  * <p>Request example: GET http://localhost:8080/carparks/latestEntries
  *
  * @return
  */
 @RequestMapping(value = "/latestEntries", method = RequestMethod.GET)
 public List<CarParkLoad> getLatestEntries() {
   LOGGER.infof("Entering getLatestEntries()");
   List<CarParkLoad> latestEntries = new LinkedList<CarParkLoad>();
   Iterable<CarPark> carParks = carParkRep.findAll();
   for (CarPark carPark : carParks) {
     final CarParkLoad carParkLoad =
         carParkLoadRep.getLatestEntry(carPark.getCarParkid(), createPageRequest(0, 1)).get(0);
     if (carParkLoad.getTimestamp().getTime() > System.currentTimeMillis() - MILIS_IN_DAY) {
       latestEntries.add(carParkLoad);
     }
   }
   if (LOGGER.isTraceEnabled()) {
     LOGGER.tracef("Leaving getLatestEntries(): %s", latestEntries);
   } else {
     LOGGER.info("Leaving getLatestEntries()");
   }
   return latestEntries;
 }