11 |
import org.jsoup.nodes.Element; |
import org.jsoup.nodes.Element; |
12 |
import org.jsoup.select.Elements; |
import org.jsoup.select.Elements; |
13 |
|
|
14 |
|
import dk.thoerup.android.traininfo.common.DepartureBean; |
15 |
|
import dk.thoerup.android.traininfo.common.DepartureEntry; |
16 |
|
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
17 |
import dk.thoerup.circuitbreaker.CircuitBreaker; |
import dk.thoerup.circuitbreaker.CircuitBreaker; |
18 |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
|
import dk.thoerup.traininfoservice.StationBean; |
|
19 |
import dk.thoerup.traininfoservice.StationDAO; |
import dk.thoerup.traininfoservice.StationDAO; |
20 |
import dk.thoerup.traininfoservice.Statistics; |
import dk.thoerup.traininfoservice.Statistics; |
21 |
|
|
65 |
|
|
66 |
DepartureBean departureBean = new DepartureBean(); |
DepartureBean departureBean = new DepartureBean(); |
67 |
|
|
68 |
StationBean station = stationDao.getById(stationID); |
StationEntry station = stationDao.getById(stationID); |
69 |
|
|
70 |
departureBean.stationName = station.getName(); |
departureBean.stationName = station.getName(); |
71 |
|
|
133 |
|
|
134 |
String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning"; |
String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning"; |
135 |
|
|
136 |
//logger.info("URI: " + uri); |
logger.fine("URI: " + uri); |
137 |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); |
138 |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
139 |
|
|
237 |
|
|
238 |
|
|
239 |
String uri = "http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode; |
String uri = "http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode; |
240 |
logger.info("URI:" + uri); |
logger.fine("URI:" + uri); |
241 |
|
|
242 |
|
|
243 |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); |
244 |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
245 |
|
|
248 |
String tableName = arrival == false ? "afgangtabel" : "ankomsttabel"; |
String tableName = arrival == false ? "afgangtabel" : "ankomsttabel"; |
249 |
Element table = page.getElementById(tableName); |
Element table = page.getElementById(tableName); |
250 |
|
|
251 |
|
|
252 |
|
|
253 |
if (table != null) { |
if (table != null) { |
254 |
Elements tableRows = table.getElementsByTag("tr"); |
Elements tableRows = table.getElementsByTag("tr"); |
255 |
|
|
256 |
|
boolean passedTidsstreg = false; |
257 |
|
boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); |
258 |
|
|
259 |
for (Element currentRow : tableRows) { |
for (Element currentRow : tableRows) { |
260 |
String rowClass = currentRow.attr("class"); |
String rowClass = currentRow.attr("class"); |
261 |
|
|
262 |
|
if (tidsstregExists == true && passedTidsstreg == false) { |
263 |
|
if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) { |
264 |
|
passedTidsstreg = true; |
265 |
|
} else { |
266 |
|
continue; |
267 |
|
} |
268 |
|
} |
269 |
|
|
270 |
|
|
271 |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
272 |
Elements fields = currentRow.getElementsByTag("td"); |
Elements fields = currentRow.getElementsByTag("td"); |
273 |
|
|