Class BackupStream

java.lang.Object
backupmanager.stream.BackupStream
All Implemented Interfaces:
BackupFunction, PamSettings, SettingsNameProvider
Direct Known Subclasses:
FileBackupStream

public abstract class BackupStream extends Object implements PamSettings, BackupFunction
This is the central management class for each datastream that's going to get automatically backed up. It will have links to the stream information, database info, etc. and manage the calls on a schedule to process and backup data.
Author:
dg50
  • Constructor Details

  • Method Details

    • runBackup

      public boolean runBackup(BackupManager backupManager)
      Run all backups associated with this stream. There is a single SwingWorker running ALL backups in turn, so this will already be running in a separate thread and it should send updates back to the manager which can forward them onto observers in the AWT thread (I think). These will have
      Parameters:
      backupManager -
      Returns:
    • catalogData

      public abstract List<StreamItem> catalogData()
      build the data catalogue from the last item in the current database.
      Individual actions may want to look in the database to see if they have themselves acted on the data, so will run their own query.

      Note that catalogData and getToDoList are separate functions, the idea being that catalog data will be listing all files in the source folder (or ones not already listed in the database table) whereas getToDoList can provide a set of files that are associated with a particular action, which may be a subset of files found in catalogData or may ignore catalogData in it's entirity.

      Returns:
    • getToDoList

      public abstract List<StreamItem> getToDoList(List<StreamItem> sourceItems, BackupAction action)
      Get a list of items that this action needs to work on. this may be a subset of sourceItems
      Parameters:
      sourceItems -
      action -
      Returns:
    • updateActedItem

      public abstract void updateActedItem(BackupAction action, StreamItem streamItem)
    • getName

      public String getName()
      Specified by:
      getName in interface BackupFunction
      Returns:
      a String name
    • doAction

      public boolean doAction(BackupManager backupManager, BackupAction action, StreamItem streamItem) throws BackupException
      Carry out some action or other on the stream item.
      Parameters:
      backupManager -
      action - Backup action to perform
      Returns:
      true if successful, otherwise false
      Throws:
      BackupException
    • addAction

      public void addAction(BackupAction action)
      Add an action
      Parameters:
      action -
    • removeAction

      public boolean removeAction(BackupAction action)
      remove an action
      Parameters:
      action -
      Returns:
    • getActions

      public ArrayList<BackupAction> getActions()
      Returns:
      the actions
    • getDialogPanel

      public PamDialogPanel getDialogPanel(Window owner)
      Description copied from interface: BackupFunction
      A dialog panel
      Specified by:
      getDialogPanel in interface BackupFunction
      Parameters:
      owner - owner should be the dialog, not the main PAMGuard frame
      Returns:
      dialog panel (can be null if no options to set).
    • getBackupSettings

      public abstract BackupSettings getBackupSettings()
      Return basic settings. Cannot be null. does not need to add all of the Action and Decision settings since that will all be handled by the calling functions getSettings from pamSettings
      Returns:
    • setBackupSettings

      public abstract boolean setBackupSettings(BackupSettings restoredSettings)
      Set settings when read back from PmSettings. Should always br the right type, but return flase if it isn't.
      Parameters:
      restoredSettings -
      Returns:
    • getUnitName

      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

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

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

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

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

      public Long getAvailableSpace()
      Get the amount of space remaining at the data source location
      Returns:
      space in bytes
    • backupComplete

      public abstract void backupComplete()
      Called when backup of a stream is complete so that catalogue can be closed, etc.
    • getAvailableActions

      public abstract List<ActionMaker> getAvailableActions()