gov.nih.nci.caarray.services.biomaterial
Class BioMaterialManagerDB

java.lang.Object
  extended by gov.nih.nci.caarray.services.util.db.ManagerDB
      extended by gov.nih.nci.caarray.services.biomaterial.BioMaterialManagerDB

public final class BioMaterialManagerDB
extends ManagerDB

Author:
muhus

Field Summary
 
Fields inherited from class gov.nih.nci.caarray.services.util.db.ManagerDB
CASCADE_LINK, CASCADE_NONE, CASCADE_OBJECT, ID_UNSET
 
Constructor Summary
BioMaterialManagerDB()
          Default Constructor
 
Method Summary
 long addBioSample(BioSample bioSample)
           
 long addBioSource(BioSource bioSource)
           
 long addLabeledExtract(LabeledExtract extract)
           
 long addTreatment(long bioMaterialId, java.lang.Class bioMaterialClass, Treatment treatment)
          Adds the specified treatment to the specified BioMaterial.
 void clearBiomaterialFromCache(BioMaterial bioMaterialToClear)
          Recursively removes a biomaterial and all it's parents from the cache, to be used after copying to make sure you get the latest copy from the database
 void close()
          Close database connection.
 long copyBioMaterial(BioMaterial bioMaterialToCopy, java.lang.Class sourceBioMaterialClass, java.lang.String duplicateBioMaterialName, java.lang.String owner)
          Recursively copies the whole biomaterial tree Move heirarchicaly fromtop down.
 long copyBioMaterial(long bioMaterialToCopyId, java.lang.Class sourceBioMaterialClass, java.lang.String duplicateBioMaterialName, java.lang.String owner)
           
 void deleteBioSample(long bioSampleId)
           
 void deleteBioSource(long bioSourceId)
           
 void deleteLabeledExtract(long extractId)
           
 void deleteTreatmentFromBioMaterial(long bioMaterialId, long treatmentId)
           
 boolean doesBioMaterialHaveTreatment(long bioMaterialId, long treatmentId)
           
 long duplicateBioMaterial(long sourceBioMaterialId, java.lang.Class sourceBioMaterialClass, java.lang.String duplicateBioMaterialName)
           
 BioMaterial getBioMaterial(long id)
          Retrieve a BioMaterial
 BioMaterial[] getBioMaterials(BioMaterialSearchCriteria criteria)
           
protected  BioMaterial[] getBioMaterials(BioMaterialSearchCriteria criteria, java.lang.Class objectClass)
          Get available BioMaterials.
 BioSample getBioSample(long id)
          Retrieve a BioSample
 BioSample getBioSampleByTreatment(long treatmentId)
          Retrieve the BioSample which has a Treatment that matches the specified treatmentId.
 BioSample[] getBioSamples(BioMaterialSearchCriteria criteria)
           
 BioSource getBioSource(long id)
          Retrieve a BioSource
 BioSource[] getBioSources(BioMaterialSearchCriteria criteria)
           
 OntologyEntry[] getCharacteristicsFromSourceBioSourcesOf(long bioMaterialId, java.lang.Class objectClass)
          Retrieves a list of distinct characteristics of the source BioSource's that are used to produce the specified product BioSample or LabeledExtract.
 LabeledExtract getLabeledExtract(long id)
          Retrieve a LabeledExtract Object
 LabeledExtract[] getLabeledExtracts(BioMaterialSearchCriteria criteria)
           
 BioMaterial[] getTopMostSourceBioMaterials(BioMaterial bioMaterial)
          Gets the parents of the specified bio material, which are in most cases bio sources.
 Treatment getTreatment(long id)
           
 Treatment[] getTreatments(long bioMaterialId)
           
static void main(java.lang.String[] args)
          Used for test only.
 void updateBioMaterialCharacteristics(long bioMaterialId, java.lang.Class bioMaterialClass, OntologyEntry[] characteristics)
          Save the specified BioMaterial with the specified characteristics.
 void updateBioSample(BioSample bioSample)
           
 void updateBioSource(BioSource bioSource)
          Update a BioSource
 void updateLabeledExtract(LabeledExtract extract)
           
 void updateTreatment(Treatment treatment, boolean updateProtocolApplication)
           
 
