Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

HTMLJobWriter.java

Go to the documentation of this file.
00001 package cedar.jetweb.html;
00002 
00003 import java.io.PrintWriter;
00004 
00005 import java.util.List;
00006 import java.util.Iterator;
00007 import java.util.Vector;
00008 import java.util.Date;
00009 
00010 import java.io.File;
00011 import java.io.IOException;
00012 
00013 import java.text.DecimalFormat;
00014 
00015 import cedar.jetweb.*;
00016 import cedar.jetweb.model.*;
00017 import cedar.jetweb.job.*;
00018 import cedar.jetweb.batch.SubmitScriptHandler;
00019 import cedar.jetweb.util.JetWebFile;
00020 
00029 public class HTMLJobWriter extends HTMLWriter {
00030 
00031 
00041     public HTMLJobWriter(PrintWriter out, String newServletPath ){
00042     super(out,newServletPath);
00043     }
00044 
00055     public HTMLJobWriter(String filename, String newServletPath ){
00056     super(filename,newServletPath);
00057     }
00058 
00062     public static String jobStats() {
00063 
00064     StringBuffer line = new StringBuffer("<!JobCounter>");
00065 
00066     Iterator iBatchNum = SubmitScriptHandler.batchNumbers.iterator();
00067     Iterator iBatchName = SubmitScriptHandler.batchNames.iterator();
00068 
00069     while (iBatchNum.hasNext()&&iBatchName.hasNext()) {  // Should have same number of entries
00070         String batchNum = ((Integer) iBatchNum.next()).toString();
00071         String batchName = (String) iBatchName.next();
00072         try {
00073         int nSub = JobUtils.countJobs(batchNum);
00074         int nComp = JobUtils.countCompletedJobs(batchNum);
00075         line.append("<br>"+nSub+" jobs submitted to "+batchName+", "+nComp+" completed");
00076         } catch (JetWebException e) {
00077         System.out.println("Error while counting jobs: "+e);
00078         }
00079     }
00080 
00081     return line.toString();
00082     }
00083 
00089     public static String getDescription(JobRequest jr) throws JetWebException { 
00090 
00091     MCProcessType proc = jr.getMCProcessType();
00092     Model model = jr.getModel();
00093     DecimalFormat df = new DecimalFormat("#####00.0#");
00094 
00095     StringBuffer text = new StringBuffer("<p>Job name  : "
00096         +JetWebConfig.jobOutDirName+"/"+jr.getJobName()+"<br/>Beams : "
00097         +proc.getMCProcessName()
00098         +" in "+proc.getCollision().getParticle1()+"-"
00099         +proc.getCollision().getParticle2()+" collisions at a CM energy of "
00100         +df.format(proc.getCollision().getCMEnergy())+" GeV "
00101         +"<br/> Generator : "+model.getGenerator()+"<br/>");
00102     text.append("Photon PDF : "+model.getPhotonPDF()+"<br/>");
00103     text.append("Proton PDF  : "+model.getProtonPDF()+"</p>");
00104     return text.toString();
00105     }
00106 
00110     public void listLogs(Vector<LogFile> list) 
00111     throws JetWebException {
00112 
00113     try {
00114         for (LogFile log : list){
00115         display(log);
00116         }
00117     } catch (JetWebException e) {
00118         throw e;
00119     }
00120 
00121     }
00122 
00126     public void display(LogFile log) throws JetWebException {
00127 
00128     try {
00129 
00130         JetWebFile file = log.getFile();
00131 
00132         String fName = file.toString();
00133 
00134         if(!file.isOut()){
00135         file = new JetWebFile(fName, JetWebFile.OUT);
00136         }
00137         
00138         fName = fName + file.extension();
00139 
00140         if(file.isZipped()){
00141         fName = fName + ".gz";
00142         }
00143 
00144         ofile.write("<li><A href='"+JetWebConfig.getHTMLRoot()
00145             +"/"+JetWebConfig.serverName+"-archive/"
00146             +fName
00147             +"'>"+file.toString()+"</a>");
00148 
00149         fName = file.toString() + JetWebFile.AIDA;
00150 
00151         ofile.write(" : <A href='"+JetWebConfig.getHTMLRoot()
00152             +"/"+JetWebConfig.serverName+"-archive/"
00153             +fName
00154             +"'>histogram file</A>");
00155 
00156         fName = file.toString() + JetWebFile.XML + ".gz";
00157 
00158         ofile.write(" : <A href='"+JetWebConfig.getHTMLRoot()
00159             +"/"+JetWebConfig.serverName+"-archive/"
00160             +fName
00161             +"'>hepml file</A> : Date ");
00162         Date date = new Date(file.lastModified());
00163         ofile.write(" "+dateFormat.format(date));       
00164         ofile.newLine();
00165 
00166     } catch (IOException e) {
00167         throw new JetWebException(e);
00168     }
00169 
00170     }
00171 }
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 

Generated Wed Jan 17 09:14:27 GMT 2007