Revision 9026
Added by Jing Tao about 10 years ago
src/edu/ucsb/nceas/metacat/IdentifierManager.java | ||
---|---|---|
927 | 927 |
* Get the pid of the head (current) version of objects match the specified sid. |
928 | 928 |
* DataONE defines the latest version as "current" if the object in question has |
929 | 929 |
* a matching SID and no value in the "obsoletedBy" field, regardless if it is "archived" or not. |
930 |
* If we can't find any pid associated with the sid doesn't have a value in obsoletedBy field, |
|
931 |
* the pid associated with the sid which has the max date_uploaded will be returned |
|
930 | 932 |
* @param sid specified sid which should match. |
931 | 933 |
* @return the pid of the head version. The null will be returned if there is no pid found. |
932 | 934 |
* @throws SQLException |
... | ... | |
951 | 953 |
pid = new Identifier(); |
952 | 954 |
pid.setValue(rs.getString(1)); |
953 | 955 |
|
954 |
} |
|
956 |
} else { |
|
957 |
//we don't find any pid associated with the sid doesn't have value in obsoletedBy field. |
|
958 |
//The pid associated with the sid which has the max date_uploaded will be returned. |
|
959 |
sql = "select guid from systemMetadata where series_id = ? and date_uploaded=(select max(date_uploaded) from systemMetadata where series_id = ?)"; |
|
960 |
stmt = dbConn.prepareStatement(sql); |
|
961 |
stmt.setString(1, sid.getValue()); |
|
962 |
stmt.setString(2, sid.getValue()); |
|
963 |
rs = stmt.executeQuery(); |
|
964 |
if(rs.next()) { |
|
965 |
pid = new Identifier(); |
|
966 |
pid.setValue(rs.getString(1)); |
|
967 |
} |
|
968 |
} |
|
955 | 969 |
|
956 | 970 |
} catch (SQLException e) { |
957 | 971 |
logMetacat.error("Error while get the head pid for the sid "+sid.getValue()+" : " |
Also available in: Unified diff
Add the code to get the most recent version of a sid which all pids are obsoleted.