Definition at line 31 of file DBJobManager.java.
Static Public Member Functions | |
synchronized void | addLogfile (LogFile log) throws JetWebException |
synchronized void | selectFromDBbyName (LogFile log) throws JetWebException |
synchronized boolean | selectFromDB (CutCollection cuts) throws JetWebException |
synchronized boolean | addToDB (CutCollection cuts) throws JetWebException |
synchronized boolean | selectFromDB (Cut cut) throws JetWebException |
synchronized boolean | addToDB (Cut cut) throws JetWebException |
synchronized void | selectFromDB (PendingJob job) throws JetWebException |
synchronized Enumeration< PendingJob > | selectPendingJobs () throws JetWebException |
synchronized PendingJob | reserveJobName (String suggestion) throws JetWebException |
synchronized void | updateStatus (LogFile log) throws JetWebException |
synchronized void | checkStatus (LogFile log) throws JetWebException |
void | removeLogFile (LogFile log) |
synchronized int | countJobs (String hostname) throws JetWebException |
synchronized int | countCompletedJobs (String hostname) throws JetWebException |
synchronized void | selectFromDB (LogFile log) throws JetWebException |
synchronized Vector< LogFile > | getLogFiles (int runSeriesId) throws JetWebException |
synchronized int | getNLogs (int runSeriesId) throws JetWebException |
Static Public Attributes | |
final String | SUCCESS = "Operation Completed Successfully" |
Static Private Member Functions | |
synchronized boolean | fillById (CutCollection cuts) throws SQLException |
synchronized boolean | fillByCuts (CutCollection cuts) throws SQLException, JetWebException |
synchronized boolean | writeCheckedCutCollection (CutCollection cuts) throws SQLException, JetWebException |
synchronized boolean | fillById (Cut cut) throws SQLException |
synchronized boolean | fillByValue (Cut cut) throws SQLException |
synchronized void | writeCheckedCut (Cut cut) throws SQLException |
String | selectNearestCut (Cut cut) |
void | fillLog (ResultSet rs, LogFile log) throws SQLException, JetWebException |
|
Adds new logfile record to the database
Definition at line 45 of file DBJobManager.java. 00046 { 00047 String ins = ""; 00048 00049 try { 00050 Statement stmt = DBConfig.getConnection().createStatement(); 00051 00052 //add the CutCollection for this logfile to the DB 00053 00054 log.getGenerator().getCutCollection().store(); 00055 00056 // add a row to the logfile table. 00057 if (log.getId() > 0) { 00058 ins = "UPDATE logfile SET file='" + log.getFile() + 00059 "',runseries_id=" + log.getRunSeries().getId() + 00060 ",status=" + log.getStatus() + 00061 ",lumi=" + log.getLumi() + 00062 ", cross_section=" +log.getCrossSection() + 00063 ",cut_collection_id=" + 00064 log.getGenerator().getCutCollection().getId()+ 00065 " WHERE log_id=" + log.getId(); 00066 } else { 00067 00068 String select = "SELECT MAX(log_id) FROM logfile"; 00069 ResultSet rs = stmt.executeQuery(select); 00070 00071 int newId = 1; 00072 00073 while(rs.next()){ 00074 newId = rs.getInt(1); 00075 ++newId; 00076 } 00077 00078 log.setId(newId); 00079 00080 ins = "INSERT INTO logfile " + 00081 "(log_id, " + 00082 "file, " + 00083 "runseries_id, " + 00084 "status, " + 00085 "lumi, " + 00086 "cross_section," + 00087 "cut_collection_id)" 00088 + "values(" + 00089 log.getId() + ", '" + 00090 log.getFile() + "'," + 00091 log.getRunSeries().getId() + "," + 00092 log.getStatus() + "," + 00093 log.getLumi() + "," + 00094 log.getCrossSection() + "," + 00095 log.getGenerator().getCutCollection().getId() + 00096 ")"; 00097 } 00098 00099 int rowsChanged = stmt.executeUpdate(ins); 00100 stmt.close(); 00101 } catch (SQLException E) { 00102 System.out.println("SQLException: " + E.getMessage()); 00103 System.out.println("SQLState: " + E.getSQLState()); 00104 System.out.println("VendorError: " + E.getErrorCode()); 00105 log.setStatus(LogFile.ERROR); 00106 throw new JetWebDBException(E, ins, "LogfileId:" + log.getId()); 00107 } 00108 }
|
|
Definition at line 441 of file DBJobManager.java. 00442 { 00443 boolean hasId = cut.getId() > 0; 00444 boolean hasName = !cut.getName().equals(""); 00445 boolean hasValue = !(cut.getValue()==null); 00446 00447 try{ 00448 00449 if(hasId){ 00450 //check that a cut with this Id doesn't already exist. 00451 //If it does already exist, do nothing 00452 if(fillById(cut)) return false; 00453 } 00454 00455 if(hasName&&hasValue){ 00456 00457 if(fillByValue(cut)) return false; 00458 00459 // if we get here then the cut has a value and a name 00460 // and is not present in the DB 00461 00462 writeCheckedCut(cut); 00463 return true; 00464 } 00465 00466 }catch(SQLException err){ 00467 throw new JetWebException(err); 00468 } 00469 00470 return false; 00471 }
|
|
Definition at line 182 of file DBJobManager.java. 00183 { 00184 00185 boolean hasId = (cuts.getId()>0); 00186 boolean hasCuts = (cuts.getCuts().size()!=0); 00187 00188 try{ 00189 //If the collection has an id that is already present in the DB 00190 // then fill the collection object from the DB and return false 00191 if(hasId){ 00192 00193 if(fillById(cuts)) return false; 00194 00195 } 00196 00197 if(hasCuts){ 00198 // if the same collection of cuts already exists in the 00199 // DB then just fill the Id and return false 00200 00201 if(fillByCuts(cuts)) return false; 00202 00203 return writeCheckedCutCollection(cuts); 00204 } 00205 00206 }catch(SQLException err){ 00207 throw new JetWebException(err); 00208 } 00209 00210 return false; 00211 }
|
|
Checks whether this logfile is already in the DB, setting the status field on the logfile object accordingly.
Definition at line 715 of file DBJobManager.java. 00716 { 00717 00718 JetWebFile lf = log.getFile(); 00719 if(lf == null) return; 00720 00721 String query = "SELECT status FROM logfile WHERE file LIKE '%" + 00722 lf + "%'"; 00723 00724 //String query = "SELECT status FROM logfile WHERE file='" + 00725 // lf.getPath() + "'"; 00726 00727 try { 00728 // See if the file is in there. 00729 Statement stmt = DBConfig.getConnection().createStatement(); 00730 ResultSet rs = stmt.executeQuery(query); 00731 00732 while (rs.next()) { 00733 00734 Integer dbStatus = rs.getInt("status"); 00735 00736 dbStatus = (dbStatus.equals(LogFile.SUBMITTED)&& 00737 log.hasAidaFile())? LogFile.RUN: dbStatus; 00738 00739 00740 log.setStatus(dbStatus); 00741 00742 } 00743 00744 // Finish up & return. 00745 rs.close(); 00746 stmt.close(); 00747 } catch (SQLException E) { 00748 System.out.println("DBFitManager.checkStatus"); 00749 System.out.println("SQLException: " + E.getMessage()); 00750 System.out.println("SQLState: " + E.getSQLState()); 00751 System.out.println("VendorError: " + E.getErrorCode()); 00752 throw new JetWebDBException(E, query, "LogFile:" + log.getId()); 00753 } 00754 }
|
|
Counts completed jobs in table "logfile" with given value of field "host".
Definition at line 818 of file DBJobManager.java. 00819 { 00820 String query = "SELECT COUNT(log_id) count_rows FROM logfile WHERE status=1" + 00821 " AND host='" + hostname + "'"; 00822 int nJobs = 0; 00823 00824 try { 00825 // First see if the file is in there. 00826 Statement stmt = DBConfig.getConnection().createStatement(); 00827 ResultSet rs = stmt.executeQuery(query); 00828 rs.next(); 00829 nJobs = rs.getInt("count_rows"); 00830 00831 // Finish up & return. 00832 rs.close(); 00833 stmt.close(); 00834 } catch (SQLException E) { 00835 System.out.println("DBFitManager.countCompletedJobs"); 00836 System.out.println("SQLException: " + E.getMessage()); 00837 System.out.println("SQLState: " + E.getSQLState()); 00838 System.out.println("VendorError: " + E.getErrorCode()); 00839 throw new JetWebDBException(E, query, "Error counting completed jobs"); 00840 } 00841 00842 return nJobs; 00843 }
|
|
Counts jobs in table "logfile" with given value of field "host".
Definition at line 784 of file DBJobManager.java. 00785 { 00786 String query = "SELECT COUNT(log_id) count_rows FROM logfile WHERE host='" + hostname + 00787 "'"; 00788 int nJobs = 0; 00789 00790 try { 00791 // First see if the file is in there. 00792 Statement stmt = DBConfig.getConnection().createStatement(); 00793 ResultSet rs = stmt.executeQuery(query); 00794 rs.next(); 00795 nJobs = rs.getInt("count_rows"); 00796 00797 // Finish up & return. 00798 rs.close(); 00799 stmt.close(); 00800 } catch (SQLException E) { 00801 System.out.println("DBFitManager.countJobs"); 00802 System.out.println("SQLException: " + E.getMessage()); 00803 System.out.println("SQLState: " + E.getSQLState()); 00804 System.out.println("VendorError: " + E.getErrorCode()); 00805 throw new JetWebDBException(E, query, "Error counting jobs"); 00806 } 00807 00808 return nJobs; 00809 }
|
|
Matches a CutCollection to a CutCollection in the DB using the Cut Ids (not the CutCollection Id) Definition at line 247 of file DBJobManager.java. 00248 { 00249 00250 Vector<Integer> foundIds = new Vector<Integer>(); 00251 Vector<Integer> cutIds = new Vector<Integer>(); 00252 00253 Statement stmt = DBConfig.getConnection().createStatement(); 00254 ResultSet rs; 00255 00256 boolean firstCut = true; 00257 //loop over all cuts 00258 for(Cut cut: cuts.getCuts()){ 00259 00260 Integer id = cut.getId(); 00261 //retrieve the cut id if necessary (and possible) 00262 if(id<0){ 00263 cut.retrieve(); 00264 id=cut.getId(); 00265 if(id<0) return false; 00266 00267 } 00268 cutIds.add(id); 00269 //get all CutCollections that contain that cut 00270 00271 String query = 00272 "SELECT cut_collection_id FROM cut_collection WHERE cut_id=" + 00273 id; 00274 00275 rs = stmt.executeQuery(query); 00276 Vector<Integer> newIds = new Vector<Integer>(); 00277 while(rs.next()){ 00278 newIds.add(rs.getInt(1)); 00279 } 00280 00281 // Find the list of CutCollections that contains the current cut 00282 // and all previous cuts (unless this is the first cut) 00283 Vector<Integer> tmpIds = new Vector<Integer>(); 00284 if(firstCut){ 00285 tmpIds = newIds; 00286 firstCut = false; 00287 }else{ 00288 00289 for(Integer i: newIds){ 00290 if(foundIds.contains(i)){ 00291 tmpIds.add(i); 00292 } 00293 } 00294 00295 } 00296 //if no CutCollection contains all previous cuts then there is no 00297 //matching CutCollection in the DB 00298 if(tmpIds.size()==0) return false; 00299 00300 foundIds = tmpIds; 00301 00302 } 00303 00304 //Of the found CutCollections, look for one that matches exactly 00305 //i.e. contains ^only^ this set of cuts 00306 00307 for(Integer Id: foundIds){ 00308 00309 String select = 00310 "SELECT cut_id FROM cut_collection WHERE cut_collection_id=" + 00311 Id; 00312 00313 rs = stmt.executeQuery(select); 00314 boolean carryOn = true; 00315 Integer numCuts = 0; 00316 while(rs.next() && carryOn){ 00317 if(!cutIds.contains(new Integer(rs.getInt(1)))) carryOn = false; 00318 ++numCuts; 00319 } 00320 00321 if(carryOn && numCuts==cutIds.size()){ 00322 cuts.setId(Id); 00323 return true; 00324 } 00325 } 00326 00327 return false; 00328 }
|
|
Fills a cut based on the Id of that cut (which must already be there) returns true if filled succesfully Definition at line 478 of file DBJobManager.java. 00479 { 00480 00481 String select = "SELECT * FROM cut WHERE cut_id="+cut.getId(); 00482 00483 Statement stmt = DBConfig.getConnection().createStatement(); 00484 ResultSet rs = stmt.executeQuery(select); 00485 00486 if(!rs.next()) return false; 00487 00488 cut.setValue(rs.getDouble("value")); 00489 cut.setName(rs.getString("name")); 00490 00491 return true; 00492 }
|
|
Definition at line 213 of file DBJobManager.java. 00214 { 00215 00216 Integer id = new Integer(cuts.getId()); 00217 00218 String select = 00219 "SELECT cut_id FROM cut_collection WHERE cut_collection_id=" + 00220 id; 00221 00222 Statement stmt = DBConfig.getConnection().createStatement(); 00223 ResultSet rs = stmt.executeQuery(select); 00224 00225 cuts.clear(); 00226 00227 boolean filled = false; 00228 00229 while(rs.next()){ 00230 filled = true; 00231 Cut cut = new Cut(rs.getInt(1)); 00232 cuts.addCut(cut); 00233 } 00234 00235 //reset the CutCollection Id because adding cuts sets it to default 00236 00237 // cuts.setId(id); 00238 00239 return filled; 00240 }
|
|
Fills a cut's Id based on the value and name of that cut. returns true if filled successfully. Definition at line 499 of file DBJobManager.java. 00500 { 00501 String select = selectNearestCut(cut); 00502 00503 Statement stmt = DBConfig.getConnection().createStatement(); 00504 ResultSet rs = stmt.executeQuery(select); 00505 if(!rs.next())return false; 00506 00507 if(!Match.compareDouble(cut.getValue(), rs.getDouble("value"))) 00508 return false; 00509 00510 cut.setId(rs.getInt("cut_id")); 00511 cut.setValue(rs.getDouble("value")); 00512 cut.setName(rs.getString("name")); 00513 00514 return true; 00515 }
|
|
Definition at line 877 of file DBJobManager.java. References JetWebFile.XML. 00878 { 00879 00880 int rsid = rs.getInt("runseries_id"); 00881 int status = rs.getInt("status"); 00882 Double cs = rs.getDouble("cross_section"); 00883 00884 //if(rsid!=0)log.setRunSeriesId(rsid); 00885 // If the LogFile status is reserved then no info has been filled 00886 // apart from the file name and log id 00887 if(status!=LogFile.RESERVED&&rsid!=0) log.setRunSeriesId(rsid); 00888 00889 //log.setRunSeriesId(rs.getInt("runseries_id")); 00890 log.setStatus(status); 00891 log.setId(rs.getInt("log_id")); 00892 log.setCrossSection(cs); 00893 String fName = rs.getString("file"); 00894 if(!(fName.endsWith(JetWebFile.XML + ".gz") && 00895 fName.endsWith(JetWebFile.XML))){ 00896 fName = fName + JetWebFile.XML; 00897 } 00898 00899 JetWebFile testFile = 00900 new JetWebFile(fName); 00901 00902 if(!testFile.exists()){ 00903 System.out.println("DBJobManager: could not find file - using " + 00904 testFile); 00905 } 00906 00907 log.setFile(testFile); 00908 }
|
|
Returns Vector of LogFiles associated with this runSeries.
Definition at line 918 of file DBJobManager.java. References LogFile.retrieve(). 00919 { 00920 Vector<LogFile> logs = new Vector<LogFile>(); 00921 String findLogs = "SELECT log_id FROM logfile WHERE runseries_id=" + runSeriesId; 00922 00923 try { 00924 Statement stmt = DBConfig.getConnection().createStatement(); 00925 ResultSet rs = stmt.executeQuery(findLogs); 00926 00927 while (rs.next()) { 00928 LogFile log = new LogFile(rs.getInt("log_id")); 00929 log.retrieve(); 00930 logs.add(log); 00931 } 00932 rs.close(); 00933 stmt.close(); 00934 } catch (SQLException e) { 00935 System.out.println("Error reading logfile table " + e); 00936 throw new JetWebDBException(e, findLogs, "RunseriesId:" + runSeriesId); 00937 } 00938 00939 return logs; 00940 }
|
|
Counts logfiles associated with this parameter set.
Definition at line 949 of file DBJobManager.java. 00950 { 00951 String findLogs = "SELECT COUNT(log_id) count_logs FROM logfile WHERE runseries_id=" + 00952 runSeriesId; 00953 00954 //System.out.println(findLogs); 00955 int n = 0; 00956 00957 try { 00958 Statement stmt = DBConfig.getConnection().createStatement(); 00959 ResultSet rs = stmt.executeQuery(findLogs); 00960 rs.next(); 00961 n = rs.getInt("count_logs"); 00962 rs.close(); 00963 stmt.close(); 00964 } catch (SQLException e) { 00965 System.out.println("Error reading logfile table " + e); 00966 throw new JetWebDBException(e, findLogs, "runseriesId:" + runSeriesId); 00967 } 00968 00969 return n; 00970 }
|
|
Remove this logfile row from the table. Definition at line 759 of file DBJobManager.java. References LogFile.getFile(). 00759 { 00760 String name = log.getFile().getPath(); 00761 System.out.println("Removing logfile: " + name + " from table"); 00762 00763 String del = "delete from logfile where file like '%" + 00764 log.getFile() + "%'"; 00765 00766 //String del = "delete from logfile where file='" + name + "'"; 00767 00768 try { 00769 Statement stmt = DBConfig.getConnection().createStatement(); 00770 stmt.executeUpdate(del); 00771 stmt.close(); 00772 } catch (SQLException e) { 00773 System.out.println("DBFitManager: Error executing " + del); 00774 } 00775 }
|
|
Gives a new unique jobname by prepending the logfile number to the suggested stem. Also reserves the place in the logfile table.
Definition at line 626 of file DBJobManager.java. 00627 { 00628 String name = "invalid"; 00629 int id = 0; 00630 String query = "SELECT MAX(log_id) FROM logfile"; 00631 00632 try { 00633 Statement stmt = DBConfig.getConnection().createStatement(); 00634 ResultSet rs = stmt.executeQuery(query); 00635 00636 while (rs.next()) { 00637 id = rs.getInt(1); 00638 id++; 00639 } 00640 00641 //now we do a check for existing files with a name corresponding 00642 //to the found log_id. Keep incrementing the name until we 00643 //find a free one 00644 boolean free = false; 00645 DecimalFormat form = new DecimalFormat("00000000000"); 00646 while(!free){ 00647 name = "n" + form.format(id); 00648 JetWebFile testFile = new JetWebFile(name, ".input"); 00649 if(testFile.exists()){ 00650 ++id; 00651 }else{ 00652 free = true; 00653 } 00654 } 00655 00656 if (id == 0) { 00657 System.out.println 00658 ("ResultManager Error allocating Id to " + suggestion); 00659 00660 return null; 00661 } 00662 00663 String ins = 00664 "INSERT INTO logfile (log_id,file,runseries_id,status,host) " + 00665 "VALUES (" + 00666 id + ",'" + 00667 name + 00668 "',0," + 00669 LogFile.RESERVED + ",'" + 00670 SubmitScriptHandler.BATCHFACILITY + 00671 "')"; 00672 00673 int itmp = stmt.executeUpdate(ins); 00674 rs.close(); 00675 stmt.close(); 00676 } catch (SQLException E) { 00677 System.out.println("ResultManager.getJobName"); 00678 System.out.println("SQLException: " + E.getMessage()); 00679 System.out.println("SQLState: " + E.getSQLState()); 00680 System.out.println("VendorError: " + E.getErrorCode()); 00681 throw new JetWebDBException(E, query, "suggestion:" + suggestion); 00682 } 00683 00684 return new PendingJob(id); 00685 }
|
|
Populate the given LogFile from the DB. This method assumes the logId is already set.
Definition at line 852 of file DBJobManager.java. 00853 { 00854 String findLog = "SELECT * FROM logfile WHERE log_id=" + log.getId(); 00855 int logId = log.getId(); 00856 00857 try { 00858 Statement stmt = DBConfig.getConnection().createStatement(); 00859 ResultSet rs = stmt.executeQuery(findLog); 00860 00861 if (rs.next()) { 00862 fillLog(rs, log); 00863 } else { 00864 System.out.println("No LogFile found with ID=" + logId); 00865 throw new JetWebDBException(findLog, "logId:" + logId); 00866 } 00867 rs.close(); 00868 stmt.close(); 00869 } catch (SQLException e) { 00870 System.out.println("Error reading logfile table " + e); 00871 throw new JetWebDBException(e, findLog, "logId:" + logId); 00872 } 00873 00874 return; 00875 }
|
|
Select a PendingJob from the DB.
Definition at line 557 of file DBJobManager.java. References Cut.setName(). 00558 { 00559 String query = "SELECT * FROM logfile WHERE log_id=" + job.getLogId(); 00560 00561 try { 00562 Statement stmt = DBConfig.getConnection().createStatement(); 00563 ResultSet rs = stmt.executeQuery(query); 00564 00565 rs.next(); 00566 00567 if (rs.getInt("status") == 0) { 00568 job.setValid(true); 00569 } else { 00570 job.setValid(false); 00571 } 00572 00573 job.setName(rs.getString("file")); 00574 job.setDate(rs.getTimestamp("time")); 00575 job.setRunSeriesId(rs.getInt("runseries_id")); 00576 00577 job.setScriptName("unknown"); 00578 rs.close(); 00579 stmt.close(); 00580 } catch (SQLException e) { 00581 System.out.println("DB access error in selectFromDB for PendingJob" + e); 00582 throw new JetWebDBException(e, query, "PendingJob logId:" + job.getLogId()); 00583 } 00584 }
|
|
Populate a Cut object from the database. If no entry matches the Cut Id or the Cut Name+value Then store the Cut under a new Id Definition at line 378 of file DBJobManager.java. 00379 { 00380 String select; 00381 int id = cut.getId(); 00382 00383 if(id > 0){ 00384 select = "SELECT * FROM cut WHERE cut_id="+id; 00385 }else{ 00386 //select the cut with the same name and nearest value 00387 //select = "SELECT * FROM cut where name="+cut.getName()+ 00388 //" AND ABS(value-" + cut.getValue() + 00389 //")=MIN(ABS(value-" + cut.getValue() + "))"; 00390 select = selectNearestCut(cut); 00391 } 00392 00393 try{ 00394 00395 Statement stmt = DBConfig.getConnection().createStatement(); 00396 ResultSet rs = stmt.executeQuery(select); 00397 00398 //if(rs.isAfterLast()){ 00399 if(!rs.next()){ 00400 //result set contains no rows - Cut is not in database 00401 //if cut name and value present, store it 00402 00403 if(cut.getName().equals("") || 00404 cut.getValue()==null){ 00405 return false; 00406 } 00407 return cut.store(); 00408 } 00409 00410 if(id>0){ 00411 //rs.next(); 00412 cut.setValue(rs.getDouble("value")); 00413 cut.setName(rs.getString("name")); 00414 return true; 00415 }else{ 00416 //need to check value in result set matches value of cut 00417 rs.next(); 00418 Double value = rs.getDouble("value"); 00419 00420 if(Match.compareDouble(value, cut.getValue())){ 00421 cut.setId(rs.getInt("cut_id")); 00422 return true; 00423 } 00424 00425 //if we get here then there is no row in the DB matching 00426 //that value, but there is a cut with that name. 00427 00428 if(cut.getValue()!=null&& 00429 !cut.getName().equals("")){ 00430 return cut.store(); 00431 } 00432 00433 } 00434 00435 }catch(SQLException err){ 00436 00437 } 00438 return false; 00439 }
|
|
Populate a CutCollection object from the DB If no entry matches the CutCollection id or the list of Cuts Then store this collection
Definition at line 160 of file DBJobManager.java. 00161 { 00162 00163 try{ 00164 if(cuts.getIdDontRetrieve()>0){ 00165 if(fillById(cuts)) return true; 00166 } 00167 00168 if(cuts.getCuts().size()!=0){ 00169 if(fillByCuts(cuts)) return true; 00170 00171 // if we get here then there are some cuts in the collection 00172 // but they do not match any collection in the DB 00173 00174 return false; 00175 } 00176 }catch(SQLException err){ 00177 throw new JetWebException(err); 00178 } 00179 return false; 00180 }
|
|
Fills runseriesId, status and logId of the input logfile. The only data which needs to be filled in the LogFile before this is the File itself.
Definition at line 118 of file DBJobManager.java. 00119 { 00120 00121 String query = "SELECT * from logfile where file like '%" + 00122 log.getFile() + "%'"; 00123 00124 try { 00125 // First see if the file is in there. 00126 Statement stmt = DBConfig.getConnection().createStatement(); 00127 ResultSet rs = stmt.executeQuery(query); 00128 00129 if (rs.next()) { 00130 System.out.println 00131 ("DBJobManager: found logfile in DB matching file " + 00132 log.getFile()); 00133 // Read from DB to get runseries id from logfile table. 00134 fillLog(rs, log); 00135 }else{ 00136 System.out.println 00137 ("DBJobManager: no file in DB found matching " + 00138 log.getFile()); 00139 } 00140 00141 // Finish up & return. 00142 rs.close(); 00143 stmt.close(); 00144 } catch (SQLException E) { 00145 System.out.println("DBFitManager.fillRunSeriesId"); 00146 System.out.println("SQLException: " + E.getMessage()); 00147 System.out.println("SQLState: " + E.getSQLState()); 00148 System.out.println("VendorError: " + E.getErrorCode()); 00149 throw new JetWebDBException(E, query, "LogfileId:" + log.getId()); 00150 } 00151 }
|
|
Definition at line 544 of file DBJobManager.java. References Cut.getName(), and Cut.getValue(). 00544 { 00545 00546 return "SELECT * FROM cut where name='" + cut.getName() + 00547 "' AND ABS(value-" + cut.getValue() + 00548 ")=(SELECT MIN(ABS(value-" + cut.getValue() + ")) FROM cut)"; 00549 }
|
|
Retrieves a list of all pending jobs from the database
Definition at line 592 of file DBJobManager.java. References PendingJob.isValid(). 00593 { 00594 Vector<PendingJob> jobs = new Vector<PendingJob>(); 00595 String query = "SELECT log_id FROM logfile WHERE status=0"; 00596 00597 try { 00598 Statement stmt = DBConfig.getConnection().createStatement(); 00599 ResultSet rs = stmt.executeQuery(query); 00600 00601 while (rs.next()) { 00602 PendingJob pj = new PendingJob(rs.getInt("log_id")); 00603 00604 if (pj.isValid()) { 00605 jobs.add(pj); 00606 } 00607 } 00608 rs.close(); 00609 stmt.close(); 00610 } catch (SQLException e) { 00611 System.out.println("DB access error in selectPendingJobs" + e); 00612 throw new JetWebDBException(e, query, ""); 00613 } 00614 00615 return jobs.elements(); 00616 }
|
|
Updates the status in the DB to match the status of the log file Definition at line 691 of file DBJobManager.java. References Cut.getId(). 00692 { 00693 00694 String update = 00695 "UPDATE logfile " + 00696 " SET status=" +log.getStatus() + 00697 " WHERE log_id="+log.getId(); 00698 00699 try{ 00700 Statement stmt = DBConfig.getConnection().createStatement(); 00701 stmt.executeUpdate(update); 00702 }catch(SQLException err){ 00703 throw new JetWebException(err); 00704 } 00705 return; 00706 }
|
|
Writes a cut that is already known to be safe to write. Definition at line 521 of file DBJobManager.java. 00522 { 00523 00524 Statement stmt = DBConfig.getConnection().createStatement(); 00525 ResultSet rs = stmt.executeQuery("SELECT MAX(cut_id) FROM cut"); 00526 int newId = 1; 00527 if(rs.next()){ 00528 newId = rs.getInt(1); 00529 ++newId; 00530 } 00531 00532 cut.setId(newId); 00533 00534 String insert = "INSERT INTO cut(cut_id, name, value)VALUES("+ 00535 cut.getId() + ",'" + 00536 cut.getName() + "', " + 00537 cut.getValue() +")"; 00538 00539 stmt.executeUpdate(insert); 00540 00541 return; 00542 }
|
|
Definition at line 331 of file DBJobManager.java. 00332 { 00333 00334 Statement stmt = DBConfig.getConnection().createStatement(); 00335 ResultSet rs = stmt.executeQuery 00336 ("SELECT MAX(cut_collection_id) FROM cut_collection"); 00337 int newId = 1; 00338 if(rs.next()){ 00339 newId = rs.getInt(1); 00340 ++newId; 00341 } 00342 00343 if(cuts.getId()<newId) cuts.setId(newId); 00344 00345 Vector<String> inserts = new Vector<String>(); 00346 00347 for(Cut cut:cuts.getCuts()){ 00348 00349 Integer Id = cut.getId(); 00350 00351 // If any of the cuts in the collection has no id 00352 // then we can't write it to the DB 00353 if(Id<0){ 00354 cut.retrieve(); 00355 Id = cut.getId(); 00356 if(Id<0) return false; 00357 } 00358 00359 inserts.add 00360 ("INSERT INTO cut_collection(cut_collection_id, cut_id)VALUES("+ 00361 cuts.getId() + ", " + 00362 cut.getId() + ")"); 00363 } 00364 00365 for(String insert:inserts){ 00366 stmt.executeUpdate(insert); 00367 } 00368 00369 return true; 00370 }
|
|
constant to signify successful completion of a DB Fit operation. Definition at line 35 of file DBJobManager.java. |
Generated Wed Jan 17 09:14:27 GMT 2007