13 |
|
|
14 |
import dk.thoerup.circuitbreaker.CircuitBreaker; |
import dk.thoerup.circuitbreaker.CircuitBreaker; |
15 |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
|
import dk.thoerup.traininfoservice.StationBean; |
|
16 |
import dk.thoerup.traininfoservice.StationDAO; |
import dk.thoerup.traininfoservice.StationDAO; |
17 |
import dk.thoerup.traininfoservice.Statistics; |
import dk.thoerup.traininfoservice.Statistics; |
18 |
|
import dk.thoerup.traininfoservice.StationBean.StationEntry; |
19 |
|
|
20 |
public class DepartureFetcher { |
public class DepartureFetcher { |
21 |
|
|
63 |
|
|
64 |
DepartureBean departureBean = new DepartureBean(); |
DepartureBean departureBean = new DepartureBean(); |
65 |
|
|
66 |
StationBean station = stationDao.getById(stationID); |
StationEntry station = stationDao.getById(stationID); |
67 |
|
|
68 |
departureBean.stationName = station.getName(); |
departureBean.stationName = station.getName(); |
69 |
|
|
131 |
|
|
132 |
String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning"; |
String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning"; |
133 |
|
|
134 |
//logger.info("URI: " + uri); |
logger.fine("URI: " + uri); |
135 |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); |
136 |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
137 |
|
|
235 |
|
|
236 |
|
|
237 |
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; |
238 |
logger.info("URI:" + uri); |
logger.fine("URI:" + uri); |
239 |
|
|
240 |
|
|
241 |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); |
242 |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
243 |
|
|
246 |
String tableName = arrival == false ? "afgangtabel" : "ankomsttabel"; |
String tableName = arrival == false ? "afgangtabel" : "ankomsttabel"; |
247 |
Element table = page.getElementById(tableName); |
Element table = page.getElementById(tableName); |
248 |
|
|
249 |
|
|
250 |
|
|
251 |
if (table != null) { |
if (table != null) { |
252 |
Elements tableRows = table.getElementsByTag("tr"); |
Elements tableRows = table.getElementsByTag("tr"); |
253 |
|
|
254 |
|
boolean passedTidsstreg = false; |
255 |
|
boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); |
256 |
|
|
257 |
for (Element currentRow : tableRows) { |
for (Element currentRow : tableRows) { |
258 |
String rowClass = currentRow.attr("class"); |
String rowClass = currentRow.attr("class"); |
259 |
|
|
260 |
|
if (tidsstregExists == true && passedTidsstreg == false) { |
261 |
|
if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) { |
262 |
|
passedTidsstreg = true; |
263 |
|
} else { |
264 |
|
continue; |
265 |
|
} |
266 |
|
} |
267 |
|
|
268 |
|
|
269 |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
270 |
Elements fields = currentRow.getElementsByTag("td"); |
Elements fields = currentRow.getElementsByTag("td"); |
271 |
|
|