Package edu.ucsb.nceas.metacat
Class DBUtil
java.lang.Object
edu.ucsb.nceas.metacat.DBUtil
A suite of utility classes for querying DB
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
findDataSetDocIdForGivenDocument
(String givenDocId) To a given docid, found a dataset docid which contains the the given docid This will be done by searching xml_relation table If couldn't find, null will be returngetAllDocids
(String scope) get the latest Accession Number from a particular scopegetAllDocidsByType
(String doctype, boolean includeRevs) return all docids with a given doctype on all serversgetAllDocidsByType
(String doctype, boolean includeRevs, int serverLocation) return all docids with a given doctype for a given servergetCurrentRevisionAndDocTypeForGivenDocument
(String givenDocId) Method to get current revision and doctype for a given docid The output will look like "rev;doctype"static int
getLatestRevisionInDocumentTable
(String docIdWithoutRev) Get last revision number from database for a docid If couldn't find an entry, -1 will return The return value is integer because we want compare it to there new onegetMaxDocid
(String scope) get the latest Accession Number from a particular scopestatic int
getMaxRevFromRevisionTable
(String docIdWithoutRev) Method to return max rev number in xml_revision for given docid.getRevListFromRevisionTable
(String docIdWithoutRev) Method to return a rev list in xml_revision for given docid.boolean
return true if the given docid is registered in either the xml_documents or xml_revisions tablestatic void
main routine used for testing.read all doctypes from db connection in XML format select all Public Id from xml_catalog tablereadDTDSchema
(String doctype) read DTD or Schema file from Metacat's XML catalog system
-
Field Details
-
NONEEXIST
public static final int NONEEXIST- See Also:
-
-
Constructor Details
-
DBUtil
public DBUtil()Construct an instance of the utility class
-
-
Method Details
-
main
main routine used for testing.Usage: java DBUtil <-dt|-dg>
-
readDoctypes
read all doctypes from db connection in XML format select all Public Id from xml_catalog table- Throws:
SQLException
-
readDTDSchema
public String readDTDSchema(String doctype) throws SQLException, MalformedURLException, IOException, edu.ucsb.nceas.utilities.PropertyNotFoundException read DTD or Schema file from Metacat's XML catalog system- Throws:
SQLException
MalformedURLException
IOException
edu.ucsb.nceas.utilities.PropertyNotFoundException
-
getMaxDocid
get the latest Accession Number from a particular scope- Throws:
SQLException
-
idExists
return true if the given docid is registered in either the xml_documents or xml_revisions table- Throws:
SQLException
-
getAllDocidsByType
public static Vector<String> getAllDocidsByType(String doctype, boolean includeRevs) throws SQLException return all docids with a given doctype on all servers- Throws:
SQLException
-
getAllDocidsByType
public static Vector<String> getAllDocidsByType(String doctype, boolean includeRevs, int serverLocation) throws SQLException return all docids with a given doctype for a given server- Throws:
SQLException
-
getAllDocids
get the latest Accession Number from a particular scope- Throws:
SQLException
-
findDataSetDocIdForGivenDocument
To a given docid, found a dataset docid which contains the the given docid This will be done by searching xml_relation table If couldn't find, null will be return- Parameters:
givenDocId
- , the docid which we want to find
-
getCurrentRevisionAndDocTypeForGivenDocument
Method to get current revision and doctype for a given docid The output will look like "rev;doctype"- Parameters:
givenDocId
- , the docid which we want- Throws:
SQLException
-
getMaxRevFromRevisionTable
Method to return max rev number in xml_revision for given docid.- Parameters:
docId
-- Returns:
- integer that holds max revision number
- Throws:
SQLException
-
getRevListFromRevisionTable
public static Vector<Integer> getRevListFromRevisionTable(String docIdWithoutRev) throws SQLException Method to return a rev list in xml_revision for given docid.- Parameters:
docId
-- Returns:
- is a vector which contains Integer object
- Throws:
SQLException
-
getLatestRevisionInDocumentTable
Get last revision number from database for a docid If couldn't find an entry, -1 will return The return value is integer because we want compare it to there new one- Parameters:
docid
-. part of Accession Number - Throws:
SQLException
-