Class HarvestDefinitionDBDAO

  • All Implemented Interfaces:
    DAO, Iterable<HarvestDefinition>

    public class HarvestDefinitionDBDAO
    extends HarvestDefinitionDAO
    A database-oriented implementation of the HarvestDefinitionDAO.

    The statements to create the tables are located in:

    • Derby: scripts/sql/createfullhddb.sql
    • MySQL: scripts/sql/createfullhddb.mysql
    • PostgreSQL: scripts/postgresql/netarchivesuite_init.sql
    • Method Detail

      • create

        public Long create​(HarvestDefinition harvestDefinition)
        Create a harvest definition in Database. The harvest definition object should not have its ID set unless we are in the middle of migrating.
        Specified by:
        create in class HarvestDefinitionDAO
        Parameters:
        harvestDefinition - A new harvest definition to store in the database.
        Returns:
        The harvestId for the just created harvest definition.
        See Also:
        HarvestDefinitionDAO.create(HarvestDefinition)
      • flipActive

        public void flipActive​(SparsePartialHarvest harvestDefinition)
        Activates or deactivates a partial harvest definition. This method is actually to be used not to have to read from the DB big harvest definitions and optimize the activation / deactivation, it is sort of a lightweight version of update.
        Specified by:
        flipActive in class HarvestDefinitionDAO
        Parameters:
        harvestDefinition - the harvest definition object.
      • exists

        public boolean exists​(String name)
        Description copied from class: HarvestDefinitionDAO
        Check, if there exists a HarvestDefinition identified by a given name.
        Specified by:
        exists in class HarvestDefinitionDAO
        Parameters:
        name - a given name
        Returns:
        true, if such a harvestdefinition exists.
      • exists

        public boolean exists​(Long oid)
        Description copied from class: HarvestDefinitionDAO
        Check, if there exists a HarvestDefinition identified by a given OID.
        Specified by:
        exists in class HarvestDefinitionDAO
        Parameters:
        oid - a given OID
        Returns:
        true, if such a harvestdefinition exists.
      • getSnapShotConfigurations

        public Iterator<DomainConfiguration> getSnapShotConfigurations()
        Gets default configurations for all domains that are not aliases.

        This method currently gives an iterator that reads in all domains, although only on demand, that is: when calling "hasNext".

        Specified by:
        getSnapShotConfigurations in class HarvestDefinitionDAO
        Returns:
        Iterator containing the default DomainConfiguration for all domains that are not aliases
      • getReadyHarvestDefinitions

        public Iterable<Long> getReadyHarvestDefinitions​(Date now)
        Returns a list of IDs of harvest definitions that are ready to be scheduled.
        Specified by:
        getReadyHarvestDefinitions in class HarvestDefinitionDAO
        Parameters:
        now - The current date
        Returns:
        List of ready harvest definitions. No check is performed for whether these are already in the middle of being scheduled.
      • getHarvestDefinition

        public HarvestDefinition getHarvestDefinition​(String name)
        Get the harvest definition that has the given name, if any.
        Specified by:
        getHarvestDefinition in class HarvestDefinitionDAO
        Parameters:
        name - The name of a harvest definition.
        Returns:
        The HarvestDefinition object with that name, or null if none has that name.
      • getHarvestRunInfo

        public List<HarvestRunInfo> getHarvestRunInfo​(long harvestID)
        Description copied from class: HarvestDefinitionDAO
        Returns a list with information on the runs of a particular harvest. The list is ordered by descending run number.
        Specified by:
        getHarvestRunInfo in class HarvestDefinitionDAO
        Parameters:
        harvestID - ID of an existing harvest
        Returns:
        List of objects with selected information.
      • getSparseDomainConfigurations

        public List<SparseDomainConfiguration> getSparseDomainConfigurations​(Long harvestDefinitionID)
        Get all domain,configuration pairs for a harvest definition in sparse version for GUI purposes.
        Specified by:
        getSparseDomainConfigurations in class HarvestDefinitionDAO
        Parameters:
        harvestDefinitionID - The ID of the harvest definition.
        Returns:
        Domain, configuration pairs for that HD. Returns an empty iterable for unknown harvest definitions.
        Throws:
        ArgumentNotValid - on null argument.
      • getSparsePartialHarvestDefinitions

        public Iterable<SparsePartialHarvest> getSparsePartialHarvestDefinitions​(boolean excludeInactive)
        Get all sparse versions of partial harvests for GUI purposes ordered by name.
        Specified by:
        getSparsePartialHarvestDefinitions in class HarvestDefinitionDAO
        Parameters:
        excludeInactive - If true only active harvest definitions are returned.
        Returns:
        An iterable (possibly empty) of SparsePartialHarvests
      • getHarvestName

        public String getHarvestName​(Long harvestDefinitionID)
        Get the name of a harvest given its ID.
        Specified by:
        getHarvestName in class HarvestDefinitionDAO
        Parameters:
        harvestDefinitionID - The ID of a harvest
        Returns:
        The name of the given harvest.
        Throws:
        ArgumentNotValid - on null argument
        UnknownID - if no harvest has the given ID.
        IOFailure - on any other error talking to the database
      • isSnapshot

        public boolean isSnapshot​(Long harvestDefinitionID)
        Get whether a given harvest is a snapshot or selective harvest.
        Specified by:
        isSnapshot in class HarvestDefinitionDAO
        Parameters:
        harvestDefinitionID - ID of a harvest
        Returns:
        True if the given harvest is a snapshot harvest, false otherwise.
        Throws:
        ArgumentNotValid - on null argument
        UnknownID - if no harvest has the given ID.
      • getListOfDomainsOfHarvestDefinition

        public List<String> getListOfDomainsOfHarvestDefinition​(String harvestName)
        Get a sorted list of all domain names of a HarvestDefinition.
        Specified by:
        getListOfDomainsOfHarvestDefinition in class HarvestDefinitionDAO
        Parameters:
        harvestName - of HarvestDefinition
        Returns:
        List of all domains of the HarvestDefinition.
      • getListOfSeedsOfDomainOfHarvestDefinition

        public List<String> getListOfSeedsOfDomainOfHarvestDefinition​(String harvestName,
                                                                      String domainName,
                                                                      boolean needSort)
        Get a list of all seeds of a Domain in a HarvestDefinition.
        Specified by:
        getListOfSeedsOfDomainOfHarvestDefinition in class HarvestDefinitionDAO
        Parameters:
        harvestName - of HarvestDefinition
        domainName - of Domain
        needSort - boolean if sort results
        Returns:
        List of all seeds of the Domain in the HarvestDefinition.
      • setIndexIsReady

        public void setIndexIsReady​(Long harvestId,
                                    boolean newValue)
        Description copied from class: HarvestDefinitionDAO
        Set the isindexready field available for snapshot harvests.
        Specified by:
        setIndexIsReady in class HarvestDefinitionDAO
        Parameters:
        harvestId - the ID of the harvest.
        newValue - the new isindexready value
      • updateNextdate

        public void updateNextdate​(long harvestId,
                                   Date nextdate)
        Description copied from class: HarvestDefinitionDAO
        Update the given PartialHarvest (i.e. Selective Harvest) with a new time for the next harvestrun. If no selective harvest matching the given id is found in the storage, the method should silently return.
        Specified by:
        updateNextdate in class HarvestDefinitionDAO
        Parameters:
        harvestId - A given PartialHarvest id (i.e. Selective Harvest).
        nextdate - A new date for the next harvest run.
      • mapToHarvestChannel

        public void mapToHarvestChannel​(long harvestDefinitionId,
                                        HarvestChannel channel)
        Description copied from class: HarvestDefinitionDAO
        Maps a harvest definition to a harvest channel.
        Specified by:
        mapToHarvestChannel in class HarvestDefinitionDAO
        Parameters:
        harvestDefinitionId - the harvest definition id
        channel - the harvest channel