2 |
|
|
3 |
|
|
4 |
import java.net.URL; |
import java.net.URL; |
|
|
|
5 |
import java.util.ArrayList; |
import java.util.ArrayList; |
6 |
import java.util.List; |
import java.util.List; |
7 |
import java.util.Map; |
import java.util.Map; |
8 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
9 |
|
|
|
|
|
10 |
import org.jsoup.nodes.Document; |
import org.jsoup.nodes.Document; |
11 |
import org.jsoup.nodes.Element; |
import org.jsoup.nodes.Element; |
12 |
import org.jsoup.select.Elements; |
import org.jsoup.select.Elements; |
13 |
|
import org.simpleframework.xml.ElementList; |
14 |
|
import org.simpleframework.xml.Root; |
15 |
|
|
16 |
import dk.thoerup.circuitbreaker.CircuitBreaker; |
import dk.thoerup.circuitbreaker.CircuitBreaker; |
17 |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
|
import dk.thoerup.traininfoservice.StationBean; |
|
18 |
import dk.thoerup.traininfoservice.StationDAO; |
import dk.thoerup.traininfoservice.StationDAO; |
19 |
import dk.thoerup.traininfoservice.Statistics; |
import dk.thoerup.traininfoservice.Statistics; |
20 |
|
import dk.thoerup.traininfoservice.StationBean.StationEntry; |
21 |
|
|
22 |
|
|
23 |
|
|
24 |
public class MetroFetcher { |
public class MetroFetcher { |
25 |
|
@Root(name="entry") |
26 |
public static class MetroEntry { |
public static class MetroEntry { |
27 |
|
|
28 |
|
@org.simpleframework.xml.Element |
29 |
String metro; |
String metro; |
30 |
|
|
31 |
|
@org.simpleframework.xml.Element |
32 |
String destination; |
String destination; |
33 |
|
|
34 |
|
@org.simpleframework.xml.Element |
35 |
String minutes; |
String minutes; |
36 |
} |
} |
37 |
|
|
38 |
|
@Root(name="metrodepatures") |
39 |
public static class MetroBean { |
public static class MetroBean { |
40 |
|
|
41 |
|
@org.simpleframework.xml.Element |
42 |
String head; |
String head; |
|
String operationInfo; //driftsinfo |
|
|
String plan; // koereplan |
|
43 |
|
|
44 |
|
|
45 |
|
@org.simpleframework.xml.Element(name="operations") |
46 |
|
String operationInfo; //driftsinfo |
47 |
|
|
48 |
|
@ElementList |
49 |
List<MetroEntry> entries = new ArrayList<MetroEntry>(); |
List<MetroEntry> entries = new ArrayList<MetroEntry>(); |
50 |
|
|
51 |
|
@org.simpleframework.xml.Element |
52 |
|
String plan; // koereplan |
53 |
} |
} |
54 |
|
|
55 |
Logger logger = Logger.getLogger(MetroFetcher.class.getName()); |
Logger logger = Logger.getLogger(MetroFetcher.class.getName()); |
74 |
|
|
75 |
public MetroBean lookupMetroDepartures(int stationID) throws Exception { |
public MetroBean lookupMetroDepartures(int stationID) throws Exception { |
76 |
|
|
77 |
StationBean station = stationDAO.getById(stationID) ; |
StationEntry station = stationDAO.getById(stationID) ; |
78 |
|
|
79 |
|
|
80 |
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"); |