public abstract class AbstractBioAssaySetExporter
extends java.lang.Object
The exporter has been designed to export three types of information associated with a bioassay set.
Subclass implementors can override doExport()
if they wish. A better option is to override the other methods
that are called from this method in this order:
beginExport()
: One time only
exportGlobalHeader()
: One time only. If false is
returned, the export skips to the last step
exportSectionHeader()
: One or more times
exportSectionData()
: One or more times
exportSectionFooter()
: One or more times. If true is
returned, the steps 3-5 are repeated.
endExport(RuntimeException)
: Always called last. If
the parameter is not null an error has occurred
Modifier and Type | Field and Description |
---|---|
private java.util.List<AssayField> |
assayFields |
private java.util.Map<java.lang.Short,java.lang.Integer> |
assayIndexMap |
private boolean |
averageOnReporter |
private java.util.List<BioAssay> |
bioAssays |
private DbControl |
dc |
private ProgressReporter |
progress |
private java.util.Map<java.lang.Integer,java.lang.Object[]> |
reporterCache |
private java.util.List<DynamicField> |
reporterFields |
private SnapshotManager |
snapshotManager |
private BioAssaySet |
source |
private java.util.List<DynamicField> |
spotFields |
Modifier | Constructor and Description |
---|---|
protected |
AbstractBioAssaySetExporter() |
Modifier and Type | Method and Description |
---|---|
protected void |
addAssayField(AssayField field)
Add information about an assay field that should be exported.
|
protected void |
addExperimentalFactorsAsAssayFields()
Adds all experimental factors from the experiment that the
source bioassay set belongs to as assay fields.
|
protected void |
addReporterField(DynamicField field)
Add information about a reporter field that should be exported.
|
protected void |
addSpotField(DynamicField field)
Add information about a spot field that should be exported.
|
protected void |
beginExport()
Make preparations for the export.
|
protected int |
cacheReporterData()
Loads and caches reporter data in an internal structure
for quick access.
|
protected void |
copyReporterFields(int key,
java.lang.Object[] data,
int startIndex)
Copy cached reporter data into a data array.
|
void |
doExport()
Run the export.
|
protected void |
endExport(java.lang.RuntimeException e)
End the export and clean up/close all aquired resources.
|
protected void |
exportGlobalFooter()
Export global footer or other data that only appears once in the
end of the exported file.
|
protected boolean |
exportGlobalHeader()
Export global headers or other data that only appear once in the
beginning of the exported file.
|
protected void |
exportSectionData()
Export section data.
|
protected boolean |
exportSectionFooter()
End the section by exporting a footer.
|
protected void |
exportSectionHeader()
Start a new section in the export by exporting section headers.
|
protected java.util.List<AssayField> |
getAssayFields()
Get the list of registered assay fields, in the order they were
registered.
|
protected int |
getAssayIndex(short column)
Get the cached index value for an assay when you know the assay's column
number.
|
protected boolean |
getAverageOnReporter() |
protected java.util.List<BioAssay> |
getBioAssays()
Get a list with all bioassays in the source bioassay set.
|
DbControl |
getDbControl()
Get the current DbControl.
|
ProgressReporter |
getProgressReporter()
Get the progress reporter
|
protected java.util.List<DynamicField> |
getReporterFields()
Get the list of registered reporter fields, in the order they were
registered.
|
protected DynamicPositionQuery |
getReporterQuery()
Get a configured query for position data that returns all
fields that has been registered with
addReporterField(DynamicField) . |
SnapshotManager |
getSnapshotManager()
Get the current snapshot manager.
|
BioAssaySet |
getSource()
Get the source bioassay set.
|
protected java.util.List<DynamicField> |
getSpotFields()
Get the list of registered spot fields, in the order they were
registered.
|
protected DynamicSpotQuery |
getSpotQuery(boolean bioAssayRestriction)
Get a configured query for spot data that returns all
fields that has been registered with
addSpotField(DynamicField) . |
protected void |
prepareAssayIndexMap(java.util.List<BioAssay> assays,
int firstIndex,
int columnsPerAssay)
Prepare a cache that maps the bioassay column (
BioAssay.getDataCubeColumnNo() )
value to an index in the 'data' array this is generated. |
protected void |
setAverageOnReporter(boolean averageOnReporter)
Specify if the exported data should be averaged on reporter
or not.
|
void |
setDbControl(DbControl dc)
Set's the DbControl that should be used to get data from the database.
|
protected void |
setProgress(int percent,
java.lang.String message)
Update the progress of the export.
|
void |
setProgressReporter(ProgressReporter progress)
Set the progress reporter that is used to report progress.
|
void |
setSnapshotManager(SnapshotManager snapshotManager)
Set's the snapshot manager that should be used to load annotation values.
|
void |
setSource(BioAssaySet source)
Set the bioassay set that is used as a source for the spot data.
|
protected void |
validate()
Validate that all required options has been set and that other
options have sensible values.
|
private BioAssaySet source
private DbControl dc
private SnapshotManager snapshotManager
private ProgressReporter progress
private java.util.List<AssayField> assayFields
private java.util.List<DynamicField> reporterFields
private java.util.List<DynamicField> spotFields
private boolean averageOnReporter
private java.util.List<BioAssay> bioAssays
private java.util.Map<java.lang.Integer,java.lang.Object[]> reporterCache
private java.util.Map<java.lang.Short,java.lang.Integer> assayIndexMap
public void setDbControl(DbControl dc)
public DbControl getDbControl()
public void setSnapshotManager(SnapshotManager snapshotManager)
public SnapshotManager getSnapshotManager()
public void setProgressReporter(ProgressReporter progress)
setProgress(int, String)
to update the current status.public ProgressReporter getProgressReporter()
public void setSource(BioAssaySet source)
public BioAssaySet getSource()
protected void addSpotField(DynamicField field)
field
- The spot field (null is ignored)protected java.util.List<DynamicField> getSpotFields()
protected void addReporterField(DynamicField field)
field
- The reporter field (null is ignored)protected java.util.List<DynamicField> getReporterFields()
protected void addAssayField(AssayField field)
field
- The assay field (null is ignored)protected java.util.List<AssayField> getAssayFields()
protected void setAverageOnReporter(boolean averageOnReporter)
protected boolean getAverageOnReporter()
public void doExport()
protected void validate()
protected void beginExport()
doExport()
and is only called once. The
default implementation does nothing.protected boolean exportGlobalHeader()
beginExport()
and is only called once. The return value can be used
to indicate if the export should continue with sections or with global
footers. The default implementation does nothing and returns TRUE.exportSectionHeader()
,
FALSE to continue with global footers exportGlobalFooter()
protected void exportSectionHeader()
exportGlobalHeader()
and may
be called multiple times as determined by the return value of
exportSectionFooter()
. The default implementation does
nothing.protected void exportSectionData()
exportSectionHeader()
and may be called multiple times as determined by the return value of
exportSectionFooter()
. The default implementation does
nothing.protected boolean exportSectionFooter()
exportSectionData()
. The return value is used to determine if the export
should be repeated with a new section or if it should move on to global footers.
The default implementation returns false.exportSectionHeader()
,
FALSE to continue with global footers exportGlobalFooter()
protected void exportGlobalFooter()
exportGlobalHeader()
or exportSectionFooter()
. The default implementation does nothing.protected void endExport(java.lang.RuntimeException e)
protected java.util.List<BioAssay> getBioAssays()
protected void addExperimentalFactorsAsAssayFields()
protected DynamicSpotQuery getSpotQuery(boolean bioAssayRestriction)
addSpotField(DynamicField)
.
The fields are selected in the order they were registered.
This method also adds the position and column of the spot as the
last two fields. Note! If the setAverageOnReporter(boolean)
option has been enabled there is no unique position so the query
returns the reporter id instead of the position in this case.bioAssayRestriction
- If TRUE a restriction is added to the
query to make it return data for a single bioassay only.
Use query.setParameter("bioAssayColumn", (int)bioAssay.getDataCubeColumnNo(), Type.INT)
to set the value for the restrictionprotected DynamicPositionQuery getReporterQuery()
addReporterField(DynamicField)
.
The fields are selected in the order they were registered. This method also
adds the position of the spot as the last field.
Note 1! If the setAverageOnReporter(boolean)
option has been enabled there is no unique position so the query
returns the reporter id instead of the position in this case.
Note 2! If the setAverageOnReporter(boolean)
option has been enabled the query may return the same reporter
information multiple times.
Note 3! A subclass may override this method, but it should at least still select the same number of fields as is expected from the default implementation.
protected int cacheReporterData()
getReporterQuery()
and read all data into a memory
structure. The data is indexed by position number or by reporter
id (if average on reporters is enabled).protected void prepareAssayIndexMap(java.util.List<BioAssay> assays, int firstIndex, int columnsPerAssay)
BioAssay.getDataCubeColumnNo()
)
value to an index in the 'data' array this is generated. The map is generated as
follows:
Use getAssayIndex(short)
to get the indexed values.
assays
- The assays that should be mappedfirstIndex
- The index of the first assaycolumnsPerAssay
- Number of columns for each assayprotected int getAssayIndex(short column)
column
- The column number (BioAssay.getDataCubeColumnNo()
)prepareAssayIndexMap(List, int, int)
protected void copyReporterFields(int key, java.lang.Object[] data, int startIndex)
key
- The cache key (=position or reporter id)data
- The data array to copy tostartIndex
- The start index in the data array for the
first reporter fieldprotected void setProgress(int percent, java.lang.String message)
ProgressReporter