2 |
|
|
3 |
|
|
4 |
import java.net.URL; |
import java.net.URL; |
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
5 |
import java.util.Map; |
import java.util.Map; |
6 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
7 |
|
|
|
|
|
8 |
import org.jsoup.nodes.Document; |
import org.jsoup.nodes.Document; |
9 |
import org.jsoup.nodes.Element; |
import org.jsoup.nodes.Element; |
10 |
import org.jsoup.select.Elements; |
import org.jsoup.select.Elements; |
11 |
|
|
12 |
|
import dk.thoerup.android.traininfo.common.MetroBean; |
13 |
|
import dk.thoerup.android.traininfo.common.MetroBean.MetroEntry; |
14 |
|
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
15 |
import dk.thoerup.circuitbreaker.CircuitBreaker; |
import dk.thoerup.circuitbreaker.CircuitBreaker; |
16 |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
|
import dk.thoerup.traininfoservice.StationBean; |
|
17 |
import dk.thoerup.traininfoservice.StationDAO; |
import dk.thoerup.traininfoservice.StationDAO; |
18 |
import dk.thoerup.traininfoservice.Statistics; |
import dk.thoerup.traininfoservice.Statistics; |
19 |
|
|
20 |
|
|
21 |
|
|
22 |
public class MetroFetcher { |
public class MetroFetcher { |
|
public static class MetroEntry { |
|
|
String metro; |
|
|
String destination; |
|
|
String minutes; |
|
|
} |
|
|
|
|
|
public static class MetroBean { |
|
|
String head; |
|
|
String operationInfo; //driftsinfo |
|
|
String plan; // koereplan |
|
|
|
|
|
List<MetroEntry> entries = new ArrayList<MetroEntry>(); |
|
|
} |
|
23 |
|
|
24 |
Logger logger = Logger.getLogger(MetroFetcher.class.getName()); |
Logger logger = Logger.getLogger(MetroFetcher.class.getName()); |
25 |
StationDAO stationDAO = new StationDAO(); |
StationDAO stationDAO = new StationDAO(); |
43 |
|
|
44 |
public MetroBean lookupMetroDepartures(int stationID) throws Exception { |
public MetroBean lookupMetroDepartures(int stationID) throws Exception { |
45 |
|
|
46 |
StationBean station = stationDAO.getById(stationID) ; |
StationEntry station = stationDAO.getById(stationID) ; |
47 |
|
|
48 |
|
|
49 |
URL url = new URL("http://www.m.dk/layouts/Metro/Widgets/MetroWidget.ashx?StationId=" + station.getMetro() + "&Congestion=true&Application=MyMetro&Expiration=true"); |
URL url = new URL("http://www.m.dk/layouts/Metro/Widgets/MetroWidget.ashx?StationId=" + station.getMetro() + "&Congestion=true&Application=MyMetro&Expiration=true"); |