--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/09/14 05:20:17 1045 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/09/16 13:32:10 1060 @@ -13,9 +13,9 @@ import dk.thoerup.circuitbreaker.CircuitBreaker; import dk.thoerup.circuitbreaker.CircuitBreakerManager; -import dk.thoerup.traininfoservice.StationBean; import dk.thoerup.traininfoservice.StationDAO; import dk.thoerup.traininfoservice.Statistics; +import dk.thoerup.traininfoservice.StationBean.StationEntry; public class DepartureFetcher { @@ -63,7 +63,7 @@ DepartureBean departureBean = new DepartureBean(); - StationBean station = stationDao.getById(stationID); + StationEntry station = stationDao.getById(stationID); departureBean.stationName = station.getName(); @@ -131,7 +131,7 @@ String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning"; - //logger.info("URI: " + uri); + logger.fine("URI: " + uri); JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); @@ -235,7 +235,9 @@ String uri = "http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode; - logger.info("URI:" + uri); + logger.fine("URI:" + uri); + + JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); @@ -244,11 +246,26 @@ String tableName = arrival == false ? "afgangtabel" : "ankomsttabel"; Element table = page.getElementById(tableName); + + if (table != null) { Elements tableRows = table.getElementsByTag("tr"); + boolean passedTidsstreg = false; + boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); + 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");