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 |
} |
} |
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() ); |
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 "; |
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 " + |
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 " + |
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 "; |
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 "; |