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 |
|
|
72 |
if (station.getRegional() != null) { |
if (station.getRegional() != null) { |
73 |
DepartureBean tempBean = lookupDepartures(station.getRegional(), TrainType.REGIONAL, arrival); |
DepartureBean tempBean = lookupDepartures(station.getRegional(), TrainType.REGIONAL, arrival); |
74 |
departureBean.departureEntries.addAll( tempBean.departureEntries ); |
departureBean.entries.addAll( tempBean.entries ); |
75 |
departureBean.notifications.addAll(tempBean.notifications); |
departureBean.notifications.addAll(tempBean.notifications); |
76 |
} |
} |
77 |
|
|
78 |
if (station.getStrain() != null) { |
if (station.getStrain() != null) { |
79 |
DepartureBean tempBean = lookupDepartures(station.getStrain(), TrainType.STOG, arrival); |
DepartureBean tempBean = lookupDepartures(station.getStrain(), TrainType.STOG, arrival); |
80 |
departureBean.departureEntries.addAll( tempBean.departureEntries ); |
departureBean.entries.addAll( tempBean.entries ); |
81 |
departureBean.notifications.addAll(tempBean.notifications); |
departureBean.notifications.addAll(tempBean.notifications); |
82 |
} |
} |
83 |
|
|
84 |
if (departureBean.departureEntries.size() == 0) { |
if (departureBean.entries.size() == 0) { |
85 |
logger.info("No departures found for station " + stationID); |
logger.info("No departures found for station " + stationID); |
86 |
} |
} |
87 |
|
|
88 |
Collections.sort( departureBean.departureEntries ); |
Collections.sort( departureBean.entries ); |
89 |
|
|
90 |
|
|
91 |
return departureBean; |
return departureBean; |
145 |
if (table != null) { |
if (table != null) { |
146 |
Elements tableRows = table.getElementsByTag("tr"); |
Elements tableRows = table.getElementsByTag("tr"); |
147 |
|
|
148 |
boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); |
//boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); |
149 |
boolean passedTidsstreg = false; |
//boolean passedTidsstreg = false; |
150 |
|
|
151 |
for (Element currentRow : tableRows) { |
for (Element currentRow : tableRows) { |
152 |
String rowClass = currentRow.attr("class"); |
String rowClass = currentRow.attr("class"); |
153 |
|
/* |
154 |
if (tidsstregExists == true && passedTidsstreg == false) { |
if (tidsstregExists == true && passedTidsstreg == false) { |
155 |
if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) { |
if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) { |
156 |
passedTidsstreg = true; |
passedTidsstreg = true; |
157 |
} else { |
} else { |
158 |
continue; |
continue; |
159 |
} |
} |
160 |
} |
}*/ |
161 |
|
|
162 |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
163 |
|
|
195 |
|
|
196 |
departure.setType(typeString); |
departure.setType(typeString); |
197 |
|
|
198 |
departureBean.departureEntries.add( departure ); |
departureBean.entries.add( departure ); |
199 |
} |
} |
200 |
} |
} |
201 |
} else { |
} else { |
253 |
if (table != null) { |
if (table != null) { |
254 |
Elements tableRows = table.getElementsByTag("tr"); |
Elements tableRows = table.getElementsByTag("tr"); |
255 |
|
|
256 |
boolean passedTidsstreg = false; |
//boolean passedTidsstreg = false; |
257 |
boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); |
//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) { |
if (tidsstregExists == true && passedTidsstreg == false) { |
263 |
if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) { |
if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) { |
264 |
passedTidsstreg = true; |
passedTidsstreg = true; |
265 |
} else { |
} else { |
266 |
continue; |
continue; |
267 |
} |
} |
268 |
} |
}*/ |
269 |
|
|
270 |
|
|
271 |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
305 |
|
|
306 |
departure.setType(type); |
departure.setType(type); |
307 |
|
|
308 |
departureBean.departureEntries.add(departure); |
departureBean.entries.add(departure); |
309 |
|
|
310 |
|
|
311 |
} |
} |