Bug #248
closed
id finder needed for metacat
Added by Chad Berkley over 23 years ago.
Updated over 22 years ago.
Description
Metacat needs a utility function so that morpho can query it and find the last
id used by a specific user. right now, if a user goes to another computer, his
id sequence is reset, causing id conflicts when the documents are uploaded.
the <profile>.xml file in morpho needs to be able to be updated with the latest
id that was used in metacat. this should be done dynamically when morpho
starts up. I will also enter a bug for morpho for this.
DONE
Included utility function about gettig the latest docid for a user:
DBUtil.getLastDocid(username).
Required Metacat' parameters:
- action='getlastdocid'
- username
The SQL Statement used:
SELECT docid, rev, date_updated
FROM xml_documents
WHERE user_owner = @username
AND date_updated = (SELECT MAX
FROM xml_documents
WHERE user_owner = @username)
UNION
SELECT docid, rev, date_updated
FROM xml_revisions
WHERE user_owner = @username
AND date_updated = (SELECT MAX
FROM xml_revisions
WHERE user_owner = @username)
ORDER BY date_updated
It appears that Metacat does NOT return the LAST ID (It seems to return the last
id of a dataset document. But there are other documents in a dataset which have
larger ids.) Morpho adds 5 to the numbe returned, but this is not always a good fix.
Need to change this function so that metacat returns the largest id number used
for a particular scope, regardless of which user owns the documents. Thus, we
may need to rename the function to "getMaxIdForScope" or something similar.
The current version of this code in Metacat will work correctly with the current
version of Morpho. The problem was related to accession numbers being assigned
in Morpho in a different order than documents were inserted into Metacat. (The
Metacat code checks insertion times rather than accession numbers.)
Morpho has been changed to insert documents in the same order that accession
numbere are assigned. Also, the next accession id stord in the profile is now
updated when Morpho starts up.
Rewrote the SQL function to select the MAX accession number used for a given
scope. The scope is now passed into Metacat using a "scope" parameter. Renamed
functions to properly reflect that they are selecting the MAX id rather than the
last id. The new SQL algorithm looks like this:
"SELECT docid, rev, acc FROM " +
"( " +
"SELECT docid, rev, acc FROM " +
"(" +
"SELECT docid, rev, " +
"SUBSTR(docid, INSTR(docid, '" + sep + "', 1)+1)+0 acc " +
"FROM xml_documents " +
"WHERE docid LIKE ? " +
"ORDER BY acc DESC " +
") " +
"WHERE rownum = 1 " +
"UNION " +
"SELECT docid, rev, acc FROM " +
"(" +
"SELECT docid, rev, " +
"SUBSTR(docid, INSTR(docid, '" + sep + "', 1)+1)+0 acc " +
"FROM xml_revisions " +
"WHERE docid LIKE ? " +
"ORDER BY acc DESC " +
") " +
"WHERE rownum = 1 " +
") " +
"ORDER BY acc DESC"
);
FIXED with previosuly committed changes.
Original Bugzilla ID was 248
Also available in: Atom
PDF