/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1410 by torben, Mon May 2 12:02:54 2011 UTC revision 1411 by torben, Mon May 2 12:19:12 2011 UTC
# Line 12  import org.jsoup.nodes.Document; Line 12  import org.jsoup.nodes.Document;
12  import org.jsoup.nodes.Element;  import org.jsoup.nodes.Element;
13  import org.jsoup.select.Elements;  import org.jsoup.select.Elements;
14    
15    import dk.thoerup.android.traininfo.common.StationBean;
16    import dk.thoerup.android.traininfo.common.StationEntry;
17  import dk.thoerup.android.traininfo.common.TimetableBean;  import dk.thoerup.android.traininfo.common.TimetableBean;
18  import dk.thoerup.android.traininfo.common.TimetableEntry;  import dk.thoerup.android.traininfo.common.TimetableEntry;
19  import dk.thoerup.circuitbreaker.CircuitBreaker;  import dk.thoerup.circuitbreaker.CircuitBreaker;
# Line 25  public class TimetableFetcher { Line 27  public class TimetableFetcher {
27    
28                                    
29          Map<String, TimetableBean> cache;          Map<String, TimetableBean> cache;
30          Map<String, Integer> stationCache;          Map<String, StationEntry> stationCache;
31    
32          StationDAO stationDao = new StationDAO();          StationDAO stationDao = new StationDAO();
33                    
# Line 38  public class TimetableFetcher { Line 40  public class TimetableFetcher {
40                  this.settings = settings;                  this.settings = settings;
41                                    
42                  cache = new TimeoutMap<String,TimetableBean>( settings.getCacheTimeout() );                  cache = new TimeoutMap<String,TimetableBean>( settings.getCacheTimeout() );
43                  stationCache = new TimeoutMap<String,Integer>( 3*60*60*1000 );                  stationCache = new TimeoutMap<String,StationEntry>( 3*60*60*1000 );
44          }          }
45                    
46                    
# Line 65  public class TimetableFetcher { Line 67  public class TimetableFetcher {
67                  }                  }
68          }          }
69                    
70          int getStationId(String name) {          StationEntry getStationId(String name) {
71                  Integer id = stationCache.get(name);                  StationEntry station = stationCache.get(name);
72                                    
73                  if (id == null) {                  if (station == null) {
74                          try {                          try {
75                                  id = stationDao.getIdByName(name);                                  StationBean bean = stationDao.getByName(name);
76                                  stationCache.put(name, id);                                  if (bean.entries.size() == 1) {
77                                            station = bean.entries.get(0);
78                                            stationCache.put(name,station);
79                                    }
80                          } catch (SQLException e) {                          } catch (SQLException e) {
81                                  logger.log(Level.SEVERE, "getStationId failed", e);                                  logger.log(Level.SEVERE, "getStationId failed", e);
                                 id = -1;  
82                          }                          }
83                  }                  }
84    
85                  return id;                  return station;
86          }          }
87                    
88          String correctStationName(String name) {          String correctStationName(String name) {

Legend:
Removed from v.1410  
changed lines
  Added in v.1411

  ViewVC Help
Powered by ViewVC 1.1.20