org.dspace.checker
Class BitstreamInfoDAO

java.lang.Object
  extended by org.dspace.checker.DAOSupport
      extended by org.dspace.checker.BitstreamInfoDAO

public final class BitstreamInfoDAO
extends DAOSupport

Database Access Object for bitstream information (metadata). Also performs the needed insert/update/delete commands on the database for the checksum checker.

Author:
Jim Downing, Grace Carpenter, Nathan Sarr

Field Summary
static String GET_OLDEST_BITSTREAM
          This selects the next bitstream in order of last processing end date.
static String GET_OLDEST_BITSTREAM_DATE
          Selects the next bitstream in order of last processing end date, ensuring that no bitstream is checked more than once since the date parameter used.
static String GET_OLDEST_BITSTREAM_DATE_ORACLE
           
static String GET_OLDEST_BITSTREAM_ORACLE
           
static int SENTINEL
          This value should be returned by next() to indicate that there are no more values.
 
Constructor Summary
BitstreamInfoDAO()
          Default constructor
 
Method Summary
protected  int deleteBitstreamInfo(int id, Connection conn)
          Deletes the bitstream from the most_recent_checksum table if it exist.
 int deleteBitstreamInfoWithHistory(int id)
           
 BitstreamInfo findByBitstreamId(int id)
          Find a bitstream by its id.
 List getCollectionBitstreams(int collectionId)
          Get the bitstream ids for a given collection
 List getCommunityBitstreams(int communityId)
          Get the bitstream ids for a given community
 List getItemBitstreams(int itemId)
          Get the bitstream ids for a given Item
 int getOldestBitstream()
          Get the oldest bitstream in the most recent checksum table.
 int getOldestBitstream(Timestamp lessThanDate)
          Returns the oldest bistream that in the set of bitstreams that are less than the specified date.
 void update(BitstreamInfo info)
          Updates most_recent_checksum with latest checksum and result of comparison with previous checksum.
 void updateMissingBitstreams()
          Queries the bitstream table for bitstream IDs that are not yet in the most_recent_checksum table, and inserts them into the most_recent_checksum and checksum_history tables.
 
Methods inherited from class org.dspace.checker.DAOSupport
cleanup, cleanup, cleanup, cleanup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SENTINEL

public static int SENTINEL
This value should be returned by next() to indicate that there are no more values.


GET_OLDEST_BITSTREAM

public static final String GET_OLDEST_BITSTREAM
This selects the next bitstream in order of last processing end date. The timestamp is truncated to milliseconds this is because the Date for java does not support nanoseconds and milliseconds were considered accurate enough

See Also:
Constant Field Values

GET_OLDEST_BITSTREAM_ORACLE

public static final String GET_OLDEST_BITSTREAM_ORACLE
See Also:
Constant Field Values

GET_OLDEST_BITSTREAM_DATE

public static final String GET_OLDEST_BITSTREAM_DATE
Selects the next bitstream in order of last processing end date, ensuring that no bitstream is checked more than once since the date parameter used.

See Also:
Constant Field Values

GET_OLDEST_BITSTREAM_DATE_ORACLE

public static final String GET_OLDEST_BITSTREAM_DATE_ORACLE
See Also:
Constant Field Values
Constructor Detail

BitstreamInfoDAO

public BitstreamInfoDAO()
Default constructor

Method Detail

update

public void update(BitstreamInfo info)
Updates most_recent_checksum with latest checksum and result of comparison with previous checksum.

Parameters:
info - The BitstreamInfo to update.
Throws:
IllegalArgumentException - if the BitstreamInfo given is null.

findByBitstreamId

public BitstreamInfo findByBitstreamId(int id)
Find a bitstream by its id.

Parameters:
id - the bitstream id
Returns:
the bitstream information needed for checksum validation. Returns null if bitstream info isn't found.

updateMissingBitstreams

public void updateMissingBitstreams()
Queries the bitstream table for bitstream IDs that are not yet in the most_recent_checksum table, and inserts them into the most_recent_checksum and checksum_history tables.


deleteBitstreamInfo

protected int deleteBitstreamInfo(int id,
                                  Connection conn)
Deletes the bitstream from the most_recent_checksum table if it exist.

Parameters:
id - the bitstream id.
Returns:
number of records deleted

deleteBitstreamInfoWithHistory

public int deleteBitstreamInfoWithHistory(int id)

getOldestBitstream

public int getOldestBitstream()
Get the oldest bitstream in the most recent checksum table. If more than one found the first one in the result set is returned.

Returns:
the bitstream id or -1 if the no bitstreams are found

getOldestBitstream

public int getOldestBitstream(Timestamp lessThanDate)
Returns the oldest bistream that in the set of bitstreams that are less than the specified date. If no bitstreams are found -1 is returned.

Parameters:
lessThanDate -
Returns:
id of olded bitstream or -1 if not bistreams are found

getItemBitstreams

public List getItemBitstreams(int itemId)
Get the bitstream ids for a given Item

Parameters:
itemId -
Returns:
the list of bitstream ids for this item

getCollectionBitstreams

public List getCollectionBitstreams(int collectionId)
Get the bitstream ids for a given collection

Parameters:
collectionId - The id of the collection
Returns:
the list of bitstream ids for this item

getCommunityBitstreams

public List getCommunityBitstreams(int communityId)
Get the bitstream ids for a given community

Parameters:
communityId - the community id
Returns:
the list of bitstream ids for this item


Copyright © 2010 DuraSpace. All Rights Reserved.