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
-
Constructor Summary
ConstructorDescriptionDBControl
(PamConfiguration pamconfiguration, String unitName, int settingsStore, boolean openImmediately) -
Method Summary
Modifier and TypeMethodDescriptionbrowseDatabases
(Component parent) boolean
canClose()
Called before Pamguard shuts down.boolean
Commit any unsaved database changes.createFileMenu
(JFrame parentFrame) createPamCursor
(EmptyTableDefinition tableDefinition) void
Read all the settings in from storage.Get all the available database systemsstatic String
getGUI
(int flag) Get the GUI for the PAMControlled unit.int
int
Get the number of different settings within the settings source.getSettings
(int settingsIndex) Get a specific PamSettingsGroupGet a name for the settings sourcelong
Gets 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.boolean
void
notifyModelChanged
(int changeType) General notification when the PAMGAURD model changes.boolean
openDatabase
(String forcedName) void
pamClose()
Called when PAMGUARD is finally closing down so that a module may free any remaining resources (e.g.Reopen a database connection.boolean
restoreSettings
(PamControlledUnitSettings pamControlledUnitSettings) boolean
saveEndSettings
(long timeNow) Save settings when processing ends.boolean
boolean
saveStartSettings
(long timeNow) Save the settings in some way or another.boolean
selectDatabase
(Frame frame, String selectTitle) Open the database dialog.boolean
selectSystem
(int systemNumber, boolean openDatabase) Select a database systemboolean
selectSystem
(int systemNumber, boolean openDatabase, String forcedName) Select a database systemboolean
selectSystem
(Class systemClass, boolean openDatabase, String forcedName) void
setDBParameters
(DBParameters dbParameters) Set dB paramatersvoid
setFullTablesCheck
(boolean fullTablesCheck) 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, getUnitType, getVerboseLevel, gotoTab, isInMainConfiguration, isNetRx, isViewer, pamHasStopped, pamToStart, playViewerSound, removePamProcess, removeUnit, rename, saveViewerData, setFrameNumber, setModuleStatusManager, setPamConfiguration, setPamController, setPamModuleInfo, setPamView, setSidePanel, setTabPanel, setToolbarComponent, setupControlledUnit, stopViewerSound, tellModule, terminalPrint, terminalPrintln, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface PamController.PamSettings
getUnitType
Methods 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
-
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 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:PamControlledUnit
Called 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:
canClose
in 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:PamControlledUnit
Called when PAMGUARD is finally closing down so that a module may free any remaining resources (e.g. files or COMM ports).- Overrides:
pamClose
in classPamControlledUnit
-
browseDatabases
-
notifyModelChanged
public void notifyModelChanged(int changeType) Description copied from class:PamControlledUnit
General notification when the PAMGAURD model changes.- Overrides:
notifyModelChanged
in classPamControlledUnit
- Parameters:
changeType
- type of change
-
fillSettingsStore
public void fillSettingsStore()Read all the settings in from storage. -
getConnection
-
getSettingsReference
- Specified by:
getSettingsReference
in interfacePamSettings
- Returns:
- The serialisable object that will be stored
-
getSettingsVersion
public long getSettingsVersion()- Specified by:
getSettingsVersion
in interfacePamSettings
- Returns:
- An integer version number for the settings
-
restoreSettings
- Specified by:
restoreSettings
in interfacePamSettings
- 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:
createFileMenu
in classPamControlledUnit
- Parameters:
parentFrame
- parent frame for the menu- Returns:
- the file menu item
-
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 classPamControlledUnit
- Returns:
- a pamSidePanel object.
- See Also:
-
getDbUnitType
-
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 interfacePamSettingsSource
- Parameters:
timeNow
- current time.- Returns:
- true if settings saved successfully
-
saveEndSettings
public boolean saveEndSettings(long timeNow) Description copied from interface:PamSettingsSource
Save settings when processing ends. This may just be an update of the settings saves with saveStartSettings, e.g. an end time.- Specified by:
saveEndSettings
in interfacePamSettingsSource
- Returns:
- true if saved correctly.
-
getNumSettings
public int getNumSettings()Description copied from interface:PamSettingsSource
Get the number of different settings within the settings source.- Specified by:
getNumSettings
in interfacePamSettingsSource
- Returns:
- the number of PamSettingsGroups.
-
getSettings
Description copied from interface:PamSettingsSource
Get a specific PamSettingsGroup- Specified by:
getSettings
in interfacePamSettingsSource
- Parameters:
settingsIndex
- index of group- Returns:
- a settings group
-
getSettingsSourceName
Description copied from interface:PamSettingsSource
Get a name for the settings source- Specified by:
getSettingsSourceName
in interfacePamSettingsSource
- Returns:
- a name
-
isFullTablesCheck
public boolean isFullTablesCheck() -
setFullTablesCheck
public void setFullTablesCheck(boolean fullTablesCheck) -
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:PamControlledUnit
Get the GUI for the PAMControlled unit. This has multiple GUI options which are instantiated depending on the view type.- Overrides:
getGUI
in classPamControlledUnit
- Parameters:
flag
- . The GUI type flag defined in PAMGuiManager.- Returns:
- the GUI for the PamControlledUnit unit.
-
getLastErrorCount
public int getLastErrorCount()- Returns:
- the lastErrorCount
-