Class DBControl
- All Implemented Interfaces:
 PamSettings,PamSettingsSource,SettingsNameProvider
- Direct Known Subclasses:
 DBControlSettings,DBControlUnit
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:
 
- 
Field Summary
FieldsFields inherited from class PamController.PamControlledUnit
isMixed, isViewer - 
Constructor Summary
ConstructorsConstructorDescriptionDBControl(PamConfiguration pamconfiguration, String unitName, int settingsStore, boolean openImmediately)  - 
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaddDatabaseSystem(DBSystem dbSystem) browseDatabases(Component parent) booleancanClose()Called before Pamguard shuts down.protected voidbooleanCommit any unsaved database changes.createFileMenu(JFrame parentFrame) createPamCursor(EmptyTableDefinition tableDefinition) protected voidexportDatabaseSchema(JFrame parentFrame) voidRead all the settings in from storage.Get all the available database systemsstatic StringgetGUI(int flag) Get the GUI for the PAMControlled unit.intprotected ArrayList<PamDataBlock> intGet the number of different settings within the settings source.getSettings(int settingsIndex) Get a specific PamSettingsGroupGet a name for the settings sourceGet the DB Setting store.longGets a reference to a small panel to be displayed along the left hand edge of the main tab panel.getSystem(int systemNumber) Get the specified database system.Get a database system by it's class name.booleanvoidnotifyModelChanged(int changeType) General notification when the PAMGAURD model changes.booleanopenDatabase(String forcedName) voidpamClose()Called when PAMGUARD is finally closing down so that a module may free any remaining resources (e.g.Reopen a database connection.booleanrestoreSettings(PamControlledUnitSettings pamControlledUnitSettings) booleansaveEndSettings(long timeNow) Save settings when processing ends.booleanbooleansaveStartSettings(long timeNow) Save the settings in some way or another.booleanselectDatabase(Frame frame, String selectTitle) Open the database dialog.booleanselectSystem(int systemNumber, boolean openDatabase) Select a database systembooleanselectSystem(int systemNumber, boolean openDatabase, String forcedName) Select a database systembooleanselectSystem(Class systemClass, boolean openDatabase, String forcedName) voidsetDBParameters(DBParameters dbParameters) Set dB paramatersvoidsetFullTablesCheck(boolean fullTablesCheck) protected voidsetWriteCount(int dbWriteOKs, int dbWriteErrors) Methods inherited from class PamController.PamControlledUnit
addOfflineTaskGroup, addOtherRelatedMenuItems, addPamProcess, addPamProcess, addRelatedMenuItems, canPlayViewerSound, createDetectionMenu, createDisplayMenu, createHelpMenu, flushDataBlockBuffers, getBackupInformation, getFrameNumber, getGuiFrame, getInstanceIndex, getModuleStatus, getModuleStatusManager, getModuleSummary, getModuleSummary, getNumOfflineTaskGroups, getNumPamProcesses, getOfflineState, getOfflineTaskGroup, getPamConfiguration, getPamController, getPamModuleInfo, getPamProcess, getPamView, getPlugin, getShortUnitType, getTabClipCopier, getTabPanel, getTabSpecificMenuBar, getToolbarComponent, getUnitName, getUnitTaskManager, getUnitTaskManager, getUnitType, getVerboseLevel, gotoTab, isInMainConfiguration, isNetRx, isViewer, pamHasStopped, pamToStart, playViewerSound, removePamProcess, removeUnit, rename, saveViewerData, setFrameNumber, setModuleStatusManager, setPamConfiguration, setPamController, setPamModuleInfo, setPamView, setSidePanel, setTabPanel, setToolbarComponent, setUnitTaskManager, setupControlledUnit, stopViewerSound, tellModule, terminalPrint, terminalPrintln, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface PamController.PamSettings
getUnitTypeMethods inherited from interface PamController.SettingsNameProvider
getUnitName 
- 
Field Details
- 
GlobalDatabaseNameArg
- See Also:
 
 
 - 
 - 
Constructor Details
- 
DBControl
public DBControl(PamConfiguration pamconfiguration, String unitName, int settingsStore, boolean openImmediately)  
 - 
 - 
Method Details
- 
addDatabaseSystem
 - 
selectSystem
 - 
selectSystem
public boolean selectSystem(int systemNumber, boolean openDatabase) Select a database system- Parameters:
 systemNumber- index of the database systemopenDatabase- flag to immediately open the database- Returns:
 - true if all ok
 
 - 
selectSystem
Select a database system- Parameters:
 systemNumber- index of the database systemopenDatabase- flag to immediately open the database- Returns:
 - true if all ok
 
 - 
openDatabase
 - 
getSystem
Get a database system by it's class name.- Parameters:
 systemClass-- Returns:
 
 - 
getSystem
Get the specified database system.- Parameters:
 systemNumber- - the index of the system.- Returns:
 - the database systems at the specified index.
 
 - 
canClose
public boolean canClose()Description copied from class:PamControlledUnitCalled before Pamguard shuts down. Rather than returning false, this function can be used as a final oportunity to save settings, write to the database, etc.- Overrides:
 canClosein classPamControlledUnit- Returns:
 - true if OK for Pamguard to shut down, false otherwise.
 
 - 
