6 |
import java.util.Map; |
import java.util.Map; |
7 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
8 |
|
|
9 |
|
import com.gargoylesoftware.htmlunit.BrowserVersion; |
10 |
import com.gargoylesoftware.htmlunit.WebClient; |
import com.gargoylesoftware.htmlunit.WebClient; |
11 |
import com.gargoylesoftware.htmlunit.html.DomNodeList; |
import com.gargoylesoftware.htmlunit.html.DomNodeList; |
12 |
import com.gargoylesoftware.htmlunit.html.HtmlElement; |
import com.gargoylesoftware.htmlunit.html.HtmlElement; |
16 |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
17 |
import dk.thoerup.traininfoservice.StationBean; |
import dk.thoerup.traininfoservice.StationBean; |
18 |
import dk.thoerup.traininfoservice.StationDAO; |
import dk.thoerup.traininfoservice.StationDAO; |
19 |
|
import dk.thoerup.traininfoservice.Statistics; |
20 |
|
|
21 |
public class DepartureFetcher { |
public class DepartureFetcher { |
22 |
|
|
44 |
list = lookupDepartures(stationID); |
list = lookupDepartures(stationID); |
45 |
cache.put(stationID, list); |
cache.put(stationID, list); |
46 |
} else { |
} else { |
47 |
|
Statistics.getInstance().incrementDepartureCacheHits(); |
48 |
logger.info("Departure: Cache hit " + stationID); //remove before production |
logger.info("Departure: Cache hit " + stationID); //remove before production |
49 |
} |
} |
50 |
return list; |
return list; |
84 |
|
|
85 |
List<DepartureBean> departureList = new ArrayList<DepartureBean>(); |
List<DepartureBean> departureList = new ArrayList<DepartureBean>(); |
86 |
|
|
87 |
final WebClient webClient = new WebClient(); |
final WebClient webClient = new WebClient( BrowserVersion.FIREFOX_3 ); |
88 |
webClient.setTimeout(2500); |
webClient.setTimeout(2500); |
89 |
webClient.setJavaScriptEnabled(false); |
webClient.setJavaScriptEnabled(false); |
90 |
|
|
134 |
String note = extractNote( fields.get(7) ); |
String note = extractNote( fields.get(7) ); |
135 |
departure.setNote(note); |
departure.setNote(note); |
136 |
|
|
137 |
|
departure.setType(type); |
138 |
|
|
139 |
departureList.add(departure); |
departureList.add(departure); |
140 |
} |
} |
141 |
} |
} |
142 |
} else { |
} else { |
143 |
logger.warning("No departures found for station=" + stationcode + ", type=" + type); |
logger.warning("No departures found for station=" + stationcode + ", type=" + type); |
144 |
} |
} |
145 |
|
webClient.closeAllWindows(); |
146 |
|
|
147 |
return departureList; |
return departureList; |
148 |
} |
} |
151 |
|
|
152 |
List<DepartureBean> departureList = new ArrayList<DepartureBean>(); |
List<DepartureBean> departureList = new ArrayList<DepartureBean>(); |
153 |
|
|
154 |
final WebClient webClient = new WebClient(); |
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3); |
155 |
webClient.setTimeout(2500); |
webClient.setTimeout(2500); |
156 |
webClient.setJavaScriptEnabled(false); |
webClient.setJavaScriptEnabled(false); |
157 |
|
|
207 |
} else { |
} else { |
208 |
logger.warning("No departures found for station=" + stationcode + ", type=" + type); |
logger.warning("No departures found for station=" + stationcode + ", type=" + type); |
209 |
} |
} |
210 |
|
webClient.closeAllWindows(); |
211 |
|
|
212 |
|
|
213 |
return departureList; |
return departureList; |
214 |
} |
} |
257 |
} |
} |
258 |
|
|
259 |
|
|
|
|
|
260 |
return number; |
return number; |
261 |
} |
} |
262 |
|
|