Class RawDataBatcher
- All Implemented Interfaces:
AutoCloseable
,AccessControlled
,Batcher
RawBioAssay
.
If the raw bioassay is connected to an array design with features
the raw data is verified against the features before it is inserted
as follows:
- Find the feature located at the same coordinates as given by the row, column and block or row, column, metaGridX and metaGridY. A block number of zero signals that meta coordinates should be used. All other values use block coordinates.
- If a feature isn't found, an
ItemNotFoundException
is thrown - If you have specified to verify the external reporter id by using the
insert(RawData, String, String)
method the external reporter id of the feature is checked against the supplied reporter id. If they don't match anInvalidDataException
is thrown. - Finally, the position and reporter is copied from the feature to the raw data. Note that any reporter you have set on the raw data yourself is overwritten and never used.
Note that if the raw bioassay isn't connected to an array design no checks are made
and none of the above apply. The major difference is that you must alsways set a
reporter youself in this case. We recommend that you use the insert(RawData)
method if no array design is connected, and the insert(RawData, String, String)
method otherwise.
- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
(package private) static class
(package private) static class
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
If we should always accept inserts when the feature has a NULL reporter.private final ArrayDesignData
The array design the raw bioassay is connected to, if any.private long
The number of bytes the spot data is occupying on disk.private final boolean
If case should be ignored when comparing strings (external ID)private int
Keeps track of the position number unless the raw bioassay is connected to an array design with features.private static final boolean
So we don't always have to call logSql.debug()private RawDataBatcher.FeatureProxy
private FeatureIdentificationMethod
The method to use for identifying features.private Query<ReporterData>
A query to find reporters by the external id.private static final Logger
Log all SQL statements.private int
The number of accepted inserts were the feature had a NULL reporterprivate int
The number of reporters that was not found.private int
The number of skipped inserts due to missing featureprivate Map<Object,
RawDataBatcher.FeatureInfo> Holds info about the features of an array design.private final RawBioAssay
The raw bioassay this batcher adds raw data to.private final RawBioAssayData
Just a copy of the data object for the raw bioassay.private final RawDataType
The type of raw data to batch.private RawDataBatcher.ReporterProxy
private boolean
If inserts that can't find a matching feature should be skipped or generate an error.Keep track of the used features to make sure that no more than raw data spot references the same feature.private boolean
If we should use the null reporter if a reporter isn't found.Fields inherited from class net.sf.basedb.core.BasicBatcher
debugEnabled, logParam
-
Constructor Summary
ConstructorDescriptionRawDataBatcher
(DbControl dc, RawBioAssay rawBioAssay, FeatureIdentificationMethod fim) -
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptInsertIfNullReporterOnFeature
(boolean accept) Specify if inserts always should be accepted if there is a matching feature that has a NULL reporter.void
delete
(int id) Always throws a PermissionDeniedException, since raw data cannot be modifed once it has been created, except if all spots are deleted at the same time.(package private) void
Delete all raw data.private void
doInsert
(RawData data, String externalReporterId, String externalFeatureId, boolean validateReporterId) Do the actual insert.(package private) static RawDataBatcher
getNew
(DbControl dc, RawBioAssay rawBioAssay, FeatureIdentificationMethod fiMethod) Create a new batcher for raw data.int
Get the number of accepted inserts because of features with a NULL reporter.int
Get the number of reporters that was not found.int
Get the number of skipped inserts because of a missing feature.(package private) PluginPermission
Get the raw bioassay this batcher is used for.getType()
Get the type of item supported by the batcher.(package private) void
initPermissions
(int granted, int denied) Grant read permission if the logged in user has read permission to the raw bioassay.void
Insert a data object.void
Insert a raw data spot and verify the external id of the reporter.Create a new raw data object.(package private) void
Update the spot count and disk usage on the raw bioassay.private void
void
skipInsertIfMissingFeature
(boolean skip) Specify if the insert method should skip the insert if a feature for the spot can't be found.void
Always throws a PermissionDeniedException, since raw data cannot be modifed once it has been created.void
useNullIfReporterNotFound
(boolean useNull) Specify if the insert method should use a null reporter if a reporter with the given external ID isn't found.void
Validate all properties for the raw data object: The data object is not null The data object belongs to the correct raw bioassay The position value is > 0 All of the extra properties using theExtendedProperty.validateValue(Object)
methodMethods inherited from class net.sf.basedb.core.BasicBatcher
checkPermission, delete, flush, flushDelete, flushInsert, flushUpdate, getPermissions, getPropertyValue, getTotalInsertCount, hasPermission, onBeforeCommit, setPropertyValue
Methods inherited from class net.sf.basedb.core.AbstractBatcher
analyzeTable, close, getBatchSize, getDbControl, getSessionControl, isClosed, setBatchSize, setDbControl, updateLastAccess
-
Field Details
-
logSql
Log all SQL statements. -
debugSqlEnabled
private static final boolean debugSqlEnabledSo we don't always have to call logSql.debug() -
rawBioAssay
The raw bioassay this batcher adds raw data to. -
rawBioAssayData
Just a copy of the data object for the raw bioassay. -
rawDataType
The type of raw data to batch. -
arrayDesign
The array design the raw bioassay is connected to, if any. -
caseInsensitive
private final boolean caseInsensitiveIf case should be ignored when comparing strings (external ID) -
currentPosition
private int currentPositionKeeps track of the position number unless the raw bioassay is connected to an array design with features. -
bytes
private long bytesThe number of bytes the spot data is occupying on disk. This value is calculated by the validate method for each spot and added to the raw bioassay by the close method. -
findReporter
A query to find reporters by the external id. -
fiMethod
The method to use for identifying features. -
preloaded
Holds info about the features of an array design. Using the feature identifier we can look up position number and reporter on each location and verify this against the raw data.- See Also:
-
reporterProxy
-
featureProxy
-
usedFeatures
Keep track of the used features to make sure that no more than raw data spot references the same feature. -
useNullIfReporterNotFound
private boolean useNullIfReporterNotFoundIf we should use the null reporter if a reporter isn't found. -
numReportersNotFound
private int numReportersNotFoundThe number of reporters that was not found. -
skipInsertIfMissingFeature
private boolean skipInsertIfMissingFeatureIf inserts that can't find a matching feature should be skipped or generate an error. -
numSkippedMissingFeature
private int numSkippedMissingFeatureThe number of skipped inserts due to missing feature -
acceptInsertIfNullReporterOnFeature
private boolean acceptInsertIfNullReporterOnFeatureIf we should always accept inserts when the feature has a NULL reporter. -
numAcceptedWithNullReporterOnFeature
private int numAcceptedWithNullReporterOnFeatureThe number of accepted inserts were the feature had a NULL reporter
-
-
Constructor Details
-
RawDataBatcher
RawDataBatcher(DbControl dc, RawBioAssay rawBioAssay, FeatureIdentificationMethod fim) throws BaseException - Throws:
BaseException
-
-
Method Details
-
getNew
static RawDataBatcher getNew(DbControl dc, RawBioAssay rawBioAssay, FeatureIdentificationMethod fiMethod) throws BaseException Create a new batcher for raw data.- Parameters:
dc
- The DbControl to use for database access and permission checkingrawBioAssay
- The raw bioassay this batcher should add raw data tofiMethod
- The method to use for identifying features, use null to use the method specified by the array design- Throws:
BaseException
- If there is an error- See Also:
-
getType
Description copied from class:BasicBatcher
Get the type of item supported by the batcher. The returned value is one of the values defined in theItem
enumeration.- Specified by:
getType
in classBasicBatcher<RawData>
- Returns:
- A value indicating the type of item
- See Also:
-
validate
Validate all properties for the raw data object:- The data object is not null
- The data object belongs to the correct raw bioassay
- The position value is > 0
- All of the extra properties using the
ExtendedProperty.validateValue(Object)
method
- Specified by:
validate
in classBasicBatcher<RawData>
- Parameters:
data
- Data object to validate- Throws:
InvalidDataException
- If the data object is invalid
-
insert
Description copied from class:BasicBatcher
Insert a data object. The data object will not be synchronized with the database. The object values may be modified.- Overrides:
insert
in classBasicBatcher<RawData>
- Parameters:
data
- Data object to be inserted- Throws:
InvalidDataException
- If the data is null or it doesn't validate against theBasicBatcher.validate(BatchableData)
methodPermissionDeniedException
- If the logged in user doesn't have create permissionBaseException
- If there is another error
-
update
Always throws a PermissionDeniedException, since raw data cannot be modifed once it has been created.- Overrides:
update
in classBasicBatcher<RawData>
- Parameters:
data
- Data object to be updated- Throws:
InvalidDataException
- If the data is null or it doesn't validate against theBasicBatcher.validate(BatchableData)
methodPermissionDeniedException
- If the logged in user doesn't have write permissionBaseException
- If there is another error
-
delete
Always throws a PermissionDeniedException, since raw data cannot be modifed once it has been created, except if all spots are deleted at the same time.- Overrides:
delete
in classBasicBatcher<RawData>
- Parameters:
id
- Id of the object to be deleted- Throws:
PermissionDeniedException
- If the logged in user doesn't have delete permissionBaseException
- If there is another error- See Also:
-
initPermissions
Grant read permission if the logged in user has read permission to the raw bioassay. Grant write, delete and create permission if the logged in user has write permission to the raw bioassay.- Overrides:
initPermissions
in classBasicBatcher<RawData>
- Parameters:
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass- Throws:
BaseException
- If the permissions couldn't be initialised
-
getPluginPermissions
PluginPermission getPluginPermissions()- Overrides:
getPluginPermissions
in classBasicBatcher<RawData>
-
onBeforeClose
Update the spot count and disk usage on the raw bioassay.- Overrides:
onBeforeClose
in classBasicBatcher<RawData>
- Throws:
BaseException
-
useNullIfReporterNotFound
public void useNullIfReporterNotFound(boolean useNull) Specify if the insert method should use a null reporter if a reporter with the given external ID isn't found. This setting only affects raw bioassays that are not connected to an array design.- Parameters:
useNull
- TRUE if the insert should use a null reporter (default), FALSE otherwise- See Also:
-
getNumReportersNotFound
public int getNumReportersNotFound()Get the number of reporters that was not found.- Since:
- 2.7
- See Also:
-
skipInsertIfMissingFeature
public void skipInsertIfMissingFeature(boolean skip) Specify if the insert method should skip the insert if a feature for the spot can't be found. This setting only affects raw bioassays that are connected to an array design.- Parameters:
skip
- TRUE if the insert should be skipped, FALSE to throw anItemNotFoundException
(default)- Since:
- 2.7
- See Also:
-
getNumSkippedMissingFeature
public int getNumSkippedMissingFeature()Get the number of skipped inserts because of a missing feature.- Since:
- 2.7
- See Also:
-
acceptInsertIfNullReporterOnFeature
public void acceptInsertIfNullReporterOnFeature(boolean accept) Specify if inserts always should be accepted if there is a matching feature that has a NULL reporter. This settings only affects raw bioassays that are connected to an array design.NOTE! The inserted data will also reference the NULL reporter.
- Parameters:
accept
- TRUE to always accept the insert, FALSE to throw anItemNotFoundException
if the insert doesn't specify a NULL reporter (default)- Since:
- 2.7
-
getNumAcceptedWithNullReporterOnFeature
public int getNumAcceptedWithNullReporterOnFeature()Get the number of accepted inserts because of features with a NULL reporter.- Since:
- 2.7
- See Also:
-
getRawBioAssay
Get the raw bioassay this batcher is used for. -
insert
Insert a raw data spot and verify the external id of the reporter. The external id is only verified if it is not null and the raw bioassay is connected to an array design with features. The external id is verified to match the external id of the reporter attached to feature of the spot's position. If the raw bioassay isn't connected to an array design, the batcher will automatically try to load the reporter with the given external ID. If you use this method you don't have the set the reporter with theRawData.setReporter(ReporterData)
method.The
externalFeatureId
is only needed if theFeatureIdentificationMethod.FEATURE_ID
identification method is used. The other methods will use properties on theRawData
object (postion or the coordinates) to find the feature. Feature identification is of course needed when the raw bioassay is connected to an array design but is also used when there is no array design to validate that duplicate spots are not inserted.- Parameters:
data
- The raw data to insertexternalReporterId
- The external id of the reporter expected to be found at the feature of this spot, or null to use the reporter attached to the featureexternalFeatureId
- The feature ID of the feature if theFeatureIdentificationMethod.FEATURE_ID
identification method is used- Throws:
BaseException
- If the insertion failed- Since:
- 2.6
-
doInsert
private void doInsert(RawData data, String externalReporterId, String externalFeatureId, boolean validateReporterId) throws BaseException Do the actual insert.- Throws:
BaseException
-
preloadFeatures
private void preloadFeatures() -
newRawData
Create a new raw data object. After you have set all properties, use one of theinsert(RawData)
orinsert(RawData, String, String)
methods to insert the raw data. You do not have to set the reporter if the raw bioassay is connected to an array design.- Returns:
- A raw data object
- Throws:
BaseException
- If there is an error
-
deleteAll
Delete all raw data.- Throws:
BaseException
- See Also:
-