/[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 994 by torben, Wed Jul 14 19:22:23 2010 UTC revision 1026 by torben, Thu Sep 2 18:37:49 2010 UTC
# Line 31  public class DepartureFetcher { Line 31  public class DepartureFetcher {
31          StationDAO stationDao = new StationDAO();          StationDAO stationDao = new StationDAO();
32                    
33          private boolean useTempSite;          private boolean useTempSite;
34            private int replyTimeout;
35                    
36          public DepartureFetcher(boolean tempSite, int cacheTimeout) {          public DepartureFetcher(boolean tempSite, int cacheTimeout, int replyTimeout) {
37                    this.replyTimeout = replyTimeout;
38                  useTempSite = tempSite;                  useTempSite = tempSite;
39                  cache = new TimeoutMap<String,DepartureBean>(cacheTimeout);                  cache = new TimeoutMap<String,DepartureBean>(cacheTimeout);
40          }          }
# Line 63  public class DepartureFetcher { Line 65  public class DepartureFetcher {
65                                    
66                  StationBean station = stationDao.getById(stationID);                  StationBean station = stationDao.getById(stationID);
67                                    
68                    departureBean.stationName = station.getName();
69                    
70                  if (station.getRegional() != null) {                  if (station.getRegional() != null) {
71                          DepartureBean tempBean = lookupDepartures(station.getRegional(), TrainType.REGIONAL, arrival);                          DepartureBean tempBean = lookupDepartures(station.getRegional(), TrainType.REGIONAL, arrival);
72                          departureBean.departureEntries.addAll( tempBean.departureEntries );                          departureBean.departureEntries.addAll( tempBean.departureEntries );
# Line 117  public class DepartureFetcher { Line 121  public class DepartureFetcher {
121                            
122                            
123              //logger.info("URI: " + uri);                        //logger.info("URI: " + uri);          
124              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), 2500);              JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout);
125              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");
126                            
127              Document page = (Document) breaker.invoke(wrapper);              Document page = (Document) breaker.invoke(wrapper);
# Line 128  public class DepartureFetcher { Line 132  public class DepartureFetcher {
132              if (table != null) {              if (table != null) {
133                      Elements tableRows =  table.getElementsByTag("tr");                      Elements tableRows =  table.getElementsByTag("tr");
134                                            
135                        boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0);
136                        boolean passedTidsstreg = false;
137                        
138                      for (Element currentRow : tableRows) {                      for (Element currentRow : tableRows) {
139                          String rowClass = currentRow.attr("class");                          String rowClass = currentRow.attr("class");
140                            
141                            if (tidsstregExists == true && passedTidsstreg == false) {
142                                    if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) {
143                                            passedTidsstreg = true;
144                                    } else {
145                                            continue;
146                                    }
147                            }
148                            
149                          if (rowClass != null && rowClass.toLowerCase().contains("station") ) {                          if (rowClass != null && rowClass.toLowerCase().contains("station") ) {
150                                    
151                                  Elements fields = currentRow.getElementsByTag("td");                                  Elements fields = currentRow.getElementsByTag("td");
152                    
153                                  DepartureEntry departure = new DepartureEntry();                                  DepartureEntry departure = new DepartureEntry();

Legend:
Removed from v.994  
changed lines
  Added in v.1026

  ViewVC Help
Powered by ViewVC 1.1.20