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 27 of file ShapeDemo.java.
String getServletInfo | ( | ) |
void doGet | ( | HttpServletRequest | request, | |
HttpServletResponse | response | |||
) | throws IOException, ServletException |
Responds to an HTTP GET request.
Definition at line 36 of file ShapeDemo.java.
00036 { 00037 response.setContentType("text/html"); 00038 PrintWriter out = response.getWriter(); 00039 00040 out.println("<h1>Shape demo (DB)</h1>"); 00041 out.println("<p>Reading in data from a Database !!!</p>"); 00042 00043 out.println(request.getParameter("irn")); 00044 String irn = request.getParameter("irn"); 00045 int spiresid = Integer.parseInt(irn); 00046 00047 String dataset = null; 00048 String yaxis = null; 00049 dataset = request.getParameter("dataset"); 00050 yaxis = request.getParameter("yaxis"); 00051 00052 Paper p = null; 00053 try { 00054 // getting from xml file 00055 // Data data = XMLUtils.getDataFromHepML(new File("/home/whalley/hd/hepdata-migration/shapes-hepml/"+ irn + ".hep.xml")); 00056 // if (data != null) p = data.getFirstPaper(); 00058 // getting from the db 00059 DbUtils.beginTransaction(); 00060 Query q = DbUtils.createQuery("from Paper as p where p._spiresId = :irn"); 00061 q.setLong("irn", spiresid) ; 00062 List results = q.list(); 00063 for (Object oPaper : results) { 00064 p = (Paper) oPaper; 00066 if (p == null) throw new Exception("Null paper"); 00067 00068 this.displayHeader(p,out); 00069 if(dataset == null){ 00070 this.displayDatasetError(p,out,String.valueOf(1)); 00071 } 00072 else{ 00073 this.displayDatasetError(p,out,dataset); 00074 } 00075 if(dataset == null){ 00076 this.displayDatasets(p,out); 00077 } 00078 else if(yaxis == null){ 00079 this.displayDataset(p,out,dataset); 00080 } 00081 else { 00082 this.displayDataset(p,out,dataset,yaxis); 00083 } 00084 } 00085 DbUtils.endTransaction(); 00086 } catch (Exception e) { 00087 out.println("Exception: " + e.toString()); 00088 out.println("<pre>"); 00089 e.printStackTrace(out); 00090 out.println("</pre>"); 00091 return; 00092 } 00093 }