generalDatabase
Class DBControl

java.lang.Object
  extended by PamController.PamControlledUnit
      extended by generalDatabase.DBControl
All Implemented Interfaces:
PamSettings, PamSettingsSource
Direct Known Subclasses:
DBControlSettings, DBControlUnit

public abstract class DBControl
extends PamControlledUnit
implements PamSettings, PamSettingsSource

Database system for accessing data in just about any type of odbc database.

This gets used in two slightly different ways in Pamguard. The first is the obvious reading and writing of data to a variety of tables. The second is the loading of settings from the PAmguard_settings and the PamguardModules tables tables in which all program settings were serialised and stored as 6 bit ascii strings each time PAMGUARD started collecting data.

So that an instance of DBControl can be made that doesn't load settings, two sub classes have been made: DBContorlUnit for normal use and DBControlSettings for reading in settings information.

Author:
Doug Gillespie
See Also:
DBControlSettings, DBControlUnit

Nested Class Summary
(package private)  class DBControl.DatabaseFileMenuAction
           
 
Field Summary
private  java.sql.Connection connection
           
(package private)  DBSystem databaseSystem
           
(package private)  java.util.ArrayList<DBSystem> databaseSystems
           
(package private)  DBParameters dbParameters
           
private  DBProcess dbProcess
           
private  DBSettingsStore dbSettingsStore
           
(package private)  DBSidePanel dbSidePanel
           
private static java.lang.String dbUnitType
           
private  boolean fullTablesCheck
          Do full check of all database tables, not just specieals for controller.
private  DBControl THIS
           
 
Fields inherited from class PamController.PamControlledUnit
isViewer
 
Constructor Summary
DBControl(java.lang.String unitName, int settingsStore)
           
 
Method Summary
 java.lang.String browseDatabases(java.awt.Component parent)
           
private  void closeConnection()
           
(package private)  void createDBControl(int settingsStore)
           
 javax.swing.JMenuItem createFileMenu(javax.swing.JFrame parentFrame)
           
 PamCursor createPamCursor(EmptyTableDefinition tableDefinition)
           
private  void fillSettingsStore()
          Read all the settings in from storage.
 java.sql.Connection getConnection()
           
 java.lang.String getDatabaseName()
           
 DBProcess getDbProcess()
           
static java.lang.String getDbUnitType()
           
protected  java.util.ArrayList<PamDataBlock> getLoggingDataBlocks()
           
 int getNumSettings()
          Get the number of different settings within the settings source.
 PamSettingsGroup getSettings(int settingsIndex)
          Get a specific PamSettingsGroup
 java.io.Serializable getSettingsReference()
           
 java.lang.String getSettingsSourceName()
          Get a name for the settings source
 long getSettingsVersion()
           
 PamSidePanel getSidePanel()
          Gets a reference to a small panel to be displayed along the left hand edge of the main tab panel.
(package private)  DBSystem getSystem(int systemNumber)
           
 boolean isFullTablesCheck()
           
 void notifyModelChanged(int changeType)
          General notification when the PAMGAURD model changes.
 boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
           
 boolean saveSettingsToDB()
           
 boolean saveStartSettings(long timeNow)
          Save the settings in some way or another.
protected  boolean selectDatabase(java.awt.Frame frame)
           
 boolean selectSystem(int systemNumber, boolean openDatabase)
           
 void setFullTablesCheck(boolean fullTablesCheck)
           
protected  void setWriteCount(int dbWriteOKs, int dbWriteErrors)
           
 
Methods inherited from class PamController.PamControlledUnit
addOtherRelatedMenuItems, addPamProcess, addRelatedMenuItems, canClose, createDetectionMenu, createDisplayMenu, createHelpMenu, fillXMLElement, fillXMLParameters, getFrameNumber, getNumPamProcesses, getPamController, getPamModuleInfo, getPamProcess, getPamView, getTabClipCopier, getTabPanel, getTabSpecificMenuBar, getUnitName, getUnitType, gotoTab, notifyArrayChanged, pamHasStopped, pamToStart, removePamProcess, removeUnit, rename, saveViewerData, setFrameNumber, setPamController, setPamModuleInfo, setPamView, setSidePanel, setTabPanel, setupControlledUnit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface PamController.PamSettings
getUnitName, getUnitType
 

Field Detail

databaseSystems

