/[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 1789 by torben, Fri Feb 24 14:26:53 2012 UTC revision 1790 by torben, Wed Apr 11 10:11:38 2012 UTC
# Line 47  public class StationDAO { Line 47  public class StationDAO {
47                  station.setIsRegional( station.getRegional() != null );                  station.setIsRegional( station.getRegional() != null );
48                  station.setIsStrain( station.getStrain() != null );                  station.setIsStrain( station.getStrain() != null );
49                  station.setIsMetro( station.getMetro() != null );                  station.setIsMetro( station.getMetro() != null );
50                    
51                    Array aliases = res.getArray( 10);
52                    if (aliases != null) {
53                            station.setAliases( (String[]) aliases.getArray() );
54                    } else {
55                            String[] emptyArray = {};
56                            station.setAliases( emptyArray );
57                    }
58    
59                  return station;                  return station;
60          }          }
# Line 87  public class StationDAO { Line 95  public class StationDAO {
95          }          }
96    
97          public StationEntry getById(int id) throws SQLException,NostationException {          public StationEntry getById(int id) throws SQLException,NostationException {
98                  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,aliases " +
99                  "FROM trainstations WHERE id=" + id + " AND enabled=true";                  "FROM trainstations WHERE id=" + id + " AND enabled=true";
100                                                                    
101                  StationBean stations =  fetchStations(SQL, new NullSetter() );                  StationBean stations =  fetchStations(SQL, new NullSetter() );
# Line 108  public class StationDAO { Line 116  public class StationDAO {
116           *     create operator ~~~ (procedure = rlike, leftarg = text, rightarg = text, commutator = ~~);           *     create operator ~~~ (procedure = rlike, leftarg = text, rightarg = text, commutator = ~~);
117           */           */
118          public StationBean getByNameNormal(final String name) throws SQLException {          public StationBean getByNameNormal(final String name) throws SQLException {
119                  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,aliases " +
120                  "FROM trainstations " +                  "FROM trainstations " +
121                  "WHERE (name ILIKE ? OR ? ~~~ ANY(aliases)) AND enabled = true " +                  "WHERE (name ILIKE ? OR ? ~~~ ANY(aliases)) AND enabled = true " +
122                  "ORDER BY name ";                  "ORDER BY name ";
# Line 127  public class StationDAO { Line 135  public class StationDAO {
135                    
136          public StationBean getByNameFuzzy(final String name) throws SQLException {          public StationBean getByNameFuzzy(final String name) throws SQLException {
137                  String SQL = "SELECT * FROM (" +                  String SQL = "SELECT * FROM (" +
138                                           "    SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0, " +                                           "    SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0, aliases, " +
139                                           "    levenshtein(lower(name),lower(?) ) as leven " +                                           "    levenshtein(lower(name),lower(?) ) as leven " +
140                                           "    FROM trainstations " +                                           "    FROM trainstations " +
141                                           "    WHERE  enabled = true ) as lev2 " +                                           "    WHERE  enabled = true ) as lev2 " +
# Line 190  public class StationDAO { Line 198  public class StationDAO {
198                  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 " : "";
199                                    
200                  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, " +
201                          "earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist " +                          "earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist,aliases " +
202                          "FROM trainstations " +                          "FROM trainstations " +
203                          "WHERE enabled = true " + limitExpression +                          "WHERE enabled = true " + limitExpression +
204                          "ORDER BY calcdist ASC " +                          "ORDER BY calcdist ASC " +
# Line 227  public class StationDAO { Line 235  public class StationDAO {
235                    
236    
237          public StationBean getByList(String list) throws SQLException {          public StationBean getByList(String list) throws SQLException {
238                  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,aliases " +
239                  "FROM trainstations " +                  "FROM trainstations " +
240                  "WHERE id IN " + list + " AND enabled = true " +                  "WHERE id IN " + list + " AND enabled = true " +
241                  "ORDER BY name ";                  "ORDER BY name ";
# Line 238  public class StationDAO { Line 246  public class StationDAO {
246    
247                    
248          public StationEntry getSimpleByName(final String name) throws SQLException {          public StationEntry getSimpleByName(final String name) throws SQLException {
249                  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,aliases " +
250                  "FROM trainstations " +                  "FROM trainstations " +
251                  "WHERE name = ?  AND enabled = true " +                  "WHERE name = ?  AND enabled = true " +
252                  "LIMIT 1 ";                  "LIMIT 1 ";

Legend:
Removed from v.1789  
changed lines
  Added in v.1790

  ViewVC Help
Powered by ViewVC 1.1.20