/[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 1045 by torben, Tue Sep 14 05:20:17 2010 UTC revision 1061 by torben, Thu Sep 16 14:04:28 2010 UTC
# Line 11  import org.jsoup.nodes.Document; Line 11  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    
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    
# Line 63  public class DepartureFetcher { Line 65  public class DepartureFetcher {
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                                    
# Line 131  public class DepartureFetcher { Line 133  public class DepartureFetcher {
133    
134              String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning";                      String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning";        
135                            
136              //logger.info("URI: " + uri);                        logger.fine("URI: " + uri);    
137              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout);              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout);
138              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");
139                            
# Line 235  public class DepartureFetcher { Line 237  public class DepartureFetcher {
237                                    
238                                                                                            
239              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;
240              logger.info("URI:" + uri);              logger.fine("URI:" + uri);
241                
242    
243              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout);              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout);
244              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");
245                            
# Line 244  public class DepartureFetcher { Line 248  public class DepartureFetcher {
248              String tableName = arrival == false ? "afgangtabel" : "ankomsttabel";              String tableName = arrival == false ? "afgangtabel" : "ankomsttabel";
249              Element table = page.getElementById(tableName);              Element table = page.getElementById(tableName);
250                            
251    
252                
253              if (table != null) {              if (table != null) {
254                      Elements tableRows =  table.getElementsByTag("tr");                      Elements tableRows =  table.getElementsByTag("tr");
255                                            
256                        boolean passedTidsstreg = false;
257                        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) {
263                                    if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) {
264                                            passedTidsstreg = true;
265                                    } else {
266                                            continue;
267                                    }
268                            }
269                            
270                            
271                          if (rowClass != null && rowClass.toLowerCase().contains("station") ) {                          if (rowClass != null && rowClass.toLowerCase().contains("station") ) {
272                                  Elements fields = currentRow.getElementsByTag("td");                                  Elements fields = currentRow.getElementsByTag("td");
273                    

Legend:
Removed from v.1045  
changed lines
  Added in v.1061

  ViewVC Help
Powered by ViewVC 1.1.20