2.17.2: 2011-06-17

net.sf.basedb.core
Class RawDataBatcher

java.lang.Object
  extended by net.sf.basedb.core.AbstractBatcher
      extended by net.sf.basedb.core.BasicBatcher<RawData>
          extended by net.sf.basedb.core.RawDataBatcher
All Implemented Interfaces:
AccessControlled, Batcher

public class RawDataBatcher
extends BasicBatcher<RawData>

Batcher class for raw data. A single instance can be used for raw data belonging to a single 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:

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) method otherwise.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Field Summary
private  boolean acceptInsertIfNullReporterOnFeature
          If we should always accept inserts when the feature has a NULL reporter.
private  ArrayDesignData arrayDesign
          The array design the raw bioassay is connected to, if any.
private  long bytes
          The number of bytes the spot data is occupying on disk.
private  boolean caseInsensitive
          If case should be ignored when comparing strings (external ID)
private  int currentPosition
          Keeps track of the position number unless the raw bioassay is connected to an array design with features.
private static boolean debugSqlEnabled
          So we don't always have to call logSql.debug()
private  FeatureIdentificationMethod fiMethod
          The method to use for identifying features.
private  org.hibernate.Query findReporter
          A query to find reporters by the external id.
private static Logger logSql
          Log all SQL statements.
private  int numAcceptedWithNullReporterOnFeature
          The number of accepted inserts were the feature had a NULL reporter
private  int numReportersNotFound
          The number of reporters that was not found.
private  int numSkippedMissingFeature
          The number of skipped inserts due to missing feature
private  Map<Object,FeatureData> preloaded
          Holds info about the features of an array design.
private  RawBioAssay rawBioAssay
          The raw bioassay this batcher adds raw data to.
private  RawBioAssayData rawBioAssayData
          Just a copy of the data object for the raw bioassay.
private  RawDataType rawDataType
          The type of raw data to batch.
private  boolean skipInsertIfMissingFeature
          If inserts that can't find a matching feature should be skipped or generate an error.
private  Set<Object> usedFeatures
          Keep track of the used features to make sure that no more than raw data spot references the same feature.
private  boolean useNullIfReporterNotFound
          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
RawDataBatcher(DbControl dc, RawBioAssay rawBioAssay, FeatureIdentificationMethod fim)
           
 
Method Summary
 void 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 deleteAll()
          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 getNumAcceptedWithNullReporterOnFeature()
          Get the number of accepted inserts because of features with a NULL reporter.
 int getNumReportersNotFound()
          Get the number of reporters that was not found.
 int getNumSkippedMissingFeature()
          Get the number of skipped inserts because of a missing feature.
(package private)  PluginPermission getPluginPermissions()
           
 RawBioAssay getRawBioAssay()
          Get the raw bioassay this batcher is used for.
 Item 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(RawData data)
          Insert a data object.
 void insert(RawData data, String externalReporterId)
          Deprecated. Use insert(RawData, String, String) instead
 void insert(RawData data, String externalReporterId, String externalFeatureId)
          Insert a raw data spot and verify the external id of the reporter.
 RawData newRawData()
          Create a new raw data object.
(package private)  void onBeforeClose()
          Update the spot count and disk usage on the raw bioassay.
 void skipInsertIfMissingFeature(boolean skip)
          Specify if the insert method should skip the insert if a feature for the spot can't be found.
 void update(RawData data)
          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(RawData data)
          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
 
Methods 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logSql

private static final Logger logSql
Log all SQL statements.


debugSqlEnabled

private static final boolean debugSqlEnabled
So we don't always have to call logSql.debug()


rawBioAssay

private final RawBioAssay rawBioAssay
The raw bioassay this batcher adds raw data to.


rawBioAssayData

private final RawBioAssayData rawBioAssayData
Just a copy of the data object for the raw bioassay.


rawDataType

private final RawDataType rawDataType
The type of raw data to batch.


arrayDesign

private final ArrayDesignData arrayDesign
The array design the raw bioassay is connected to, if any.


caseInsensitive

private final boolean caseInsensitive
If case should be ignored when comparing strings (external ID)


currentPosition

private int currentPosition
Keeps track of the position number unless the raw bioassay is connected to an array design with features.


bytes

private long bytes
The 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

private org.hibernate.Query findReporter
A query to find reporters by the external id.


fiMethod

private FeatureIdentificationMethod fiMethod
The method to use for identifying features.


preloaded

private final Map<Object,FeatureData> 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:
FeatureIdentificationMethod

usedFeatures

private Set<Object> usedFeatures
Keep track of the used features to make sure that no more than raw data spot references the same feature.


useNullIfReporterNotFound

private boolean useNullIfReporterNotFound
If we should use the null reporter if a reporter isn't found.


numReportersNotFound

