Package tethys.dbxml

Class DBXMLConnect

java.lang.Object
tethys.dbxml.DBXMLConnect

public class DBXMLConnect extends Object
Class containing functions for managing the database connection. Opening, closing, writing, keeping track of performance, etc.
Author:
Doug Gillespie, Katie O'Laughlin
  • Constructor Details

    • DBXMLConnect

      public DBXMLConnect(TethysControl tethysControl)
  • Method Details

    • getJerseyClient

      public dbxml.JerseyClient getJerseyClient()
      Get the client. The client will only be recreated if the url changes
      Returns:
      Jersy client
    • getTethysQueries

      public dbxml.Queries getTethysQueries()
      Get the Queries object. This will only be recreated if the client changes.
      Returns:
    • createXMLDocument

      public File createXMLDocument(Object nilusObject, File file) throws TethysException
      Convert a nilus Object into a file
      Parameters:
      nilusObject - nilus object
      file - file (should not exist)
      Returns:
      file (will be the same as input file)
      Throws:
      TethysException
    • createTempXMLDocument

      public File createTempXMLDocument(Object nilusObject) throws TethysException
      Create a temporary nilus file.
      Parameters:
      nilusObject -
      Returns:
      Throws:
      TethysException
    • postAndLog

      public boolean postAndLog(Object nilusObject) throws TethysException
      Throws:
      TethysException
    • postAndLog

      public boolean postAndLog(Object nilusObject, String documentName) throws TethysException
      I don't think this should ever be used since everything goes a bit pear shaped if the documentName isn't the same as the Id. However, for Calibration documents this is no longer the case, since a Calibration can have multiple entries on different dates, so allow it !
      Parameters:
      nilusObject -
      documentName -
      Returns:
      Throws:
      TethysException
    • updateDocument

      public boolean updateDocument(Object nilusDocument) throws TethysException
      Update a document within Tethys. We're assuming that a document with the same name in the same collection already exists. If it doesn't / has a different name, then use the removedocument function
      Parameters:
      nilusDocument -
      Returns:
      Throws:
      TethysException
    • deleteDocument

      public boolean deleteDocument(Object nilusDocument) throws TethysException
      Delete a nilus document from the database. The only field which needs to be populated here is the Id. The code also uses the object class to identify the correct collection.
      Parameters:
      nilusDocument -
      Returns:
      Throws:
      TethysException
    • deleteDeployment

      public boolean deleteDeployment(String deploymentId) throws TethysException
      Delete a Deploymnet and any contained Detections document. Doesn't work !
      Parameters:
      deploymentId -
      Returns:
      Throws:
      TethysException
    • removeDocument

      public boolean removeDocument(Collection collection, String documentName) throws TethysException
      Remove a document based on a collection name and a cdocument Id.
      Parameters:
      collection - collection name.
      documentName - document name (not the internal Document Id)
      Returns:
      Throws:
      TethysException
    • removeDocument

      public boolean removeDocument(String collectionName, String documentName) throws TethysException
      Remove a document based on a collection name and a document namw.
      Parameters:
      collectionName - collection name.
      documentName - document name (not the internal Document Id)
      Returns:
      Throws:
      TethysException
    • checkTempFolder

      public File checkTempFolder()
      Get a temp folder to hold xml output. This will be the standard temp folder + /PAMGuardTethys. Files will be left here until PAMGUard exits then should delete automatically
    • getDocumentId

      public static String getDocumentId(Object nilusObject)
      Get a document Id string. All Document objects should have a getId() function however they do not have a type hierarchy, so it can't be accessed directly. instead go via the class.getDeclaredMethod function and it should be possible to find it.
      Parameters:
      nilusObject -
      Returns:
      document Id for any type of document, or null if the document doesn't have a getID function
    • openConnections

      public boolean openConnections()
    • closeConnections

      public void closeConnections()
    • pingServer

      public ServerStatus pingServer()
      Get the server state via a ping ?
      Returns:
      Server state ?