dk.netarkivet.harvester.datamodel
Class ScheduleDAO

java.lang.Object
  extended by dk.netarkivet.harvester.datamodel.ScheduleDAO
All Implemented Interfaces:
java.lang.Iterable<Schedule>
Direct Known Subclasses:
ScheduleDBDAO

public abstract class ScheduleDAO
extends java.lang.Object
implements java.lang.Iterable<Schedule>

A DAO for reading and writing schedules by name.


Constructor Summary
protected ScheduleDAO()
          Constructor made private to enforce singleton.
 
Method Summary
abstract  void create(Schedule schedule)
          Create a new schedule.
abstract  boolean exists(java.lang.String scheduleName)
          Returns whether a named schedule exists.
abstract  java.util.Iterator<Schedule> getAllSchedules()
          Get iterator to all available schedules.
abstract  int getCountSchedules()
          Get the number of defined schedules.
static ScheduleDAO getInstance()
          Gets the singleton instance of the ScheduleDAO.
 java.util.Iterator<Schedule> iterator()
          Get an iterator over the schedules handled by this DAO.
abstract  Schedule read(java.lang.String scheduleName)
          Read an existing schedule.
(package private) static void reset()
          Reset the DAO.
abstract  void update(Schedule schedule)
          Update a schedule in the DAO.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScheduleDAO

protected ScheduleDAO()
Constructor made private to enforce singleton.

Method Detail

getInstance

public static ScheduleDAO getInstance()
Gets the singleton instance of the ScheduleDAO.

Returns:
ScheduleDAO singleton

create

public abstract void create(Schedule schedule)
Create a new schedule.

Parameters:
schedule - The schedule to create
Throws:
ArgumentNotValid - if schedule is null
PermissionDenied - if a schedule already exists

exists

public abstract boolean exists(java.lang.String scheduleName)
Returns whether a named schedule exists.

Parameters:
scheduleName - The name of a schedule
Returns:
True if the schedule exists.
Throws:
ArgumentNotValid - if the schedulename is null or empty

read

public abstract Schedule read(java.lang.String scheduleName)
Read an existing schedule.

Parameters:
scheduleName - the name of the schedule
Returns:
The schedule read
Throws:
ArgumentNotValid - if schedulename is null or empty
UnknownID - if the schedule doesn't exist

update

public abstract void update(Schedule schedule)
Update a schedule in the DAO.

Parameters:
schedule - The schedule to update
Throws:
ArgumentNotValid - If the schedule is null
UnknownID - If the schedule doesn't exist in the DAO
IOFailure - If the edition of the schedule to update is older than the DAO's

getAllSchedules

public abstract java.util.Iterator<Schedule> getAllSchedules()
Get iterator to all available schedules.

Returns:
iterator to all available schedules

iterator

public java.util.Iterator<Schedule> iterator()
Get an iterator over the schedules handled by this DAO. Implements the Iterable interface.

Specified by:
iterator in interface java.lang.Iterable<Schedule>
Returns:
Iterator of all current schedules.

getCountSchedules

public abstract int getCountSchedules()
Get the number of defined schedules.

Returns:
The number of defined schedules

reset

static void reset()
Reset the DAO. Only for use from within tests.