145 |
return stations; |
return stations; |
146 |
} |
} |
147 |
|
|
148 |
|
private String removeSuffix(String str, String suffix) { |
149 |
|
if (str.endsWith(suffix)) { |
150 |
|
return str.substring(0, str.length() - suffix.length() ); |
151 |
|
} else { |
152 |
|
return str; |
153 |
|
} |
154 |
|
} |
155 |
|
|
156 |
public StationBean getByName(String name) throws SQLException { |
public StationBean getByName(String name) throws SQLException { |
157 |
|
name = removeSuffix(name, " st."); |
158 |
|
name = removeSuffix(name, " st"); |
159 |
|
name = removeSuffix(name, " station"); |
160 |
|
|
161 |
StationBean stations = getByNameNormal(name); |
StationBean stations = getByNameNormal(name); |
162 |
|
|
163 |
if (stations.entries.size() == 0) { |
if (stations.entries.size() == 0) { |
|
logger.info("getByName failover: " + name); |
|
|
name = name.replace(".", ""); //remove any .'s before fuzzy search |
|
164 |
stations = getByNameFuzzy(name); |
stations = getByNameFuzzy(name); |
165 |
|
|
166 |
|
logger.info("getByName failover: " + name + "(" + (stations.entries.size() >0) + ")" ); |
167 |
} |
} |
168 |
return stations; |
return stations; |
169 |
} |
} |
258 |
} |
} |
259 |
|
|
260 |
//used to create full dump in order to populate Google Appengine DB |
//used to create full dump in order to populate Google Appengine DB |
261 |
@Deprecated |
//after 1.1.0 also used to populate client-side station list |
262 |
public StationBean dumpAll() throws SQLException { |
public StationBean dumpAll() throws SQLException { |
263 |
|
|
264 |
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 " + |
265 |
"FROM trainstations WHERE enabled = true ORDER BY id"; |
"FROM trainstations WHERE enabled = true ORDER BY name"; |
266 |
|
|
267 |
Connection conn = null; |
Connection conn = null; |
268 |
Statement stmt = null; |
Statement stmt = null; |