/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 992 by torben, Wed Jul 14 08:05:31 2010 UTC revision 1021 by torben, Mon Aug 30 13:59:54 2010 UTC
# Line 2  package dk.thoerup.traininfoservice.bane Line 2  package dk.thoerup.traininfoservice.bane
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;
# Line 62  public class DepartureFetcher { Line 63  public class DepartureFetcher {
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 );
# Line 108  public class DepartureFetcher { Line 111  public class DepartureFetcher {
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");
# Line 124  public class DepartureFetcher { Line 130  public class DepartureFetcher {
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();

Legend:
Removed from v.992  
changed lines
  Added in v.1021

  ViewVC Help
Powered by ViewVC 1.1.20