2.17.2: 2011-06-17

net.sf.basedb.core
Class FeatureBatcher

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

public class FeatureBatcher
extends BasicBatcher<FeatureData>

Batcher class for Features or AffyFeatures. A single instance can be used for features belonging to a single ArrayDesign.

Create new FeatureData objects with either newFeature(ArrayDesignBlock, ReporterData) or newFeature(ArrayDesignBlock, Well). Use the latter method if the array desing is connected to plates.

Depending on the FeatureIdentificationMethod used by the array design, you must set different properties on the FeatureData object.

For all methods, each feature that is inserted must have a unqiue value. For example, there can't be two features with the same external ID if the FEATURE_ID method is used. Values for the methods that are not used can still be set and saved to the database, but the uniqueness is not checked. The position number will be auto-generated (and overwritten) if the identification method is not POSITION.

Version:
2.0
Author:
Enell, Nicklas
Last modified
$Date$

Field Summary
private  ArrayDesign arrayDesign
          The array design this batcher adds features to.
private  ArrayDesignData arrayDesignData
          Just a copy of the data object for the array design.
private  int currentPosition
          Keeps track of the position number.
private  Set<Object> featureIds
          Holds identification of already inserted features.
private  FeatureIdentificationMethod fiMethod
           
 
Fields inherited from class net.sf.basedb.core.BasicBatcher
debugEnabled, logParam
 
Fields inherited from class net.sf.basedb.core.AbstractBatcher
debugSqlEnabled, logSql
 
Constructor Summary
FeatureBatcher(DbControl dc, ArrayDesign arrayDesign)
           
 
Method Summary
 void delete(int id)
          Always throws a PermissionDeniedException, since a feature cannot be modifed once it has been created.
(package private)  void deleteAll()
          Delete all features belonging to this array design.
 ArrayDesign getArrayDesign()
          Get the array design this batcher is used for.
(package private) static FeatureBatcher getNew(DbControl dc, ArrayDesign arrayDesign)
          Create a new batcher for regular features.
(package private)  PluginPermission getPluginPermissions()
           
 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 array design.
 void insert(FeatureData data)
          Set the position number and add the feature to the insert queue.
 FeatureData newFeature(ArrayDesignBlock adb, ReporterData reporter)
          Create a new feature.
 FeatureData newFeature(ArrayDesignBlock adb, Well well)
          Create a new feature.
(package private)  void onBeforeClose()
          Set the hasFeature flag on the array design if features has been added.
 void update(FeatureData data)
          Always throws a PermissionDeniedException, since a feature cannot be modifed once it has been created.
 void validate(FeatureData data)
          Validate all properties for the feature object: The data object is not null An array design block has been specfied The postion number is > 0 The external id is not null or too long The feature identification is unique The data object belongs to the correct array design The reporter match the well's reporter if a well has been specified
 
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

arrayDesign

private final ArrayDesign arrayDesign
The array design this batcher adds features to.


arrayDesignData

private final ArrayDesignData arrayDesignData
Just a copy of the data object for the array design.


fiMethod

private final FeatureIdentificationMethod fiMethod

featureIds

private Set<Object> featureIds
Holds identification of already inserted features.


currentPosition

private int currentPosition
Keeps track of the position number.

Constructor Detail

FeatureBatcher

FeatureBatcher(DbControl dc,
               ArrayDesign arrayDesign)
         throws BaseException
Throws:
BaseException
Method Detail

getNew

static FeatureBatcher getNew(DbControl dc,
                             ArrayDesign arrayDesign)
                      throws DatabaseException,
                             BaseException
Create a new batcher for regular features.

Parameters:
dc - The DbControl to use for database access and permission checking
arrayDesign - The array design this batcher should add features to
Throws:
BaseException - If there is an error
DatabaseException
See Also:
ArrayDesign.getFeatureBatcher(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<FeatureData>
Returns:
A value indicating the type of item
See Also:
Item

validate

public void validate(FeatureData data)
              throws InvalidDataException
Validate all properties for the feature object:

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

insert

public void insert(FeatureData data)
            throws BaseException
Set the position number and add the feature to the insert queue.

Overrides:
insert in class BasicBatcher<FeatureData>
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(FeatureData data)
            throws BaseException
Always throws a PermissionDeniedException, since a feature cannot be modifed once it has been created.

Overrides:
update in class BasicBatcher<FeatureData>
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 a feature cannot be modifed once it has been created.

Overrides:
delete in class BasicBatcher<FeatureData>
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 array design. Grant write, delete and create permission if the logged in user has write permission to the array design.

Overrides:
initPermissions in class BasicBatcher<FeatureData>
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<FeatureData>

onBeforeClose

void onBeforeClose()
             throws BaseException
Set the hasFeature flag on the array design if features has been added.

Overrides:
onBeforeClose in class BasicBatcher<FeatureData>
Throws:
BaseException

getArrayDesign

public ArrayDesign getArrayDesign()
Get the array design this batcher is used for.

Returns:
An ArrayDesign

newFeature

public FeatureData newFeature(ArrayDesignBlock adb,
                              Well well)
                       throws BaseException
Create a new feature.

Parameters:
adb - The array design of the feature.
well - The well of the feature. Null is not allowed. The plate of the well must have a position on the ArrayDesign of the current FeatureBatcher.
Returns:
A feature data object
Throws:
BaseException - If there is an error

newFeature

public FeatureData newFeature(ArrayDesignBlock adb,
                              ReporterData reporter)
                       throws BaseException
Create a new feature.

Parameters:
adb -
reporter -
Returns:
A feature data object
Throws:
BaseException - If there is an error

deleteAll

void deleteAll()
         throws BaseException
Delete all features belonging to this array design.

Throws:
BaseException

2.17.2: 2011-06-17