--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java 2010/09/08 12:38:26 1035 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java 2010/09/08 12:49:22 1036 @@ -30,11 +30,11 @@ Logger logger = Logger.getLogger(TimetableFetcher.class.getName()); - private boolean useTempSite; + private boolean useAzureSite; private int replyTimeout; - public TimetableFetcher(boolean tmpSite, int cacheTimeout, int replyTimeout) { - useTempSite = tmpSite; + public TimetableFetcher(boolean azureSite, int cacheTimeout, int replyTimeout) { + useAzureSite = azureSite; this.replyTimeout = replyTimeout; cache = new TimeoutMap>(cacheTimeout); @@ -57,10 +57,11 @@ } List lookupTimetable(String trainID, String type) throws Exception { - if (useTempSite == false ){ - return lookupTimetableRealSite(trainID, type); + if (useAzureSite == true ){ + return lookupTimetableAzureSite(trainID, type); + } else { - return new ArrayList(); // no timetable data on temp site + return lookupTimetableWwwSite(trainID, type); } } @@ -80,7 +81,7 @@ return id; } - List lookupTimetableRealSite(String trainID, String type) throws Exception { + List lookupTimetableAzureSite(String trainID, String type) throws Exception { List timetableList = new ArrayList(); //String url = "http://www.bane.dk/visRute.asp?W=" + type + "&TogNr=" + trainID + "&artikelId=4276"; @@ -169,5 +170,70 @@ return timetableList; } + + List lookupTimetableWwwSite(String trainID, String type) throws Exception { + List timetableList = new ArrayList(); + + String url = "http://www.bane.dk/visRute.asp?W=" + type + "&TogNr=" + trainID + "&artikelId=4276"; + + + + JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , replyTimeout); + CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); + + Document doc = (Document) breaker.invoke(wrapper); + + + boolean currentStation = false; + boolean currentStationSaved = false; + + Elements tables = doc.getElementsByClass("Rute"); + + if (tables.size() == 1) { + Element timetable = tables.get(0); + Elements rows = timetable.getElementsByTag("tr"); + + for (int i=0; i