Class HarvestDefinitionDAO
- java.lang.Object
-
- dk.netarkivet.harvester.datamodel.HarvestDefinitionDAO
-
- All Implemented Interfaces:
DAO
,Iterable<HarvestDefinition>
- Direct Known Subclasses:
HarvestDefinitionDBDAO
public abstract class HarvestDefinitionDAO extends Object implements DAO, Iterable<HarvestDefinition>
A Data Access Object for harvest definitions. This object is a singleton to ensure thread-safety. It handles the transformation from harvest definitions to persistent storage.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
HarvestDefinitionDAO()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addDomainConfiguration(PartialHarvest hdd, SparseDomainConfiguration sparseDomainConfiguration)
Add a domainconfiguration to a PartialHarvest.abstract Long
create(HarvestDefinition harvestDefinition)
Create a harvest definition in persistent storage.abstract boolean
exists(Long oid)
Check, if there exists a HarvestDefinition identified by a given OID.abstract boolean
exists(String name)
Check, if there exists a HarvestDefinition identified by a given name.abstract void
flipActive(SparsePartialHarvest harvestDefinition)
Activates or deactivates a partial harvest definition, depending on its activation status.abstract Iterator<HarvestDefinition>
getAllHarvestDefinitions()
Get a list of all existing harvest definitions.abstract Iterable<SparseFullHarvest>
getAllSparseFullHarvestDefinitions()
Get all sparse versions of full harvests for GUI purposes.abstract HarvestDefinition
getHarvestDefinition(String name)
Get the harvest definition that has the given name, or null, if no harvestdefinition exist with this name.abstract String
getHarvestName(Long harvestDefinitionID)
Get the name of a harvest given its ID.abstract List<HarvestRunInfo>
getHarvestRunInfo(long harvestID)
Returns a list with information on the runs of a particular harvest.static HarvestDefinitionDAO
getInstance()
Creates the singleton.abstract Set<Long>
getJobIdsForSnapshotDeduplicationIndex(Long harvestId)
Get a collection of jobIds for snapshot deduplication index.abstract List<String>
getListOfDomainsOfHarvestDefinition(String harvestName)
Get a sorted list of all domainnames of a HarvestDefintionabstract List<String>
getListOfSeedsOfDomainOfHarvestDefinition(String harvestName, String domainName, boolean needSort)
Get a list of all seeds of a Domain in a HarvestDefinition.abstract Iterable<Long>
getReadyHarvestDefinitions(Date now)
Get the IDs of the harvest definitions that are ready to run.abstract Iterator<DomainConfiguration>
getSnapShotConfigurations()
Gets default configurations for all domains.abstract List<SparseDomainConfiguration>
getSparseDomainConfigurations(Long harvestDefinitionID)
Get all domain,configuration pairs for a harvest definition in sparse version for GUI purposes.abstract SparseFullHarvest
getSparseFullHarvest(String harvestName)
Get a sparse version of a full harvest for GUI purposes.abstract SparsePartialHarvest
getSparsePartialHarvest(String harvestName)
Get a sparse version of a partial harvest for GUI purposes.abstract Iterable<SparsePartialHarvest>
getSparsePartialHarvestDefinitions(boolean excludeInactive)
Get all sparse versions of partial harvests for GUI purposes.abstract boolean
isSnapshot(Long harvestDefinitionID)
Get whether a given harvest is a snapshot or selective harvest.Iterator<HarvestDefinition>
iterator()
Get an iterator of all harvest definitions.abstract void
mapToHarvestChannel(long harvestDefinitionId, HarvestChannel channel)
Maps a harvest definition to a harvest channel.abstract HarvestDefinition
read(Long harvestDefinitionID)
Read the stored harvest definition for the given ID.abstract void
removeDomainConfiguration(Long harvestId, SparseDomainConfiguration key)
Remove Domain configuration from a specific PartialHarvest.abstract void
resetDomainConfigurations(PartialHarvest hdd, List<DomainConfiguration> dcList)
Reset the list of domainconfiguration for a PartialHarvest.abstract void
setIndexIsReady(Long harvestId, boolean newValue)
Set the isindexready field available for snapshot harvests.abstract void
update(HarvestDefinition harvestDefinition)
Update an existing harvest definition with new info in persistent storage.abstract void
updateNextdate(long harvestId, Date nextdate)
Update the given PartialHarvest (i.e.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getInstance
public static HarvestDefinitionDAO getInstance()
Creates the singleton.- Returns:
- the HarvestDefinitionDAO singleton.
- Throws:
IOFailure
- if unable to create the singleton.
-
create
public abstract Long create(HarvestDefinition harvestDefinition)
Create a harvest definition in persistent storage.- Parameters:
harvestDefinition
- A new harvest definition to write out.- Returns:
- The harvestId for the just created harvest definition.
-
read
public abstract HarvestDefinition read(Long harvestDefinitionID) throws UnknownID, IOFailure
Read the stored harvest definition for the given ID.- Parameters:
harvestDefinitionID
- An ID number for a harvest definition- Returns:
- A harvest definition that has been read from persistent storage.
- Throws:
UnknownID
- if no file with that ID existsIOFailure
- if the File does not exist, does not have the correct ID, or otherwise fails to load correctly.
-
update
public abstract void update(HarvestDefinition harvestDefinition)
Update an existing harvest definition with new info in persistent storage.- Parameters:
harvestDefinition
- An updated harvest definition object to be persisted.
-
flipActive
public abstract void flipActive(SparsePartialHarvest harvestDefinition)
Activates or deactivates a partial harvest definition, depending on its activation status.- Parameters:
harvestDefinition
- the harvest definition object
-
exists
public abstract boolean exists(Long oid)
Check, if there exists a HarvestDefinition identified by a given OID.- Parameters:
oid
- a given OID- Returns:
- true, if such a harvestdefinition exists.
-
exists
public abstract boolean exists(String name)
Check, if there exists a HarvestDefinition identified by a given name.- Parameters:
name
- a given name- Returns:
- true, if such a harvestdefinition exists.
-
getAllHarvestDefinitions
public abstract Iterator<HarvestDefinition> getAllHarvestDefinitions()
Get a list of all existing harvest definitions.- Returns:
- An iterator that give the existing harvest definitions in turn
-
iterator
public Iterator<HarvestDefinition> iterator()
Get an iterator of all harvest definitions. Implements the Iterable interface.- Specified by:
iterator
in interfaceIterable<HarvestDefinition>
- Returns:
- Iterator of all harvest definitions, Selective and Full both.
-
getSnapShotConfigurations
public abstract Iterator<DomainConfiguration> getSnapShotConfigurations()
Gets default configurations for all domains.- Returns:
- Iterator containing the default DomainConfiguration for all domains
-
getReadyHarvestDefinitions
public abstract Iterable<Long> getReadyHarvestDefinitions(Date now)
Get the IDs of the harvest definitions that are ready to run.- Parameters:
now
-- Returns:
- IDs of the harvest definitions that are currently ready to be scheduled. Some of these might already be in the process of being scheduled.
-
getHarvestDefinition
public abstract HarvestDefinition getHarvestDefinition(String name)
Get the harvest definition that has the given name, or null, if no harvestdefinition exist with this name.- Parameters:
name
- The name of a harvest definition.- Returns:
- The HarvestDefinition object with that name, or null if none has that name.
-
getHarvestRunInfo
public abstract List<HarvestRunInfo> getHarvestRunInfo(long harvestID)
Returns a list with information on the runs of a particular harvest. The list is ordered by descending run number.- Parameters:
harvestID
- ID of an existing harvest- Returns:
- List of objects with selected information.
-
getSparseDomainConfigurations
public abstract List<SparseDomainConfiguration> getSparseDomainConfigurations(Long harvestDefinitionID)
Get all domain,configuration pairs for a harvest definition in sparse version for GUI purposes.- Parameters:
harvestDefinitionID
- The ID of the harvest definition.- Returns:
- Domain, configuration pairs for that HD. Returns an empty list for unknown harvest definitions.
- Throws:
ArgumentNotValid
- on null argument.
-
getSparsePartialHarvest
public abstract SparsePartialHarvest getSparsePartialHarvest(String harvestName)
Get a sparse version of a partial harvest for GUI purposes.- Parameters:
harvestName
- Name of harvest definition.- Returns:
- Sparse version of partial harvest or null for none.
- Throws:
ArgumentNotValid
- on null or empty name.
-
getSparsePartialHarvestDefinitions
public abstract Iterable<SparsePartialHarvest> getSparsePartialHarvestDefinitions(boolean excludeInactive)
Get all sparse versions of partial harvests for GUI purposes.- Parameters:
excludeInactive
- If true only active harvest definitions are returned.- Returns:
- An iterable (possibly empty) of SparsePartialHarvests
-
getSparseFullHarvest
public abstract SparseFullHarvest getSparseFullHarvest(String harvestName)
Get a sparse version of a full harvest for GUI purposes.- Parameters:
harvestName
- Name of harvest definition.- Returns:
- Sparse version of full harvest or null for none.
- Throws:
ArgumentNotValid
- on null or empty name.
-
getAllSparseFullHarvestDefinitions
public abstract Iterable<SparseFullHarvest> getAllSparseFullHarvestDefinitions()
Get all sparse versions of full harvests for GUI purposes.- Returns:
- An iterable (possibly empty) of SparseFullHarvests
-
getHarvestName
public abstract String getHarvestName(Long harvestDefinitionID)
Get the name of a harvest given its ID.- Parameters:
harvestDefinitionID
- The ID of a harvest- Returns:
- The name of the given harvest.
- Throws:
ArgumentNotValid
- on null argumentUnknownID
- if no harvest has the given ID.IOFailure
- on any other error talking to the database
-
isSnapshot
public abstract boolean isSnapshot(Long harvestDefinitionID)
Get whether a given harvest is a snapshot or selective harvest.- Parameters:
harvestDefinitionID
- ID of a harvest- Returns:
- True if the given harvest is a snapshot harvest, false otherwise.
- Throws:
ArgumentNotValid
- on null argumentUnknownID
- if no harvest has the given ID.IOFailure
- on any other error talking to the database
-
getListOfDomainsOfHarvestDefinition
public abstract List<String> getListOfDomainsOfHarvestDefinition(String harvestName)
Get a sorted list of all domainnames of a HarvestDefintion- Parameters:
harvestName
- of HarvestDefintion- Returns:
- List of all domains of the HarvestDefinition.
- Throws:
ArgumentNotValid
- on null argumentIOFailure
- on any other error talking to the database
-
getListOfSeedsOfDomainOfHarvestDefinition
public abstract List<String> getListOfSeedsOfDomainOfHarvestDefinition(String harvestName, String domainName, boolean needSort)
Get a list of all seeds of a Domain in a HarvestDefinition.- Parameters:
harvestName
- of HarvestDefinitiondomainName
- of DomainneedSort
- boolean if sort results- Returns:
- List of all seeds of the Domain in the HarvestDefinition.
-
getJobIdsForSnapshotDeduplicationIndex
public abstract Set<Long> getJobIdsForSnapshotDeduplicationIndex(Long harvestId)
Get a collection of jobIds for snapshot deduplication index.- Parameters:
harvestId
- the id of the harvest- Returns:
- a collection of jobIds to create a deduplication index.
-
setIndexIsReady
public abstract void setIndexIsReady(Long harvestId, boolean newValue)
Set the isindexready field available for snapshot harvests.- Parameters:
harvestId
- the ID of the harvest.newValue
- the new isindexready value
-
removeDomainConfiguration
public abstract void removeDomainConfiguration(Long harvestId, SparseDomainConfiguration key)
Remove Domain configuration from a specific PartialHarvest.- Parameters:
harvestId
- Id for a specific PartialHarvestkey
- a SparseDomainConfiguration uniquely identifying the domainconfig.
-
updateNextdate
public abstract void updateNextdate(long harvestId, Date nextdate)
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.- Parameters:
harvestId
- A given PartialHarvest id (i.e. Selective Harvest).nextdate
- A new date for the next harvest run.
-
addDomainConfiguration
public abstract void addDomainConfiguration(PartialHarvest hdd, SparseDomainConfiguration sparseDomainConfiguration)
Add a domainconfiguration to a PartialHarvest.- Parameters:
hdd
- a given PartialHarvestsparseDomainConfiguration
- a reduced domainconfiguration object
-
resetDomainConfigurations
public abstract void resetDomainConfigurations(PartialHarvest hdd, List<DomainConfiguration> dcList)
Reset the list of domainconfiguration for a PartialHarvest.- Parameters:
hdd
- a given PartialHarvestdcList
- the new list of domainconfigurations
-
mapToHarvestChannel
public abstract void mapToHarvestChannel(long harvestDefinitionId, HarvestChannel channel)
Maps a harvest definition to a harvest channel.- Parameters:
harvestDefinitionId
- the harvest definition idchannel
- the harvest channel
-
-