java.util.ArrayList<DBSystem> databaseSystems

databaseSystem

DBSystem databaseSystem

connection

private java.sql.Connection connection

dbParameters

DBParameters dbParameters

dbProcess

private DBProcess dbProcess

dbSidePanel

DBSidePanel dbSidePanel

dbSettingsStore

private DBSettingsStore dbSettingsStore

fullTablesCheck

private boolean fullTablesCheck
Do full check of all database tables, not just specieals for controller.


dbUnitType

private static java.lang.String dbUnitType

THIS

private DBControl THIS
Constructor Detail

DBControl

public DBControl(java.lang.String unitName,
                 int settingsStore)
Method Detail

createDBControl

void createDBControl(int settingsStore)

selectSystem

public boolean selectSystem(int systemNumber,
                            boolean openDatabase)

getSystem

DBSystem getSystem(int systemNumber)

closeConnection

private void closeConnection()

browseDatabases

public java.lang.String browseDatabases(java.awt.Component parent)

notifyModelChanged

public void notifyModelChanged(int changeType)
Description copied from class: PamControlledUnit
General notification when the PAMGAURD model changes.

Overrides:
notifyModelChanged in class PamControlledUnit
Parameters:
changeType - type of change

fillSettingsStore

private void fillSettingsStore()
Read all the settings in from storage.


getConnection

public java.sql.Connection getConnection()

getSettingsReference

public java.io.Serializable getSettingsReference()
Specified by:
getSettingsReference in interface PamSettings
Returns:
The serialisable object that will be stored

getSettingsVersion

public long getSettingsVersion()
Specified by:
getSettingsVersion in interface PamSettings
Returns:
An integer version number for the settings

restoreSettings

public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
Specified by:
restoreSettings in interface PamSettings
Returns:
true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required

createFileMenu

public javax.swing.JMenuItem createFileMenu(javax.swing.JFrame parentFrame)
Overrides:
createFileMenu in class PamControlledUnit
Parameters:
parentFrame - parent frame for the menu
Returns:
the file menu item

setWriteCount

protected void setWriteCount(int dbWriteOKs,
                             int dbWriteErrors)

selectDatabase

protected boolean selectDatabase(java.awt.Frame frame)

getSidePanel

public PamSidePanel getSidePanel()
Description copied from class: PamControlledUnit
Gets a reference to a small panel to be displayed along the left hand edge of the main tab panel. Side panels should be small since they are always visible and any space they take will be taken from the main tab panel.

It is possible for a PamControlled unit to have a side panel without having a pamTabPanel.

Overrides:
getSidePanel in class PamControlledUnit
Returns:
a pamSidePanel object.
See Also:
PamSidePanel, PamTabPanel

getDbUnitType

public static java.lang.String getDbUnitType()

getDbProcess

public DBProcess getDbProcess()

saveSettingsToDB

public boolean saveSettingsToDB()

saveStartSettings

public boolean saveStartSettings(long timeNow)
Description copied from interface: PamSettingsSource
Save the settings in some way or another.

Specified by:
saveStartSettings in interface PamSettingsSource
Parameters:
timeNow - current time.
Returns:
true if settings saved successfully

getNumSettings

public int getNumSettings()
Description copied from interface: PamSettingsSource
Get the number of different settings within the settings source.

Specified by:
getNumSettings in interface PamSettingsSource
Returns:
the number of PamSettingsGroups.

getSettings

public PamSettingsGroup getSettings(int settingsIndex)
Description copied from interface: PamSettingsSource
Get a specific PamSettingsGroup

Specified by:
getSettings in interface PamSettingsSource
Parameters:
settingsIndex - index of group
Returns:
a settings group

getSettingsSourceName

public java.lang.String getSettingsSourceName()
Description copied from interface: PamSettingsSource
Get a name for the settings source

Specified by:
getSettingsSourceName in interface PamSettingsSource
Returns:
a name

isFullTablesCheck

public boolean isFullTablesCheck()

setFullTablesCheck

public void setFullTablesCheck(boolean fullTablesCheck)

getLoggingDataBlocks

protected java.util.ArrayList<PamDataBlock> getLoggingDataBlocks()

getDatabaseName

public java.lang.String getDatabaseName()
Returns:
the name of the current database

createPamCursor

public PamCursor createPamCursor(EmptyTableDefinition tableDefinition)