commitChanges
public boolean commitChanges()Commit any unsaved database changes.- Returns:
 - true if successful. false if no database or exception thrown.
 
 - 
pamClose
public void pamClose()Description copied from class:PamControlledUnitCalled when PAMGUARD is finally closing down so that a module may free any remaining resources (e.g. files or COMM ports).- Overrides:
 pamClosein classPamControlledUnit
 - 
closeConnection
protected void closeConnection() - 
browseDatabases
 - 
notifyModelChanged
public void notifyModelChanged(int changeType) Description copied from class:PamControlledUnitGeneral notification when the PAMGAURD model changes.- Overrides:
 notifyModelChangedin classPamControlledUnit- Parameters:
 changeType- type of change
 - 
fillSettingsStore
public void fillSettingsStore()Read all the settings in from storage. - 
getConnection
 - 
getSettingsReference
- Specified by:
 getSettingsReferencein interfacePamSettings- Returns:
 - The serialisable object that will be stored
 
 - 
getSettingsVersion
public long getSettingsVersion()- Specified by:
 getSettingsVersionin interfacePamSettings- Returns:
 - An integer version number for the settings
 
 - 
restoreSettings
- Specified by:
 restoreSettingsin interfacePamSettings- Parameters:
 pamControlledUnitSettings-- 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
- Overrides:
 createFileMenuin classPamControlledUnit- Parameters:
 parentFrame- parent frame for the menu- Returns:
 - the file menu item
 
 - 
exportDatabaseSchema
 - 
setWriteCount
protected void setWriteCount(int dbWriteOKs, int dbWriteErrors)  - 
getSidePanel
Description copied from class:PamControlledUnitGets 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:
 getSidePanelin classPamControlledUnit- Returns:
 - a pamSidePanel object.
 - See Also:
 
 - 
getDbUnitType
 - 
getDbProcess
 - 
saveSettingsToDB
public boolean saveSettingsToDB() - 
saveStartSettings
public boolean saveStartSettings(long timeNow) Description copied from interface:PamSettingsSourceSave the settings in some way or another.- Specified by:
 saveStartSettingsin interfacePamSettingsSource- Parameters:
 timeNow- current time.- Returns:
 - true if settings saved successfully
 
 - 
saveEndSettings
public boolean saveEndSettings(long timeNow) Description copied from interface:PamSettingsSourceSave settings when processing ends. This may just be an update of the settings saves with saveStartSettings, e.g. an end time.- Specified by:
 saveEndSettingsin interfacePamSettingsSource- Parameters:
 timeNow-- Returns:
 - true if saved correctly.
 
 - 
getNumSettings
public int getNumSettings()Description copied from interface:PamSettingsSourceGet the number of different settings within the settings source.- Specified by:
 getNumSettingsin interfacePamSettingsSource- Returns:
 - the number of PamSettingsGroups.
 
 - 
getSettings
Description copied from interface:PamSettingsSourceGet a specific PamSettingsGroup- Specified by:
 getSettingsin interfacePamSettingsSource- Parameters:
 settingsIndex- index of group- Returns:
 - a settings group
 
 - 
getSettingsStore
Get the DB Setting store. Need to occasionally manipulate this externally.- Returns:
 - database settings store.
 
 - 
getSettingsSourceName
Description copied from interface:PamSettingsSourceGet a name for the settings source- Specified by:
 getSettingsSourceNamein interfacePamSettingsSource- Returns:
 - a name
 
 - 
isFullTablesCheck
public boolean isFullTablesCheck() - 
setFullTablesCheck
public void setFullTablesCheck(boolean fullTablesCheck)  - 
getLoggingDataBlocks
 - 
getDatabaseName
- Returns:
 - the name of the current database
 
 - 
getLongDatabaseName
- Returns:
 - the name of the current database
 
 - 
createPamCursor
 - 
getDatabaseSystem
- Returns:
 - the current databaseSystem
 
 - 
reOpenConnection
Reopen a database connection. This has a default action of doing absolutely nothing since it's only actually required by SqLite before it writes after doing some reading.Turned out this was never needed, but leave in in case it get's handy lter for some reason. e.g. see http://www.sqlite.org/lockingv3.html
- Parameters:
 connection- existing connection- Returns:
 - new connection.
 
 - 
getDbParameters
- Returns:
 - the dbParameters
 
 - 
getDatabaseSystems
Get all the available database systems- Returns:
 - an arrya of all available database systems .
 
 - 
selectDatabase
Open the database dialog.- Parameters:
 frame- - the GUI frameselectTitle- - the title of the dialog- Returns:
 - - true if a database has been successfully selected.
 
 - 
setDBParameters
Set dB paramaters- Parameters:
 dbParameters-
 - 
getGUI
Description copied from class:PamControlledUnitGet the GUI for the PAMControlled unit. This has multiple GUI options which are instantiated depending on the view type.- Overrides:
 getGUIin classPamControlledUnit- Parameters:
 flag- . The GUI type flag defined in PAMGuiManager.- Returns:
 - the GUI for the PamControlledUnit unit.
 
 - 
getLastErrorCount
public int getLastErrorCount()- Returns:
 - the lastErrorCount
 
 
 -