Class RecordDataService

java.lang.Object
org.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.
Version:
$Id: RecordDataService.java,v 1.58 2010/07/14 00:18:49 jweather Exp $
Author:
John Weatherley
See Also:
  • Field Details

    • QUERY_OTHER

      public static int QUERY_OTHER
      Use to query within a other collection
    • QUERY_SAME

      public static int QUERY_SAME
      Use to query within a the same collection
    • QUERY_BOTH

      public static int QUERY_BOTH
      Use 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 Parameter
      annotationPathwaysSchemaUrl - URL to the annotation pathways schema
      See Also:
  • Method Details

    • 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(RepositoryManager rm)
      Initialize the RecordDataService.
      Parameters:
      rm - The RepositoryManager
    • getIndex

      public SimpleLuceneIndex getIndex()
      Gets the index used by this RecordData service to retrieve data.
      Returns:
      The index.
    • getCollectCollectionID

      public String getCollectCollectionID()
      Returns the value of collectCollectionID.
      Returns:
      The collectCollectionID value
    • setCollectCollectionID

      public void setCollectCollectionID(String collectCollectionID)
      Sets the value of collectCollectionID.
      Parameters:
      collectCollectionID - The value to assign collectCollectionID.
    • getIdMapperQueryObject

      public Query getIdMapperQueryObject()
      Gets a IDMapper Query Object to use in getMmdRec(String, String, Query) or getAssociatedMMDRecs(int, String, String, Query). The Query may be used multiple times. After use, the caller must be sure to close the Query using the closeIdMapperQueryObject(Query).
      Returns:
      The a Query Object, or null if unable to obtain
    • closeIdMapperQueryObject

      public void closeIdMapperQueryObject(Query queryObject)
      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

      public String getFilePathForId(MmdRec rec)
      Gets the filePathForId attribute of the RecordDataService object
      Parameters:
      rec - Description of the Parameter
      Returns:
      The filePathForId value
    • getFileForId

      public File getFileForId(MmdRec rec)
      Gets the fileForId attribute of the RecordDataService object
      Parameters:
      rec - Description of the Parameter
      Returns:
      The fileForId value
    • getAssociatedIDs

      public String[] getAssociatedIDs(String id, MmdRec[] associatedMmdRecs)
      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 associatedIDs
      associatedMmdRecs - An array of MmdRecs
      Returns:
      The associatedIDs value
    • getIdentifiedErrors

      public String[] getIdentifiedErrors(MmdRec[] mmdRecs)
      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

      public 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. Splits the IDs and collectionKeys by spaces and uses the first one.
      Parameters:
      queryType - Specify to look in other or the same collection
      IDs - An ID(s) to an item-level resource, separated by spaces - the first is used
      collectionKeys - The collection keys for the collection of files, for example "dcc" or "comet", separated by spaces - the first is used
      qo - The IDMapper Query Object to use
      Returns:
      The associated MmdRecs
    • getAssociatedMMDRecs

      public 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. Splits the IDs and collectionKeys by spaces and uses the first one.
      Parameters:
      queryType - Specify to look in other or the same collection
      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 associated MmdRecs
    • getMmdRec

      public MmdRec getMmdRec(String id, String collectionKey, Query qo)
      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

      public MmdRec getMmdRec(String id, String collectionKey)
      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

      public String getAccessionStatus(MmdRec[] mmdRecs)
      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

      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. Returns null if none exists.
      Parameters:
      itemId - The ID to a given item-level record.
      Returns:
      The ResultDoc for that item or null.
    • getDisplayableItemResultDocs

      public ResultDocList 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 ResultDocList 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 ResultDocList getDleseAnnoResultDocs(String[] ids)
      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

      public ArrayList getAnnoTypesFromResultDocs(ResultDocList annoResultDocs)
      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

      public ArrayList getAnnoStatusFromResultDocs(ResultDocList annoResultDocs)
      Gets the annoStatusFromReaders attribute of the RecordDataService object
      Parameters:
      annoResultDocs - An array of ResultDocs
      Returns:
      The annoStatusFromReaders value
    • getAnnoFormatsFromResultDocs

      public ArrayList getAnnoFormatsFromResultDocs(ResultDocList annoResultDocs)
      Gets the annotation formats from the anno result docs.
      Parameters:
      annoResultDocs - An array of ResultDocs
      Returns:
      The anno formats
    • getCompletedAnnoCollectionKeysFromResultDocs

      public ArrayList 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.
      Parameters:
      annoResultDocs - An array of ResultDocs of annotation records
      Returns:
      A list of annotation collection keys, or null
    • getAnnoPathwaysFromResultDocs

      public ArrayList getAnnoPathwaysFromResultDocs(ResultDocList annoResultDocs)
      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

      public static boolean hasDRCAnnotation(ResultDocList 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.
    • hasDRCItem

      public static boolean hasDRCItem(ResultDocList itemResultDocs)
      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

      public ArrayList getCollectionKeysFromResultDocs(ResultDocList collectionResults)
      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

      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