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  void delete(java.lang.String scheduleName)
          Delete a schedule in the DAO.
abstract  java.lang.String describeUsages(java.lang.String scheduleName)
          Get a string describing usages of the named schedule, or null if it is not used anywhere.
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  boolean mayDelete(Schedule schedule)
          Return whether the given schedule can be deleted.
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

describeUsages

public abstract java.lang.String describeUsages(java.lang.String scheduleName)
Get a string describing usages of the named schedule, or null if it is not used anywhere.

Parameters:
scheduleName - the name of a given Schedule
Returns:
the above mentioned usage-description.

delete

public abstract void delete(java.lang.String scheduleName)
Delete a schedule in the DAO.

Parameters:
scheduleName - The schedule to delete
Throws:
ArgumentNotValid - if the schedulename is null or empty
UnknownID - if no schedule exists

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

mayDelete

public abstract boolean mayDelete(Schedule schedule)
Return whether the given schedule can be deleted. This should be a fairly lightweight method, but is not likely to be instantaneous. Note that to increase speed, this method may rely on underlying systems to enforce transitive invariants. This means that if this method says a schedule can be deleted, the dao may still reject a delete request. If this method returns false, deletion will however definitely not be allowed.

Parameters:
schedule - a given Schedule
Returns:
true, if the given schedule can be deleted without problems.

reset

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