Revision 2606
Added by Jing Tao about 19 years ago
src/edu/ucsb/nceas/metacat/DBUtil.java | ||
---|---|---|
571 | 571 |
} |
572 | 572 |
return revision+";"+docType; |
573 | 573 |
}//getCurrentRevisionAndDocTypeForGivenDocument |
574 |
|
|
575 |
/** |
|
576 |
* Method to return a rev list in xml_revision for given docid. |
|
577 |
* @param docId |
|
578 |
* @return is a vector which contains Integer object |
|
579 |
* @throws SQLException |
|
580 |
*/ |
|
581 |
public static Vector getRevListFromRevisionTable(String docId) throws SQLException |
|
582 |
{ |
|
583 |
Vector list = new Vector(); |
|
584 |
int rev = 1; |
|
585 |
PreparedStatement pStmt = null; |
|
586 |
DBConnection dbConn = null; |
|
587 |
int serialNumber = -1; |
|
588 |
// get rid of rev |
|
589 |
docId = MetaCatUtil.getDocIdFromString(docId); |
|
590 |
try { |
|
591 |
//check out DBConnection |
|
592 |
dbConn = DBConnectionPool |
|
593 |
.getDBConnection("getRevListFromRevisionTable"); |
|
594 |
serialNumber = dbConn.getCheckOutSerialNumber(); |
|
595 |
|
|
596 |
pStmt = dbConn |
|
597 |
.prepareStatement("SELECT rev FROM xml_revisions WHERE docid='" |
|
598 |
+ docId + "'"); |
|
599 |
pStmt.execute(); |
|
600 |
|
|
601 |
ResultSet rs = pStmt.getResultSet(); |
|
602 |
boolean hasRow = rs.next(); |
|
603 |
while (hasRow) { |
|
604 |
rev = rs.getInt(1); |
|
605 |
MetaCatUtil.debugMessage("rev "+ rev +" is added to list", 20); |
|
606 |
list.add(new Integer(rev)); |
|
607 |
hasRow = rs.next(); |
|
608 |
|
|
609 |
} |
|
610 |
pStmt.close(); |
|
611 |
}//try |
|
612 |
finally { |
|
613 |
try { |
|
614 |
pStmt.close(); |
|
615 |
} catch (Exception ee) { |
|
616 |
MetaCatUtil.debugMessage("Error in DocumentImpl." |
|
617 |
+ "getLatestRevisionNumber: " + ee.getMessage(), 50); |
|
618 |
} finally { |
|
619 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
|
620 |
} |
|
621 |
}//finally |
|
622 |
|
|
623 |
return list; |
|
624 |
}//getLatestRevisionNumber |
|
574 | 625 |
|
575 | 626 |
} |
Also available in: Unified diff
Add method to get revision list in xml_revisions table for a given docid.