DLESE Tools
v1.2

org.dlese.dpc.repository
Class RecordDataService

java.lang.Object
  extended byorg.dlese.dpc.repository.RecordDataService

public class RecordDataService
extends Object

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.

Author:
John Weatherley
See Also:
RecordData, Query

Constructor Summary
RecordDataService(String dbUrl, MetadataVocab vocab, String collBaseDir, String annotationPathwaysSchemaUrl)
          Constructor for a RecordDataService that has access to an MmdRecord Query service.
 
Method Summary
 void closeIdMapper()
          Closes the Query API after use, releasing it's memory.
 String getAccessionStatus(String IDs, String collectionKeys)
          Gets the accession status of the given resource or, if multiple resources get all statuses separated by spaces.
 ArrayList getAnnoPathwaysFromResultDocs(ResultDoc[] annoResultDocs)
          Gets all annotation pathways in the given set of DleseAnnoDocReaders, or null if none exist.
 ArrayList getAnnoStatusFromResultDocs(ResultDoc[] annoResultDocs)
          Gets the annoStatusFromReaders attribute of the RecordDataService object
 SimpleLuceneIndex getAnnotationsIndex()
          Gets the annotationssIndex attribute of the RecordDataService object
 ArrayList getAnnoTypesFromResultDocs(ResultDoc[] annoResultDocs)
          Gets all annotation types in the given set of DleseAnnoDocReaders, or null if none exist.
 String[] getAssociatedCollections(String ID, String collectionKey)
          Gets an array of collection keys for collections that also catalog this same resource.
 String[] getAssociatedIDs(String IDs, String collectionKeys)
          Gets the associatedIDs for the given IDs, records that catalog the same resource, or null if none exist.
 MmdRecord[] getAssociatedMMDRecs(String IDs, String collectionKeys)
          Gets the associatedIDs for the given IDs, records that catalog the same resource, or null if none exist.
 ArrayList getCollectionKeysFromResultDocs(ResultDoc[] collectionResults)
          Gets all collection keys for the given documents.
protected static String getDateStamp()
          Return a string for the current time and date, sutiable for display in log files and output to standout:
 ResultDoc getDisplayableItemResultDoc(String itemId)
          Gets the ResultDoc for the given item-level metata record id but only if it should be displayed in discovery.
 ResultDoc[] getDisplayableItemResultDocs(String[] itemIds)
          Gets the item result docs for each of the ids listed regardless, returning only those that should be displayed in discovery.
 ResultDoc[] getDleseAnnoResultDocs(String[] ids)
          Gets the dleseAnnoResultDocs attribute of the RecordDataService object
 File getFileForId(MmdRecord rec)
          Gets the fileForId attribute of the RecordDataService object
 String getFilePathForId(MmdRecord rec)
          Gets the filePathForId attribute of the RecordDataService object
 String[] getIdentifiedErrors(String IDs, String collectionKeys)
          Gets all errors identified by the ID mapper service for the given IDs, or null if none exist.
 ResultDoc getItemResultDoc(String itemId)
          Gets the ResultDoc for the given item-level metata record id regardless of the records status, or null if none exists.
 ResultDoc[] getItemResultDocs(String[] itemIds)
          Gets the item result docs for each of the ids listed regardless of their status.
 SimpleLuceneIndex getitmesIndex()
          Gets the itmesIndex attribute of the RecordDataService object
 MmdRecord getMmdRecord(String id, String collectionKey)
          Gets the ID mapper record for the given ID.
 MetadataVocab getVocab()
          Gets the vocab attribute of the RecordDataService object
static boolean hasDRCAnnotation(ResultDoc[] annoResultDocs)
          Return true if there is an annotation present that is part of the DRC.
 void init(SimpleLuceneIndex itmesIndex, SimpleLuceneIndex annotationsIndex, RepositoryManager rm)
          Initialize the RecordDataService.
 void initIdMapper(String metadataFormat)
          Initializes the Query service.
protected static void prtln(String s)
          Output a line of text to standard out, with datestamp, if debug is set to true.
protected static void prtlnErr(String s)
          Output a line of text to error out, with datestamp.
static void setDebug(boolean db)
          Sets the debug attribute of the object
 void updateVocab(MetadataVocab newVocab)
          Updates the MetadataVocab being used by this service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecordDataService

public RecordDataService(String dbUrl,
                         MetadataVocab vocab,
                         String collBaseDir,
                         String annotationPathwaysSchemaUrl)
Constructor for a RecordDataService that has access to an MmdRecord 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 Parameter
annotationPathwaysSchemaUrl - DESCRIPTION
See Also:
Query
Method Detail

updateVocab

public void updateVocab(MetadataVocab newVocab)
Updates the MetadataVocab being used by this service.

Parameters:
newVocab - The new MetadataVocab that will be used.

init

public void init(SimpleLuceneIndex itmesIndex,
                 SimpleLuceneIndex annotationsIndex,
                 RepositoryManager rm)
Initialize the RecordDataService.

Parameters:
itmesIndex - The index where the collections reside.
annotationsIndex - The index where the annotations reside.
rm - DESCRIPTION

initIdMapper

public void initIdMapper(String metadataFormat)
                  throws MmdException
Initializes the Query service. This must be called prior to use over a collection of files

Parameters:
metadataFormat - The metadataFormat of the files that will be searched for associated IDs.
Throws:
MmdException - Description of the Exception

