Package org.dlese.dpc.repository
Class RecordDataService
java.lang.Object
org.dlese.dpc.repository.RecordDataService
Provides data related to a given collection-level record such as its associated IDs and annotations. This
class is used by class
ItemFileIndexingWriter to insert data into the
index for each record at index creation time.- Version:
- $Id: RecordDataService.java,v 1.58 2010/07/14 00:18:49 jweather Exp $
- Author:
- John Weatherley
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intUse to query within both other and the same collectionstatic intUse to query within a other collectionstatic intUse to query within a the same collection -
Constructor Summary
ConstructorsConstructorDescriptionRecordDataService(String dbUrl, MetadataVocab vocab, String collBaseDir, String annotationPathwaysSchemaUrl) Constructor for a RecordDataService that has access to an MmdRec Query service. -
Method Summary
Modifier and TypeMethodDescriptionvoidCloses the local Query Object, releasing it's resources.voidcloseIdMapperQueryObject(Query queryObject) Closes an IDMapper Query object, releasing its resources.getAccessionStatus(MmdRec[] mmdRecs) Gets the accession status of the given records or, if multiple resources get all statuses separated by spaces.getAnnoFormatsFromResultDocs(ResultDocList annoResultDocs) Gets the annotation formats from the anno result docs.getAnnoPathwaysFromResultDocs(ResultDocList annoResultDocs) Gets all annotation pathways in the given set of DleseAnnoDocReaders, or null if none exist.getAnnoStatusFromResultDocs(ResultDocList annoResultDocs) Gets the annoStatusFromReaders attribute of the RecordDataService objectgetAnnoTypesFromResultDocs(ResultDocList annoResultDocs) Gets all annotation types in the given set of DleseAnnoDocReaders, or null if none exist.String[]getAssociatedIDs(String id, MmdRec[] associatedMmdRecs) Gets the IDs for records that catalog the same resource, not including the ID that is given.MmdRec[]getAssociatedMMDRecs(int queryType, String IDs, String collectionKeys) Gets the associated MMD records for the given IDs, records that catalog the same resource, or null if none exist, using the local Query Object.MmdRec[]getAssociatedMMDRecs(int queryType, String IDs, String collectionKeys, Query qo) Gets the associated MMD records for the given IDs, records that catalog the same resource, or null if none exist, using the given Query Object.Returns the value of collectCollectionID.getCollectionKeysFromResultDocs(ResultDocList collectionResults) Gets all collection keys encoded by Vocab Mgr, for example {06, 08}, for the given records.getCompletedAnnoCollectionKeysFromResultDocs(ResultDocList annoResultDocs) Gets a list of keys, for example {06, 04}, for each of the annotation collections that have at least one status completed record.protected static final StringReturn a string for the current time and date, sutiable for display in log files and output to standout:getDisplayableItemResultDoc(String itemId) Gets the ResultDoc for the given item level metata record id but only if it should be displayed in discovery.getDisplayableItemResultDocs(String[] itemIds) Gets the item result docs for each of the ids listed regardless, returning only those that should be displayed in discovery.getDleseAnnoResultDocs(String[] ids) Gets the DLESEAnno docs that annotate the given ids, or null if none.getFileForId(MmdRec rec) Gets the fileForId attribute of the RecordDataService objectgetFilePathForId(MmdRec rec) Gets the filePathForId attribute of the RecordDataService objectString[]getIdentifiedErrors(MmdRec[] mmdRecs) Gets all errors identified by the ID mapper service for the given records, or null if none exist.Gets a IDMapper Query Object to use ingetMmdRec(String, String, Query)orgetAssociatedMMDRecs(int, String, String, Query).getIndex()Gets the index used by this RecordData service to retrieve data.getItemResultDoc(String itemId) Gets the ResultDoc for the given item-level metata record id regardless of the records status, or null if none exists.getItemResultDocs(String[] itemIds) Gets the item result docs for each of the ids listed regardless of their status.Gets the ID mapper record for the given ID using the local Query Object.Gets the ID mapper record for the given ID using the given Query Object.getVocab()Gets the vocab attribute of the RecordDataService objectstatic booleanhasDRCAnnotation(ResultDocList annoResultDocs) Return true if there is an annotation present that is part of the DRC.static booleanhasDRCItem(ResultDocList itemResultDocs) Return true if there is an item present that is part of the DRC as determined by the items collection.voidInitialize the RecordDataService.voidInitializes the local Query Object.booleanGets the idMapperDisabled attribute of the RecordDataService objectprotected static final voidOutput a line of text to standard out, with datestamp, if debug is set to true.protected static final voidOutput a line of text to error out, with datestamp.voidsetCollectCollectionID(String collectCollectionID) Sets the value of collectCollectionID.static voidsetDebug(boolean db) Sets the debug attribute of the objectvoidupdateVocab(MetadataVocab newVocab) Updates the MetadataVocab being used by this service.
-
Field Details
-
QUERY_OTHER
public static int QUERY_OTHERUse to query within a other collection -
QUERY_SAME
public static int QUERY_SAMEUse to query within a the same collection -
QUERY_BOTH
public static int QUERY_BOTHUse to query within both other and the same collection
-
-
Constructor Details
-
RecordDataService
public RecordDataService(String dbUrl, MetadataVocab vocab, String collBaseDir, String annotationPathwaysSchemaUrl) Constructor for a RecordDataService that has access to an MmdRec Query service.- Parameters:
dbUrl- URL of the database, or use the String "useRandomIds" to generate random associated IDs, or null if not using the Query API.vocab- The MetadataVocab to use, or null if not needed.collBaseDir- Description of the ParameterannotationPathwaysSchemaUrl- URL to the annotation pathways schema- See Also:
-
-
Method Details
-
updateVocab
Updates the MetadataVocab being used by this service.- Parameters:
newVocab- The new MetadataVocab that will be used.
-
init
Initialize the RecordDataService.- Parameters:
rm- The RepositoryManager
-
getIndex
Gets the index used by this RecordData service to retrieve data.- Returns:
- The index.
-
getCollectCollectionID
Returns the value of collectCollectionID.- Returns:
- The collectCollectionID value
-
setCollectCollectionID
Sets the value of collectCollectionID.- Parameters:
collectCollectionID- The value to assign collectCollectionID.
-
getIdMapperQueryObject
Gets a IDMapper Query Object to use ingetMmdRec(String, String, Query)orgetAssociatedMMDRecs(int, String, String, Query). The Query may be used multiple times. After use, the caller must be sure to close the Query using thecloseIdMapperQueryObject(Query).- Returns:
- The a Query Object, or null if unable to obtain
-
closeIdMapperQueryObject
Closes an IDMapper Query object, releasing its resources.- Parameters:
queryObject- The Query Object to close
-
initIdMapper
public void initIdMapper()Initializes the local Query Object. This must be called prior to use over a collection of files. -
closeIdMapper
public void closeIdMapper()Closes the local Query Object, releasing it's resources. This should be called after finished using the idmapper for a collection of files. -
isIdMapperDisabled
public boolean isIdMapperDisabled()Gets the idMapperDisabled attribute of the RecordDataService object- Returns:
- The idMapperDisabled [true | false]
-
getFilePathForId
Gets the filePathForId attribute of the RecordDataService object- Parameters:
rec- Description of the Parameter- Returns:
- The filePathForId value
-
getFileForId
Gets the fileForId attribute of the RecordDataService object- Parameters:
rec- Description of the Parameter- Returns:
- The fileForId value
-
getAssociatedIDs
Gets the IDs for records that catalog the same resource, not including the ID that is given.- Parameters:
id- The id to the item-level record - will be ommitted from the list of associatedIDsassociatedMmdRecs- An array of MmdRecs- Returns:
- The associatedIDs value
-
getIdentifiedErrors
Gets all errors identified by the ID mapper service for the given records, or null if none exist.- Parameters:
mmdRecs- An array of MmdRecords- Returns:
- A String array of IDMapper error codes
-
getAssociatedMMDRecs
Gets the associated MMD records for the given IDs, records that catalog the same resource, or null if none exist, using the given Query Object. Splits the IDs and collectionKeys by spaces and uses the first one.- Parameters:
queryType- Specify to look in other or the same collectionIDs- An ID(s) to an item-level resource, separated by spaces - the first is usedcollectionKeys- The collection keys for the collection of files, for example "dcc" or "comet", separated by spaces - the first is usedqo- The IDMapper Query Object to use- Returns:
- The associated MmdRecs
-
getAssociatedMMDRecs
Gets the associated MMD records for the given IDs, records that catalog the same resource, or null if none exist, using the local Query Object. Splits the IDs and collectionKeys by spaces and uses the first one.- Parameters:
queryType- Specify to look in other or the same collectionIDs- An ID(s) to an item-level resource, separated by spaces.collectionKeys- The collection keys for the collection of files, for example "dcc" or "comet", separated by spaces.- Returns:
- The associated MmdRecs
-
getMmdRec
Gets the ID mapper record for the given ID using the given Query Object.- Parameters:
id- The ID of a given record, for example DLESE-000-000-000-001.collectionKey- The collection in which the given record resides, for example dcc.qo- The Query Object to use- Returns:
- The ID mapper mmdRecord.
-
getMmdRec
Gets the ID mapper record for the given ID using the local Query Object.- Parameters:
id- The ID of a given record, for example DLESE-000-000-000-001.collectionKey- The collection in which the given record resides, for example dcc.- Returns:
- The ID mapper mmdRecord.
-
getAccessionStatus
Gets the accession status of the given records or, if multiple resources get all statuses separated by spaces.- Parameters:
mmdRecs- The MmdRecords- Returns:
- The status value
-
getDisplayableItemResultDoc
Gets the ResultDoc for the given item level metata record id but only if it should be displayed in discovery. Returns null if none exists.- Parameters:
itemId- The ID to a given item-level record.- Returns:
- The ResultDoc for that item or null.
-
getDisplayableItemResultDocs
Gets the item result docs for each of the ids listed regardless, returning only those that should be displayed in discovery.- Parameters:
itemIds- An array of IDs.- Returns:
- The items that matched or null if none.
-
getItemResultDoc
Gets the ResultDoc for the given item-level metata record id regardless of the records status, or null if none exists.- Parameters:
itemId- The ID to a given item-level record.- Returns:
- The ResultDoc for that item.
-
getItemResultDocs
Gets the item result docs for each of the ids listed regardless of their status.- Parameters:
itemIds- An array of IDs.- Returns:
- The items that matched or null if none.
-
getDleseAnnoResultDocs
Gets the DLESEAnno docs that annotate the given ids, or null if none.- Parameters:
ids- Ids for records in the repository.- Returns:
- The matching DLESE anno records, or null if none.
-
getAnnoTypesFromResultDocs
Gets all annotation types in the given set of DleseAnnoDocReaders, or null if none exist.- Parameters:
annoResultDocs- An array of ResultDocs- Returns:
- The annoTypes value or null.
-
getAnnoStatusFromResultDocs
Gets the annoStatusFromReaders attribute of the RecordDataService object- Parameters:
annoResultDocs- An array of ResultDocs- Returns:
- The annoStatusFromReaders value
-
getAnnoFormatsFromResultDocs
Gets the annotation formats from the anno result docs.- Parameters:
annoResultDocs- An array of ResultDocs- Returns:
- The anno formats
-
getCompletedAnnoCollectionKeysFromResultDocs
Gets a list of keys, for example {06, 04}, for each of the annotation collections that have at least one status completed record.- Parameters:
annoResultDocs- An array of ResultDocs of annotation records- Returns:
- A list of annotation collection keys, or null
-
getAnnoPathwaysFromResultDocs
Gets all annotation pathways in the given set of DleseAnnoDocReaders, or null if none exist. Currently, this is not used!- Parameters:
annoResultDocs- An array of ResultDocs- Returns:
- The annoPathways value or null.
-
hasDRCAnnotation
Return true if there is an annotation present that is part of the DRC. The definition of DRC is obtains from the current pathways.xsd schema at the DPC.- Parameters:
annoResultDocs- Annotation records.- Returns:
- True if one or more of the annotations is part of the DRC.
-
hasDRCItem
Return true if there is an item present that is part of the DRC as determined by the items collection.- Parameters:
itemResultDocs- Array of Item result docs.- Returns:
- True if one or more of the items is part of the DRC.
-
getCollectionKeysFromResultDocs
Gets all collection keys encoded by Vocab Mgr, for example {06, 08}, for the given records.- Parameters:
collectionResults- ResultDocs of records- Returns:
- The collection keys or null.
-
getVocab
Gets the vocab attribute of the RecordDataService object- Returns:
- The vocab value
-
getDateStamp
Return a string for the current time and date, sutiable for display in log files and output to standout:- Returns:
- The dateStamp value
-
prtlnErr
Output a line of text to error out, with datestamp.- Parameters:
s- The text that will be output to error out.
-
prtln
Output a line of text to standard out, with datestamp, if debug is set to true.- Parameters:
s- The String that will be output.
-
setDebug
public static void setDebug(boolean db) Sets the debug attribute of the object- Parameters:
db- The new debug value
-