public class RawDataFlatFileImporter extends AbstractFlatFileImporter implements InteractivePlugin, ConfigureByExample, AnnotationSetterPlugin
Modifier and Type | Class and Description |
---|---|
(package private) class |
RawDataFlatFileImporter.FileIterator |
Plugin.MainType
complexMappings, dataFooterRegexpParameter, dataHeaderRegexpParameter, dataSplitterRegexpParameter, defaultErrorParameter, errorSection, fileParameter, fileType, headerRegexpParameter, ignoreRegexpParameter, invalidUseOfNullErrorParameter, mappingSection, maxDataColumnsParameter, minDataColumnsParameter, numberFormatErrorParameter, numberOutOfRangeErrorParameter, numDataColumnsType, optionalRegexpType, parserSection, requiredRegexpType, sectionRegexpParameter, stringTooLongErrorParameter, trimQuotesParameter
annotationSection, configuration, COPY_ANNOTATIONS, job, OVERWRITE_ANNOTATIONS, sc
Constructor and Description |
---|
RawDataFlatFileImporter() |
Modifier and Type | Method and Description |
---|---|
private void |
addExperimentParameters(DbControl dc,
Experiment currentExp,
java.util.List<PluginParameter<?>> parameters) |
private void |
addRawBioAssayParameters(DbControl dc,
RawBioAssay currentRaw,
java.util.List<PluginParameter<?>> parameters) |
protected void |
begin(FlatFileParser ffp)
Prepare for importing the next file.
|
protected void |
beginData()
Initialise column
Mapper :s. |
void |
configure(GuiContext context,
Request request,
Response response)
Store configuration settings for
Request.COMMAND_CONFIGURE_PLUGIN ,
COMMAND_CONFIGURE_PARSER and Request.COMMAND_CONFIGURE_JOB . |
protected boolean |
continueWithNextFileAfterError(java.lang.Throwable t)
We will continue if:
The file is not of the correct format, eg. t =
UnsupportedFileFormatException . |
protected void |
end(boolean success)
Close and commit/rollback the RawDataBatcher and DbControl.
|
java.lang.String |
finish(java.lang.Throwable t)
Commit/rollback transaction if needed.
|
private java.util.List<PluginParameter<java.lang.String>> |
getAllColumnMappings(RawDataType rdt)
Loads the column mappings if they hasn't been loaded already.
|
java.lang.String |
getAnnotationMessage()
Get a message that explains what the plug-in does with the annotations
it has.
|
ItemQuery<AnnotationType> |
getAnnotationTypes()
Return a query that finds annotation types for raw bioassays.
|
private RequestInformation |
getConfigureJobParameters(GuiContext context) |
private RequestInformation |
getConfigureParserParameters(RawDataType rdt) |
private RequestInformation |
getConfigureRawDataTypeParameters() |
protected java.util.Iterator<File> |
getFileIterator()
Get an iterator that returns the files to be imported.
|
java.util.Set<GuiContext> |
getGuiContexts()
Get a set containing all items that the plugin handles.
|
java.util.Collection<Permissions> |
getPermissions()
Request write access to RawBioAssay:s and read access to ArrayDesign:s, File:s,
Reporter:s, Platform:s and DataFileType:s
|
private ItemQuery<RawBioAssay> |
getRawBioAssayQuery(Experiment exp)
Get a query that returns all raw bioassays which it may be possible to
import raw data to for the given experiment.
|
RequestInformation |
getRequestInformation(GuiContext context,
java.lang.String command)
The
Request.COMMAND_CONFIGURE_PLUGIN command will ask for
what type of rawdata to import. |
protected java.lang.String |
getSuccessMessage(int skippedLines)
Return
x spots inserted . |
protected long |
getTotalFileSize()
Get the total file size of all files that are going to be imported.
|
protected void |
handleData(FlatFileParser.Data data)
Called by the parser for every line in the file that is
a data line.
|
protected void |
handleHeader(FlatFileParser.Line line)
Called by the parser for every line in the file that is
a header line.
|
java.lang.String |
isInContext(GuiContext context,
java.lang.Object item)
Returns null if the item is a
RawBioAssay of the correct
RawDataType and doesn't already have spots. |
boolean |
requiresConfiguration()
Return TRUE, since the implementation requires it for finding the
regular expressions used by the
FlatFileParser . |
protected void |
start()
Prepare for the import.
|
boolean |
supportsConfigurations()
Returns TRUE, since that is how the plugins used to work before this method
was introduced.
|
addErrorHandler, checkColumnMapping, checkColumnMapping, doImport, getCharset, getCharset, getDecimalSeparator, getErrorHandler, getErrorOption, getInitializedFlatFileParser, getMainType, getMapper, getMapper, getNumberFormat, getNumBytes, getProgress, getSignalHandler, handleSection, isImportable, isImportable, log, log, log, log, run, setUpErrorHandling, wrapInputStream
cloneParameterWithDefaultValue, closeLogFile, createLogFile, done, getCopyAnnotationsParmeter, getCurrentConfiguration, getCurrentJob, getJobOrConfigurationValue, getOverwriteAnnotationsParameters, init, log, log, storeValue, storeValue, storeValues, validateRequestParameters
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
done, getMainType, init, run
private static final java.util.Set<GuiContext> guiContexts
private static final java.util.Set<Permissions> permissions
private static final StringParameterType optionalColumnMapping
private static final StringParameterType requiredColumnMapping
private static final PluginParameter<java.lang.String> positionColumnMapping
private static final PluginParameter<java.lang.String> blockColumnMapping
private static final PluginParameter<java.lang.String> columnColumnMapping
private static final PluginParameter<java.lang.String> rowColumnMapping
private static final PluginParameter<java.lang.String> metaGridXColumnMapping
private static final PluginParameter<java.lang.String> metaGridYColumnMapping
private static final PluginParameter<java.lang.String> xColumnMapping
private static final PluginParameter<java.lang.String> yColumnMapping
private static final PluginParameter<java.lang.String> reporterIdColumnMapping
private static final PluginParameter<java.lang.String> featureIdColumnMapping
protected static final PluginParameter<java.lang.String> missingReporterErrorParameter
protected static final PluginParameter<java.lang.String> featureMismatchErrorParameter
protected static final PluginParameter<java.lang.String> duplicateFeatureErrorParameter
public static final java.lang.String COMMAND_CONFIGURE_PARSER
private java.util.List<PluginParameter<java.lang.String>> allColumnMappings
private RequestInformation configureParser
private RequestInformation configureJob
private RequestInformation configureRawDataType
private StringParameterType rawDataTypeType
private PluginParameter<java.lang.String> rawDataTypeParameter
private DbControl dc
private FlatFileParser ffp
private java.text.NumberFormat numberFormat
private boolean nullIfException
private boolean continueAfterError
private boolean transactionPerFile
private RawDataFlatFileImporter.FileIterator fileIterator
private long totalFileSize
private RawBioAssay rawBioAssay
private RawDataBatcher batcher
private FileSetMember rawDataMember
private Mapper featureIdMapper
private Mapper reporterMapper
private Mapper positionMapper
private Mapper blockMapper
private Mapper columnMapper
private Mapper rowMapper
private Mapper metaGridXMapper
private Mapper metaGridYMapper
private Mapper xMapper
private Mapper yMapper
private java.util.Map<RawDataProperty,Mapper> extendedMappers
public boolean supportsConfigurations()
AbstractPlugin
supportsConfigurations
in interface Plugin
supportsConfigurations
in class AbstractPlugin
public boolean requiresConfiguration()
AbstractFlatFileImporter
FlatFileParser
. If this
method is overridden and returns FALSE, the subclass must also override
the AbstractFlatFileImporter.getInitializedFlatFileParser()
method and provide a
parser with all regular expressions and other options set.requiresConfiguration
in interface Plugin
requiresConfiguration
in class AbstractFlatFileImporter
public java.util.Collection<Permissions> getPermissions()
getPermissions
in interface Plugin
getPermissions
in class AbstractPlugin
public java.util.Set<GuiContext> getGuiContexts()
InteractivePlugin
Item.REPORTER
.
This information is used by client applications to put the plugin
in the proper place in the user interface.getGuiContexts
in interface InteractivePlugin
Set
containing Item
:s, or null
if the plugin is not concerned about itemspublic java.lang.String isInContext(GuiContext context, java.lang.Object item)
RawBioAssay
of the correct
RawDataType
and doesn't already have spots.isInContext
in interface InteractivePlugin
context
- The current context of the client application,
it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
item
- The currently active item, it's type should match the
GuiContext.getItem()
type, or null if the context is a list
contextNull
if the plugin can use that item, or
a warning-level message explaining why the plugin can't be usedPermissionDeniedException
- If the raw bioasssay already has raw data
or if the logged in user doesn't have write permissionpublic RequestInformation getRequestInformation(GuiContext context, java.lang.String command) throws BaseException
Request.COMMAND_CONFIGURE_PLUGIN
command will ask for
what type of rawdata to import.
The COMMAND_CONFIGURE_PARSER
command will ask for
parser regular expressions and column mappings.
The Request.COMMAND_CONFIGURE_JOB
command will ask for
a file and the RawBioAssay
where the data should be added.getRequestInformation
in interface InteractivePlugin
command
- context
- The current context of the client application,
it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
RequestInformation
for the commandBaseException
- if there is an errorpublic void configure(GuiContext context, Request request, Response response)
Request.COMMAND_CONFIGURE_PLUGIN
,
COMMAND_CONFIGURE_PARSER
and Request.COMMAND_CONFIGURE_JOB
.configure
in interface InteractivePlugin
context
- The current context of the client application,
it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
request
- Request object with the command and parametersresponse
- Response object in for the plugin to response
throughpublic ItemQuery<AnnotationType> getAnnotationTypes()
getAnnotationTypes
in interface AnnotationSetterPlugin
public java.lang.String getAnnotationMessage()
AnnotationSetterPlugin
getAnnotationMessage
in interface AnnotationSetterPlugin
protected void start()
start
in class AbstractFlatFileImporter
protected boolean continueWithNextFileAfterError(java.lang.Throwable t)
UnsupportedFileFormatException
.
continueWithNextFileAfterError
in class AbstractFlatFileImporter
t
- The error that happenedprotected java.util.Iterator<File> getFileIterator()
AbstractFlatFileImporter
AbstractFlatFileImporter.getTotalFileSize()
method to return sum of all
file sizes. Eg. File.getSize()
.getFileIterator
in class AbstractFlatFileImporter
protected long getTotalFileSize()
AbstractFlatFileImporter
getTotalFileSize
in class AbstractFlatFileImporter
protected void begin(FlatFileParser ffp) throws BaseException
DbControl
(if needed) and a RawDataBatcher
.
Load the RawBioAssay
that has been specified.begin
in class AbstractFlatFileImporter
BaseException
AbstractFlatFileImporter.end(boolean)
protected void beginData()
Mapper
:s.beginData
in class AbstractFlatFileImporter
protected void end(boolean success) throws BaseException
end
in class AbstractFlatFileImporter
success
- TRUE if the file was parsed successfully, FALSE otherwiseBaseException
AbstractFlatFileImporter.begin(FlatFileParser)
public java.lang.String finish(java.lang.Throwable t)
finish
in class AbstractFlatFileImporter
t
- Null if no error has happenedprotected void handleData(FlatFileParser.Data data) throws BaseException
AbstractFlatFileImporter
handleData
in class AbstractFlatFileImporter
BaseException
protected void handleHeader(FlatFileParser.Line line) throws BaseException
AbstractFlatFileImporter
handleHeader
in class AbstractFlatFileImporter
BaseException
protected java.lang.String getSuccessMessage(int skippedLines)
x spots inserted
.getSuccessMessage
in class AbstractFlatFileImporter
skippedLines
- The number of data lines that were skipped due to errorsprivate java.util.List<PluginParameter<java.lang.String>> getAllColumnMappings(RawDataType rdt)
rdt
- the RawDataType
that defines the extra
properties.private RequestInformation getConfigureJobParameters(GuiContext context)
private void addRawBioAssayParameters(DbControl dc, RawBioAssay currentRaw, java.util.List<PluginParameter<?>> parameters)
private void addExperimentParameters(DbControl dc, Experiment currentExp, java.util.List<PluginParameter<?>> parameters)
private RequestInformation getConfigureRawDataTypeParameters()
private RequestInformation getConfigureParserParameters(RawDataType rdt)
private ItemQuery<RawBioAssay> getRawBioAssayQuery(Experiment exp)
exp
- The experiment