Methods inherited from class gov.nih.nci.caarray.services.util.db.ManagerDB
clearCache, countObjects, countObjects, deleteByQuery, deleteMtoNRelation, deleteObject, deleteObject, deleteObject, deleteObjectByQuery, exists, getIdentifiable, getObject, getObject, getObject, getObject, getObject, getObject, getObjectIterator, getObjectIterator, getObjects, getObjects, getObjects, getPersistenceBroker, getSqlInLimit, insertMtoNRelation, insertMtoNRelation, insertObject, insertObject, link, link, removeFromCache, retrieveReference, retrieveReferences, setCascadeDelete, setCascadeRetrieve, setCascadeStore, storeObject, storeObject, unlink, unlink, updateObject, updateObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BioMaterialManagerDB

public BioMaterialManagerDB()
Default Constructor

Method Detail

getBioMaterial

public BioMaterial getBioMaterial(long id)
                           throws java.lang.Exception
Retrieve a BioMaterial

Parameters:
id -
Throws:
ObjectNotExistException, - DBException
java.lang.Exception

getBioSource

public BioSource getBioSource(long id)
                       throws java.lang.Exception
Retrieve a BioSource

Parameters:
id -
Throws:
ObjectNotExistException, - DBException
java.lang.Exception

getBioSample

public BioSample getBioSample(long id)
                       throws java.lang.Exception
Retrieve a BioSample

Parameters:
id -
Throws:
ObjectNotExistException, - DBException
java.lang.Exception

getBioSampleByTreatment

public BioSample getBioSampleByTreatment(long treatmentId)
                                  throws java.lang.Exception
Retrieve the BioSample which has a Treatment that matches the specified treatmentId. This Treatment comes from the BioSample.treatments association.

Parameters:
treatmentId -
Returns:
Throws:
ObjectNotExistException
DBException
java.lang.Exception

getLabeledExtract

public LabeledExtract getLabeledExtract(long id)
                                 throws java.lang.Exception
Retrieve a LabeledExtract Object

Parameters:
id -
Throws:
ObjectNotExistException, - DBException
java.lang.Exception

updateBioSource

public void updateBioSource(BioSource bioSource)
                     throws java.lang.Exception
Update a BioSource

Parameters:
BioSource -
Throws:
ObjectNotExistException, - DBException
java.lang.Exception

updateBioSample

public void updateBioSample(BioSample bioSample)
                     throws java.lang.Exception
Throws:
java.lang.Exception

updateLabeledExtract

public void updateLabeledExtract(LabeledExtract extract)
                          throws java.lang.Exception
Throws:
java.lang.Exception

addBioSource

public long addBioSource(BioSource bioSource)
                  throws java.lang.Exception
Throws:
java.lang.Exception

addBioSample

public long addBioSample(BioSample bioSample)
                  throws java.lang.Exception
Throws:
java.lang.Exception

addLabeledExtract

public long addLabeledExtract(LabeledExtract extract)
                       throws java.lang.Exception
Throws:
java.lang.Exception

updateBioMaterialCharacteristics

public void updateBioMaterialCharacteristics(long bioMaterialId,
                                             java.lang.Class bioMaterialClass,
                                             OntologyEntry[] characteristics)
                                      throws java.lang.Exception
Save the specified BioMaterial with the specified characteristics. The saving implies adding, updating, or deleting characterstics and is done as follows:

Parameters:
bioMaterialId - - The ID of the BioMaterial associated with the specified characteristics.
characteristics - - The characteristics to be updated.
Throws:
java.lang.Exception

updateTreatment

public void updateTreatment(Treatment treatment,
                            boolean updateProtocolApplication)
                     throws java.lang.Exception
Parameters:
treatment -
updateProtocolApplication - - True to indicate that the associated protocolApplication(s) should also be updated. False to ignore.
Throws:
ObjectNotExistException
DBException
java.lang.Exception

doesBioMaterialHaveTreatment

public boolean doesBioMaterialHaveTreatment(long bioMaterialId,
                                            long treatmentId)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

addTreatment

public long addTreatment(long bioMaterialId,
                         java.lang.Class bioMaterialClass,
                         Treatment treatment)
                  throws java.lang.Exception
Adds the specified treatment to the specified BioMaterial. If this treatment is the first one to be added to the BioMaterial, it must contain one or more source BioMaterialMeasurement's. If the BioMaterial already have at least one existing treatment, the specified treatment is associated with the same source BioMaterialMeasurements and any source BioMaterialMeasurements currently associated with the treatments are ignored.

