dk.netarkivet.harvester.datamodel
Class ScheduleDBDAO

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

public class ScheduleDBDAO
extends ScheduleDAO

A database-based implementation of the ScheduleDAO. The statements to create the tables are now in scripts/sql/createfullhddb.sql and scripts/sql/createfullhddb.mysql.


Constructor Summary
protected ScheduleDBDAO()
          Constructor for this class, that only checks that the schedules table has the expected version (1).
 
Method Summary
 void create(Schedule schedule)
          Create a new schedule.
 void delete(java.lang.String scheduleName)
          Delete a schedule in the DAO.
 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.
 boolean exists(java.lang.String scheduleName)
          Returns whether a named schedule exists.
 java.util.Iterator<Schedule> getAllSchedules()
          Get iterator to all available schedules.
 int getCountSchedules()
          Get the number of defined schedules.
 boolean mayDelete(Schedule schedule)
          Return whether the given schedule can be deleted.
 Schedule read(java.lang.String scheduleName)
          Read an existing schedule.
 void update(Schedule schedule)
          Update a schedule in the DAO.
 
Methods inherited from class dk.netarkivet.harvester.datamodel.ScheduleDAO
getInstance, iterator, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScheduleDBDAO

protected ScheduleDBDAO()
Constructor for this class, that only checks that the schedules table has the expected version (1).

Method Detail

create

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

Specified by:
create in class ScheduleDAO
Parameters:
schedule - The schedule to create
Throws:
ArgumentNotValid - if schedule is null
PermissionDenied - if a schedule already exists

exists

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

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

read

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

Specified by:
read in class ScheduleDAO
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 java.lang.String describeUsages(java.lang.String scheduleName)
Description copied from class: ScheduleDAO
Get a string describing usages of the named schedule, or null if it is not used anywhere.

Specified by:
describeUsages in class ScheduleDAO
Parameters:
scheduleName - the name of a given Schedule
Returns:
the above mentioned usage-description.
See Also:
ScheduleDAO.describeUsages(String)

delete

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

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

update

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

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

getAllSchedules

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

Specified by:
getAllSchedules in class ScheduleDAO
Returns:
iterator to all available schedules

getCountSchedules

public int getCountSchedules()
Description copied from class: ScheduleDAO
Get the number of defined schedules.

Specified by:
getCountSchedules in class ScheduleDAO
Returns:
The number of defined schedules
See Also:
ScheduleDAO.getCountSchedules()

mayDelete

public boolean mayDelete(Schedule schedule)
Description copied from class: ScheduleDAO
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.

Specified by:
mayDelete in class ScheduleDAO
Parameters:
schedule - a given Schedule
Returns:
true, if the given schedule can be deleted without problems.
See Also:
ScheduleDAO.mayDelete(Schedule)