2 |
|
|
3 |
|
|
4 |
import java.net.URL; |
import java.net.URL; |
5 |
|
import java.net.URLEncoder; |
6 |
import java.util.Collections; |
import java.util.Collections; |
7 |
import java.util.Map; |
import java.util.Map; |
8 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
63 |
|
|
64 |
StationBean station = stationDao.getById(stationID); |
StationBean station = stationDao.getById(stationID); |
65 |
|
|
66 |
|
departureBean.stationName = station.getName(); |
67 |
|
|
68 |
if (station.getRegional() != null) { |
if (station.getRegional() != null) { |
69 |
DepartureBean tempBean = lookupDepartures(station.getRegional(), TrainType.REGIONAL, arrival); |
DepartureBean tempBean = lookupDepartures(station.getRegional(), TrainType.REGIONAL, arrival); |
70 |
departureBean.departureEntries.addAll( tempBean.departureEntries ); |
departureBean.departureEntries.addAll( tempBean.departureEntries ); |
111 |
|
|
112 |
String typeString = getTypeString(type); |
String typeString = getTypeString(type); |
113 |
String arrivalDeparture = (arrival==false) ? "Afgang" : "Ankomst"; |
String arrivalDeparture = (arrival==false) ? "Afgang" : "Ankomst"; |
114 |
|
|
115 |
|
stationcode = URLEncoder.encode(stationcode,"ISO-8859-1"); |
116 |
//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; |
117 |
String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning"; |
String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning"; |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
//logger.info("URI: " + uri); |
//logger.info("URI: " + uri); |
122 |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), 2500); |
JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), 2500); |
123 |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); |
130 |
if (table != null) { |
if (table != null) { |
131 |
Elements tableRows = table.getElementsByTag("tr"); |
Elements tableRows = table.getElementsByTag("tr"); |
132 |
|
|
133 |
|
boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); |
134 |
|
boolean passedTidsstreg = false; |
135 |
|
|
136 |
for (Element currentRow : tableRows) { |
for (Element currentRow : tableRows) { |
137 |
String rowClass = currentRow.attr("class"); |
String rowClass = currentRow.attr("class"); |
138 |
|
|
139 |
|
if (tidsstregExists == true && passedTidsstreg == false) { |
140 |
|
if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) { |
141 |
|
passedTidsstreg = true; |
142 |
|
} else { |
143 |
|
continue; |
144 |
|
} |
145 |
|
} |
146 |
|
|
147 |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
148 |
|
|
149 |
Elements fields = currentRow.getElementsByTag("td"); |
Elements fields = currentRow.getElementsByTag("td"); |
150 |
|
|
151 |
DepartureEntry departure = new DepartureEntry(); |
DepartureEntry departure = new DepartureEntry(); |