dk.netarkivet.harvester.datamodel
Class HarvestDefinitionDBDAO

java.lang.Object
  extended by dk.netarkivet.harvester.datamodel.HarvestDefinitionDAO
      extended by dk.netarkivet.harvester.datamodel.HarvestDefinitionDBDAO
All Implemented Interfaces:
java.lang.Iterable<HarvestDefinition>

public class HarvestDefinitionDBDAO
extends HarvestDefinitionDAO

A database-oriented implementation of the HarvestDefinitionDAO. The statements to create the tables are located in:


Constructor Summary
HarvestDefinitionDBDAO()
          Create a new HarvestDefinitionDAO using database.
 
Method Summary
 java.lang.Long create(HarvestDefinition harvestDefinition)
          Create a harvest definition in Database.
 boolean exists(java.lang.Long oid)
          Check, if there exists a HarvestDefinition identified by a given OID.
 void flipActive(SparsePartialHarvest harvestDefinition)
          Activates or deactivates a partial harvest definition.
 java.util.Iterator<HarvestDefinition> getAllHarvestDefinitions()
          Get a list of all existing harvest definitions ordered by name.
 java.lang.Iterable<SparseFullHarvest> getAllSparseFullHarvestDefinitions()
          Get all sparse versions of full harvests for GUI purposes.
 java.lang.Iterable<SparsePartialHarvest> getAllSparsePartialHarvestDefinitions()
          Get all sparse versions of partial harvests for GUI purposes.
 HarvestDefinition getHarvestDefinition(java.lang.String name)
          Get the harvest definition that has the given name, if any.
 java.lang.String getHarvestName(java.lang.Long harvestDefinitionID)
          Get the name of a harvest given its ID.
 java.util.List<HarvestRunInfo> getHarvestRunInfo(long harvestID)
          Returns a list with information on the runs of a particular harvest.
 java.util.Set<java.lang.Long> getJobIdsForSnapshotDeduplicationIndex(java.lang.Long harvestId)
          Get a collection of jobIds for snapshot deduplication index.
 java.util.List<java.lang.String> getListOfDomainsOfHarvestDefinition(java.lang.String harvestName)
          Get a sorted list of all domain names of a HarvestDefinition.
 java.util.List<java.lang.String> getListOfSeedsOfDomainOfHarvestDefinition(java.lang.String harvestName, java.lang.String domainName)
          Get a sorted list of all seeds of a Domain in a HarvestDefinition.
 java.lang.Iterable<java.lang.Long> getReadyHarvestDefinitions(java.util.Date now)
          Returns a list of IDs of harvest definitions that are ready to be scheduled.
 java.util.Iterator<DomainConfiguration> getSnapShotConfigurations()
          Gets default configurations for all domains that are not aliases.
 java.util.List<SparseDomainConfiguration> getSparseDomainConfigurations(java.lang.Long harvestDefinitionID)
          Get all domain,configuration pairs for a harvest definition in sparse version for GUI purposes.
 SparseFullHarvest getSparseFullHarvest(java.lang.String harvestName)
          Get a sparse version of a full harvest for GUI purposes.
 SparsePartialHarvest getSparsePartialHarvest(java.lang.String harvestName)
          Get a sparse version of a partial harvest for GUI purposes.
 boolean isSnapshot(java.lang.Long harvestDefinitionID)
          Get whether a given harvest is a snapshot or selective harvest.
 HarvestDefinition read(java.lang.Long harvestDefinitionID)
          Read the stored harvest definition for the given ID.
 void setIndexIsReady(java.lang.Long harvestId, boolean newValue)
          Set the isindexready field available for snapshot harvests.
 void update(HarvestDefinition hd)
          Update an existing harvest definition with new info.
 
Methods inherited from class dk.netarkivet.harvester.datamodel.HarvestDefinitionDAO
getInstance, iterator, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HarvestDefinitionDBDAO

HarvestDefinitionDBDAO()
Create a new HarvestDefinitionDAO using database.

Method Detail

create

public java.lang.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)

read

public HarvestDefinition read(java.lang.Long harvestDefinitionID)
                       throws UnknownID,
                              IOFailure
Read the stored harvest definition for the given ID.

