Class HarvestDefinitionDBDAO
- java.lang.Object
-
- dk.netarkivet.harvester.datamodel.HarvestDefinitionDAO
-
- dk.netarkivet.harvester.datamodel.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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDomainConfiguration(PartialHarvest ph, SparseDomainConfiguration dcKey)
Add a domainconfiguration to a PartialHarvest.Long
create(HarvestDefinition harvestDefinition)
Create a harvest definition in Database.boolean
exists(Long oid)
Check, if there exists a HarvestDefinition identified by a given OID.boolean
exists(String name)
Check, if there exists a HarvestDefinition identified by a given name.void
flipActive(SparsePartialHarvest harvestDefinition)
Activates or deactivates a partial harvest definition.Iterator<HarvestDefinition>
getAllHarvestDefinitions()
Get a list of all existing harvest definitions ordered by name.Iterable<SparseFullHarvest>
getAllSparseFullHarvestDefinitions()
Get all sparse versions of full harvests for GUI purposes.HarvestDefinition
getHarvestDefinition(String name)
Get the harvest definition that has the given name, if any.String
getHarvestName(Long harvestDefinitionID)
Get the name of a harvest given its ID.List<HarvestRunInfo>
getHarvestRunInfo(long harvestID)
Returns a list with information on the runs of a particular harvest.Set<Long>
getJobIdsForSnapshotDeduplicationIndex(Long harvestId)
Get a collection of jobIds for snapshot deduplication index.List<String>
getListOfDomainsOfHarvestDefinition(String harvestName)
Get a sorted list of all domain names of a HarvestDefinition.List<String>
getListOfSeedsOfDomainOfHarvestDefinition(String harvestName, String domainName, boolean needSort)
Get a list of all seeds of a Domain in a HarvestDefinition.Iterable<Long>
getReadyHarvestDefinitions(Date now)
Returns a list of IDs of harvest definitions that are ready to be scheduled.Iterator<DomainConfiguration>
getSnapShotConfigurations()
Gets default configurations for all domains that are not aliases.List<SparseDomainConfiguration>
getSparseDomainConfigurations(Long harvestDefinitionID)
Get all domain,configuration pairs for a harvest definition in sparse version for GUI purposes.SparseFullHarvest
getSparseFullHarvest(String harvestName)
Get a sparse version of a full harvest for GUI purposes.SparsePartialHarvest
getSparsePartialHarvest(String harvestName)
Get a sparse version of a partial harvest for GUI purposes.Iterable<SparsePartialHarvest>
getSparsePartialHarvestDefinitions(boolean excludeInactive)
Get all sparse versions of partial harvests for GUI purposes ordered by name.boolean
isSnapshot(Long harvestDefinitionID)
Get whether a given harvest is a snapshot or selective harvest.void
mapToHarvestChannel(long harvestDefinitionId, HarvestChannel channel)
Maps a harvest definition to a harvest channel.HarvestDefinition
read(Long harvestDefinitionID)
Read the stored harvest definition for the given ID.void
removeDomainConfiguration(Long harvestId, SparseDomainConfiguration key)
Remove Domain configuration from a specific PartialHarvest.void
resetDomainConfigurations(PartialHarvest ph, List<DomainConfiguration> dcList)
Reset the list of domainconfiguration for a PartialHarvest.void
setIndexIsReady(Long harvestId, boolean newValue)
Set the isindexready field available for snapshot harvests.void
update(HarvestDefinition hd)
Update an existing harvest definition with new info.void
updateNextdate(long harvestId, Date nextdate)
Update the given PartialHarvest (i.e.-
Methods inherited from class dk.netarkivet.harvester.datamodel.HarvestDefinitionDAO
getInstance, iterator
-
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
-
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 classHarvestDefinitionDAO
- 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(Long harvestDefinitionID) throws UnknownID, IOFailure
Read the stored harvest definition for the given ID.- Specified by:
read
in classHarvestDefinitionDAO
- 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 databaseIOFailure
- 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 classHarvestDefinitionDAO
- 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 classHarvestDefinitionDAO
- 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 classHarvestDefinitionDAO
- 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 classHarvestDefinitionDAO
- Parameters:
oid
- a given OID- Returns:
- true, if such a harvestdefinition exists.
-
getAllHarvestDefinitions
public Iterator<HarvestDefinition> getAllHarvestDefinitions()
Get a list of all existing harvest definitions ordered by name.- Specified by:
getAllHarvestDefinitions
in classHarvestDefinitionDAO
- Returns:
- An iterator that give the existing harvest definitions in turn
-
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 classHarvestDefinitionDAO
- 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 classHarvestDefinitionDAO
- 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 classHarvestDefinitionDAO
- 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 classHarvestDefinitionDAO
- 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 classHarvestDefinitionDAO
- 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 classHarvestDefinitionDAO
- Parameters:
excludeInactive
- If true only active harvest definitions are returned.- Returns:
- An iterable (possibly empty) of SparsePartialHarvests
-
getSparsePartialHarvest
public SparsePartialHarvest getSparsePartialHarvest(String harvestName)
Get a sparse version of a partial harvest for GUI purposes.- Specified by:
getSparsePartialHarvest
in classHarvestDefinitionDAO
- 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 Iterable<SparseFullHarvest> getAllSparseFullHarvestDefinitions()
Get all sparse versions of full harvests for GUI purposes.- Specified by:
getAllSparseFullHarvestDefinitions
in classHarvestDefinitionDAO
- Returns:
- An iterable (possibly empty) of SparseFullHarvests
-
getHarvestName
public String getHarvestName(Long harvestDefinitionID)
Get the name of a harvest given its ID.- Specified by:
getHarvestName
in classHarvestDefinitionDAO
- 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 boolean isSnapshot(Long harvestDefinitionID)
Get whether a given harvest is a snapshot or selective harvest.- Specified by:
isSnapshot
in classHarvestDefinitionDAO
- 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.
-
getSparseFullHarvest
public SparseFullHarvest getSparseFullHarvest(String harvestName)
Get a sparse version of a full harvest for GUI purposes.- Specified by:
getSparseFullHarvest
in classHarvestDefinitionDAO
- 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 List<String> getListOfDomainsOfHarvestDefinition(String harvestName)
Get a sorted list of all domain names of a HarvestDefinition.- Specified by:
getListOfDomainsOfHarvestDefinition
in classHarvestDefinitionDAO
- 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 classHarvestDefinitionDAO
- Parameters:
harvestName
- of HarvestDefinitiondomainName
- of DomainneedSort
- boolean if sort results- Returns:
- List of all seeds of the Domain in the HarvestDefinition.
-
getJobIdsForSnapshotDeduplicationIndex
public Set<Long> getJobIdsForSnapshotDeduplicationIndex(Long harvestId)
Description copied from class:HarvestDefinitionDAO
Get a collection of jobIds for snapshot deduplication index.- Specified by:
getJobIdsForSnapshotDeduplicationIndex
in classHarvestDefinitionDAO
- Parameters:
harvestId
- the id of the harvest- Returns:
- a collection of jobIds to create a deduplication index.
-
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 classHarvestDefinitionDAO
- Parameters:
harvestId
- the ID of the harvest.newValue
- the new isindexready value
-
removeDomainConfiguration
public void removeDomainConfiguration(Long harvestId, SparseDomainConfiguration key)
Description copied from class:HarvestDefinitionDAO
Remove Domain configuration from a specific PartialHarvest.- Specified by:
removeDomainConfiguration
in classHarvestDefinitionDAO
- Parameters:
harvestId
- Id for a specific PartialHarvestkey
- a SparseDomainConfiguration uniquely identifying the domainconfig.
-
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 classHarvestDefinitionDAO
- Parameters:
harvestId
- A given PartialHarvest id (i.e. Selective Harvest).nextdate
- A new date for the next harvest run.
-
addDomainConfiguration
public void addDomainConfiguration(PartialHarvest ph, SparseDomainConfiguration dcKey)
Description copied from class:HarvestDefinitionDAO
Add a domainconfiguration to a PartialHarvest.- Specified by:
addDomainConfiguration
in classHarvestDefinitionDAO
- Parameters:
ph
- a given PartialHarvestdcKey
- a reduced domainconfiguration object
-
resetDomainConfigurations
public void resetDomainConfigurations(PartialHarvest ph, List<DomainConfiguration> dcList)
Description copied from class:HarvestDefinitionDAO
Reset the list of domainconfiguration for a PartialHarvest.- Specified by:
resetDomainConfigurations
in classHarvestDefinitionDAO
- Parameters:
ph
- a given PartialHarvestdcList
- the new list of domainconfigurations
-
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 classHarvestDefinitionDAO
- Parameters:
harvestDefinitionId
- the harvest definition idchannel
- the harvest channel
-
-