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) $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReporterCloneBatcher.CloneSource
Specifies which source table to use for finding out which reporters that are part of the current experiment.
-
Field Summary
Fields Modifier and Type Field Description 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 theinsertSql
statement.private int[]
parameterTypes
private VirtualDb
virtualDb
-
Fields inherited from class net.sf.basedb.core.AbstractBatcher
debugSqlEnabled, logSql
-
-
Constructor Summary
Constructors Constructor Description ReporterCloneBatcher(DbControl dc, Experiment experiment)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
-
-
-
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 (?, ?, ?, ...)
-
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 classAbstractBatcher
- 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 theRawBioAssay
: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 propertiessource
- The source of the cloned reporters, null is the same as AUTOprogress
- An optional progress reporter- Returns:
- The number of cloned reporters
- Throws:
InvalidUseOfNullException
- If the template is nullPermissionDeniedException
- 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.
-
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()
-
-