Class DocumentHandler


  • public class DocumentHandler
    extends Object
    Overloaded class for the general handling of documents. Singleton.
    • Constructor Detail

      • DocumentHandler

        public DocumentHandler​(Registry registry)
        Creates a new DocumentHandler.
        Parameters:
        registry - the registry.
    • Method Detail

      • find

        public edu.byu.hbll.box.QueryResult find​(String sourceName,
                                                 edu.byu.hbll.box.BoxQuery query)
        Retrieves documents from the database and returns them. If the process flag is set, documents are processed and then returned rather than retrieving the cached versions. If the wait flag is set, cached documents are retrieved, any unprocessed documents are processed, and all are returned. If no flag is set, all documents are retrieved from the database. Any unprocessed ones are indicated so.
        Parameters:
        sourceName - the source to query
        query - the query
        Returns:
        documents in the same number and order as requested
      • process

        public List<edu.byu.hbll.box.BoxDocument> process​(String sourceName,
                                                          Collection<String> ids)
        Processes and saves the documents for the given sourceName and ids. Waits for the processing to finish and returns the newly processed documents.
        Parameters:
        sourceName - the source name
        ids - the ids to be processed
        Returns:
        the resulting newly processed documents
      • addToQueue

        public void addToQueue​(String sourceName,
                               Collection<String> ids,
                               Instant attempt,
                               boolean overwrite)
        Queues up the ids for the given source to be processed in the background.
        Parameters:
        sourceName - the source name
        ids - the ids to queue
        attempt - attempt processing at this time
        overwrite - whether or not to overwrite the attempt if id already exists in queue
      • save

        public void save​(String sourceName,
                         edu.byu.hbll.box.BoxDocument document)
        Same as saveDocument, but pulls the oldDocument from the database first.
        Parameters:
        sourceName - the source name
        document - the document to be saved