Package edu.byu.hbll.box.internal.core
Class DocumentHandler
- java.lang.Object
-
- edu.byu.hbll.box.internal.core.DocumentHandler
-
public class DocumentHandler extends Object
Overloaded class for the general handling of documents. Singleton.
-
-
Constructor Summary
Constructors Constructor Description DocumentHandler(Registry registry)
Creates a newDocumentHandler
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.edu.byu.hbll.box.QueryResult
find(String sourceName, edu.byu.hbll.box.BoxQuery query)
Retrieves documents from the database and returns them.List<edu.byu.hbll.box.BoxDocument>
process(String sourceName, Collection<String> ids)
Processes and saves the documents for the given sourceName and ids.void
save(String sourceName, edu.byu.hbll.box.BoxDocument document)
Same as saveDocument, but pulls the oldDocument from the database first.
-
-
-
Constructor Detail
-
DocumentHandler
public DocumentHandler(Registry registry)
Creates a newDocumentHandler
.- 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 queryquery
- 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 nameids
- 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 nameids
- the ids to queueattempt
- attempt processing at this timeoverwrite
- 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 namedocument
- the document to be saved
-
-