dk.netarkivet.harvester.datamodel
Class HarvestChannelDBDAO

java.lang.Object
  extended by dk.netarkivet.harvester.datamodel.HarvestChannelDAO
      extended by dk.netarkivet.harvester.datamodel.HarvestChannelDBDAO
All Implemented Interfaces:
java.lang.Iterable<HarvestChannel>

public class HarvestChannelDBDAO
extends HarvestChannelDAO

Implementation class for the DAO handling the persistence of HarvestChannel instances.


Constructor Summary
protected HarvestChannelDBDAO()
          Create a new HarvestChannelDAO implemented using database.
 
Method Summary
 void create(HarvestChannel harvestChan)
          Creates a HarvestChannel object in the storage backend.
 boolean defaultFocusedChannelExists()
          Returns true if a default channel exists for focused jobs.
 java.util.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 a HarvestChannel by its UID.
 HarvestChannel getByName(java.lang.String name)
          Retrieves a HarvestChannel by its unique name.
 HarvestChannel getChannelForHarvestDefinition(long harvestDefinitionId)
          Returns the HarvestChannel mapped to the given HarvestDefinition id.
 HarvestChannel getDefaultChannel(boolean isSnapshot)
          Returns the default HarvestChannel for the given type of harvest.
 java.util.Iterator<HarvestChannel> iterator()
           
 void update(HarvestChannel harvestChan)
          Updates a HarvestChannel 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
 

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 an IllegalState 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 a HarvestChannel by its UID.

Specified by:
getById in class HarvestChannelDAO
Parameters:
id - the UID to look for
Returns:
the corresponding instance
Throws:
ArgumentNotValid - if not ID is supplied
UnknownID - if the ID is not present in the persistent storage.

getByName

public HarvestChannel getByName(java.lang.String name)
                         throws ArgumentNotValid,
                                UnknownID
Description copied from class: HarvestChannelDAO
Retrieves a HarvestChannel by its unique name.

Specified by:
getByName in class HarvestChannelDAO
Parameters:
name - the name to look for
Returns:
the corresponding instance
Throws:
ArgumentNotValid - if not name is supplied
UnknownID - if the name is not present in the persistent storage.

create

public void create(HarvestChannel harvestChan)
Description copied from class: HarvestChannelDAO
Creates a HarvestChannel object in the storage backend.

Specified by:
create in class HarvestChannelDAO
Parameters:
harvestChan - the HarvestChannel object

update

public void update(HarvestChannel harvestChan)
Description copied from class: HarvestChannelDAO
Updates a HarvestChannel object in the storage backend.

Specified by:
update in class HarvestChannelDAO
Parameters:
harvestChan - the HarvestChannel object

iterator

public java.util.Iterator<HarvestChannel> iterator()
Specified by:
iterator in interface java.lang.Iterable<HarvestChannel>
Specified by:
iterator in class HarvestChannelDAO

getAll

public java.util.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 class HarvestChannelDAO
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 class HarvestChannelDAO
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 default HarvestChannel for the given type of harvest.

Specified by:
getDefaultChannel in class HarvestChannelDAO
Parameters:
isSnapshot - snapshot or partial harvest
Returns:
the default HarvestChannel

getChannelForHarvestDefinition

public HarvestChannel getChannelForHarvestDefinition(long harvestDefinitionId)
Description copied from class: HarvestChannelDAO
Returns the HarvestChannel mapped to the given HarvestDefinition id. If no mapping was explicitly defined, returns null.

Specified by:
getChannelForHarvestDefinition in class HarvestChannelDAO
Parameters:
harvestDefinitionId - the HarvestDefinition id to look for
Returns:
the mapped HarvestChannel id or null