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 19 of file ModelDemo2.java.
String getServletInfo | ( | ) |
void doGet | ( | HttpServletRequest | request, | |
HttpServletResponse | response | |||
) | throws IOException, ServletException |
Responds to an HTTP GET request.
Definition at line 28 of file ModelDemo2.java.
00028 { 00029 response.setContentType("text/html"); 00030 PrintWriter out = response.getWriter(); 00031 00032 out.println("<h1>Model demo2</h1>"); 00033 out.println("<p>Reading in data from an xml file!</p>"); 00034 00035 out.println(request.getParameter("irn")); 00036 String irn = request.getParameter("irn"); 00037 00038 Paper p = null; 00039 try { 00040 // Data data = XMLUtils.getDataFromHepML(new File("/home/whalley/hd/hepdata-webapp/xml/test.hepml.xml")); 00041 Data data = XMLUtils.getDataFromHepML(new File("/home/whalley/hd/hepdata-migration/shapes-hepml/"+ irn + ".hep.xml")); 00042 if (data != null) p = data.getFirstPaper(); 00043 if (p == null) throw new Exception("Null paper"); 00044 } catch (Exception e) { 00045 out.println("Exception: " + e.toString()); 00046 out.println("<pre>"); 00047 e.printStackTrace(out); 00048 out.println("</pre>"); 00049 return; 00050 } 00051 00052 // out.println("<pre>" + p.toString() + "</pre>"); 00053 // this is my new code 00054 StringBuffer s = new StringBuffer(); 00055 out.println("<pre>"); 00056 out.println("irn = " + p.getSpiresId()); 00057 out.println("red = " + p.getRedId()); 00058 int icom = 0; 00059 for ( String comment : p.getComments() ){ 00060 icom++; 00061 out.println(icom + ":" + comment); 00062 } 00063 int imod = 0; 00064 for ( Modification modification : p.getModifications() ){ 00065 imod++; 00066 if(imod == 1){out.println("Created on " + modification.getTimestamp() + " by " + modification.getModifier());} 00067 else {out.println("Modified on " + modification.getTimestamp() + " by " + modification.getModifier());} 00068 } 00069 for (String auth: p.getAuthors() ) { 00070 out.println("author: " + auth); 00071 } 00072 out.println("Title:" + p.getTitle()); 00073 00074 out.println("Number if references are: " + p.getReferences().size()); 00075 00076 for (Reference ref : p.getReferences() ) { 00077 out.println("Reference:" + ref.getDescription()); 00078 } 00079 for (Experiment exp : p.getExperiments() ) { 00080 out.println("Experiment:" + exp.getName()); 00081 out.println("Laboratory:" + exp.getLaboratory()); 00082 out.println("InformalName:" + exp.getInformalName()); 00083 } 00084 out.println("</pre>"); 00085 out.println("Next the datasets....\n"); 00086 00087 int ndata = 0; 00088 for ( Dataset d : p.getDatasets() ) { 00089 ndata++; 00090 for (DatasetError de : d.getErrors() ) { 00091 out.println("\n Dataset Error"); 00092 if (de.getComment() != null) { out.println("<br>" + de.getComment() ); } 00093 if (de.getPlus() != null) { out.println("<br>" + de.getPlus() ); } 00094 if (de.getMinus() != null) { out.println("<br>" + de.getMinus() ); } 00095 if (de.getSourceType() != null) { out.println("<br>" + de.getSourceType() ); } 00096 if (de.getNormType() != null) { out.println("<br>" + de.getNormType() ); } 00097 } 00098 00099 // count the number of x and y axes and the number of bins 00100 00101 int ny = d.getYAxes().size(); 00102 int nx = d.getXAxes().size(); 00103 int npoints = 0; 00104 for (XAxis x : d.getXAxes()){npoints = x.getBins().size();} 00105 00106 // counting done 00108 // output each y axis in turn in a separate table 00109 int my = 0; 00110 for (YAxis y : d.getYAxes()){ 00111 my++; 00112 // first the reactions for this yaxis 00113 out.println("<table border=1>"); 00114 int nspan = nx+1; 00115 out.println("<th colspan=" + nspan + ">Dataset " + ndata + " yaxis " + my + "</th></tr><tr>"); 00116 for ( Reaction reac : y.getReactions() ){ 00117 for (XAxis x : d.getXAxes()){ 00118 out.println("<th> - </th>"); 00119 } 00120 out.println("<th>"); 00121 00122 for ( Particle part : reac.getInitialState() ){ 00123 out.println(part.getName() + " "); 00124 } 00125 out.println("-->"); 00126 for ( Particle part : reac.getFinalState() ){ 00127 out.println(part.toString()); 00128 if (part.getMultRelation() != Relation.EQUALS) {out.println( part.getMultRelation() );} 00129 if (part.getMultiplicity() > 1) {out.println( part.getMultiplicity() );} 00130 out.println(part.getName() + " "); 00131 } 00132 out.println("</th></tr>"); 00133 } 00134 00135 // next the yaxis comments (non-numerical properties!) 00136 for (String comment : y.getComments()){ 00137 out.println("<tr>"); 00138 for (XAxis x : d.getXAxes()){ 00139 out.println("<th> - </th>"); 00140 } 00141 out.println("<th>" + comment + "</th></tr>"); 00142 } 00143 00144 // next the properties 00145 for ( Property prop: y.getProperties() ){ 00146 out.println("<tr>"); 00147 for (XAxis x : d.getXAxes()){ 00148 out.println("<th> - </th>"); 00149 } 00150 out.println("<th>"); 00151 out.println( prop.getName() + " : "); 00152 if (prop.getLowValue() != null && prop.getHighValue() != null && 00153 prop.getLowValue().equals(prop.getHighValue())) { 00154 out.println(prop.getLowValue()); 00155 } 00156 else{out.println(prop.getLowValue() + " TO " + prop.getHighValue());} 00157 if (!prop.getUnit().toString().equals("num")){ 00158 out.println(" " + prop.getUnit().toString()); 00159 } 00160 out.println("</th>" ) ; 00161 } 00162 00163 // here for the headers 00164 out.println("<tr>"); 00165 for (XAxis x : d.getXAxes()){ 00166 out.println("<th>" + x.getHeader() + "</th>"); 00167 } 00168 out.println("<th>" + y.getHeader() + "</th>"); 00169 out.println("</tr>"); 00170 00171 // finally the numbers themselves 00172 Double f = null; 00173 for (int ip=1 ; ip<=npoints; ip++){ 00174 out.println("<tr>"); 00175 for (int ix=1 ; ix<=nx; ix++){ 00176 XAxis xaxis = d.getXAxis(ix); 00177 for (Bin b : xaxis.getBins()){ 00178 if(b.getId() == ip) {f = b.getFocus();} 00179 } 00180 out.println("<td>" + f + "</td>"); 00181 } 00182 try { 00183 Point pt2 = y.getPoint(ip); 00184 out.println("<td>" + pt2.getValue()); 00185 for ( Uncertainty e : pt2.getErrors() ){ 00186 if( e.getPlus().equals(e.getMinus()) ) { 00187 out.println(" +- " + e.getPlus() ); 00188 } 00189 else{ 00190 out.println(" +" + e.getPlus() + ",-" + e.getMinus() ); 00191 } 00192 if ( e.getNormType() == ErrorNorm.PCT ) { 00193 out.println(" (" + e.getNormType().toString() + ")"); 00194 } 00195 } 00196 out.println("</td>"); 00197 } catch (Exception e) { 00198 out.println("<td>-</td>"); 00199 } 00200 out.println("</tr>"); 00201 } 00202 out.println("</table>"); 00203 } 00205 // to here 00206 } 00207 }