Public Member Functions | |
String | getServletInfo () |
Returns a short description of the servlet. | |
void | doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException |
Responds to an HTTP GET request. |
Definition at line 18 of file DbDemo.java.
String getServletInfo | ( | ) |
void doGet | ( | HttpServletRequest | request, | |
HttpServletResponse | response | |||
) | throws IOException, ServletException |
Responds to an HTTP GET request.
Definition at line 27 of file DbDemo.java.
00027 { 00028 response.setContentType("text/html"); 00029 PrintWriter out = response.getWriter(); 00030 00031 try { 00032 out.println("<h1>Model-db demo</h1>"); 00033 DbUtils.beginTransaction(); 00034 String qstr = "select distinct p from Paper as p"; 00035 qstr += " left join fetch p._datasets as d"; 00036 //qstr += " join fetch d._xAxes as xax"; 00037 //qstr += " join fetch xax._bins as bin"; 00038 //qstr += " join fetch d._yAxes as yax"; 00039 //qstr += " join fetch yax._points as pt"; 00040 //qstr += " join fetch pt._errors as pterr"; 00041 Query q = DbUtils.createQuery(qstr); 00042 List results = q.list(); 00043 if (results != null) { 00044 for (Object result : results) { 00045 Paper p = (Paper) result; 00046 out.println("<div style=\"background:#c6deff; border:#82cafa 1px solid; margin:2em 1em; padding:1em; width:80%;\">"); 00047 out.println("<h2>" + p.getSpiresId().toString() + "</h2>"); 00048 out.println("<pre style=\"background:#ffc; border:#fc3 1px solid; padding:1em; overflow:hidden; \">" + p.toString() + "</pre>"); 00049 out.println("<pre style=\"background:#ffc; border:#fc3 1px solid; padding:1em;\">" + XMLUtils.makeHepMLString(p) + "</pre>"); 00050 out.println("</div>"); 00051 } 00052 } 00053 DbUtils.endTransaction(); 00054 00055 } catch (Exception e) { 00056 out.println("Exception: " + e.toString()); 00057 } 00058 00059 }