org.activemath.webapp.tools.data.storage
Class JDBCGapStorageDatabase

java.lang.Object
  extended by org.activemath.webapp.tools.data.storage.GapDB
      extended by org.activemath.webapp.tools.data.storage.JDBCGapStorageDatabase

public class JDBCGapStorageDatabase
extends GapDB


Field Summary
protected static Logger log
           
 
Constructor Summary
JDBCGapStorageDatabase()
          standard constructor
 
Method Summary
 boolean appendDataIfGapExists(Gap gap)
          appends the data of the give gap if a gap for this MBaseId does already exist
 int countGaps()
           
 boolean deleteGapById(int gapId)
          deletes gap from the database *
 Connection getConnection()
           
static GapDB getInstance()
           
 boolean init()
          Initializes the database.
 boolean resetDB()
          resets the database to its initial state
 Gap retrieveGapById(int gapId)
          returns the indicated gap from the database.
 Gap retrieveGapByMBaseId(String mbaseId)
          returns the indicated gap from the database.
 Iterator<Gap> selectAllGaps(Boolean limit)
          selects all gaps from the database gaps
 Iterator<Gap> selectAllGaps(Gap filterGap)
          selects all gaps from the database gaps
 boolean storeGap(Gap gap2store)
          stores the given gap in the database
 boolean updateGap(Gap gap)
          stores the given gap in the database the given gap needs to have a set derby id
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Logger log
Constructor Detail

JDBCGapStorageDatabase

public JDBCGapStorageDatabase()
standard constructor

Method Detail

getInstance

public static GapDB getInstance()

init

public boolean init()
Initializes the database. It uses the properties Gaps.JDBCDatabaseURL and Gaps.JDBCDatabaseFile. The actually used URL is made up by concatenation of Gaps.JDBCDatabaseURL and Gaps.JDBCDatabaseFile. The Driver is defined by the property Gaps.JDBCDatabaseDriver. In order to ease installation procedure, if no table named gaps is found, a new one will be generated. This may happen after deleting the directory AMHOME/data/db/derby-GapStorage-derby-db

Returns:
success of the operation

storeGap

public boolean storeGap(Gap gap2store)
                 throws GapDBAccessException
stores the given gap in the database

Parameters:
gap - gap that is stored in the database
Returns:
success of the operation
Throws:
GapDBAccessException - trouble with accessing the database

appendDataIfGapExists

public boolean appendDataIfGapExists(Gap gap)
appends the data of the give gap if a gap for this MBaseId does already exist

Parameters:
gap - gap to be stored in the database
Returns:
success of the operation
Throws:
GapDBAccessException - trouble with accessing the database

updateGap

public boolean updateGap(Gap gap)
                  throws GapDBIdInvalidException
stores the given gap in the database the given gap needs to have a set derby id

Parameters:
gap - gap that is stored in the database
Returns:
success of the operation
Throws:
GapDBAccessException - trouble with accessing the database
GapDBIdInvalidException

retrieveGapById

public Gap retrieveGapById(int gapId)
                    throws GapDBIdInvalidException
returns the indicated gap from the database. Throws an exception if the gap does not exist

Parameters:
gapId - the id of the gap
Returns:
gap selected from the database
Throws:
GapDBIdInvalidException - is thrown if the gapId is not valid.

retrieveGapByMBaseId

public Gap retrieveGapByMBaseId(String mbaseId)
returns the indicated gap from the database. Throws an exception if the gap does not exist

Parameters:
mbaseId - the mbaseId of the item the gap is for
Returns:
gap selected from the database

selectAllGaps

public Iterator<Gap> selectAllGaps(Boolean limit)
selects all gaps from the database gaps

Parameters:
limit - to improve performance. Can be null. If set and true, only the first 100 results are output by default
Returns:
Iterator containing gaps

selectAllGaps

public Iterator<Gap> selectAllGaps(Gap filterGap)
selects all gaps from the database gaps

Parameters:
important - integer referencing important gaps (1 means select)
ignore - integer referencing gaps to ignore (1 means select)
Returns:
Iterator containing gaps

deleteGapById

public boolean deleteGapById(int gapId)
                      throws GapDBIdInvalidException
deletes gap from the database *

Parameters:
gapId - of the gap to delete
Returns:
success of the operation
Throws:
GapDBIdInvalidException - is thrown if the gap is not stored in the database

resetDB

public boolean resetDB()
resets the database to its initial state


countGaps

public int countGaps()
Returns:
total number of gaps

getConnection

public Connection getConnection()