closeIdMapper

public void closeIdMapper()
Closes the Query API after use, releasing it's memory. This should be called after finished using the idmapper for a collection of files.


getFilePathForId

public String getFilePathForId(MmdRecord rec)
Gets the filePathForId attribute of the RecordDataService object

Parameters:
rec - Description of the Parameter
Returns:
The filePathForId value

getFileForId

public File getFileForId(MmdRecord rec)
Gets the fileForId attribute of the RecordDataService object

Parameters:
rec - Description of the Parameter
Returns:
The fileForId value

getAssociatedIDs

public String[] getAssociatedIDs(String IDs,
                                 String collectionKeys)
Gets the associatedIDs for the given IDs, records that catalog the same resource, or null if none exist.

Parameters:
IDs - 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 associatedIDs value

getIdentifiedErrors

public String[] getIdentifiedErrors(String IDs,
                                    String collectionKeys)
Gets all errors identified by the ID mapper service for the given IDs, or null if none exist.

Parameters:
IDs - 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 associatedIDs value

getAssociatedMMDRecs

public MmdRecord[] getAssociatedMMDRecs(String IDs,
                                        String collectionKeys)
Gets the associatedIDs for the given IDs, records that catalog the same resource, or null if none exist.

Parameters:
IDs - 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 associatedIDs value

getMmdRecord

public MmdRecord getMmdRecord(String id,
                              String collectionKey)
                       throws MmdException
Gets the ID mapper record for the given ID.

Parameters:
id - The ID of a given record.
collectionKey - The collection in wich the given record resides.
Returns:
The ID mapper mmdRecord.
Throws:
MmdException - If error retrieving the record info.

getAssociatedCollections

public String[] getAssociatedCollections(String ID,
                                         String collectionKey)
Gets an array of collection keys for collections that also catalog this same resource.

Parameters:
ID - The ID of a given record.
collectionKey - The collection in wich the given record resides.
Returns:
Array of collections that also catalog this resource.

getitmesIndex

public SimpleLuceneIndex getitmesIndex()
Gets the itmesIndex attribute of the RecordDataService object

Returns:
The itmesIndex value

getAnnotationsIndex

public SimpleLuceneIndex getAnnotationsIndex()
Gets the annotationssIndex attribute of the RecordDataService object

Returns:
The annotationsIndex value

getAccessionStatus

public String getAccessionStatus(String IDs,
                                 String collectionKeys)
Gets the accession status of the given resource or, if multiple resources get all statuses separated by spaces.

Parameters:
IDs - An ID(s) to an item-level resource, separated by spaces. If more than one, the first ID is the primary one.
collectionKeys - The collection keys for the collection of files, for example "dcc" or "comet", separated by spaces.
Returns:
The status value

getDisplayableItemResultDoc

public ResultDoc getDisplayableItemResultDoc(String itemId)
Gets the ResultDoc for the given item-level metata record id but only if it should be displayed in discovery. null if none exists.

Parameters:
itemId - The ID to a given item-level record.
Returns:
The ResultDoc for that item or null.

getDisplayableItemResultDocs

public ResultDoc[] getDisplayableItemResultDocs(String[] itemIds)
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

public ResultDoc getItemResultDoc(String itemId)
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

public ResultDoc[] getItemResultDocs(String[] itemIds)
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

public ResultDoc[] getDleseAnnoResultDocs(String[] ids)
Gets the dleseAnnoResultDocs attribute of the RecordDataService object

Parameters:
ids - Description of the Parameter
Returns:
The dleseAnnoResultDocs value

getAnnoTypesFromResultDocs

public ArrayList getAnnoTypesFromResultDocs(ResultDoc[] annoResultDocs)
Gets all annotation types in the given set of DleseAnnoDocReaders, or null if none exist.

Parameters:
annoResultDocs - DESCRIPTION
Returns:
The annoTypes value or null.

getAnnoStatusFromResultDocs

public ArrayList getAnnoStatusFromResultDocs(ResultDoc[] annoResultDocs)
Gets the annoStatusFromReaders attribute of the RecordDataService object

Parameters:
annoResultDocs - DESCRIPTION
Returns:
The annoStatusFromReaders value

getAnnoPathwaysFromResultDocs

public ArrayList getAnnoPathwaysFromResultDocs(ResultDoc[] annoResultDocs)
Gets all annotation pathways in the given set of DleseAnnoDocReaders, or null if none exist. Currently, this is not used!

Parameters:
annoResultDocs - DESCRIPTION
Returns:
The annoPathways value or null.

hasDRCAnnotation

public static boolean hasDRCAnnotation(ResultDoc[] annoResultDocs)
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.

getCollectionKeysFromResultDocs

public ArrayList getCollectionKeysFromResultDocs(ResultDoc[] collectionResults)
Gets all collection keys for the given documents.

Parameters:
collectionResults - DESCRIPTION
Returns:
The collection keys or null.

getVocab

public MetadataVocab getVocab()
Gets the vocab attribute of the RecordDataService object

Returns:
The vocab value

getDateStamp

protected static final String 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

protected static final void prtlnErr(String s)
Output a line of text to error out, with datestamp.

Parameters:
s - The text that will be output to error out.

prtln

protected static final void prtln(String s)
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

DLESE Tools
v1.2