Package edu.ucsb.nceas.metacat.util
Class DocumentUtil
java.lang.Object
edu.ucsb.nceas.metacat.util.DocumentUtil
A suite of utility classes for the metadata catalog server
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
If the given docid only have one seperter, we need append rev for it.static String
generateDocumentId
(int revision) Create a unique docid for use in inserts and updates using the default prefix from the document.accNumPrefix property.static String
generateDocumentId
(String idPrefix, int revision) Create a unique docid for use in inserts and updates using the prefix that is provided.static String
getAccessionNumberFromEcogridIdentifier
(String identifier) Eocgorid identifier will look like: ecogrid://knb/tao.1.1 The AccessionNumber tao.1.1 will be returned.static String
getContentWithoutSystemMetadata
(String docInfoStr) Get the string WITHOUT the content between the system metadata start and end tagstatic String
getDocIdFromAccessionNumber
(String accessionNumber) This method will get docid from an AccessionNumber.static String
getDocIdFromString
(String str) Utility method to get docid from a given stringstatic int
getRevisionFromAccessionNumber
(String accessionNumber) This method will get revision from an AccessionNumber.static String
Utility method to get version string from a given stringstatic String
getSmartDocId
(String str) This method will call both getDocIdFromString and getDocIdFromAccessionNumber.static String
getSystemMetadataContent
(String docInfoStr) Get the content between the system metadata start and end tagstatic int
Utility method to get version number from a given string
-
Field Details
-
dbAdapter
-
startTag
-
endTag
-
-
Constructor Details
-
DocumentUtil
public DocumentUtil()
-
-
Method Details
-
getAccessionNumberFromEcogridIdentifier
Eocgorid identifier will look like: ecogrid://knb/tao.1.1 The AccessionNumber tao.1.1 will be returned. If the given doesn't contains ecogrid, null will be returned.- Parameters:
identifier
- String- Returns:
- String
-
getDocIdFromString
Utility method to get docid from a given string- Parameters:
string
- , the given string should be these two format: 1) str1.str2 in this case docid= str1.str2 2) str1.str2.str3, in this case docid =str1.str2the
- sperator char
-
getVersionFromString
Utility method to get version number from a given string- Parameters:
string
- , the given string should be these two format: 1) str1.str2(no version) version =-1; 2) str1.str2.str3, in this case version = str3; 3) other, vresion =-2- Throws:
NumberFormatException
-
getRevisionStringFromString
Utility method to get version string from a given string- Parameters:
string
- , the given string should be these two format: 1) str1.str2(no version) version=null; 2) str1.str2.str3, in this case version = str3; 3) other, vresion =null;- Throws:
NumberFormatException
-
appendRev
public static String appendRev(String docid) throws edu.ucsb.nceas.utilities.PropertyNotFoundException, SQLException, McdbDocNotFoundException If the given docid only have one seperter, we need append rev for it. The rev come from xml_documents- Throws:
edu.ucsb.nceas.utilities.PropertyNotFoundException
SQLException
McdbDocNotFoundException
-
getDocIdFromAccessionNumber
This method will get docid from an AccessionNumber. There is no assumption the accessnumber will be str1.str2.str3. It can be more. So we think the docid will be get rid of last part -
getSmartDocId
This method will call both getDocIdFromString and getDocIdFromAccessionNumber. So first, if the string looks str1.str2, the docid will be str1.str2. If the string is str1.str2.str3, the docid will be str1.str2. If the string is str1.str2.str3.str4 or more, the docid will be str1.str2.str3. If the string look like str1, null will be returned -
getRevisionFromAccessionNumber
public static int getRevisionFromAccessionNumber(String accessionNumber) throws NumberFormatException This method will get revision from an AccessionNumber. There is no assumption the accessnumber will be str1.str2.str3. It can be more. So we think the docid will be get rid of last part- Throws:
NumberFormatException
-
generateDocumentId
Create a unique docid for use in inserts and updates using the default prefix from the document.accNumPrefix property. Does not include the 'revision' part of the id if revision is '0', otherwise sets the revision number to 'revision'.- Parameters:
idPrefix
- the prefix to be used to construct the scope portion of the docidrevision
- the integer revision to use for this docid- Returns:
- a String docid based on the current date and time
-
generateDocumentId
Create a unique docid for use in inserts and updates using the prefix that is provided. Does not include the 'revision' part of the id if revision is '0', otherwise sets the revision number to 'revision'.- Parameters:
idPrefix
- the prefix to be used to construct the scope portion of the docidrevision
- the integer revision to use for this docid- Returns:
- a String docid based on the current date and time
-
getSystemMetadataContent
Get the content between the system metadata start and end tag -
getContentWithoutSystemMetadata
Get the string WITHOUT the content between the system metadata start and end tag
-