Class DBProcess

java.lang.Object
PamguardMVC.PamProcess
generalDatabase.DBProcess
All Implemented Interfaces:
PamObserver, ProcessAnnotator

public class DBProcess extends PamProcess
  • Constructor Details

    • DBProcess

      public DBProcess(DBControl databaseControll)
  • 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 class PamProcess
    • pamStop

      public void pamStop()
      Description copied from class: PamProcess
      Stops the process.
      Specified by:
      pamStop in class PamProcess
    • 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

      public void repopulateLoggerTables(FormsControl formsControlTemp)
      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

      public boolean checkTable(SQLLogging sqlLogging)
      Check a table and it's subtable if there is one.
      Parameters:
      sqlLogging -
      Returns:
    • checkTable

      public boolean checkTable(EmptyTableDefinition tableDef)
      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

      public ArrayList<String> getListOfTables()
      Returns a list of all table names in the database
      Returns:
    • tableExists

      public boolean tableExists(EmptyTableDefinition tableDef)
      Check a database table exists.
      Parameters:
      tableDef - table definition
      Returns:
      true if the table exists
    • renameTable

      public boolean renameTable(String oldName, String newName)
      Parameters:
      oldName -
      newName -
      Returns:
      true if worked
    • checkColumn

      public boolean checkColumn(EmptyTableDefinition tableDef, PamTableItem tableItem)
      Check a database table column exists. If it doesn't exist, attempt to create it.
      Parameters:
      tableDef - table definition
      tableItem - 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 modify
      tableColWithValues - the table column to copy the values FROM
      tableColToUpdate - the table column to copy the values TO
      Returns:
      true if data was properly copied
    • columnExists

      public boolean columnExists(EmptyTableDefinition tableDef, PamTableItem tableItem)
      Check that a specific table column exists
      Parameters:
      tableDef - table definition
      tableItem - table item
      Returns:
      true if the column exists
    • changeColumnFormat

      public boolean changeColumnFormat(String tableName, PamTableItem tableItem)
      Change the format of a column.
      Returns:
      true if change sucessful
    • columnNull

      public int columnNull(String tableName, PamTableItem tableItem)
      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

      public boolean deleteTable(EmptyTableDefinition tableDef)
      Deletes table
      Parameters:
      tableDef - tableDef identifying the table to be deleted.
      Returns:
      true if successful.
    • clearTable

      public boolean clearTable(EmptyTableDefinition tableDef)
      Completely clear the contents of a table
      Parameters:
      tableDef - tabledef identifying the table.
      Returns:
      true if successful.
    • clearTable

      public boolean clearTable(String tableName)
    • updateProcessList

      public void updateProcessList()
    • newData

      public void newData(PamObservable o, PamDataUnit dataUnit)
      Overrides:
      newData in class PamProcess
    • updateData

      public void updateData(PamObservable o, PamDataUnit dataUnit)
      Description copied from interface: PamObserver
      Informs the PamObserver that existing data have been updated
      Specified by:
      updateData in interface PamObserver
      Overrides:
      updateData in class PamProcess
    • getLogSettings

      public LogSettings getLogSettings()
    • getLogLastSettings

      public LogSettings getLogLastSettings()
    • getLogViewerSettings

      public LogSettings getLogViewerSettings()
      Returns:
      the logViewerSettings
    • exportDatabaseSchema

      public void exportDatabaseSchema(JFrame parentFrame)
      Export all available database schema, converting PamTableDefinitions into valid xsd documents.
      Parameters:
      parentFrame -
    • getStoreStatus

      public StoreStatus getStoreStatus(DBControlUnit dbControlUnit, boolean getDetail)
      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)