private int numReportersNotFound
The number of reporters that was not found.


skipInsertIfMissingFeature

private boolean skipInsertIfMissingFeature
If inserts that can't find a matching feature should be skipped or generate an error.


numSkippedMissingFeature

private int numSkippedMissingFeature
The number of skipped inserts due to missing feature


acceptInsertIfNullReporterOnFeature

private boolean acceptInsertIfNullReporterOnFeature
If we should always accept inserts when the feature has a NULL reporter.


numAcceptedWithNullReporterOnFeature

private int numAcceptedWithNullReporterOnFeature
The number of accepted inserts were the feature had a NULL reporter

Constructor Detail

RawDataBatcher

RawDataBatcher(DbControl dc,
               RawBioAssay rawBioAssay,
               FeatureIdentificationMethod fim)
         throws BaseException
Throws:
BaseException
Method Detail

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 checking
rawBioAssay - The raw bioassay this batcher should add raw data to
fiMethod - 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:
RawBioAssay.getRawDataBatcher(FeatureIdentificationMethod, Job)

getType

public Item 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 the Item enumeration.

Specified by:
getType in class BasicBatcher<RawData>
Returns:
A value indicating the type of item
See Also:
Item

validate

public void validate(RawData data)
              throws InvalidDataException
Validate all properties for the raw data object:

Specified by:
validate in class BasicBatcher<RawData>
Parameters:
data - Data object to validate
Throws:
InvalidDataException - If the data object is invalid

insert

public void insert(RawData data)
            throws BaseException
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 class BasicBatcher<RawData>
Parameters:
data - Data object to be inserted
Throws:
InvalidDataException - If the data is null or it doesn't validate against the BasicBatcher.validate(BatchableData) method
PermissionDeniedException - If the logged in user doesn't have create permission
BaseException - If there is another error

update

public void update(RawData data)
            throws BaseException
Always throws a PermissionDeniedException, since raw data cannot be modifed once it has been created.

Overrides:
update in class BasicBatcher<RawData>
Parameters:
data - Data object to be updated
Throws:
InvalidDataException - If the data is null or it doesn't validate against the BasicBatcher.validate(BatchableData) method
PermissionDeniedException - If the logged in user doesn't have write permission
BaseException - If there is another error

delete

public void delete(int id)
            throws BaseException
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 class BasicBatcher<RawData>
Parameters:
id - Id of the object to be deleted
Throws:
PermissionDeniedException - If the logged in user doesn't have delete permission
BaseException - If there is another error
See Also:
deleteAll()

initPermissions

void initPermissions(int granted,
                     int denied)
               throws BaseException
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 class BasicBatcher<RawData>
Parameters:
granted - Permissions that have been granted by the subclass
denied - Permissions that have been denied by the subclass
Throws:
BaseException - If the permissions couldn't be initialised

getPluginPermissions

PluginPermission getPluginPermissions()
Overrides:
getPluginPermissions in class BasicBatcher<RawData>

onBeforeClose

void onBeforeClose()
             throws BaseException
Update the spot count and disk usage on the raw bioassay.

Overrides:
onBeforeClose in class BasicBatcher<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:
skipInsertIfMissingFeature(boolean)

getNumReportersNotFound

public int getNumReportersNotFound()
Get the number of reporters that was not found.

Since:
2.7
See Also:
useNullIfReporterNotFound(boolean)

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 an ItemNotFoundException (default)
Since:
2.7
See Also:
useNullIfReporterNotFound(boolean)

getNumSkippedMissingFeature

public int getNumSkippedMissingFeature()
Get the number of skipped inserts because of a missing feature.

Since:
2.7
See Also:
skipInsertIfMissingFeature(boolean)

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 an ItemNotFoundException 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:
acceptInsertIfNullReporterOnFeature(boolean)

getRawBioAssay

public RawBioAssay getRawBioAssay()
Get the raw bioassay this batcher is used for.


insert

public void insert(RawData data,
                   String externalReporterId)
            throws BaseException
Deprecated. Use insert(RawData, String, String) instead

Throws:
BaseException

insert

public void insert(RawData data,
                   String externalReporterId,
                   String externalFeatureId)
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 the RawData.setReporter(ReporterData) method.

The externalFeatureId is only needed if the FeatureIdentificationMethod.FEATURE_ID identification method is used. The other methods will use properties on the RawData 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 insert
externalReporterId - 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 feature
externalFeatureId - The feature ID of the feature if the FeatureIdentificationMethod.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

newRawData

public RawData newRawData()
                   throws BaseException
Create a new raw data object. After you have set all properties, use one of the insert(RawData) or insert(RawData, 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

void deleteAll()
         throws BaseException
Delete all raw data.

Throws:
BaseException
See Also:
RawBioAssay.deleteRawData()

2.17.2: 2011-06-17