3.1.2: 2012-07-31

net.sf.basedb.core
Class ReporterCloneBatcher

java.lang.Object
  extended by net.sf.basedb.core.AbstractBatcher
      extended by net.sf.basedb.core.ReporterCloneBatcher
All Implemented Interfaces:
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: 2011-12-02 12:09:46 +0100 (Fri, 02 Dec 2011) $

Nested Class Summary
static class ReporterCloneBatcher.CloneSource
          Specifies which source table to use for finding out which reporters that are part of the current experiment.
 
Field Summary
private  long bytesPerRow
          The number of bytes used by a single row.
private  Experiment experiment
          The experiment this batcher inserts data for.
private  PreparedStatement insertSql
          The statement that inserts cloned reporter data.
private  String insertSqlStatement
          The SQL string for the insertSql statement.
private  int[] parameterTypes
           
private  VirtualDb virtualDb
           
 
Fields inherited from class net.sf.basedb.core.AbstractBatcher
debugSqlEnabled, logSql
 
Constructor Summary
ReporterCloneBatcher(DbControl dc, Experiment experiment)
           
 
Method Summary
private  PreparedStatement buildInsertSql()
          Builds the insert SQL statement.
private  DynamicRawDataQuery buildRawSelectQuery()
           
private  DynamicPositionQuery buildSelectQuery()
          Builds a query that select all reporter properties that should be cloned from the real reporter table.
 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.
 void dropClonedReporters()
          Drop the cloned reporter information from the dynamic database.
 void flush()
          Flush the batcher and send all remaining items in memory to the database.
private  void flushInternal()
           
 Experiment getExperiment()
          Get the current experiment this batcher is used with.
(package private)  void onBeforeClose()
          Update disk usage and close open SQL statements.
 
Methods inherited from class net.sf.basedb.core.AbstractBatcher
analyzeTable, close, getBatchSize, getDbControl, getSessionControl, isClosed, setBatchSize, setDbControl, updateLastAccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 Detail

ReporterCloneBatcher

ReporterCloneBatcher(DbControl dc,
                     Experiment experiment)
Method Detail

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()

3.1.2: 2012-07-31