--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/07/14 19:22:23 994 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/09/02 18:37:49 1026 @@ -31,8 +31,10 @@ StationDAO stationDao = new StationDAO(); private boolean useTempSite; + private int replyTimeout; - public DepartureFetcher(boolean tempSite, int cacheTimeout) { + public DepartureFetcher(boolean tempSite, int cacheTimeout, int replyTimeout) { + this.replyTimeout = replyTimeout; useTempSite = tempSite; cache = new TimeoutMap(cacheTimeout); } @@ -63,6 +65,8 @@ StationBean station = stationDao.getById(stationID); + departureBean.stationName = station.getName(); + if (station.getRegional() != null) { DepartureBean tempBean = lookupDepartures(station.getRegional(), TrainType.REGIONAL, arrival); departureBean.departureEntries.addAll( tempBean.departureEntries ); @@ -117,7 +121,7 @@ //logger.info("URI: " + uri); - JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), 2500); + JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); Document page = (Document) breaker.invoke(wrapper); @@ -128,9 +132,22 @@ if (table != null) { Elements tableRows = table.getElementsByTag("tr"); + boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); + boolean passedTidsstreg = false; + for (Element currentRow : tableRows) { String rowClass = currentRow.attr("class"); + + if (tidsstregExists == true && passedTidsstreg == false) { + if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) { + passedTidsstreg = true; + } else { + continue; + } + } + if (rowClass != null && rowClass.toLowerCase().contains("station") ) { + Elements fields = currentRow.getElementsByTag("td"); DepartureEntry departure = new DepartureEntry();