[HepData-svn] r1310 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Nov 10 13:06:30 GMT 2009


Author: whalley
Date: Tue Nov 10 13:06:29 2009
New Revision: 1310

Log:
code to stop duplication in systematic error output

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplaySystematics.java

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplaySystematics.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplaySystematics.java	Tue Nov 10 10:48:31 2009	(r1309)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplaySystematics.java	Tue Nov 10 13:06:29 2009	(r1310)
@@ -22,119 +22,104 @@
                 irn = _paper.getHepdataId();
             }
 
-	    String filename = "/home/whalley/systematics/files/" + irn + ".sys";
+	        String filename = "/home/whalley/systematics/files/" + irn + ".sys";
 // 	    writer.write("Systematics from " + filename + " are:");
             try{
-	        BufferedReader in = new BufferedReader(new FileReader(filename));
-	        String line;
-        writer.element("table");
-        writer.attributes("class", "dataset");
-//                writer.element("table  bgcolor='#f1ffff' border='0' cellspacing='0' cellpadding='5' ");
-//                writer.element("tr");
-//		writer.element("th colspan=8 align='center'");
-//		writer.write("Additional Systematical Errors and Comments");
-//		writer.end();
-//		writer.end();
+	            BufferedReader in = new BufferedReader(new FileReader(filename));
+	            String line;
+                writer.element("table");
+                writer.attributes("class", "dataset");
                 writer.element("tr");
-		writer.element("th align='center'");writer.write("Variable");writer.end();
-		writer.element("th align='center'");writer.write("SYS-ERR");writer.end();
-		writer.element("th align='center'");writer.write("INCLUDED?");writer.end();
-		writer.element("th align='center' colspan='2'");writer.write("QUALIFIER 1");writer.end();
-		writer.element("th align='center' colspan='2'");writer.write("QUALIFIER 2");writer.end();
-		writer.end();
+		        writer.element("th align='center'");writer.write("Variable");writer.end();
+		        writer.element("th align='center'");writer.write("SYS-ERR");writer.end();
+		        writer.element("th align='center'");writer.write("INCLUDED?");writer.end();
+		        writer.element("th align='center' colspan='2'");writer.write("QUALIFIER 1");writer.end();
+		        writer.element("th align='center' colspan='2'");writer.write("QUALIFIER 2");writer.end();
+		        writer.end();
 
+                List <String> inlist = new ArrayList();
+                int nlist = -1;
 	        while((line = in.readLine()) != null) {
-		    writer.element("tr");
                     String[] words = line.split("\t");
-		    if(words.length > 7){ 
+                    String lineshort = "";
+                    for (int n = 2; n<words.length; n++){ lineshort = lineshort + "\t" + words[n]; }
+                    boolean matchlist = false;
+                    for(int i=0; i<=nlist; i++){
+                        String[] wordslist = inlist.get(i).split("\t");
+                        String linelist = "";
+                        for (int n=2; n<wordslist.length; n++){ linelist = linelist + "\t" + wordslist[n]; }
+                        if(linelist.equals(lineshort)) matchlist = true;
+                    }
+                    if(!matchlist) {
+                        nlist += 1;
+                        inlist.add(line);
+                    }
+                    if(!matchlist) {
+		            writer.element("tr");
+                    if(words.length > 7){ 
                         if(!words[7].equals("")) { writer.element("td align='center'"); writer.write(words[7]); writer.end(); }
-		                             else{ writer.element("td align='center'"); writer.write("ALL");    writer.end(); }
+		                else{ writer.element("td align='center'"); writer.write("ALL");    writer.end(); }
                     }
-		    else                         { writer.element("td align='center'"); writer.write("ALL");    writer.end(); } 
+		            else                         { writer.element("td align='center'"); writer.write("ALL");    writer.end(); } 
                     if(words.length > 2) { 
-		        if(!words[2].equals("")) { writer.element("td align='center'"); writer.write(words[2]); writer.end(); }
-		        else                     { writer.element("td align='center'"); writer.write("-");      writer.end(); }
+		                if(!words[2].equals("")) { writer.element("td align='center'"); writer.write(words[2]); writer.end(); }
+		                else                     { writer.element("td align='center'"); writer.write("-");      writer.end(); }
                     }
-		    else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
+		            else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
                     if(words.length > 3) { 
-		        if(!words[3].equals("")) { writer.element("td align='center'"); writer.write("INCLUDED");     writer.end(); }
-		        else                     { writer.element("td align='center'"); writer.write("NOT INCLUDED"); writer.end(); }
+		                if(!words[3].equals("")) { writer.element("td align='center'"); writer.write("INCLUDED");     writer.end(); }
+		                else                     { writer.element("td align='center'"); writer.write("NOT INCLUDED"); writer.end(); }
                     }
-		    else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
+		            else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
                     if(words.length > 8) {
-		        if(!words[8].equals("")) { writer.element("td align='center'"); writer.write(words[8]); writer.end(); }
-		        else                     { writer.element("td align='center'"); writer.write("-");      writer.end(); }
+		                if(!words[8].equals("")) { writer.element("td align='center'"); writer.write(words[8]); writer.end(); }
+		                else                     { writer.element("td align='center'"); writer.write("-");      writer.end(); }
                     }
-		    else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
+		            else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
                     if(words.length > 9) {
-		        if(!words[9].equals("")) { writer.element("td align='center'"); writer.write(words[9]); writer.end(); }
-		        else                     { writer.element("td align='center'"); writer.write("-");      writer.end(); }
+		                if(!words[9].equals("")) { writer.element("td align='center'"); writer.write(words[9]); writer.end(); }
+		                else                     { writer.element("td align='center'"); writer.write("-");      writer.end(); }
                     }
-		    else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
+		            else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
                     if(words.length > 10) {
-		        if(!words[10].equals("")) { writer.element("td align='center'"); writer.write(words[10]); writer.end(); }
-		        else                      { writer.element("td align='center'"); writer.write("-");       writer.end(); }
+		                if(!words[10].equals("")) { writer.element("td align='center'"); writer.write(words[10]); writer.end(); }
+		                else                      { writer.element("td align='center'"); writer.write("-");       writer.end(); }
                     }
-		    else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
+		             else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
                     if(words.length > 11) {
-		        if(!words[11].equals("")) { writer.element("td align='center'"); writer.write(words[11]); writer.end(); }
-		        else                      { writer.element("td align='center'"); writer.write("-");       writer.end(); }
+		                if(!words[11].equals("")) { writer.element("td align='center'"); writer.write(words[11]); writer.end(); }
+		                else                      { writer.element("td align='center'"); writer.write("-");       writer.end(); }
                     }
-		    else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
-		    if(words.length > 4) { 
-		        if(!words[4].equals("")) { 
-			    writer.end();
-			    writer.element("tr");
-			    writer.element("td colspan=8'"); writer.write(words[4]); writer.end(); 
-			}
-		    }
-		    if(words.length > 5) { 
-		        if(!words[5].equals("")) { 
-			    writer.end();
-			    writer.element("tr");
-			    writer.element("td colspan=8'"); writer.write(words[5]); writer.end(); 
-			}
-		    }
-		    if(words.length > 6) { 
-		        if(!words[6].equals("")) { 
-			    writer.end();
-			    writer.element("tr");
-			    writer.element("td colspan=8'"); writer.write(words[6]); writer.end(); 
-			}
-		    }
-		    
+		            else                         { writer.element("td align='center'"); writer.write("-");    writer.end(); } 
+		            if(words.length > 4) { 
+		                if(!words[4].equals("")) { 
+			            writer.end();
+			            writer.element("tr");
+			            writer.element("td colspan=8'"); writer.write(words[4]); writer.end(); 
+			            }
+		            }
+		            if(words.length > 5) { 
+		                if(!words[5].equals("")) { 
+			                writer.end();
+			                writer.element("tr");
+			                writer.element("td colspan=8'"); writer.write(words[5]); writer.end(); 
+			            }
+		            }
+		            if(words.length > 6) { 
+		                if(!words[6].equals("")) { 
+			                 writer.end();
+			                writer.element("tr");
+			                writer.element("td colspan=8'"); writer.write(words[6]); writer.end(); 
+			            }
+		            }
                     writer.end();  // end of the tr element
-
-
-//		    if(words.length > 7){ 
-//                        if(!words[7].equals("")) { writer.element("br"); writer.write("For the measurement of " + words[7]); writer.end(); }
-//		                             else{ writer.element("br"); writer.write("For all measurements");               writer.end(); }
-//                    }
-//		    else                         { writer.element("br"); writer.write("For all measurments");                writer.end(); } 
-//                    if(words.length > 2) { 
-//		        if(!words[2].equals("")) { writer.element("br"); writer.write("the quoted systematic error is " + words[2]); writer.end(); }
-//                    }
-//                    if(words.length > 8) {
-//		        if(!words[8].equals("")) {writer.element("br"); writer.write("and the variable " +  words[8] + " = " +  words[9]); writer.end();}
-//                    }
-//                    if(words.length > 10) {
-//		        if(!words[10].equals("")) {writer.element("br"); writer.write("and the variable " +  words[10] + " = " +  words[11]); writer.end();}
-//                    }
-//                    if(words.length > 2) { 
-//		        if(!words[2].equals("")) { writer.element("br"); writer.write("the quoted systematic error is " + words[2]); writer.end(); }
-//                    }
-//                     if(words.length > 3) { 
-//		        if(!words[3].equals("")) { writer.element("br"); writer.write("(already included)"); writer.end(); }
-//                    }
-//                     if(words.length > 4) { 
-//		        if(!words[4].equals("")) { writer.element("br"); writer.write(words[4]); writer.end(); }
-//                    }
- 	        }
+                    }
+ 	            }
                 writer.end();  // end of the table element
- 	    }
-	    catch (IOException e) {
+ 	        }
+	        catch (IOException e) {
 	       // Handle FileNotFoundException here....
-	    }
+	        }
 	   
         }
     }


More information about the HepData-svn mailing list