dk.netarkivet.harvester.datamodel.extendedfield
Class ExtendedFieldDAO

java.lang.Object
  extended by dk.netarkivet.harvester.datamodel.extendedfield.ExtendedFieldDAO
Direct Known Subclasses:
ExtendedFieldDBDAO

public abstract class ExtendedFieldDAO
extends java.lang.Object

Interface for creating and accessing extended fields in persistent storage.


Field Summary
protected static ExtendedFieldDAO instance
          The database singleton model.
 
Constructor Summary
protected ExtendedFieldDAO()
          constructor used when creating singleton.
 
Method Summary
abstract  void create(ExtendedField aExtendedField)
          Creates an instance in persistent storage of the given extended Field.
abstract  void delete(long aExtendedFieldID)
          deletes an ExtendedField from persistent storage.
abstract  boolean exists(java.lang.Long aExtendedfieldId)
          Check if an extendedfield exists for a given ID.
abstract  java.util.List<ExtendedField> getAll(long aExtendedFieldTypeId)
          Return a list of all ExtendedFields of the given Extended Field Type.
static ExtendedFieldDAO getInstance()
           
abstract  ExtendedField read(java.lang.Long aExtendedFieldID)
          Reads an ExtendedField from persistent storage.
static void reset()
          Reset the DAO instance.
abstract  void update(ExtendedField aExtendedField)
          Update a ExtendedField in persistent storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

protected static ExtendedFieldDAO instance
The database singleton model.

Constructor Detail

ExtendedFieldDAO

protected ExtendedFieldDAO()
constructor used when creating singleton. Do not call directly.

Method Detail

reset

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


exists

public abstract boolean exists(java.lang.Long aExtendedfieldId)
Check if an extendedfield exists for a given ID.

Parameters:
aExtendedfieldId - a given ID.
Returns:
true, if an extendedfield exists for the given ID

create

public abstract void create(ExtendedField aExtendedField)
Creates an instance in persistent storage of the given extended Field.

Parameters:
aExtendedField - a ExtendedField to create in persistent storage.

read

public abstract ExtendedField read(java.lang.Long aExtendedFieldID)
                            throws ArgumentNotValid,
                                   UnknownID,
                                   IOFailure
Reads an ExtendedField from persistent storage.

Parameters:
aExtendedFieldID - The ID of the ExtendedField to read
Returns:
a ExtendedField instance
Throws:
ArgumentNotValid - If failed to create ExtendedField instance in case aExtendedFieldID is invalid
UnknownID - If the job with the given jobID does not exist in persistent storage.
IOFailure - If the loaded ID of ExtendedField does not match the expected.

update

public abstract void update(ExtendedField aExtendedField)
                     throws IOFailure
Update a ExtendedField in persistent storage.

Parameters:
aExtendedField - The ExtendedField to update
Throws:
IOFailure - If writing the ExtendedField to persistent storage fails

getAll

public abstract java.util.List<ExtendedField> getAll(long aExtendedFieldTypeId)
Return a list of all ExtendedFields of the given Extended Field Type.

Parameters:
aExtendedFieldTypeId - extended field type.
Returns:
A list of all ExtendedFields with given Extended Field Type

delete

public abstract void delete(long aExtendedFieldID)
                     throws IOFailure
deletes an ExtendedField from persistent storage. The implementation of this method must also delete all belonging extended field values.

Parameters:
aExtendedFieldID - The ID of the ExtendedField to read
Throws:
IOFailure - If deleting the ExtendedField fails

getInstance

public static ExtendedFieldDAO getInstance()
Returns:
an instance of this class.