Class LinkedDatabaseUpdate

java.lang.Object
PamguardMVC.uid.repair.LinkedDatabaseUpdate

public class LinkedDatabaseUpdate extends Object
Functions for updating data in a linked database table, i.e. UID's are being primarily set by counting up binary data, but some entries are also in a database table, so also need updating.
Effectively this only ever happens with the offline clicks table.
A system whereby a query was run to update record by record based on a search of the database to match the table record was way too slow, so need to have a quicker way whereby all the records from the database associated with a binary file are read (based on time or other information such as file name), then matching can take place in memory and the records can be more quickly updated in the database based on their Id (which is indexed so faster querying).
Author:
dg50
  • Constructor Details

    • LinkedDatabaseUpdate

      public LinkedDatabaseUpdate(PamDataBlock dataBlock)
  • Method Details

    • getFileQueryString

      public String getFileQueryString(PamConnection con, BinaryOfflineDataMapPoint mapPoint)
      Return a WHERE clause to select records in the database associated with a map point.
      Parameters:
      mapPoint -
      Returns:
      SQL string beginning with the word "WHERE ..."
    • getLessThanQueryString

      public String getLessThanQueryString(PamConnection con, BinaryOfflineDataMapPoint mapPoint, boolean onlyNulls, String colNameToTest)
      Return a WHERE clause to select records in the database with a time less than the mapPoint end time. This method can also limit the results to only rows with a null in a specified column.
      Parameters:
      con - the PamConnection to use
      mapPoint - the mapPoint containing the end time
      onlyNulls - whether to only include rows with nulls in a specific column (true) or all rows (false)
      colNameToTest - which column to check for nulls - ignored if onlyNulls is false
      Returns:
    • loadFileDatabaseData

      public boolean loadFileDatabaseData(PamConnection con, BinaryOfflineDataMapPoint mapPoint)
    • loadUIDNulls

      public boolean loadUIDNulls(PamConnection con)
      Load up the pamCursor with a dataset of UID values == null
      Parameters:
      con -
      Returns:
    • replaceUIDsWithNegatives

      public Long replaceUIDsWithNegatives(Long startingValue)
      Replace all the UID's in the PamCursors dataset with negative values.
      Parameters:
      startingValue - the negative value to start at
      Returns:
      the next negative value to use
    • updateCursorRecord

      public boolean updateCursorRecord(PamDataUnit dataUnit)
      Match the data unit to a cursor record and update that cursor record with the UID.
      Parameters:
      dataUnit -
      Returns:
    • matchCursorRecord

      public boolean matchCursorRecord(PamDataUnit dataUnit)
      Function to match data units with a database record. If the data unit is a ClickDetection object, try to match the click number. Otherwise, try to match the time.
      Parameters:
      dataUnit -
      Returns:
      true if the data unit matches the selected database row.
    • updateDatabase

      public boolean updateDatabase()
      push everything down into the database.
      Returns:
      true if successful.