Class AbstractItemImporter<I extends BasicItem>
- java.lang.Object
-
- net.sf.basedb.core.plugin.AbstractPlugin
-
- net.sf.basedb.plugins.AbstractFlatFileImporter
-
- net.sf.basedb.plugins.batchimport.AbstractItemImporter<I>
-
- All Implemented Interfaces:
AutoDetectingImporter
,InteractivePlugin
,Plugin
,SignalTarget
,ConfigureByExample
- Direct Known Subclasses:
AnnotationTypeImporter
,ArrayBatchImporter
,ArrayDesignImporter
,ArraySlideImporter
,BioPlateImporter
,BioSourceImporter
,DerivedBioAssayImporter
,ExtractImporter
,FileImporter
,KitImporter
,PhysicalBioAssayImporter
,RawBioAssayImporter
,SampleImporter
,TagImporter
public abstract class AbstractItemImporter<I extends BasicItem> extends AbstractFlatFileImporter implements InteractivePlugin, ConfigureByExample
An abstract base class for plug-ins that import items in batch. This class implements job configuration, file parsing, logging, error handling, etc. Actual implementations have to provide item-specific parts, such as:- The context the plug-in can be used = the type of item it can import.
Eg, implement the
InteractivePlugin.getGuiContexts()
method. - The methods that can be used for item identification:
getIdMethods()
- Job configuration parameters for column mappings to item-specific
properties:
addMoreColumnMappingParameters(List)
- Query used to find items of the specific type:
createItemQuery()
- Create actual column mappers used to extract data from the file
when running the plug-in:
createColumnMappers(FlatFileParser, boolean)
- Create a new item and populate it with data from the file:
createItem(DbControl, FlatFileParser.Data)
- Update an item with data from the file:
updateItem(DbControl, BasicItem, FlatFileParser.Data)
andupdateMultiLineItem(DbControl, BasicItem, FlatFileParser.Data, int)
- Version:
- 2.8
- Author:
- nicklas
- Last modified
- $Date: 2020-10-13 14:31:34 +0200 (Tue, 13 Oct 2020) $
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sf.basedb.core.plugin.Plugin
Plugin.MainType
-
-
Field Summary
-
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 AbstractItemImporter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addMoreColumnMappingParameters(List<PluginParameter<?>> parameters)
Add column mapping parameters for item-specific properties.protected void
addMoreErrorParameters(List<PluginParameter<?>> parameters)
Add extra parameters to the "Error handling" section that the subclass needs.protected void
addMoreJobParameters(List<PluginParameter<?>> parameters)
Add extra job parameters that the subclass needs.protected void
addMoreParsingParameters(List<PluginParameter<?>> parameters)
Add extra parameters to the "Parser settings" section that the subclass needs.protected void
begin(FlatFileParser ffp)
Setup error handling and pre-load some of the configuration options.protected void
beginData()
Setup column mapping.void
configure(GuiContext context, Request request, Response response)
Configure the plugin.protected 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 abstract I
createItem(DbControl dc, FlatFileParser.Data data)
Create a new item and populate it with data from the current line.protected abstract ItemQuery<I>
createItemQuery()
Create a new query that returns items of the importable type.protected ItemQuery<I>
createItemQuery(ItemList list)
Create a new query that returns items that are members of the given list.protected void
doneWithItem(DbControl dc, I item, int numMultiLines)
Called when the importer is finished with an item.protected void
end(boolean success)
Called just after the last line of the file has been parsed, or immediately after an error has ocurred.protected AnnotationTypeCategory
findAnnotationTypeCategory(DbControl dc, IdMethod idMethod, String identifier)
Find an annotation type category with a given identifier.protected ArrayBatch
findArrayBatch(DbControl dc, IdMethod idMethod, String identifier)
Find an array batch with a given identifier.protected ArrayDesign
findArrayDesign(DbControl dc, IdMethod idMethod, String identifier)
Find an array design with a given identifier.protected ArraySlide
findArraySlide(DbControl dc, IdMethod idMethod, String identifier)
Find an array slide with a given identifier.protected BioPlate
findBioPlate(DbControl dc, IdMethod idMethod, String identifier)
Find a bioplate with a given identifier.protected BioPlateType
findBioPlateType(DbControl dc, IdMethod idMethod, String identifier)
Find a bioplate type with a given identifier.protected BioSource
findBioSource(DbControl dc, IdMethod idMethod, String identifier)
Same asfindBioSource(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.protected BioSource
findBioSource(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a biosource with a given identifier.protected BioWell
findBioWell(DbControl dc, BioPlate plate, String row, String column)
Find a well on a bioplate.protected DataFileType
findDataFileType(DbControl dc, IdMethod idMethod, String identifier)
Find a data file type with a given identifier.protected DerivedBioAssay
findDerivedBioAssay(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a derived bioassay with a given identifier.protected Extract
findExtract(DbControl dc, IdMethod idMethod, String identifier)
Same asfindSample(DbControl, IdMethod, String, ItemSubtype)
with a null subtype.protected Extract
findExtract(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find an extract with a given identifier.protected FileServer
findFileServer(DbControl dc, IdMethod idMethod, String identifier)
Find a file server with a given identifier.protected Hardware
findHardware(DbControl dc, IdMethod idMethod, String identifier)
Same asfindHardware(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.protected Hardware
findHardware(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a hardware with a given identifier.protected PhysicalBioAssay
findHybridization(DbControl dc, IdMethod idMethod, String identifier)
Find a hybridization with a given identifier.protected ItemSubtype
findItemSubtype(DbControl dc, Item mainItemType, FlatFileParser.Data data)
Try to find subtype from the given file data.protected ItemSubtype
findItemSubtype(DbControl dc, IdMethod idMethod, Item mainType, String identifier)
Find an item subtype with a given identifier.protected Kit
findKit(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a kit with a given identifier.protected Extract
findLabeledExtract(DbControl dc, IdMethod idMethod, String identifier)
Find a labled extract with a given identifier.protected PermissionTemplate
findPermissionTemplate(DbControl dc, IdMethod idMethod, String identifier)
Find a permission template with a given identifier.protected PhysicalBioAssay
findPhysicalBioAssay(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a physical bioassay with a given identifier.protected PlateGeometry
findPlateGeometry(DbControl dc, IdMethod idMethod, String identifier)
Find a plate geometry with a given identifier.protected Platform
findPlatform(DbControl dc, IdMethod idMethod, String identifier)
Find a platform with a given identifier.protected Protocol
findProtocol(DbControl dc, IdMethod idMethod, String identifier)
Same asfindProtocol(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.protected Protocol
findProtocol(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a protocol with a given identifier.protected RawDataType
findRawDataType(DbControl dc, Platform platform, PlatformVariant variant, String identifier)
Find a matching raw data type.protected <T extends BasicItem>
TfindReferencedItem(DbControl dc, IdMethod idMethod, ItemQuery<T> query, String identifier, int subtypeId, boolean ignoreNotFound)
Find a referenced item.protected <T extends BasicItem>
TfindReferencedItemWithSubtype(DbControl dc, IdMethod idMethod, ItemQuery<T> query, String identifier, ItemSubtype subtype, boolean ignoreNotFound)
Find a referenced item with a subtype.protected Sample
findSample(DbControl dc, IdMethod idMethod, String identifier)
Same asfindSample(DbControl, IdMethod, String, ItemSubtype)
with a null subtype.protected Sample
findSample(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a sample with a given identifier.protected Software
findSoftware(DbControl dc, IdMethod idMethod, String identifier)
Same asfindSoftware(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.protected Software
findSoftware(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a software with a given identifier.protected Tag
findTag(DbControl dc, IdMethod idMethod, String identifier)
Same asfindTag(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.protected Tag
findTag(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a tag with a given identifier.protected Unit
findUnit(DbControl dc, IdMethod idMethod, String identifier)
Find a unit with a given identifier.protected PlatformVariant
findVariant(DbControl dc, Platform platform, IdMethod idMethod, String identifier)
Find a platform variant with a given identifier.protected List<IdMethod>
getAnnotationIdMethods(DbControl dc)
Get identification methods that are based on annotations.protected RequestInformation
getConfigureOptionsParameters(GuiContext context)
protected RequestInformation
getConfigureParserParameters(GuiContext context, boolean forJob)
protected <T extends Nameable>
DefaultItemFunction<T>getDefaultItemFunction(Item itemType)
Create aDefaultItemFunction
for the given item type.protected IdMethod
getIdMethod(DbControl dc, String method)
Get the id method to use for finding items.protected IdMethod[]
getIdMethods()
Get an array with all identification methods that can be used to find items.protected Item
getItemForAnnotationTypes()
Does the importer want to use annotation types as identifiers importing?protected Item
getItemForSubtypes()
Does the importer want to use item subtypes when importing?private ItemList
getItemListFromContext(DbControl dc, GuiContext context)
If the current context is the "Members" tab for an item list we load the item list and will later require that all items to be annotated are members of that list.protected Platform
getProjectDefaultPlatform(DbControl dc)
Get the default platform of the currently active project.protected RawDataType
getProjectDefaultRawDataType(DbControl dc)
Get the default raw data type of the currently active project.protected PlatformVariant
getProjectDefaultVariant(DbControl dc)
Get the default platform variant of the currently active project.RequestInformation
getRequestInformation(GuiContext context, String command)
This method will return theRequestInformation
for a given command, i.e.protected String
getSuccessMessage(int skippedLines)
Called if the parsing was successful to let the subclass generate a simple message that is sent back to the core and user interface.protected void
handleData(FlatFileParser.Data data)
Called by the parser for every line in the file that is a data line.protected <T extends BasicItem>
ItemQuery<T>initReferenceQuery(DbControl dc, IdMethod idMethod, ItemQuery<T> query, boolean subtype)
Initialise a query that is used to find referenced items.String
isInContext(GuiContext context, Object item)
Check if the plugin can be used on the specified object.protected Date
parseDate(String date)
Deprecated.In 3.15, useFlatFileParser.getDateMapper(String)
orFlatFileParser.getTimestampMapper(String)
andMapper.getDate(FlatFileParser.Data)
insteadboolean
requiresConfiguration()
Return TRUE, since the implementation requires it for finding the regular expressions used by theFlatFileParser
.protected FileSetMember
setOrAddFile(FileStoreEnabled item, DataFileType fileType, File file)
Set or add a file to a file set.protected void
setUpErrorHandling()
Don't use AbstractFlatFileImporter to handle errors.boolean
supportsConfigurations()
Returns TRUE, since that is how the plugins used to work before this method was introduced.protected abstract void
updateItem(DbControl dc, I item, FlatFileParser.Data data)
Update an item with data from the current line.protected void
updateItemSubtype(DbControl dc, Subtypable item, FlatFileParser.Data data)
If a mapping for item subtype has been specified or if a single subtype was selected for item identification in this job, this method is will update the subtype on the item.protected void
updateMultiLineItem(DbControl dc, I item, FlatFileParser.Data data, int multiLineNum)
Update an item with data from a multi-line entry.protected void
updatePermissions(DbControl dc, Shareable item, FlatFileParser.Data data, boolean merge)
If a mapping for a permission template has been specified for the job, this method is automatically called.-
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.InteractivePlugin
getGuiContexts
-
Methods inherited from interface net.sf.basedb.core.plugin.Plugin
done, getMainType, getPermissions, init, run
-
-
-
-
Field Detail
-
CONFIGURE_OPTIONS
private static final String CONFIGURE_OPTIONS
- See Also:
- Constant Field Values
-
optionalColumnMapping
protected static final StringParameterType optionalColumnMapping
-
requiredColumnMapping
protected static final StringParameterType requiredColumnMapping
-
defaultsSection
protected static final PluginParameter<String> defaultsSection
-
identificationSection
protected static final PluginParameter<String> identificationSection
-
internalIdColumnMapping
protected static final PluginParameter<String> internalIdColumnMapping
-
nameColumnMapping
protected static final PluginParameter<String> nameColumnMapping
-
idAnnotationColumnMapping
protected static final PluginParameter<String> idAnnotationColumnMapping
Column mapping parameter for the annotation column used for item identification.- Since:
- 3.15
-
subtypeColumnMapping
protected static final PluginParameter<String> subtypeColumnMapping
-
descriptionColumnMapping
protected static final PluginParameter<String> descriptionColumnMapping
-
externalIdColumnMapping
protected static final PluginParameter<String> externalIdColumnMapping
-
registeredColumnMapping
protected static final PluginParameter<String> registeredColumnMapping
Column mapping parameter for the item registration date.- Since:
- 3.11
-
protocolColumnMapping
protected static final PluginParameter<String> protocolColumnMapping
-
kitColumnMapping
protected static final PluginParameter<String> kitColumnMapping
-
permissionTemplateColumnMapping
protected static final PluginParameter<String> permissionTemplateColumnMapping
-
itemNotFoundErrorParameter
private static final PluginParameter<String> itemNotFoundErrorParameter
-
itemExistsErrorParameter
private static final PluginParameter<String> itemExistsErrorParameter
-
multipleItemsFoundErrorParameter
private static final PluginParameter<String> multipleItemsFoundErrorParameter
-
referenceNotFoundErrorParameter
private static final PluginParameter<String> referenceNotFoundErrorParameter
-
multipleReferencesFoundErrorParameter
private static final PluginParameter<String> multipleReferencesFoundErrorParameter
-
noWritePermissionToItemErrorParameter
private static final PluginParameter<String> noWritePermissionToItemErrorParameter
-
noUsePermissionToReferenceErrorParameter
private static final PluginParameter<String> noUsePermissionToReferenceErrorParameter
-
dc
private DbControl dc
-
activeProject
private Project activeProject
-
ffp
private FlatFileParser ffp
-
idMethod
private IdMethod idMethod
-
idMapping
private String idMapping
-
idMapper
private Mapper idMapper
-
permissionTemplateMapper
private Mapper permissionTemplateMapper
-
subtypeMapper
private Mapper subtypeMapper
-
selectedSubtype
private ItemSubtype selectedSubtype
-
itemList
private ItemList itemList
-
updateMode
boolean updateMode
-
createMode
boolean createMode
-
addMembersMode
boolean addMembersMode
-
removeMembersMode
boolean removeMembersMode
-
lastIdentifier
private String lastIdentifier
-
numMultiLines
private int numMultiLines
-
skippedLast
private boolean skippedLast
-
dryRun
private boolean dryRun
-
errorHandler
private ClassMapErrorHandler errorHandler
-
cropStrings
private boolean cropStrings
-
createNotFoundItems
private boolean createNotFoundItems
-
failIfNotFoundItems
private boolean failIfNotFoundItems
-
updateExistingItems
private boolean updateExistingItems
-
failIfItemExists
private boolean failIfItemExists
-
failIfMultipleFoundItems
private boolean failIfMultipleFoundItems
-
failIfNotFoundReference
private boolean failIfNotFoundReference
-
failIfMultipleFoundReferences
private boolean failIfMultipleFoundReferences
-
failIfNoWritePermissionToItem
private boolean failIfNoWritePermissionToItem
-
failIfNoUsePermissionToReference
private boolean failIfNoUsePermissionToReference
-
numUpdated
private int numUpdated
-
numCreated
private int numCreated
-
numError
private int numError
-
numNotFound
private int numNotFound
-
numExisted
private int numExisted
-
subtypeQuery
private ItemQuery<ItemSubtype> subtypeQuery
-
annotationTypeCategoryQuery
private ItemQuery<AnnotationTypeCategory> annotationTypeCategoryQuery
-
variantQuery
private ItemQuery<PlatformVariant> variantQuery
-
fileTypeQuery
private ItemQuery<DataFileType> fileTypeQuery
-
permissionTemplateQuery
private ItemQuery<PermissionTemplate> permissionTemplateQuery
-
arraySlideQuery
private ItemQuery<ArraySlide> arraySlideQuery
-
hybQuery
private ItemQuery<PhysicalBioAssay> hybQuery
-
physicalBioAssayQuery
private ItemQuery<PhysicalBioAssay> physicalBioAssayQuery
-
derivedBioAssayQuery
private ItemQuery<DerivedBioAssay> derivedBioAssayQuery
-
designQuery
private ItemQuery<ArrayDesign> designQuery
-
batchQuery
private ItemQuery<ArrayBatch> batchQuery
-
geometryQuery
private ItemQuery<PlateGeometry> geometryQuery
-
bioPlateTypeQuery
private ItemQuery<BioPlateType> bioPlateTypeQuery
-
fileServerQuery
private ItemQuery<FileServer> fileServerQuery
-
itemCache
private Map<String,BasicItem> itemCache
Cache that holds loaded/created items. The cache key is item type + identifier, eq. SAMPLE:My sample, EXTRACT:An extract. The same item may be cached under more than one key depending on which identifier has been used to look it up, eg name, id, etc.: SAMPLE:My sample, SAMPLE:10.
-
configureParser
private RequestInformation configureParser
-
configureOptions
private RequestInformation configureOptions
-
-
Method Detail
-
requiresConfiguration
public boolean requiresConfiguration()
Description copied from class:AbstractFlatFileImporter
Return TRUE, since the implementation requires it for finding the regular expressions used by theFlatFileParser
. If this method is overridden and returns FALSE, the subclass must also override theAbstractFlatFileImporter.getInitializedFlatFileParser()
method and provide a parser with all regular expressions and other options set.- Specified by:
requiresConfiguration
in interfacePlugin
- Overrides:
requiresConfiguration
in classAbstractFlatFileImporter
- Returns:
- TRUE or FALSE
-
supportsConfigurations
public boolean supportsConfigurations()
Description copied from class:AbstractPlugin
Returns TRUE, since that is how the plugins used to work before this method was introduced.- Specified by:
supportsConfigurations
in interfacePlugin
- Overrides:
supportsConfigurations
in classAbstractPlugin
- Returns:
- TRUE or FALSE
-
isInContext
public String isInContext(GuiContext context, Object item)
Description copied from interface:InteractivePlugin
Check if the plugin can be used on the specified object. The item is either aBasicItem
orBasicData
object, or null if called from a list context. A client application should only call this method for contexts matching one of the contexts in the set returned by theInteractivePlugin.getGuiContexts()
method. ForGuiContext.Type.ITEM
contexts an item of the correct type should be passed as a parameter.The plug-in can response with a null value indicating success, a warning-level message or throw an exception to indicate an error-level message. Client application should normally only show error-level messages to users, unless the user has requested to see warning messages.
NOTE! Before BASE 2.4 all messages were treated as error-level messages.
- Specified by:
isInContext
in interfaceInteractivePlugin
- Parameters:
context
- The current context of the client application, it is one of the values found in set returned byInteractivePlugin.getGuiContexts()
item
- The currently active item, it's type should match theGuiContext.getItem()
type, or null if the context is a list context- Returns:
Null
if the plugin can use that item, or a warning-level message explaining why the plugin can't be used
-
configure
public void configure(GuiContext context, Request request, Response response)
Description copied from interface:InteractivePlugin
Configure the plugin. Hopefully the client is supplying values for the parameters specified byInteractivePlugin.getRequestInformation(GuiContext, String)
.- Specified by:
configure
in interfaceInteractivePlugin
- 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
-
getRequestInformation
public RequestInformation getRequestInformation(GuiContext context, String command) throws BaseException
Description copied from interface:InteractivePlugin
This method will return theRequestInformation
for a given command, i.e. the list of parameters and some nice help text.- Specified by:
getRequestInformation
in interfaceInteractivePlugin
- Parameters:
context
- The current context of the client application, it is one of the values found in set returned byInteractivePlugin.getGuiContexts()
command
- The command- Returns:
- The
RequestInformation
for the command - Throws:
BaseException
- if there is an error
-
setUpErrorHandling
protected void setUpErrorHandling()
Don't use AbstractFlatFileImporter to handle errors.- Overrides:
setUpErrorHandling
in classAbstractFlatFileImporter
-
begin
protected void begin(FlatFileParser ffp)
Setup error handling and pre-load some of the configuration options.- Overrides:
begin
in classAbstractFlatFileImporter
- See Also:
AbstractFlatFileImporter.end(boolean)
-
beginData
protected void beginData()
Setup column mapping. Creates DbControl and query to find items.- Overrides:
beginData
in classAbstractFlatFileImporter
-
handleData
protected void handleData(FlatFileParser.Data data) throws BaseException
Description copied from class:AbstractFlatFileImporter
Called by the parser for every line in the file that is a data line.- Specified by:
handleData
in classAbstractFlatFileImporter
- Throws:
BaseException
-
end
protected void end(boolean success)
Description copied from class:AbstractFlatFileImporter
Called just after the last line of the file has been parsed, or immediately after an error has ocurred. A subclass should clean up any resources aquired in theAbstractFlatFileImporter.begin(FlatFileParser)
method here. Note that this metod is called once for every file returned by theAbstractFlatFileImporter.getFileIterator()
iterator.- Overrides:
end
in classAbstractFlatFileImporter
- Parameters:
success
- TRUE if the file was parsed successfully, FALSE otherwise- See Also:
AbstractFlatFileImporter.begin(FlatFileParser)
-
getSuccessMessage
protected String getSuccessMessage(int skippedLines)
Description copied from class:AbstractFlatFileImporter
Called if the parsing was successful to let the subclass generate a simple message that is sent back to the core and user interface. An example message might by:178 reporters imported successfully
. The default implementation always return null. Note that this method is called once for every file returned byAbstractFlatFileImporter.getFileIterator()
.- Overrides:
getSuccessMessage
in classAbstractFlatFileImporter
- Parameters:
skippedLines
- The number of data lines that were skipped due to errors
-
getIdMethods
protected IdMethod[] getIdMethods()
Get an array with all identification methods that can be used to find items. The default implementation returns an array with thePropertyIdMethod.NAME
,InternalIdMethod.INTERNAL_ID
andFallbackIdMethod.NAME_OR_ID
ID methods. Subclasses that import items that can use other ID methods, should override this method.
-
getAnnotationIdMethods
protected List<IdMethod> getAnnotationIdMethods(DbControl dc)
Get identification methods that are based on annotations. The default implementation first calls thegetItemForAnnotationTypes()
. If this returns a non-null value it will make a query for all annotation types that are suitable as identifiers: The value type must be one of STRING, INT or LONG It must not be an enumeration The 'identifier' flag must be set- Since:
- 3.15
-
addMoreJobParameters
protected void addMoreJobParameters(List<PluginParameter<?>> parameters)
Add extra job parameters that the subclass needs. This method is called during configuration of the plug-in and the default implementation does nothing.- Parameters:
parameters
- The list of parameters to add the column mapping parameters to
-
addMoreParsingParameters
protected void addMoreParsingParameters(List<PluginParameter<?>> parameters)
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.- Parameters:
parameters
- The list of parameters to add the column mapping parameters to
-
addMoreColumnMappingParameters
protected void addMoreColumnMappingParameters(List<PluginParameter<?>> parameters)
Add column mapping parameters for item-specific properties. A subclass must add parameters for all properties, including name and description. This class has already created some useful parameters for this purpose, for example:nameColumnMapping
anddescriptionColumnMapping
. This method is called during configuration of the plug-in.- Parameters:
parameters
- The list of parameters to add the column mapping parameters to
-
addMoreErrorParameters
protected void addMoreErrorParameters(List<PluginParameter<?>> parameters)
Add extra parameters to the "Error handling" section that the subclass needs. This method is called during configuration of the plug-in and the default implementation does nothing.- Parameters:
parameters
- The list of parameters to add the column mapping parameters to
-
createItemQuery
protected ItemQuery<I> createItemQuery(ItemList list)
Create a new query that returns items that are members of the given list. The default implementation callscreateItemQuery()
and then applies a restriction to it if the list is not null and have the same member type as the query.- Since:
- 3.15
-
createItemQuery
protected abstract ItemQuery<I> createItemQuery()
Create a new query that returns items of the importable type. The query should be a plain query not including any restrictions or other elements. This will automatically be added as needed by the core implementation. This method is called during execution of the plug-in. Typically, the result fromgetQuery()
should be returned, eg.Sample.getQuery()
.- Returns:
- A query
-
getItemForSubtypes
protected Item getItemForSubtypes()
Does the importer want to use item subtypes when importing? If this method returns a non-null, this class will add a parameter in the "Item identification" section that makes it possible to select which subtypes the importer should use to limit the search for existing items. The default implementation returns null.- Returns:
- An Item or null
-
getItemForAnnotationTypes
protected Item getItemForAnnotationTypes()
Does the importer want to use annotation types as identifiers importing? If this method returns a non-null, this class will add all annotation types from thegetAnnotationIdMethods(DbControl)
to the ID method parameter. The subclass must also add theidAnnotationColumnMapping
to theaddMoreColumnMappingParameters(List)
method. The default implementation returns null.- Returns:
- An Item or null
- Since:
- 3.15
-
createColumnMappers
protected 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
. 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);
- 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
protected abstract I createItem(DbControl dc, FlatFileParser.Data data)
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.
- Parameters:
dc
- The DbControl to use for database accessdata
- The current data line- Returns:
- A new item
-
updateItem
protected abstract void updateItem(DbControl dc, I item, FlatFileParser.Data data)
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.- Parameters:
dc
- The DbControl to use for database accessitem
- The item to updatedata
- The current data line
-
updateMultiLineItem
protected void updateMultiLineItem(DbControl dc, I item, FlatFileParser.Data data, int multiLineNum)
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.- Parameters:
dc
- The DbControl to use for database accessitem
- The item to updatedata
- The current data linemultiLineNum
- The number of the multi-line entry, starting with 1 for the first multi-line
-
doneWithItem
protected void doneWithItem(DbControl dc, I item, int numMultiLines)
Called when the importer is finished with an item. This method is useful when working with multi-line entries, when the subclass needs to do some additional work after all data has been set. NOTE! This assumes that the lines in the data file are sorted in the correct order and the no lines for the same item will follow later on.- Parameters:
dc
- The DbControl to use for database accessitem
- The item to updatenumMultiLines
- The number of the multi-line entries, starting with 1 for the first multi-line (0 for single-line entries)
-
updatePermissions
protected void updatePermissions(DbControl dc, Shareable item, FlatFileParser.Data data, boolean merge)
If a mapping for a permission template has been specified for the job, this method is automatically called. It will merge or replace the permissions on the item with the permissions from the template.- Parameters:
dc
- A DbControl used to lookup the permission templateitem
- The item to updatedata
- Data from the filemerge
- TRUE to merge the permissions, FALSE to replace the permissions- Since:
- 2.16
-
updateItemSubtype
protected void updateItemSubtype(DbControl dc, Subtypable item, FlatFileParser.Data data)
If a mapping for item subtype has been specified or if a single subtype was selected for item identification in this job, this method is will update the subtype on the item.- Parameters:
dc
- A DbControl used to lookup the subtypeitem
- The item to updatedata
- Data from the file- Since:
- 3.0
-
findItemSubtype
protected ItemSubtype findItemSubtype(DbControl dc, Item mainItemType, FlatFileParser.Data data)
Try to find subtype from the given file data. If a single subtype was selected for item identification in this job, that subtype is used if no mapped subtype can be found.- Parameters:
dc
- A DbControl used to lookup the subtypemainItemType
- The main item type of the subtypedata
- Data from the file- Returns:
- A subtype of null if no subtype could be found
- Since:
- 3.0
-
getDefaultItemFunction
protected <T extends Nameable> DefaultItemFunction<T> getDefaultItemFunction(Item itemType)
Create aDefaultItemFunction
for the given item type. The currently active project (if any) is used.- Parameters:
itemType
- The type of items the function should look for- Since:
- 3.1
-
getIdMethod
protected IdMethod getIdMethod(DbControl dc, String method)
Get the id method to use for finding items. This implementation searches the methods returned bygetIdMethods()
andgetAnnotationIdMethods(DbControl)
for a method with the given name. If no method can be foundPropertyIdMethod.NAME
is returned.
-
parseDate
@Deprecated protected Date parseDate(String date)
Deprecated.In 3.15, useFlatFileParser.getDateMapper(String)
orFlatFileParser.getTimestampMapper(String)
andMapper.getDate(FlatFileParser.Data)
insteadParse a string to a date using the date format specified by the 'Date format' parameter. This is a utility method that subclasses can use to extract date values, since theMapper
interface doesn't supports it.
-
findItemSubtype
protected ItemSubtype findItemSubtype(DbControl dc, IdMethod idMethod, Item mainType, String identifier)
Find an item subtype with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier for the subtypemainType
- The main item type for the subtype- Returns:
- A subtype, or null if no item could be found
- Since:
- 3.0
-
findProtocol
protected Protocol findProtocol(DbControl dc, IdMethod idMethod, String identifier)
Same asfindProtocol(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.
-
findProtocol
protected Protocol findProtocol(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a protocol with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no protocol is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The protocol subtype, or null if the type doesn't matter- Returns:
- A protocol, or null if no item could be found
- Since:
- 3.0
-
findKit
protected Kit findKit(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a kit with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no kit is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The kit subtype, or null if the type doesn't matter- Returns:
- A kit, or null if no item could be found
- Since:
- 3.7
-
findTag
protected Tag findTag(DbControl dc, IdMethod idMethod, String identifier)
Same asfindTag(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.
-
findTag
protected Tag findTag(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a tag with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no hardware is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The tag subtype, or null if the type doesn't matter- Returns:
- A tag, or null if no item could be found
- Since:
- 3.0
-
findHardware
protected Hardware findHardware(DbControl dc, IdMethod idMethod, String identifier)
Same asfindHardware(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.
-
findHardware
protected Hardware findHardware(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a hardware with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no hardware is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The hardware subtype, or null if the type doesn't matter- Returns:
- A hardware, or null if no item could be found
- Since:
- 3.0
-
findSoftware
protected Software findSoftware(DbControl dc, IdMethod idMethod, String identifier)
Same asfindSoftware(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.
-
findSoftware
protected Software findSoftware(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a software with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no software is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The software subtype, or null if the type doesn't matter- Returns:
- A software, or null if no item could be found
- Since:
- 3.0
-
findAnnotationTypeCategory
protected AnnotationTypeCategory findAnnotationTypeCategory(DbControl dc, IdMethod idMethod, String identifier)
Find an annotation type category with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- An annotation type category, or null if no item could be found
- Since:
- 3.8
-
findUnit
protected Unit findUnit(DbControl dc, IdMethod idMethod, String identifier)
Find a unit with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- A unit, or null if no item could be found
- Since:
- 3.8
-
findPlatform
protected Platform findPlatform(DbControl dc, IdMethod idMethod, String identifier)
Find a platform with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- A platform, or null if no item could be found
-
getProjectDefaultPlatform
protected Platform getProjectDefaultPlatform(DbControl dc)
Get the default platform of the currently active project. If there is more than one default platform, the first one is selected.- Returns:
- The active platform, or null if no project is active or the project doesn't specify a platform
- Since:
- 2.9
-
getProjectDefaultVariant
protected PlatformVariant getProjectDefaultVariant(DbControl dc)
Get the default platform variant of the currently active project.- Returns:
- The active platform variant, or null if no project is active or the project doesn't specify a variant
- Since:
- 2.9
-
findVariant
protected PlatformVariant findVariant(DbControl dc, Platform platform, IdMethod idMethod, String identifier)
Find a platform variant with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessplatform
- If given, searched only variants of this platformidentifier
- The identifier protocol- Returns:
- A platform, or null if no item could be found
-
getProjectDefaultRawDataType
protected RawDataType getProjectDefaultRawDataType(DbControl dc)
Get the default raw data type of the currently active project.- Returns:
- The active raw data type, or null if no project is active or the project doesn't specify raw data type
- Since:
- 2.9
-
findDataFileType
protected DataFileType findDataFileType(DbControl dc, IdMethod idMethod, String identifier)
Find a data file type with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- A data file, or null if no item could be found
-
findPermissionTemplate
protected PermissionTemplate findPermissionTemplate(DbControl dc, IdMethod idMethod, String identifier)
Find a permission template with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier for the template- Returns:
- A permission template, or null if no item could be found
-
findBioSource
protected BioSource findBioSource(DbControl dc, IdMethod idMethod, String identifier)
Same asfindBioSource(DbControl, IdMethod, String, ItemSubtype)
with a null item subtype.
-
findBioSource
protected BioSource findBioSource(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a biosource with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no biosource is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The biosource subtype, or null if the type doesn't matter- Returns:
- A biosource, or null if no item could be found
- Since:
- 3.0
-
findSample
protected Sample findSample(DbControl dc, IdMethod idMethod, String identifier)
Same asfindSample(DbControl, IdMethod, String, ItemSubtype)
with a null subtype.
-
findSample
protected Sample findSample(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a sample with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no sample is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The sample subtype, or null if the type doesn't matter- Returns:
- A sample, or null if no item could be found
- Since:
- 3.0
-
findExtract
protected Extract findExtract(DbControl dc, IdMethod idMethod, String identifier)
Same asfindSample(DbControl, IdMethod, String, ItemSubtype)
with a null subtype.
-
findExtract
protected Extract findExtract(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find an extract with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no extract is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The extract subtype, or null if the type doesn't matter- Returns:
- An extract, or null if no item could be found
- Since:
- 3.0
-
findLabeledExtract
protected Extract findLabeledExtract(DbControl dc, IdMethod idMethod, String identifier)
Find a labled extract with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! A labeled extract is an extract with a subtype
Extract.LABELED
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- A labeled extract, or null if no item could be found
-
findBioPlate
protected BioPlate findBioPlate(DbControl dc, IdMethod idMethod, String identifier)
Find a bioplate with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- A bioplate, or null if no item could be found
-
findBioWell
protected BioWell findBioWell(DbControl dc, BioPlate plate, String row, String column)
Find a well on a bioplate. Null is allowed for all parameters but will always result in a null return value.- Parameters:
dc
- The DbControl to use for database accessplate
- The plate to look onrow
- The row coordinate in alphabetic or 1-based valuescolumn
- The column coordinate in alphabetic or 1-based values- Returns:
- A biowell, or null if no item could be found
- Since:
- 2.16
-
findArraySlide
protected ArraySlide findArraySlide(DbControl dc, IdMethod idMethod, String identifier)
Find an array slide with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- An array slide, or null if no item could be found
-
findHybridization
protected PhysicalBioAssay findHybridization(DbControl dc, IdMethod idMethod, String identifier)
Find a hybridization with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! A hybridization is a physical bioassay with a subtype
PhysicalBioAssay.HYBRIDIZATION
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- A hybridization, or null if no item could be found
-
findPhysicalBioAssay
protected PhysicalBioAssay findPhysicalBioAssay(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a physical bioassay with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no bioassay is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The bioassay subtype, or null if the type doesn't matter- Returns:
- A physical bioassay, or null if no item could be found
- Since:
- 3.0
-
findDerivedBioAssay
protected DerivedBioAssay findDerivedBioAssay(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
Find a derived bioassay with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.NOTE! If this method is called with a non-null item subtype parameter and no bioassay is found the query will be retried without any subtype.
- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocolsubtype
- The bioassay subtype, or null if the type doesn't matter- Returns:
- A derived bioassay, or null if no item could be found
- Since:
- 3.0
-
findArrayDesign
protected ArrayDesign findArrayDesign(DbControl dc, IdMethod idMethod, String identifier)
Find an array design with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- An array design, or null if no item could be found
-
findArrayBatch
protected ArrayBatch findArrayBatch(DbControl dc, IdMethod idMethod, String identifier)
Find an array batch with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- An array batch, or null if no item could be found
-
findPlateGeometry
protected PlateGeometry findPlateGeometry(DbControl dc, IdMethod idMethod, String identifier)
Find a plate geometry with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- A plate geometry, or null if no item could be found
- Since:
- 2.16
-
findBioPlateType
protected BioPlateType findBioPlateType(DbControl dc, IdMethod idMethod, String identifier)
Find a bioplate type with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- A bioplate type, or null if no item could be found
- Since:
- 2.16
-
findRawDataType
protected RawDataType findRawDataType(DbControl dc, Platform platform, PlatformVariant variant, String identifier)
Find a matching raw data type. This method will look in the following order:- The raw data type locked to the platform variant:
PlatformVariant.getRawDataType()
- The raw data type locked to the platform:
Platform.getRawDataType()
- Any registered raw data type with the given 'id':
RawDataTypes.getRawDataType(String)
- Any registered raw data type with the given 'name':
RawDataTypes.getRawDataTypes()
- The project default raw data type:
getProjectDefaultRawDataType(DbControl)
failIfMultipleFoundReferences
andfailIfNotFoundReference
) determine if an exception is thrown or not.- Parameters:
platform
- The current platform or null to not use a platform for lookupvariant
- The current platform variant or null to not use a variant for lookupidentifier
- The 'id' or 'name' of a raw data type, or null to not use this for lookup- Returns:
- A raw data type or null if not found
- Since:
- 2.15
- The raw data type locked to the platform variant:
-
findFileServer
protected FileServer findFileServer(DbControl dc, IdMethod idMethod, String identifier)
Find a file server with a given identifier. This is a utility method that subclasses can use when creating or updating items.NOTE! The first time this method is called a query object is initialised using the
IdMethod.prepareQuery(DbControl, ItemQuery)
method. Subsequent calls uses the same query. Thus, this method should always be called with the same id method object, otherwise the result is undefined.- Parameters:
dc
- The DbControl to use for database accessidentifier
- The identifier protocol- Returns:
- A file server, or null if no item could be found
- Since:
- 3.3
-
setOrAddFile
protected FileSetMember setOrAddFile(FileStoreEnabled item, DataFileType fileType, File file)
Set or add a file to a file set. The first time this method is called for a given item and file type combinationFileSet.setMember(File, DataFileType)
is used to add the file to the file set (which will replace all other files of the same file type. If this method is called more times thenFileSet.addMember(File, DataFileType)
is used so that already added files are preserved. If the file is null the first time, all files of the given file types are removed. If the file is null after the first time, this call is ignored.- Parameters:
item
- The item to set/add a file tofileType
- The type of the filefile
- The file, or null- Returns:
- The new member entry, or null if the call didn't result in an addition
- Since:
- 3.0
-
initReferenceQuery
protected <T extends BasicItem> ItemQuery<T> initReferenceQuery(DbControl dc, IdMethod idMethod, ItemQuery<T> query, boolean subtype)
Initialise a query that is used to find referenced items. This method delegates toIdMethod.prepareQuery(DbControl, ItemQuery)
and then addsInclude
options: MINE, IN_PROJECT, SHARED and OTHERS.- Parameters:
dc
- A DbControl used for database accessidMethod
- The identification method to usequery
- The query to initialisedsubtype
- If TRUE a restriction for subtype is added to the query- Returns:
- The initialised query
-
findReferencedItemWithSubtype
protected <T extends BasicItem> T findReferencedItemWithSubtype(DbControl dc, IdMethod idMethod, ItemQuery<T> query, String identifier, ItemSubtype subtype, boolean ignoreNotFound)
Find a referenced item with a subtype. This method may call thefindReferencedItem(DbControl, IdMethod, ItemQuery, String, int, boolean)
method two times. First, with a query limited to return items of the given subtype, then a second time without the limit. The query must have been created by theinitReferenceQuery(DbControl, IdMethod, ItemQuery, boolean)
method with TRUE for the last parameter. If the subtype parameter is null the first query is skipped.
-
findReferencedItem
protected <T extends BasicItem> T findReferencedItem(DbControl dc, IdMethod idMethod, ItemQuery<T> query, String identifier, int subtypeId, boolean ignoreNotFound)
Find a referenced item. This method will first look in theitemCache
. If no item is found in the cache it uses the query and id method (IdMethod.find(DbControl, ItemQuery, String)
) to look for the item. The result of the lookup is stored in the cache (even if no item is found).- Parameters:
dc
- A DbControl used for database accessidMethod
- The identification methodignoreNotFound
- TRUE to ignore not found errors- Returns:
- The item, or null if none is found
- Throws:
ItemNotFoundException
- If no item is found and the error handling is set to fail for this conditionBaseException
- If multiple items are found and the error handling is set to fail for this condition
-
getItemListFromContext
private ItemList getItemListFromContext(DbControl dc, GuiContext context)
If the current context is the "Members" tab for an item list we load the item list and will later require that all items to be annotated are members of that list.
-
getConfigureParserParameters
protected RequestInformation getConfigureParserParameters(GuiContext context, boolean forJob)
-
getConfigureOptionsParameters
protected RequestInformation getConfigureOptionsParameters(GuiContext context)
-
-