Class Source


  • public class Source
    extends Object
    Main interface into a source.
    Author:
    Charles Draper
    • Method Detail

      • isPrincipal

        public boolean isPrincipal()
        Returns whether or not this source is the principal source.
        Returns:
        whether or not this source is the principal source
      • clear

        public void clear()
        Clears the database. All documents, metadata, cursor, etc are removed.
      • collect

        public edu.byu.hbll.box.QueryResult collect​(edu.byu.hbll.box.BoxQuery query)
        Collects and returns all documents found according to the given query.
        Parameters:
        query - the query
        Returns:
        found documents
      • find

        public Iterable<edu.byu.hbll.box.BoxDocument> find​(edu.byu.hbll.box.BoxQuery query)
        Returns documents found according to the given query in the form of an Iterable.
        Parameters:
        query - the query
        Returns:
        found documents
      • getConfig

        public SourceConfig getConfig()
        Returns the underlying configuration.
        Returns:
        the underlying configuration
      • getHealth

        public SourceHealth getHealth()
        Returns a snapshot of the health of the Source.
        Returns:
        the health of Box
      • getName

        public String getName()
        Returns the name of this source.
        Returns:
        the name of this source
      • addToQueue

        public void addToQueue​(String id,
                               Instant attempt)
        Queues up the given id to be run against the processor at the given time. Depending on how many ids are in the queue ready to be processed, processing of this could take place considerably after the given time. If the id is already in the queue, this will overwrite the attempt time.
        Parameters:
        id - the id to add to the queue
        attempt - attempt to process at this time
      • addToQueue

        public void addToQueue​(String... ids)
        Queues up the given ids to be run against the processor.
        Parameters:
        ids - the ids to add to the queue
      • addToQueue

        public void addToQueue​(Collection<String> ids)
        Queues up the given ids to be run against the processor.
        Parameters:
        ids - the ids to add to the queue
      • addToQueue

        public void addToQueue​(Collection<String> ids,
                               Instant attempt)
        Queues up the given ids to be run against the processor at the given time. Depending on how many ids are in the queue ready to be processed, processing of these could take place considerably after the given time. If the id is already in the queue, this will overwrite the attempt time.
        Parameters:
        ids - the ids to add to the queue
        attempt - attempt to process at this time
      • registerForUpdateNotifications

        public void registerForUpdateNotifications​(Runnable listener)
        Registers a listener with the updates notification system. The update notification system executes all registered listeners at most once per second whenever there is an update within a source.
        Parameters:
        listener - the runnable to execute when there's an update detected
      • save

        public void save​(edu.byu.hbll.box.BoxDocument document)
        Saves the given document to the database. The document is only saved and subsequently the modified and cursor fields are only updated if it is new or has been updated.
        Parameters:
        document - the document to save
      • stream

        public Stream<edu.byu.hbll.box.BoxDocument> stream​(edu.byu.hbll.box.BoxQuery query)
        Returns documents found according to the given query in the form of a Stream.
        Parameters:
        query - the query
        Returns:
        found documents
      • triggerHarvest

        public void triggerHarvest()
        Triggers the harvester to run.