00001 package cedar.jetweb.job; 00002 00003 import java.io.*; 00004 00005 import java.io.InputStreamReader; 00006 00007 import java.util.NoSuchElementException; 00008 import java.util.Vector; 00009 import java.util.Enumeration; 00010 import java.util.Hashtable; 00011 import java.util.HashMap; 00012 import java.util.TreeMap; 00013 import java.util.Iterator; 00014 import java.util.Map; 00015 import java.util.Map.Entry; 00016 import java.text.DecimalFormat; 00017 00018 //import org.apache.commons.io.FileUtils; 00019 00020 import cedar.jetweb.model.*; 00021 00022 //import cedar.jetweb.html.HTMLUtils; 00023 import cedar.jetweb.html.HTMLJobWriter; 00024 00025 import cedar.jetweb.JetWebException; 00026 import cedar.jetweb.JetWebConfig; 00027 00028 import cedar.jetweb.db.DBJobManager; 00029 import cedar.jetweb.db.JetWebDBException; 00030 00031 import cedar.jetweb.batch.SubmitScriptHandler; 00032 00039 public class JobRequest { 00040 00041 00042 // Private variables 00044 private String suggestion; 00045 private String cardName; 00046 private PendingJob pj; 00047 private File submitScript; 00048 private String jobname; 00049 00050 private Model model; 00051 private MCProcessType proc; 00052 00053 private String requestingHost; 00054 public String getRequestingHost(){ return requestingHost;} 00055 00056 00060 public static void main(String[] args) throws JetWebException { 00061 JetWebConfig.init(); 00062 ResultSearchPattern search = new ResultSearchPattern(); 00063 search.setDefaults(); 00064 Model model = new Model(search); 00065 //model.getGeneratorList().add(new Ge); 00066 // model.getPhotonPDFList().add("GRVLO"); 00067 //model.getProtonPDFList().add("CTEQ5"); 00068 00069 model.getPhotonPDFList().add(new PDF(352)); 00070 model.getProtonPDFList().add(new PDF(20470)); 00071 00072 model.dumpParms(); 00073 MCProcessType proc = new MCProcessType(); 00074 JobRequest request = new JobRequest(model,proc,""); 00075 //System.out.println(HTMLUtils.getDescription(request)); 00076 System.out.println(HTMLJobWriter.getDescription(request)); 00077 // File submitScript = request.getSubmitScript(); 00078 // System.out.println(submitScript.getName()); 00079 // request.setJobName("testname"); 00080 00081 // Make the files for this job. 00082 JobUtils.makeCards(request); 00083 String newFilePath = JetWebConfig.jobOutDirName+"/testname"; 00084 JobUtils.makeScript(newFilePath,model.getGenerator()); 00085 00086 JobUtils.submit(request); 00087 // SubmitScriptHandler.make(request); 00088 } 00089 00090 // Getters & Setters 00092 00098 public String getJobName() { 00099 return jobname; 00100 } 00109 public void setJobName() throws JetWebException { 00110 00111 pj = DBJobManager.reserveJobName(suggestion); 00112 jobname = pj.getName(); 00113 00114 if (jobname.equalsIgnoreCase("invalid")){ 00115 throw new JobRequestException("JobRequest has Invalid Job Name"); 00116 } 00117 00118 cardName = JetWebConfig.jobOutDirName+"/"+jobname+".input"; 00119 File test = new File(cardName); 00120 00121 if (test.exists()) { 00122 throw new JobRequestException 00123 ("JobRequest has Invalid Job Name - file with this name already exists:" 00124 +cardName); 00125 } 00126 00127 } 00128 00134 //public boolean isValid(){ return this.valid; } 00135 00141 public void setMCProcessType(MCProcessType inProc){ 00142 proc = inProc; 00143 } 00149 public MCProcessType getMCProcessType(){return proc;} 00150 00156 public Model getModel(){return model;} 00157 00164 public JobRequest(Model inModel, MCProcessType inProc, String rqh) 00165 throws JetWebException { 00166 00167 requestingHost = rqh; 00168 model = inModel; 00169 proc = inProc; 00170 //valid = false; 00171 00172 } 00173 00179 public File getSubmitScript(){ return submitScript; } 00180 00184 public void setSubmitScript(File script){ 00185 submitScript=script; 00186 } 00187 00191 public String getCardName(){ return cardName; } 00192 00193 } 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220
Generated Wed Jan 17 09:14:27 GMT 2007