--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java 2011/05/02 12:02:54 1410 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java 2011/05/02 12:19:12 1411 @@ -12,6 +12,8 @@ import org.jsoup.nodes.Element; import org.jsoup.select.Elements; +import dk.thoerup.android.traininfo.common.StationBean; +import dk.thoerup.android.traininfo.common.StationEntry; import dk.thoerup.android.traininfo.common.TimetableBean; import dk.thoerup.android.traininfo.common.TimetableEntry; import dk.thoerup.circuitbreaker.CircuitBreaker; @@ -25,7 +27,7 @@ Map cache; - Map stationCache; + Map stationCache; StationDAO stationDao = new StationDAO(); @@ -38,7 +40,7 @@ this.settings = settings; cache = new TimeoutMap( settings.getCacheTimeout() ); - stationCache = new TimeoutMap( 3*60*60*1000 ); + stationCache = new TimeoutMap( 3*60*60*1000 ); } @@ -65,20 +67,22 @@ } } - int getStationId(String name) { - Integer id = stationCache.get(name); + StationEntry getStationId(String name) { + StationEntry station = stationCache.get(name); - if (id == null) { + if (station == null) { try { - id = stationDao.getIdByName(name); - stationCache.put(name, id); + StationBean bean = stationDao.getByName(name); + if (bean.entries.size() == 1) { + station = bean.entries.get(0); + stationCache.put(name,station); + } } catch (SQLException e) { logger.log(Level.SEVERE, "getStationId failed", e); - id = -1; } } - return id; + return station; } String correctStationName(String name) {