Class HarvestChannelDBDAO
- java.lang.Object
-
- dk.netarkivet.harvester.datamodel.HarvestChannelDAO
-
- dk.netarkivet.harvester.datamodel.HarvestChannelDBDAO
-
- All Implemented Interfaces:
DAO
,Iterable<HarvestChannel>
public class HarvestChannelDBDAO extends HarvestChannelDAO
Implementation class for the DAO handling the persistence ofHarvestChannel
instances.- Author:
- ngiraud
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
HarvestChannelDBDAO()
Create a new HarvestChannelDAO implemented using database.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
create(HarvestChannel harvestChan)
Creates aHarvestChannel
object in the storage backend.boolean
defaultFocusedChannelExists()
Returns true if a default channel exists for focused jobs.Iterator<HarvestChannel>
getAll(boolean includeSnapshot)
Returns harvest channels by type, sorted first by type (focused first, then broad) and then by name.HarvestChannel
getById(long id)
Retrieves aHarvestChannel
by its UID.HarvestChannel
getByName(String name)
Retrieves aHarvestChannel
by its unique name.HarvestChannel
getChannelForHarvestDefinition(long harvestDefinitionId)
Returns theHarvestChannel
mapped to the givenHarvestDefinition
id.HarvestChannel
getDefaultChannel(boolean isSnapshot)
Returns the defaultHarvestChannel
for the given type of harvest.Iterator<HarvestChannel>
iterator()
void
update(HarvestChannel harvestChan)
Updates aHarvestChannel
object in the storage backend.-
Methods inherited from class dk.netarkivet.harvester.datamodel.HarvestChannelDAO
getInstance
-
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
-
-
-
-
Constructor Detail
-
HarvestChannelDBDAO
protected HarvestChannelDBDAO()
Create a new HarvestChannelDAO implemented using database. This constructor also tries to upgrade the jobs and jobs_configs tables in the current database. Throws anIllegalState
exception, if default channels are missing in the DB.
-
-
Method Detail
-
getById
public HarvestChannel getById(long id) throws ArgumentNotValid, UnknownID
Description copied from class:HarvestChannelDAO
Retrieves aHarvestChannel
by its UID.- Specified by:
getById
in classHarvestChannelDAO
- Parameters:
id
- the UID to look for- Returns:
- the corresponding instance
- Throws:
ArgumentNotValid
- if not ID is suppliedUnknownID
- if the ID is not present in the persistent storage.
-
getByName
public HarvestChannel getByName(String name) throws ArgumentNotValid, UnknownID
Description copied from class:HarvestChannelDAO
Retrieves aHarvestChannel
by its unique name.- Specified by:
getByName
in classHarvestChannelDAO
- Parameters:
name
- the name to look for- Returns:
- the corresponding instance
- Throws:
ArgumentNotValid
- if not name is suppliedUnknownID
- if the name is not present in the persistent storage.
-
create
public void create(HarvestChannel harvestChan)
Description copied from class:HarvestChannelDAO
Creates aHarvestChannel
object in the storage backend.- Specified by:
create
in classHarvestChannelDAO
- Parameters:
harvestChan
- theHarvestChannel
object
-
update
public void update(HarvestChannel harvestChan)
Description copied from class:HarvestChannelDAO
Updates aHarvestChannel
object in the storage backend.- Specified by:
update
in classHarvestChannelDAO
- Parameters:
harvestChan
- theHarvestChannel
object
-
iterator
public Iterator<HarvestChannel> iterator()
- Specified by:
iterator
in interfaceIterable<HarvestChannel>
- Specified by:
iterator
in classHarvestChannelDAO
-
getAll
public Iterator<HarvestChannel> getAll(boolean includeSnapshot)
Description copied from class:HarvestChannelDAO
Returns harvest channels by type, sorted first by type (focused first, then broad) and then by name.- Specified by:
getAll
in classHarvestChannelDAO
- Parameters:
includeSnapshot
- if true, returns the single snapshot channel in the iterator.- Returns:
- an iterator on
HarvestChannel
.
-
defaultFocusedChannelExists
public boolean defaultFocusedChannelExists()
Description copied from class:HarvestChannelDAO
Returns true if a default channel exists for focused jobs.- Specified by:
defaultFocusedChannelExists
in classHarvestChannelDAO
- Returns:
- true if a default channel exists for focused jobs, false otherwise.
-
getDefaultChannel
public HarvestChannel getDefaultChannel(boolean isSnapshot)
Description copied from class:HarvestChannelDAO
Returns the defaultHarvestChannel
for the given type of harvest.- Specified by:
getDefaultChannel
in classHarvestChannelDAO
- Parameters:
isSnapshot
- snapshot or partial harvest- Returns:
- the default
HarvestChannel
-
getChannelForHarvestDefinition
public HarvestChannel getChannelForHarvestDefinition(long harvestDefinitionId)
Description copied from class:HarvestChannelDAO
Returns theHarvestChannel
mapped to the givenHarvestDefinition
id. If no mapping was explicitly defined, returns null.- Specified by:
getChannelForHarvestDefinition
in classHarvestChannelDAO
- Parameters:
harvestDefinitionId
- theHarvestDefinition
id to look for- Returns:
- the mapped
HarvestChannel
id or null
-
-