/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/db/StationDAO.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/db/StationDAO.java

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

revision 1831 by torben, Wed Apr 11 10:11:38 2012 UTC revision 1832 by torben, Mon Aug 20 21:15:37 2012 UTC
# Line 55  public class StationDAO { Line 55  public class StationDAO {
55                          String[] emptyArray = {};                          String[] emptyArray = {};
56                          station.setAliases( emptyArray );                          station.setAliases( emptyArray );
57                  }                  }
58                    
59                    station.setTritStation( res.getInt(11) );
60                    if (res.wasNull())
61                            station.setTritStation( -1 );
62    
63                  return station;                  return station;
64          }          }
# Line 95  public class StationDAO { Line 99  public class StationDAO {
99          }          }
100    
101          public StationEntry getById(int id) throws SQLException,NostationException {          public StationEntry getById(int id) throws SQLException,NostationException {
102                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0,aliases " +                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0,aliases,tritstation " +
103                  "FROM trainstations WHERE id=" + id + " AND enabled=true";                  "FROM trainstations WHERE id=" + id + " AND enabled=true";
104                                                                    
105                  StationBean stations =  fetchStations(SQL, new NullSetter() );                  StationBean stations =  fetchStations(SQL, new NullSetter() );
# Line 116  public class StationDAO { Line 120  public class StationDAO {
120           *     create operator ~~~ (procedure = rlike, leftarg = text, rightarg = text, commutator = ~~);           *     create operator ~~~ (procedure = rlike, leftarg = text, rightarg = text, commutator = ~~);
121           */           */
122          public StationBean getByNameNormal(final String name) throws SQLException {          public StationBean getByNameNormal(final String name) throws SQLException {
123                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0,aliases " +                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0,aliases,tritstation " +
124                  "FROM trainstations " +                  "FROM trainstations " +
125                  "WHERE (name ILIKE ? OR ? ~~~ ANY(aliases)) AND enabled = true " +                  "WHERE (name ILIKE ? OR ? ~~~ ANY(aliases)) AND enabled = true " +
126                  "ORDER BY name ";                  "ORDER BY name ";
# Line 135  public class StationDAO { Line 139  public class StationDAO {
139                    
140          public StationBean getByNameFuzzy(final String name) throws SQLException {          public StationBean getByNameFuzzy(final String name) throws SQLException {
141                  String SQL = "SELECT * FROM (" +                  String SQL = "SELECT * FROM (" +
142                                           "    SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0, aliases, " +                                           "    SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0, aliases, tritstation, " +
143                                           "    levenshtein(lower(name),lower(?) ) as leven " +                                           "    levenshtein(lower(name),lower(?) ) as leven " +
144                                           "    FROM trainstations " +                                           "    FROM trainstations " +
145                                           "    WHERE  enabled = true ) as lev2 " +                                           "    WHERE  enabled = true ) as lev2 " +
# Line 198  public class StationDAO { Line 202  public class StationDAO {
202                  String limitExpression = (geolimit == true) ? "AND abs(latitude-?)<0.4 AND abs(longitude-?)<0.75 " : "";                  String limitExpression = (geolimit == true) ? "AND abs(latitude-?)<0.4 AND abs(longitude-?)<0.75 " : "";
203                                    
204                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, " +                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, " +
205                          "earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist,aliases " +                          "earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist,aliases,tritstation " +
206                          "FROM trainstations " +                          "FROM trainstations " +
207                          "WHERE enabled = true " + limitExpression +                          "WHERE enabled = true " + limitExpression +
208                          "ORDER BY calcdist ASC " +                          "ORDER BY calcdist ASC " +
# Line 235  public class StationDAO { Line 239  public class StationDAO {
239                    
240    
241          public StationBean getByList(String list) throws SQLException {          public StationBean getByList(String list) throws SQLException {
242                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro, address,0.0,aliases " +                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro, address,0.0,aliases,tritstation " +
243                  "FROM trainstations " +                  "FROM trainstations " +
244                  "WHERE id IN " + list + " AND enabled = true " +                  "WHERE id IN " + list + " AND enabled = true " +
245                  "ORDER BY name ";                  "ORDER BY name ";
# Line 246  public class StationDAO { Line 250  public class StationDAO {
250    
251                    
252          public StationEntry getSimpleByName(final String name) throws SQLException {          public StationEntry getSimpleByName(final String name) throws SQLException {
253                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0,aliases " +                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0,aliases,tritstation " +
254                  "FROM trainstations " +                  "FROM trainstations " +
255                  "WHERE name = ?  AND enabled = true " +                  "WHERE name = ?  AND enabled = true " +
256                  "LIMIT 1 ";                  "LIMIT 1 ";
# Line 278  public class StationDAO { Line 282  public class StationDAO {
282          //after 1.1.0 also used to populate client-side station list          //after 1.1.0 also used to populate client-side station list
283          public StationBean dumpAll() throws SQLException {          public StationBean dumpAll() throws SQLException {
284                                    
285                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0,aliases " +                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0,aliases,tritstation " +
286                                  "FROM trainstations WHERE enabled = true";                                  "FROM trainstations WHERE enabled = true";
287                                    
288                                    
# Line 328  public class StationDAO { Line 332  public class StationDAO {
332                                    
333          }          }
334    
335            /*
336          @Deprecated          @Deprecated
337          public static String getStationName(int stationID) {          public static String getStationName(int stationID) {
338                  String station = "";                  String station = "";
# Line 350  public class StationDAO { Line 355  public class StationDAO {
355                  }                  }
356    
357                  return station;                  return station;
358          }          }*/
359                    
360          public boolean hasDisabledStation(final String name) throws SQLException {          public boolean hasDisabledStation(final String name) throws SQLException {
361                  String SQL = "Select count(*) as antal from trainstations where name = '" + name + "'  and enabled=false " ;                  String SQL = "Select count(*) as antal from trainstations where name = '" + name + "'  and enabled=false " ;
# Line 370  public class StationDAO { Line 375  public class StationDAO {
375                  return (antal > 0);                  return (antal > 0);
376          }          }
377                    
378                    /*
379          @Deprecated          @Deprecated
380          public int getIdByName(final String name) throws SQLException {          public int getIdByName(final String name) throws SQLException {
381                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0 " +                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0 " +
# Line 392  public class StationDAO { Line 397  public class StationDAO {
397                  } else {                  } else {
398                          return -1;                          return -1;
399                  }                  }
400          }          }*/
401  }  }

Legend:
Removed from v.1831  
changed lines
  Added in v.1832

  ViewVC Help
Powered by ViewVC 1.1.20