26 |
|
|
27 |
} |
} |
28 |
|
|
29 |
Map<String, List<TimetableBean>> cache = new TimeoutMap<String,List<TimetableBean>>(120 * 1000); |
Map<String, List<TimetableBean>> cache; |
30 |
|
|
31 |
|
|
32 |
Logger logger = Logger.getLogger(TimetableFetcher.class.getName()); |
Logger logger = Logger.getLogger(TimetableFetcher.class.getName()); |
33 |
|
|
34 |
|
private boolean useTempSite; |
35 |
|
|
36 |
|
public TimetableFetcher(boolean tmpSite, int cacheTimeout) { |
37 |
|
useTempSite = tmpSite; |
38 |
|
|
39 |
|
cache = new TimeoutMap<String,List<TimetableBean>>(cacheTimeout); |
40 |
|
} |
41 |
|
|
42 |
|
|
43 |
List<TimetableBean> cachedLookupTimetable(String trainID, String type) throws Exception { |
List<TimetableBean> cachedLookupTimetable(String trainID, String type) throws Exception { |
44 |
String key = trainID+type; |
String key = trainID+type; |
52 |
} |
} |
53 |
return list; |
return list; |
54 |
} |
} |
55 |
|
|
56 |
|
List<TimetableBean> lookupTimetable(String trainID, String type) throws Exception { |
57 |
|
if (useTempSite == false ){ |
58 |
|
return lookupTimetableRealSite(trainID, type); |
59 |
|
} else { |
60 |
|
return new ArrayList<TimetableBean>(); // no timetable data on temp site |
61 |
|
} |
62 |
|
} |
63 |
|
|
64 |
List<TimetableBean> lookupTimetable(String trainID, String type) throws Exception { |
List<TimetableBean> lookupTimetableRealSite(String trainID, String type) throws Exception { |
65 |
List<TimetableBean> timetableList = new ArrayList<TimetableBean>(); |
List<TimetableBean> timetableList = new ArrayList<TimetableBean>(); |
66 |
|
|
67 |
String url = "http://www.bane.dk/visRute.asp?W=" + type + "&TogNr=" + trainID + "&artikelId=4276"; |
String url = "http://www.bane.dk/visRute.asp?W=" + type + "&TogNr=" + trainID + "&artikelId=4276"; |