3 |
import java.io.ByteArrayOutputStream; |
import java.io.ByteArrayOutputStream; |
4 |
import java.io.IOException; |
import java.io.IOException; |
5 |
import java.sql.SQLException; |
import java.sql.SQLException; |
6 |
import java.util.List; |
|
7 |
import java.util.logging.Level; |
import java.util.logging.Level; |
8 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
9 |
|
|
10 |
import javax.jdo.PersistenceManager; |
|
|
import javax.jdo.Query; |
|
11 |
import javax.servlet.ServletException; |
import javax.servlet.ServletException; |
12 |
import javax.servlet.http.HttpServlet; |
import javax.servlet.http.HttpServlet; |
13 |
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.http.HttpServletRequest; |
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; |
|
import dk.thoerup.traininfoservice.jdo.JdoStationBean; |
|
|
import dk.thoerup.traininfoservice.jdo.PMF; |
|
20 |
|
|
21 |
/** |
/** |
22 |
* Servlet implementation class LocateStations |
* Servlet implementation class LocateStations |
85 |
return out.toString(); |
return out.toString(); |
86 |
} |
} |
87 |
|
|
|
@SuppressWarnings("unchecked") |
|
88 |
@Override |
@Override |
89 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
90 |
|
|
|
if (true) { |
|
|
PersistenceManager pm = null; |
|
|
try { |
|
|
pm = PMF.get().getPersistenceManager(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JdoStationBean b = new JdoStationBean(); |
|
|
b.setId(1000); |
|
|
b.setName("TestStation"); |
|
|
b.setNameLower( b.getName().toLowerCase() ); |
|
|
b.setMetro("12"); |
|
|
pm.makePersistent(b); |
|
|
|
|
|
|
|
|
JdoStationBean b2 = new JdoStationBean(); |
|
|
b2.setId(1001); |
|
|
b2.setName("teststation 2"); |
|
|
b2.setNameLower( b2.getName().toLowerCase() ); |
|
|
b2.setMetro("12"); |
|
|
pm.makePersistent(b2); |
|
|
|
|
|
JdoStationBean b3 = new JdoStationBean(); |
|
|
b3.setId(1002); |
|
|
b3.setName("Horsens"); |
|
|
b3.setNameLower( b3.getName().toLowerCase() ); |
|
|
b3.setMetro("13"); |
|
|
pm.makePersistent(b3); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//String query = "select from " + JdoStationBean.class.getName();// + " where nameLower.startsWith('test')"; |
|
|
|
|
|
String query = "select from " + JdoStationBean.class.getName() + " where (id == 1001 || id == 1002) "; |
|
|
|
|
|
List<JdoStationBean> stations = (List<JdoStationBean>) pm.newQuery( query ).execute(); |
|
|
|
|
|
logger.info("size=" + stations.size() ); |
|
|
for(JdoStationBean bean : stations) { |
|
|
logger.info("Station: " + bean.getId() + "/" + bean.getName()); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} finally { |
|
|
if (pm != null) |
|
|
pm.close(); |
|
|
} |
|
|
|
|
|
|
|
|
return; |
|
|
} |
|
|
|
|
91 |
try { |
try { |
92 |
StationBean stations = getStations(request); |
StationBean stations = getStations(request); |
93 |
|
|