Class SqliteSystem

java.lang.Object
generalDatabase.DBSystem
generalDatabase.sqlite.SqliteSystem
All Implemented Interfaces:
PamSettings, SettingsNameProvider

public class SqliteSystem extends DBSystem implements PamSettings
PAMGuard database system to make use of Sqlite databases: https://www.sqlite.org/ Specifically, this database system makes use of the xerial sqlite-jdbc library, https://github.com/xerial/sqlite-jdbc. NB: The default sqlite-jdbc from xerial does not support JDBC escape syntax, which is used by PAMGuard to interpret timestamps in mixed and viewer modes. Until this is addressed, sqlite database will fail in mixed and viewer mode.
Author:
brian_mil
  • Field Details Link icon

  • Constructor Details Link icon

    • SqliteSystem Link icon

      public SqliteSystem(DBControl dbControl, int settingsStore)
  • Method Details Link icon

    • getRecentDatabases Link icon

      public ArrayList<File> getRecentDatabases()
      Returns:
      the recentDatabases
    • setDatabaseName Link icon

      public void setDatabaseName(String databaseName)
      Set the database name, check it exists, check it's end and add to top of list of databases.
      Parameters:
      databaseName -
    • browseDatabases Link icon

      public String browseDatabases(Component parent)
      Specified by:
      browseDatabases in class DBSystem
    • createNewDatabase Link icon

      public File createNewDatabase(String newDB, Component parent, boolean askFirst)
      Create a new empty database file.
      Parameters:
      newDB - full path for database file (can be missing .sqlit3 if you like - this will get checked and added).
      parent - window (for confirm dialog, can be null)
      askFirst - show a confirm dialog before creating the database file.
      Returns:
      a path to the file, whether created or no.
    • canCreate Link icon

      public boolean canCreate()
      Specified by:
      canCreate in class DBSystem
      Returns:
      true if the system can create new databases.
    • create Link icon

      public boolean create()
      Description copied from class: DBSystem
      Create a new database

      The underlying DBSystem will be responsible for any dialogs to chose database names, etc.

      Specified by:
      create in class DBSystem
      Returns:
      true if successful.
    • createPamCursor Link icon

      public PamCursor createPamCursor(EmptyTableDefinition tableDefinition)
      Specified by:
      createPamCursor in class DBSystem
    • exists Link icon

      public boolean exists()
      Specified by:
      exists in class DBSystem
      Returns:
      true if the database exists
    • getConnection Link icon

      public PamConnection getConnection(String dbName)
      Description copied from class: DBSystem
      Open new database connection with a specific name
      Specified by:
      getConnection in class DBSystem
      Parameters:
      dbName -
      Returns:
    • closeConnection Link icon

      public void closeConnection(PamConnection connection)
      Description copied from class: DBSystem
      Close the database connection
      Overrides:
      closeConnection in class DBSystem
      Parameters:
      connection -
    • hasDriver Link icon

      public boolean hasDriver()
      Specified by:
      hasDriver in class DBSystem
      Returns:
      true if the driver for this database system is available on this computer. the availability of database system will depend both on the OS and whether software are installed.
    • checkDatabaseExists Link icon

      public boolean checkDatabaseExists(String dbName)
      Overrides:
      checkDatabaseExists in class DBSystem
    • getDatabaseName Link icon

      public String getDatabaseName()
      Specified by:
      getDatabaseName in class DBSystem
      Returns:
      the name of the currently open database.
    • getShortDatabaseName Link icon

      public String getShortDatabaseName()
      Description copied from class: DBSystem
      Get a shorter version of the currently open database name (e.g. without the file path name)
      Overrides:
      getShortDatabaseName in class DBSystem
      Returns:
      a shorter name
    • getDialogPanel Link icon

      public SystemDialogPanel getDialogPanel(Component parent)
      Description copied from class: DBSystem
      Get a database specific dialog panel to include in the database select dialog.
      Specified by:
      getDialogPanel in class DBSystem
      Parameters:
      parent - parent component
      Returns:
      dialog panel
    • getSqlTypes Link icon

      public SQLTypes getSqlTypes()
      Description copied from class: DBSystem
      Get the SQLTypes object which can be used to preform system specific formatting of SQL strings.
      Specified by:
      getSqlTypes in class DBSystem
      Returns:
    • getSystemName Link icon

      public String getSystemName()
      Specified by:
      getSystemName in class DBSystem
      Returns:
      The name of the database system
    • getUnitName Link icon

      public String getUnitName()
      Specified by:
      getUnitName in interface SettingsNameProvider
      Returns:
      A Name specific to this instance of the particular class, e.g. Sperm whale detector, Beaked whale detector, etc.
    • getUnitType Link icon

      public String getUnitType()
      Specified by:
      getUnitType in interface PamSettings
      Returns:
      A Name specific to the type, e.g. Click detector
    • getSettingsReference Link icon

      public Serializable getSettingsReference()
      Specified by:
      getSettingsReference in interface PamSettings
      Returns:
      The serialisable object that will be stored
    • getSettingsVersion Link icon

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

      public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
      Specified by:
      restoreSettings in interface PamSettings
      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
    • getKeywords Link icon

      public String getKeywords()
      Description copied from class: DBSystem
      Get a list of keywords which potentially may not be used for column names in an SQL statement. In reality, this list is complete overkill. Override for each system and try to reduce the list as much as possible.
      Overrides:
      getKeywords in class DBSystem
      Returns:
      list of restricted keywords.
    • canOpenDatabase Link icon

      public boolean canOpenDatabase()
      Description copied from class: DBSystem
      find out if it's possible to open the current databse with a host application (e.g. MS Access).
      Overrides:
      canOpenDatabase in class DBSystem
      Returns:
      true if it's possible.
    • openCurrentDatabase Link icon

      public boolean openCurrentDatabase()
      Description copied from class: DBSystem
      Open the database with it's host application if available (e.g. open MS access database with Access).
      Overrides:
      openCurrentDatabase in class DBSystem
      Returns:
      true if opened sucessfully.
    • browseDatabasesFX Link icon

      public String browseDatabasesFX(int type)
      FX methods to browse for an sqlite file.
      Specified by:
      browseDatabasesFX in class DBSystem
      Parameters:
      type -
      Returns:
    • configureFileChooser Link icon

      protected static void configureFileChooser(javafx.stage.FileChooser fileChooser)
      Set parameters for the file chooser.
      Parameters:
      fileChooser - - filechooser to configure.
    • getDialogPaneFX Link icon

      public SystemDialogPaneFX getDialogPaneFX()
      Description copied from class: DBSystem
      Get the FX pane for the database system
      Specified by:
      getDialogPaneFX in class DBSystem
      Returns:
      the FX settings pane for the database system.
    • createNewDatabase Link icon

      protected boolean createNewDatabase(String forcedName)
      Specified by:
      createNewDatabase in class DBSystem