Package generalDatabase
Class DBProcess
java.lang.Object
PamguardMVC.PamProcess
generalDatabase.DBProcess
- All Implemented Interfaces:
PamObserver
,ProcessAnnotator
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
changeColumnFormat
(String tableName, PamTableItem tableItem) Change the format of a column.boolean
checkColumn
(EmptyTableDefinition tableDef, PamTableItem tableItem) Check a database table column exists.boolean
checkTable
(EmptyTableDefinition tableDef) Check a database table.boolean
checkTable
(SQLLogging sqlLogging) Check a table and it's subtable if there is one.void
boolean
clearTable
(EmptyTableDefinition tableDef) Completely clear the contents of a tableboolean
clearTable
(String tableName) boolean
columnExists
(EmptyTableDefinition tableDef, PamTableItem tableItem) Check that a specific table column existsint
columnNull
(String tableName, PamTableItem tableItem) Check to see if a column is empty.boolean
deleteDataFrom
(long timeMillis) boolean
deleteTable
(EmptyTableDefinition tableDef) Deletes tablevoid
exportDatabaseSchema
(JFrame parentFrame) Export all available database schema, converting PamTableDefinitions into valid xsd documents.Returns a list of all table names in the databasegetStoreStatus
(DBControlUnit dbControlUnit, boolean getDetail) Get the store status for use with pre-process checks.void
newData
(PamObservable o, PamDataUnit dataUnit) void
pamStart()
Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway).void
pamStop()
Stops the process.boolean
populateNewColumn
(EmptyTableDefinition tableDef, PamTableItem tableColWithValues, PamTableItem tableColToUpdate) Copies the data from one column to anotherboolean
renameTable
(String oldName, String newName) void
repopulateLoggerTables
(FormsControl formsControlTemp) Similar to the checkTables method, this will copy the logger table information currently in memory to the database.boolean
Called from the settings manager whenever settings would normally be saved to file.boolean
tableExists
(EmptyTableDefinition tableDef) Check a database table exists.void
updateData
(PamObservable o, PamDataUnit dataUnit) Informs the PamObserver that existing data have been updatedvoid
Methods inherited from class PamguardMVC.PamProcess
absMillisecondsToSamples, absSamplesToMilliseconds, addData, addMultiPlexDataBlock, addOutputDataBlock, changedThreading, clearOldData, createAnnotations, destroyProcess, dumpBufferStatus, flushDataBlockBuffers, getAncestorDataBlock, getAnnotation, getChainPosition, getCompatibleDataUnits, getCpuPercent, getFrequencyRange, getLastSourceNotificationObject, getLastSourceNotificationType, getMuiltiplexDataBlock, getNumAnnotations, getNumMuiltiplexDataBlocks, getNumOutputDataBlocks, getObserverName, getObserverObject, getOfflineData, getOfflineData, getOutputDataBlock, getOutputDataBlocks, getPamControlledUnit, getParentDataBlock, getParentDataBlocks, getParentProcess, getProcessCheck, getProcessName, getRawSourceDataBlock, getRawSourceDataBlock, getRequiredDataHistory, getSampleRate, getSourceDataBlock, getSourceProcess, hasOutputDatablock, isCanMultiThread, isExternalProcess, isMultiplex, makePamProcess, masterClockUpdate, noteNewSettings, notifyModelChanged, prepareProcess, prepareProcessOK, processNewBuoyData, receiveSourceNotification, relMillisecondsToSamples, relSamplesToMilliseconds, removeAllDataBlocks, removeAllMultiPlexDataBlocks, removeMultiPlexDataBlock, removeObservable, removeOutputDatablock, resetDataBlocks, saveViewerData, setCanMultiThread, setExternalProcess, setMultiplex, setParentDataBlock, setParentDataBlock, setProcessCheck, setProcessName, setSampleRate, setupProcess, toString
-
Constructor Details
-
DBProcess
-
-
Method Details
-
pamStart
public void pamStart()Description copied from class:PamProcess
Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway).- Specified by:
pamStart
in classPamProcess
-
pamStop
public void pamStop()Description copied from class:PamProcess
Stops the process.- Specified by:
pamStop
in classPamProcess
-
saveSettingsToDB
public boolean saveSettingsToDB()Called from the settings manager whenever settings would normally be saved to file. Just saves the latest of all PAMGUARD settings, first deleting any other settings in the logLastSettings table.The logSettings object does a slightly different task of always storing the current PAMGAURD settings in a table which grows and grows, giving a permanent record of PAMGUARD settings over time.
Unlike the settings in the growing table of logSettings, the settings stored from logLastSettings are also stored when viewer or mixed mode is exited.
- Returns:
- true if successful.
-
checkTables
public void checkTables() -
repopulateLoggerTables
Similar to the checkTables method, this will copy the logger table information currently in memory to the database. Note that this refers to the form definitions table, beginning with the UDF_ prefix. If the table already exists in the database, the user is given the option to overwrite it with the current format in memory, or leave it in the database as is. Note that a FormsControl object is also passed to this method, as a backup, because the user doesn't necessarily need a User Forms module in their setup. If they are only using the forms for annotations (say, for the detection group localiser) then all they need are the tables in the database. But without a FormsControl object registered to PamController, the repopulateLoggerTables call will fail. If there is a FormsControl object registered to PamController, or if formsControlTemp is null, then formsControlTemp is ignored. The only time it is used is if there is no official Logger form module in the users setup, yet there are UDF tables in the database.- Parameters:
formsControlTemp
- a FormsControl object with information about UDF tables in the database. Can be null. Ye
-
checkTable
Check a table and it's subtable if there is one.- Parameters:
sqlLogging
-- Returns:
-
checkTable
Check a database table. If it does not exist, create it.Then check all columns and if a column does not exist, create that too.
- Parameters:
tableDef
- table definition- Returns:
- true if table is OK, i.e. table and all columns either existed or were successfully created.
-
getListOfTables
Returns a list of all table names in the database- Returns:
-
tableExists
Check a database table exists.- Parameters:
tableDef
- table definition- Returns:
- true if the table exists
-
renameTable
- Parameters:
oldName
-newName
-- Returns:
- true if worked
-
checkColumn
Check a database table column exists. If it doesn't exist, attempt to create it.- Parameters:
tableDef
- table definitiontableItem
- table item- Returns:
- true if column existed or was created.
-
populateNewColumn
public boolean populateNewColumn(EmptyTableDefinition tableDef, PamTableItem tableColWithValues, PamTableItem tableColToUpdate) Copies the data from one column to another- Parameters:
tableDef
- the table to modifytableColWithValues
- the table column to copy the values FROMtableColToUpdate
- the table column to copy the values TO- Returns:
- true if data was properly copied
-
columnExists
Check that a specific table column exists- Parameters:
tableDef
- table definitiontableItem
- table item- Returns:
- true if the column exists
-
changeColumnFormat
Change the format of a column.- Returns:
- true if change sucessful
-
columnNull
Check to see if a column is empty.- Parameters:
tableName
-tableItem
-- Returns:
- 0 if there are data, 1 if no rows at all and 2 if there are data, but some are null
-
deleteTable
Deletes table- Parameters:
tableDef
- tableDef identifying the table to be deleted.- Returns:
- true if successful.
-
clearTable
Completely clear the contents of a table- Parameters:
tableDef
- tabledef identifying the table.- Returns:
- true if successful.
-
clearTable
-
updateProcessList
public void updateProcessList() -
newData
- Overrides:
newData
in classPamProcess
-
updateData
Description copied from interface:PamObserver
Informs the PamObserver that existing data have been updated- Specified by:
updateData
in interfacePamObserver
- Overrides:
updateData
in classPamProcess
-
getLogSettings
-
getLogLastSettings
-
getLogViewerSettings
- Returns:
- the logViewerSettings
-
exportDatabaseSchema
Export all available database schema, converting PamTableDefinitions into valid xsd documents.- Parameters:
parentFrame
-
-
getStoreStatus
Get the store status for use with pre-process checks.- Parameters:
getDetail
- get full details of start and end times.- Returns:
- database store status.
-
deleteDataFrom
public boolean deleteDataFrom(long timeMillis)
-