Class ReporterCloneBatcher

java.lang.Object
net.sf.basedb.core.AbstractBatcher
net.sf.basedb.core.ReporterCloneBatcher
All Implemented Interfaces:
AutoCloseable, Batcher

public class ReporterCloneBatcher
extends AbstractBatcher
Batcher implementation that is used to handle cloned reporter information in the dynamic database.
Since:
3.1
Author:
Nicklas
Last modified
$Date: 2015-05-13 11:36:12 +0200 (on, 13 maj 2015) $
  • Field Details

    • experiment

      private final Experiment experiment
      The experiment this batcher inserts data for.
    • virtualDb

      private final VirtualDb virtualDb
    • bytesPerRow

      private final long bytesPerRow
      The number of bytes used by a single row.
    • insertSql

      private PreparedStatement insertSql
      The statement that inserts cloned reporter data.
      INSERT INTO D#Reporter# (id, version, external_id, ...)
      VALUES (?, ?, ?, ...)
      
    • insertSqlStatement

      private String insertSqlStatement
      The SQL string for the insertSql statement.
    • parameterTypes

      private int[] parameterTypes
  • Constructor Details

  • Method Details

    • flush

      public void flush() throws BaseException
      Description copied from interface: Batcher
      Flush the batcher and send all remaining items in memory to the database.
      Throws:
      BaseException - If there is an error
      See Also:
      Batcher.close()
    • onBeforeClose

      void onBeforeClose() throws BaseException
      Update disk usage and close open SQL statements.
      Overrides:
      onBeforeClose in class AbstractBatcher
      Throws:
      BaseException
    • getExperiment

      public Experiment getExperiment()
      Get the current experiment this batcher is used with.
    • dropClonedReporters

      public void dropClonedReporters()
      Drop the cloned reporter information from the dynamic database. If the current experiment doesn't have any cloned reporters, nothing is done.
      Throws:
      PermissionDeniedException - If the logged in user does't have write permission in this experiment
    • cloneReporters

      public int cloneReporters​(ReporterCloneBatcher.CloneSource source, ReporterCloneTemplate template, ProgressReporter progress)
      Create a reporter clone table in the dynamic database for this experiment and populate it with the current reporter annotations for all reporters that are part of the experiment.

      To find out which reporters that are part of the experiment, the batcher can use either what has already been inserted into the VirtualTable.POSITION table (source=ReporterCloneBatcher.CloneSource.VIRTUAL) or the reporters that are referenced by the RawBioAssay:s attached to the experiment (source=ReporterCloneBatcher.CloneSource.RAW). The AUTO method uses the position table if it exists. The RAW method can't be used with raw data types that doesn't store raw data in the database.

      This method will create an immutable copy of the template so that we can always know which fields that have been cloned, even if the template is modified. If there already is a cloned reporter information it will be removed.

      Parameters:
      template - The reporter clone template to use or null to clone all properties
      source - The source of the cloned reporters, null is the same as AUTO
      progress - An optional progress reporter
      Returns:
      The number of cloned reporters
      Throws:
      InvalidUseOfNullException - If the template is null
      PermissionDeniedException - If the logged in user does't have write permission in this experiment or use permission for the template or read permission for reporters
    • flushInternal

      private void flushInternal() throws SQLException
      Throws:
      SQLException
    • buildInsertSql

      private PreparedStatement buildInsertSql() throws SQLException, BaseException
      Builds the insert SQL statement.
      Throws:
      SQLException
      BaseException
      See Also:
      BatchUtil.buildInsertSql(VirtualDb, VirtualTable, VirtualColumn[], Object[])
    • buildSelectQuery

      private DynamicPositionQuery buildSelectQuery()
      Builds a query that select all reporter properties that should be cloned from the real reporter table.
    • buildRawSelectQuery

      private DynamicRawDataQuery buildRawSelectQuery()