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

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/LocateStations.java

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

revision 1061 by torben, Thu Sep 16 14:04:28 2010 UTC revision 1557 by torben, Fri Jul 8 12:47:02 2011 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfoservice;  package dk.thoerup.traininfoservice;
2    
3  import java.io.ByteArrayOutputStream;  
4  import java.io.IOException;  import java.io.IOException;
5    import java.io.StringWriter;
6  import java.sql.SQLException;  import java.sql.SQLException;
7  import java.util.logging.Level;  import java.util.logging.Level;
8  import java.util.logging.Logger;  import java.util.logging.Logger;
# Line 16  import org.simpleframework.xml.Serialize Line 17  import org.simpleframework.xml.Serialize
17  import org.simpleframework.xml.core.Persister;  import org.simpleframework.xml.core.Persister;
18    
19  import dk.thoerup.android.traininfo.common.StationBean;  import dk.thoerup.android.traininfo.common.StationBean;
20    import dk.thoerup.traininfoservice.db.StationDAO;
21    
22  /**  /**
23   * Servlet implementation class LocateStations   * Servlet implementation class LocateStations
# Line 47  public class LocateStations extends Http Line 49  public class LocateStations extends Http
49    
50          protected StationBean getStations(HttpServletRequest req) throws SQLException {          protected StationBean getStations(HttpServletRequest req) throws SQLException {
51                  StationBean stations = null;                  StationBean stations = null;
52                    
53                    boolean dummy = req.getParameter("dummy") != null;
54                    if (dummy == true)
55                            stations = new StationBean();
56                    
57                  if (req.getParameter("latitude") != null && req.getParameter("latitude") != null) {                  if (req.getParameter("latitude") != null && req.getParameter("latitude") != null) {
58                                                    
59                          Statistics.getInstance().incrementStationLookupsLocation();                          Statistics.getInstance().incrementStationLookupsLocation();
60                                                    
61                          double latitude = Double.parseDouble( req.getParameter("latitude") );                          double latitude = Double.parseDouble( req.getParameter("latitude") );
62                          double longitude = Double.parseDouble( req.getParameter("longitude") );                          double longitude = Double.parseDouble( req.getParameter("longitude") );
63                          stations = stationDao.getByLocation(latitude, longitude);                          if (dummy == false)
64                                    stations = stationDao.getByLocation(latitude, longitude);
65    
66                  } else if (req.getParameter("name") != null) {                  } else if (req.getParameter("name") != null) {
67                          Statistics.getInstance().incrementStationLookupsName();                          Statistics.getInstance().incrementStationLookupsName();
68                          String name = req.getParameter("name").trim();                          String name = req.getParameter("name").trim();
69                          stations = stationDao.getByName(name);                          if (dummy == false)
70                                    stations = stationDao.getByName(name);
71    
72                  } else if (req.getParameter("list") != null) {                  } else if (req.getParameter("list") != null) {
73                          Statistics.getInstance().incrementStationLookupsFavorites();                          Statistics.getInstance().incrementStationLookupsFavorites();
74                          String list = transformToIntList( req.getParameter("list"));                          String list = transformToIntList( req.getParameter("list"));
75                          stations = stationDao.getByList(list);                          if (dummy == false)
76                                    stations = stationDao.getByList(list);
77                    } else if (req.getParameter("dump") != null) {
78                            stations = stationDao.dumpAll();
79                  }                  }
80                  return stations;                  return stations;
81          }          }
# Line 73  public class LocateStations extends Http Line 85  public class LocateStations extends Http
85    
86                  Serializer serializer = new Persister();                  Serializer serializer = new Persister();
87    
88                  ByteArrayOutputStream out = new ByteArrayOutputStream();                  StringWriter out = new StringWriter();
89    
90                  try {                  try {
91                          serializer.write(stations, out);                          serializer.write(stations, out);

Legend:
Removed from v.1061  
changed lines
  Added in v.1557

  ViewVC Help
Powered by ViewVC 1.1.20