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

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

public class JDBCTutorPresetStorage
extends Object


Field Summary
protected static Logger log
           
 
Constructor Summary
JDBCTutorPresetStorage()
          standard constructor
 
Method Summary
 int countPresets()
           
 boolean deletePresetById(int TPID)
          deletes preset from the database *
 Connection getConnection()
           
static Timestamp getCurrentJavaSqlTimestamp()
           
static JDBCTutorPresetStorage getInstance()
           
 boolean init()
          Initializes the database.
 boolean resetDB()
          resets the database to its initial state
 TutorPreset retrieveTutorPresetById(int TPID)
          returns the indicated preset from the database.
 Iterator<TutorPreset> selectAllTutorPresets(Boolean limit)
          selects all presets from the database tutorPresets
 int storePreset(TutorPreset preset)
          stores the given preset in the database
 
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

JDBCTutorPresetStorage

public JDBCTutorPresetStorage()
standard constructor

Method Detail

getInstance

public static JDBCTutorPresetStorage 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


storePreset

public int storePreset(TutorPreset preset)
stores the given preset in the database

Parameters:
preset - preset that is stored in the database
Returns:
success of the operation

getCurrentJavaSqlTimestamp

public static Timestamp getCurrentJavaSqlTimestamp()

retrieveTutorPresetById

public TutorPreset retrieveTutorPresetById(int TPID)
returns the indicated preset 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

selectAllTutorPresets

public Iterator<TutorPreset> selectAllTutorPresets(Boolean limit)
selects all presets from the database tutorPresets

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

deletePresetById

public boolean deletePresetById(int TPID)
deletes preset from the database *

Parameters:
TPID - of the preset to delete
Returns:
success of the operation

resetDB

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


countPresets

public int countPresets()
Returns:
total number of tutor Presets

getConnection

public Connection getConnection()