Class AnnotationTypeImporter
java.lang.Object
net.sf.basedb.core.plugin.AbstractPlugin
net.sf.basedb.plugins.AbstractFlatFileImporter
net.sf.basedb.plugins.batchimport.AbstractItemImporter<AnnotationType>
net.sf.basedb.plugins.batchimport.AnnotationTypeImporter
- All Implemented Interfaces:
AutoDetectingImporter
,InteractivePlugin
,Plugin
,SignalTarget
,ConfigureByExample
public class AnnotationTypeImporter extends AbstractItemImporter<AnnotationType>
Plug-in for importing annotation type items in a batch. The plug-in can create new
items and updated existing items.
- Since:
- 3.8
- Author:
- nicklas
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.sf.basedb.core.plugin.Plugin
Plugin.MainType
-
Field Summary
Fields Modifier and Type Field Description private static PluginParameter<String>
categoryColumnMapping
Column mapping parameter for assigning annotation types to categories.private Mapper
categoryMapper
private static PluginParameter<String>
defaultUnitColumnMapping
Column mapping parameter for "Default unit".private Mapper
defaultUnitMapper
private static PluginParameter<String>
defaultValueColumnMapping
Column mapping parameter for "Default value".private Mapper
defaultValueMapper
private Mapper
descriptionMapper
private static PluginParameter<String>
disableChangeLogColumnMapping
Column mapping parameter for "Disabled history log" flag.private Mapper
disableChangeLogMapper
private static PluginParameter<String>
disableInheritanceColumnMapping
Column mapping parameter for "Disable inheritance" flag.private Mapper
disableInheritanceMapper
private static PluginParameter<String>
enumerationColumnMapping
Column mapping parameter for "Enumeration".private Mapper
enumerationMapper
private Pattern
enumerationSplitter
private static PluginParameter<String>
enumerationSplitterRegexpParameter
Regular expression splitter parameter for enumerations.private Mapper
externalIdMapper
private static Set<GuiContext>
guiContexts
private static PluginParameter<String>
isIdentifierColumnMapping
Column mapping parameter for "Is identifier" flag.private Mapper
isIdentifierMapper
private static PluginParameter<String>
itemTypesColumnMapping
Column mapping parameter for "Item types".private Mapper
itemTypesMapper
private static PluginParameter<String>
maxValueColumnMapping
Column mapping parameter for "Max value".private Mapper
maxValueMapper
private static PluginParameter<String>
miameColumnMapping
Column mapping parameter for "Required for MIAME" flag.private Mapper
miameMapper
private static PluginParameter<String>
minValueColumnMapping
Column mapping parameter for "Min value".private Mapper
minValueMapper
private static PluginParameter<String>
multiplicityColumnMapping
Column mapping parameter for annotation multiplicty.private Mapper
multiplicityMapper
private Mapper
nameMapper
private NumberFormat
numberFormat
private static PluginParameter<String>
protocolParameterColumnMapping
Column mapping parameter for "Protocol parameter" flag.private Mapper
protocolParameterMapper
private Mapper
registeredMapper
private static PluginParameter<String>
usableUnitColumnMapping
Column mapping parameter for "Usable unit".private Mapper
usableUnitMapper
private static PluginParameter<String>
valueTypeColumnMapping
Column mapping parameter for the annotation value typeprivate Mapper
valueTypeMapper
Fields inherited from class net.sf.basedb.plugins.batchimport.AbstractItemImporter
addMembersMode, createMode, defaultsSection, descriptionColumnMapping, externalIdColumnMapping, idAnnotationColumnMapping, identificationSection, internalIdColumnMapping, kitColumnMapping, nameColumnMapping, optionalColumnMapping, permissionTemplateColumnMapping, protocolColumnMapping, registeredColumnMapping, removeMembersMode, requiredColumnMapping, subtypeColumnMapping, updateMode
Fields inherited from class net.sf.basedb.plugins.AbstractFlatFileImporter
complexMappings, dataFooterRegexpParameter, dataHeaderRegexpParameter, dataSplitterRegexpParameter, defaultErrorParameter, errorSection, excelSheetParameter, fileParameter, fileType, headerRegexpParameter, ignoreRegexpParameter, invalidUseOfNullErrorParameter, mappingSection, maxDataColumnsParameter, minDataColumnsParameter, numberFormatErrorParameter, numberOutOfRangeErrorParameter, numDataColumnsType, optionalRegexpType, parserSection, requiredRegexpType, sectionRegexpParameter, stringTooLongErrorParameter, trimQuotesParameter
Fields inherited from class net.sf.basedb.core.plugin.AbstractPlugin
annotationSection, configuration, COPY_ANNOTATIONS, job, OVERWRITE_ANNOTATIONS, sc
-
Constructor Summary
Constructors Constructor Description AnnotationTypeImporter()
-
Method Summary
Modifier and Type Method Description protected void
addMoreColumnMappingParameters(List<PluginParameter<?>> parameters)
Adds column mappings for name and description.protected void
addMoreParsingParameters(List<PluginParameter<?>> parameters)
Add extra parameters to the "Parser settings" section that the subclass needs.void
configure(GuiContext context, Request request, Response response)
Override this method so that we can make some extra parameter checks: A mapping for 'Value type' must be specified when 'create' or 'create+update' mode is usedprotected void
createColumnMappers(FlatFileParser ffp, boolean cropStrings)
Create mappers that can be used to extract data values from the file that is currently being parsed by theffp
FlatFileParser
.protected AnnotationType
createItem(DbControl dc, FlatFileParser.Data data)
Create a new item and populate it with data from the current line.protected ItemQuery<AnnotationType>
createItemQuery()
Set<GuiContext>
getGuiContexts()
Get a set containing all items that the plugin handles.protected IdMethod[]
getIdMethods()
protected void
updateItem(DbControl dc, AnnotationType at, FlatFileParser.Data data)
Update an item with data from the current line.protected void
updateMultiLineItem(DbControl dc, AnnotationType at, FlatFileParser.Data data, int multiLineNum)
Update an item with data from a multi-line entry.Methods inherited from class net.sf.basedb.plugins.batchimport.AbstractItemImporter
addMoreErrorParameters, addMoreJobParameters, begin, beginData, createItemQuery, doneWithItem, end, findAnnotationTypeCategory, findArrayBatch, findArrayDesign, findArraySlide, findBioPlate, findBioPlateType, findBioSource, findBioSource, findBioWell, findDataFileType, findDerivedBioAssay, findExtract, findExtract, findFileServer, findHardware, findHardware, findHybridization, findItemSubtype, findItemSubtype, findKit, findLabeledExtract, findPermissionTemplate, findPhysicalBioAssay, findPlateGeometry, findPlatform, findProtocol, findProtocol, findRawDataType, findReferencedItem, findReferencedItemWithSubtype, findSample, findSample, findSoftware, findSoftware, findTag, findTag, findUnit, findVariant, getAnnotationIdMethods, getConfigureOptionsParameters, getConfigureParserParameters, getDefaultItemFunction, getIdMethod, getItemForAnnotationTypes, getItemForSubtypes, getProjectDefaultPlatform, getProjectDefaultRawDataType, getProjectDefaultVariant, getRequestInformation, getSuccessMessage, handleData, initReferenceQuery, isInContext, parseDate, requiresConfiguration, setOrAddFile, setUpErrorHandling, supportsConfigurations, updateItemSubtype, updatePermissions
Methods inherited from class net.sf.basedb.plugins.AbstractFlatFileImporter
addErrorHandler, checkColumnMapping, checkColumnMapping, continueWithNextFileAfterError, doImport, finish, getCharset, getCharset, getDateFormatter, getDecimalSeparator, getErrorHandler, getErrorOption, getFileIterator, getInitializedFlatFileParser, getInitializedFlatFileParser, getMainType, getMapper, getMapper, getNumberFormat, getNumBytes, getPattern, getPattern, getProgress, getSignalHandler, getTimestampFormatter, getTotalFileSize, handleHeader, handleSection, isImportable, isImportable, log, log, log, log, run, start, wrapInputStream
Methods inherited from class net.sf.basedb.core.plugin.AbstractPlugin
cloneParameterWithDefaultValue, closeLogFile, createLogFile, done, getCopyAnnotationsParmeter, getCurrentConfiguration, getCurrentJob, getJobOrConfigurationValue, getOverwriteAnnotationsParameters, getPermissions, init, log, log, storeValue, storeValue, storeValues, validateRequestParameters
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.basedb.core.plugin.Plugin
done, getMainType, getPermissions, init, run
-
Field Details
-
guiContexts
-
valueTypeColumnMapping
Column mapping parameter for the annotation value type -
categoryColumnMapping
Column mapping parameter for assigning annotation types to categories. -
multiplicityColumnMapping
Column mapping parameter for annotation multiplicty. -
defaultValueColumnMapping
Column mapping parameter for "Default value". -
isIdentifierColumnMapping
Column mapping parameter for "Is identifier" flag. -
miameColumnMapping
Column mapping parameter for "Required for MIAME" flag. -
protocolParameterColumnMapping
Column mapping parameter for "Protocol parameter" flag. -
disableChangeLogColumnMapping
Column mapping parameter for "Disabled history log" flag. -
disableInheritanceColumnMapping
Column mapping parameter for "Disable inheritance" flag. -
itemTypesColumnMapping
Column mapping parameter for "Item types". -
defaultUnitColumnMapping
Column mapping parameter for "Default unit". -
usableUnitColumnMapping
Column mapping parameter for "Usable unit". -
enumerationColumnMapping
Column mapping parameter for "Enumeration". -
enumerationSplitterRegexpParameter
Regular expression splitter parameter for enumerations. -
minValueColumnMapping
Column mapping parameter for "Min value". -
maxValueColumnMapping
Column mapping parameter for "Max value". -
nameMapper
-
externalIdMapper
-
descriptionMapper
-
valueTypeMapper
-
categoryMapper
-
registeredMapper
-
multiplicityMapper
-
defaultValueMapper
-
isIdentifierMapper
-
miameMapper
-
protocolParameterMapper
-
disableChangeLogMapper
-
disableInheritanceMapper
-
itemTypesMapper
-
defaultUnitMapper
-
usableUnitMapper
-
enumerationMapper
-
minValueMapper
-
maxValueMapper
-
numberFormat
-
enumerationSplitter
-
-
Constructor Details
-
AnnotationTypeImporter
public AnnotationTypeImporter()
-
-
Method Details
-
getGuiContexts
Description copied from interface:InteractivePlugin
Get a set containing all items that the plugin handles. Ie. if the plugin imports reporters, return a set containingItem.REPORTER
. This information is used by client applications to put the plugin in the proper place in the user interface.- Returns:
- A
Set
containingItem
:s, or null if the plugin is not concerned about items
-
configure
Override this method so that we can make some extra parameter checks: A mapping for 'Value type' must be specified when 'create' or 'create+update' mode is used- Specified by:
configure
in interfaceInteractivePlugin
- Overrides:
configure
in classAbstractItemImporter<AnnotationType>
- Parameters:
context
- The current context of the client application, it is one of the values found in set returned byInteractivePlugin.getGuiContexts()
request
- Request object with the command and parametersresponse
- Response object in for the plugin to response through
-
getIdMethods
Useable methods are:- Overrides:
getIdMethods
in classAbstractItemImporter<AnnotationType>
-
addMoreParsingParameters
Description copied from class:AbstractItemImporter
Add extra parameters to the "Parser settings" section that the subclass needs. This method is called during configuration of the plug-in and the default implementation does nothing.- Overrides:
addMoreParsingParameters
in classAbstractItemImporter<AnnotationType>
- Parameters:
parameters
- The list of parameters to add the column mapping parameters to
-
addMoreColumnMappingParameters
Adds column mappings for name and description.- Overrides:
addMoreColumnMappingParameters
in classAbstractItemImporter<AnnotationType>
- Parameters:
parameters
- The list of parameters to add the column mapping parameters to
-
createItemQuery
- Specified by:
createItemQuery
in classAbstractItemImporter<AnnotationType>
- Returns:
- A query
-
createColumnMappers
Description copied from class:AbstractItemImporter
Create mappers that can be used to extract data values from the file that is currently being parsed by theffp
FlatFileParser
. This method is called during initialisation of the plug-in when theFlatFileParser.parseHeaders()
has successfully found the start of data. Use theAbstractFlatFileImporter.getMapper(FlatFileParser, String, Integer, Mapper)
to create column mappers. Example:nameMapper = getMapper(ffp, job.getValue("nameColumnMapping"), cropStrings ? Nameable.MAX_NAME_LENGTH : null, null);
- Overrides:
createColumnMappers
in classAbstractItemImporter<AnnotationType>
- Parameters:
ffp
- The parser that is parsing the data filecropStrings
- If strings that are too long to fit in the database should be cropped or not (=generate an error)
-
createItem
Description copied from class:AbstractItemImporter
Create a new item and populate it with data from the current line. Do not callDbControl.saveItem(BasicItem)
. This is done automatically by the core implementation.BioSource bs = BioSource.getNew(dc); // Set properties. See example on updateItem method return bs;
If the current data line doesn't have data for all required properties, this method should throw an
InvalidUseOfNullException
exception.This method is called during import when current item can be found and if the user has selected to create missing item.
- Specified by:
createItem
in classAbstractItemImporter<AnnotationType>
- Parameters:
dc
- The DbControl to use for database accessdata
- The current data line- Returns:
- A new item
-
updateItem
Description copied from class:AbstractItemImporter
Update an item with data from the current line. Example:if (nameMapper != null) item.setName(nameMapper.getValue(data)); if (descriptionMapper != null) item.setDescription(descriptionMapper.getValue(data)); ...
This method is called during import to update an existing item.- Specified by:
updateItem
in classAbstractItemImporter<AnnotationType>
- Parameters:
dc
- The DbControl to use for database accessat
- The item to updatedata
- The current data line
-
updateMultiLineItem
protected void updateMultiLineItem(DbControl dc, AnnotationType at, FlatFileParser.Data data, int multiLineNum)Description copied from class:AbstractItemImporter
Update an item with data from a multi-line entry. Items which can have multiple parents should have data for the other parents on lines following the first line.- Overrides:
updateMultiLineItem
in classAbstractItemImporter<AnnotationType>
- Parameters:
dc
- The DbControl to use for database accessat
- The item to updatedata
- The current data linemultiLineNum
- The number of the multi-line entry, starting with 1 for the first multi-line
-