Class QuotaDBManager

java.lang.Object
edu.ucsb.nceas.metacat.dataone.quota.QuotaDBManager

public class QuotaDBManager extends Object
Represents a class to manipulate the usages table for the quota service in the postgresql database
Author:
tao
  • Field Details

  • Constructor Details

    • QuotaDBManager

      public QuotaDBManager()
  • Method Details

    • createUsage

      public static void createUsage(org.dataone.bookkeeper.api.Usage usage, Date date) throws SQLException
      Create a usage record in the usages table with the given date as the reported date If the date is null, it will create a usage record without the reported date
      Parameters:
      usage - the usage will be record into the db table
      date - the reported date associated with the usage. If it is null, the reported date will be blank in the table
      Throws:
      SQLException
    • setReportedDateAndRemoteId

      public static void setReportedDateAndRemoteId(int localId, Date date, int remoteId) throws SQLException
      Set the reported date and remote id for a given usage local id
      Parameters:
      localId - the local id of the usage will be set
      date - the date to report to the bookkeeper server
      remoteId - the remote id will be set
      Throws:
      SQLException
    • getUnReportedUsages

      public static ResultSet getUnReportedUsages() throws SQLException
      Get the result set from the table which haven't been reported to the bookkeeper server. The indication is the reported date is null in the usages table
      Returns:
      the result set which usages which haven't been reported to the bookkeeper server
      Throws:
      SQLException
    • lookupRemoteUsageId

      public static int lookupRemoteUsageId(int quotaId, String instanceId) throws SQLException
      Find the remote usage id in the local database for the given quota id and instance id
      Parameters:
      quotaId - the quota id associated with the usage
      instanceId - the instance id associated with the usage
      Returns:
      the remote usage id. If it is -1, which means there is no remote usage id found.
      Throws:
      SQLException