Specified by:
read in class HarvestDefinitionDAO
Parameters:
harvestDefinitionID - An ID number for a harvest definition
Returns:
A harvest definition that has been read from persistent storage.
Throws:
UnknownID - if no entry with that ID exists in the database
IOFailure - If DB-failure occurs?
See Also:
HarvestDefinitionDAO.read(Long)

update

public void update(HarvestDefinition hd)
Update an existing harvest definition with new info.

Specified by:
update in class HarvestDefinitionDAO
Parameters:
hd - An updated harvest definition
See Also:
HarvestDefinitionDAO.update(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(java.lang.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.
See Also:
HarvestDefinitionDAO.exists(Long)

getAllHarvestDefinitions

public java.util.Iterator<HarvestDefinition> getAllHarvestDefinitions()
Get a list of all existing harvest definitions ordered by name.

Specified by:
getAllHarvestDefinitions in class HarvestDefinitionDAO
Returns:
An iterator that give the existing harvest definitions in turn

getSnapShotConfigurations

public java.util.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 java.lang.Iterable<java.lang.Long> getReadyHarvestDefinitions(java.util.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(java.lang.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 java.util.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.
See Also:
HarvestDefinitionDAO.getHarvestRunInfo(long)

getSparseDomainConfigurations

public java.util.List<SparseDomainConfiguration> getSparseDomainConfigurations(java.lang.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.

getAllSparsePartialHarvestDefinitions

public java.lang.Iterable<SparsePartialHarvest> getAllSparsePartialHarvestDefinitions()
Get all sparse versions of partial harvests for GUI purposes.

Specified by:
getAllSparsePartialHarvestDefinitions in class HarvestDefinitionDAO
Returns:
An iterable (possibly empty) of SparsePartialHarvests

getSparsePartialHarvest

public SparsePartialHarvest getSparsePartialHarvest(java.lang.String harvestName)
Get a sparse version of a partial harvest for GUI purposes.

Specified by:
getSparsePartialHarvest in class HarvestDefinitionDAO
Parameters:
harvestName - Name of harvest definition.
Returns:
Sparse version of partial harvest or null for none.
Throws:
ArgumentNotValid - on null or empty name.

getAllSparseFullHarvestDefinitions

public java.lang.Iterable<SparseFullHarvest> getAllSparseFullHarvestDefinitions()
Get all sparse versions of full harvests for GUI purposes.

Specified by:
getAllSparseFullHarvestDefinitions in class HarvestDefinitionDAO
Returns:
An iterable (possibly empty) of SparseFullHarvests

getHarvestName

public java.lang.String getHarvestName(java.lang.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(java.lang.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.

getSparseFullHarvest

public SparseFullHarvest getSparseFullHarvest(java.lang.String harvestName)
Get a sparse version of a full harvest for GUI purposes.

Specified by:
getSparseFullHarvest in class HarvestDefinitionDAO
Parameters:
harvestName - Name of harvest definition.
Returns:
Sparse version of full harvest or null for none.
Throws:
ArgumentNotValid - on null or empty name.
UnknownID - if no harvest has the given ID.
IOFailure - on any other error talking to the database

getListOfDomainsOfHarvestDefinition

public java.util.List<java.lang.String> getListOfDomainsOfHarvestDefinition(java.lang.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 java.util.List<java.lang.String> getListOfSeedsOfDomainOfHarvestDefinition(java.lang.String harvestName,
                                                                                  java.lang.String domainName)
Get a sorted list of all seeds of a Domain in a HarvestDefinition.

Specified by:
getListOfSeedsOfDomainOfHarvestDefinition in class HarvestDefinitionDAO
Parameters:
harvestName - of HarvestDefinition
domainName - of Domain
Returns:
List of all seeds of the Domain in the HarvestDefinition.

getJobIdsForSnapshotDeduplicationIndex

public java.util.Set<java.lang.Long> getJobIdsForSnapshotDeduplicationIndex(java.lang.Long harvestId)
Description copied from class: HarvestDefinitionDAO
Get a collection of jobIds for snapshot deduplication index.

Specified by:
getJobIdsForSnapshotDeduplicationIndex in class HarvestDefinitionDAO
Parameters:
harvestId - the id of the harvest
Returns:
a collection of jobIds to create a deduplication index.

setIndexIsReady

public void setIndexIsReady(java.lang.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