Parameters:
bioMaterialId -
treatment -
Returns:
- The ID of the inserted treatment
Throws:
ObjectNotExistException
InsertObjectException
DBException
java.lang.Exception

duplicateBioMaterial

public long duplicateBioMaterial(long sourceBioMaterialId,
                                 java.lang.Class sourceBioMaterialClass,
                                 java.lang.String duplicateBioMaterialName)
                          throws java.lang.Exception
Throws:
java.lang.Exception

copyBioMaterial

public long copyBioMaterial(long bioMaterialToCopyId,
                            java.lang.Class sourceBioMaterialClass,
                            java.lang.String duplicateBioMaterialName,
                            java.lang.String owner)
                     throws java.lang.Exception
Throws:
java.lang.Exception

clearBiomaterialFromCache

public void clearBiomaterialFromCache(BioMaterial bioMaterialToClear)
Recursively removes a biomaterial and all it's parents from the cache, to be used after copying to make sure you get the latest copy from the database

Parameters:
bioMaterialToClear -

copyBioMaterial

public long copyBioMaterial(BioMaterial bioMaterialToCopy,
                            java.lang.Class sourceBioMaterialClass,
                            java.lang.String duplicateBioMaterialName,
                            java.lang.String owner)
                     throws java.lang.Exception
Recursively copies the whole biomaterial tree Move heirarchicaly fromtop down. duplicating biosource first and then the sample and then the extract

Parameters:
id -
Returns:
Throws:
ObjectNotExistException
DBException
java.lang.Exception

getTreatment

public Treatment getTreatment(long id)
                       throws java.lang.Exception
Parameters:
id -
Returns:
Throws:
java.lang.Exception

getTreatments

public Treatment[] getTreatments(long bioMaterialId)
                          throws java.lang.Exception
Parameters:
id -
Returns:
Throws:
java.lang.Exception

deleteTreatmentFromBioMaterial

public void deleteTreatmentFromBioMaterial(long bioMaterialId,
                                           long treatmentId)
                                    throws java.lang.Exception
Parameters:
bioSampleId -
treatmentId -
Throws:
ObjectNotExistException
DBException
ObjectInUseException - - When the treatment is the only one remaining.
java.lang.Exception

close

public void close()
Description copied from class: ManagerDB
Close database connection.

Overrides:
close in class ManagerDB

getTopMostSourceBioMaterials

public BioMaterial[] getTopMostSourceBioMaterials(BioMaterial bioMaterial)
Gets the parents of the specified bio material, which are in most cases bio sources. The parents of a bio material are the source for producing one or more other bio materials through treatments.

Parameters:
material -
Returns:

getCharacteristicsFromSourceBioSourcesOf

public OntologyEntry[] getCharacteristicsFromSourceBioSourcesOf(long bioMaterialId,
                                                                java.lang.Class objectClass)
                                                         throws java.lang.Exception
Retrieves a list of distinct characteristics of the source BioSource's that are used to produce the specified product BioSample or LabeledExtract.

Parameters:
bioMaterialId - - The ID of a BioSample or LabeledExtract.
Throws:
java.lang.Exception

getBioMaterials

public BioMaterial[] getBioMaterials(BioMaterialSearchCriteria criteria)

getBioSources

public BioSource[] getBioSources(BioMaterialSearchCriteria criteria)

getBioSamples

public BioSample[] getBioSamples(BioMaterialSearchCriteria criteria)

getLabeledExtracts

public LabeledExtract[] getLabeledExtracts(BioMaterialSearchCriteria criteria)

getBioMaterials

protected BioMaterial[] getBioMaterials(BioMaterialSearchCriteria criteria,
                                        java.lang.Class objectClass)
Get available BioMaterials.

Returns:

deleteBioSource

public void deleteBioSource(long bioSourceId)
                     throws java.lang.Exception
Throws:
java.lang.Exception

deleteBioSample

public void deleteBioSample(long bioSampleId)
                     throws java.lang.Exception
Throws:
java.lang.Exception

deleteLabeledExtract

public void deleteLabeledExtract(long extractId)
                          throws java.lang.Exception
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
Used for test only.