gov.nih.nci.caarray.services.protocol
Class ProtocolManagerDB

java.lang.Object
  extended by gov.nih.nci.caarray.services.util.db.ManagerDB
      extended by gov.nih.nci.caarray.services.protocol.ProtocolManagerDB

public final class ProtocolManagerDB
extends ManagerDB

Author:
TranP

Field Summary
 
Fields inherited from class gov.nih.nci.caarray.services.util.db.ManagerDB
CASCADE_LINK, CASCADE_NONE, CASCADE_OBJECT, ID_UNSET
 
Constructor Summary
ProtocolManagerDB()
          Default Constructor
 
Method Summary
 void addHardware(long protocolId, long hardwareId)
          Adds the specified Hardware to the specified Protocol.
 long addOrUpdateProtocolApplication(ProtocolApplication protApp)
           
 long addParameter(long protocolId, Parameter parameter)
          Adds the specified Parameter to the specified Protocol.
 long addProtocol(Protocol protocol)
          Adds a Protocol to the persistence store.
 long addProtocolApplication(ProtocolApplication protApp)
           
 void addSoftware(long protocolId, long softwareId)
          Adds the specified Software to the specified Protocol.
 void close()
          Close database connection.
 long countProtocolApplications(long protocolId)
          Counts how many ProtocolApplication are using the specified Protocol.
 void deleteParameterFromProtocol(long protocolId, long parameterId)
          Removes the specified Parameter from the specified Protocol and delete it from the persistence store.
 boolean deleteProtocol(long protocolId)
          Removes the specified Protocol from the persistence store.
 HardwareManagerDB getHardwareManagerDB()
           
 Protocol getProtocol(long id)
          Searches for the Protocol that match the specified ID.
 ProtocolApplication[] getProtocolApplications()
           
 ProtocolApplication[] getProtocolApplications(long protocolId)
          Gets an array of ProtocolApplication that use the specified Protocol.
 Protocol[] getProtocols(ProtocolSearchCriteria searchCriteria)
          Gets an array of Protocol's that match the specified criteria.
 OntologyEntry[] getProtocolTypes()
          Get available protocol types.
 SoftwareManagerDB getSoftwareManagerDB()
           
 void removeHardware(long protocolId, long hardwareId)
          Removes the specified Hardware from the specified Protocol.
 void removeSoftware(long protocolId, long softwareId)
          Removes the specified Software from the specified Protocol.
 void resetParameterizableApplication(ParameterizableApplication paramApp)
          Resets the specified ParameterizableApplication by setting its id, associated ParameterizableApplications' id, and their ParameterValues' id, to 0.
 boolean updateProtocol(Protocol protocol)
          Updates a Protocol.
 
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

ProtocolManagerDB

public ProtocolManagerDB()
Default Constructor

Method Detail

getHardwareManagerDB

public HardwareManagerDB getHardwareManagerDB()
Returns:

getSoftwareManagerDB

public SoftwareManagerDB getSoftwareManagerDB()
Returns:

getProtocol

public Protocol getProtocol(long id)
                     throws java.lang.Exception
Searches for the Protocol that match the specified ID.

Parameters:
id - - The Protocol's ID to be searched.
Returns:
- A Protocol if found or null otherwise.
Throws:
java.lang.Exception

getProtocols

public Protocol[] getProtocols(ProtocolSearchCriteria searchCriteria)
                        throws java.lang.Exception
Gets an array of Protocol's that match the specified criteria.

Parameters:
criteria - - An OJB Criteria that specifies the criteria for Protocol to be searched.
Returns:
- An array of Protocol if there's at least one match or a zero-length array otherwise.
Throws:
java.lang.Exception

updateProtocol

public boolean updateProtocol(Protocol protocol)
                       throws java.lang.Exception
Updates a Protocol.

Precondition: Hardware, Software and Type are existing elements so they can contain only identifying data.

Parameters:
protocol - - The Protocol to be updated
Returns:
True if the Protocol is updated or false otherwise.
Throws:
java.lang.Exception

addProtocol

public long addProtocol(Protocol protocol)
                 throws java.lang.Exception
Adds a Protocol to the persistence store. Only scalar attributes and OntologyEntry.type are inserted.

Precondition: OntologyEntry.type can be either an existing or a new OntologyEntry.

Parameters:
protocol - - The Protocol to be added.
Returns:
- An object representing the ID of the added Protocol.
Throws:
java.lang.Exception

deleteProtocol

public boolean deleteProtocol(long protocolId)
                       throws java.lang.Exception
Removes the specified Protocol from the persistence store.

Parameters:
id - - The ID of the Protocol to be removed.
Returns:
- True if the Protocol was deleted or false otherwise.
Throws:
java.lang.Exception

addHardware

public void addHardware(long protocolId,
                        long hardwareId)
                 throws java.lang.Exception
Adds the specified Hardware to the specified Protocol.

Parameters:
protocolId - - The ID of the Protocol to add the Hardware to.
hardwareId - - The ID of the Hardware to add to the Protocol.
Throws:
ObjectNotExistException - - If either the Protocol or Hardware does not exist.
GeneralException - -
java.lang.Exception

removeHardware

public void removeHardware(long protocolId,
                           long hardwareId)
                    throws java.lang.Exception,
                           GeneralException
Removes the specified Hardware from the specified Protocol.

Parameters:
protocolId - - The ID of the Protocol to remove the Hardware from.
hardwareId - - The ID of the Hardware to remove from the Protocol.
Throws:
ObjectNotExistException - - If either the Protocol or Hardware does not exist.
GeneralException - -
java.lang.Exception

addSoftware

public void addSoftware(long protocolId,
                        long softwareId)
                 throws java.lang.Exception
Adds the specified Software to the specified Protocol.

Parameters:
protocolId - - The ID of the Protocol to add the Software to.
hardwareId - - The ID of the Software to add to the Protocol.
Throws:
ObjectNotExistException - - If either the Protocol or Software does not exist.
GeneralException - -
java.lang.Exception

removeSoftware

public void removeSoftware(long protocolId,
                           long softwareId)
                    throws java.lang.Exception
Removes the specified Software from the specified Protocol.

Parameters:
protocolId - - The ID of the Protocol to remove the Software from.
hardwareId - - The ID of the Software to remove from the Protocol.
Throws:
ObjectNotExistException - - If either the Protocol or Software does not exist.
GeneralException - -
java.lang.Exception

addParameter

public long addParameter(long protocolId,
                         Parameter parameter)
                  throws java.lang.Exception
Adds the specified Parameter to the specified Protocol.

Pre-condition: The Parameter is fully populated having an ID less than or equal to 0. The Parameter.dataType is an existing OntologyEntry having an ID greater than 0.

Post-condition: The Parameter has an ID greater than 0 to indicate that it was added.

Parameters:
protocolId - - The ID of the Protocol to add the Parameter to.
parameter - - The Parameter object to add to the Protocol.
Throws:
ObjectNotExistException - - If the Protocol does not exist.
java.lang.Exception

deleteParameterFromProtocol

public void deleteParameterFromProtocol(long protocolId,
                                        long parameterId)
                                 throws java.lang.Exception
Removes the specified Parameter from the specified Protocol and delete it from the persistence store.

Parameters:
protocolId - - The ID of the Protocol from which the Parameter to be removed.
parameterId - - The ID of the Parameter to be removed from the Protocol and deleted from the persistence store.
Throws:
java.lang.Exception

getProtocolTypes

public OntologyEntry[] getProtocolTypes()
Get available protocol types.

Returns:

getProtocolApplications

public ProtocolApplication[] getProtocolApplications(long protocolId)
                                              throws java.lang.Exception
Gets an array of ProtocolApplication that use the specified Protocol.

Parameters:
protocolId - - The ID of the Protocol to search for.
Returns:
- An array of ProtocolApplication if there's at least one match or a zero-length array otherwise.
Throws:
java.lang.Exception

getProtocolApplications

public ProtocolApplication[] getProtocolApplications()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

countProtocolApplications

public long countProtocolApplications(long protocolId)
Counts how many ProtocolApplication are using the specified Protocol.

Parameters:
protocolId - - The ID of the Protocol to search for.
Returns:
- The number of ProtocolApplication.

addProtocolApplication

public long addProtocolApplication(ProtocolApplication protApp)
                            throws java.lang.Exception
Parameters:
protApp -
Returns:
Throws:
ObjectNotExistException
InsertObjectException
DBException
java.lang.Exception

resetParameterizableApplication

public void resetParameterizableApplication(ParameterizableApplication paramApp)
                                     throws java.lang.Exception
Resets the specified ParameterizableApplication by setting its id, associated ParameterizableApplications' id, and their ParameterValues' id, to 0. Typically, this method is combined with a call to store/add to make a duplicate.

Parameters:
paramApp -
Throws:
ObjectNotExistException
DBException
java.lang.Exception

addOrUpdateProtocolApplication

public long addOrUpdateProtocolApplication(ProtocolApplication protApp)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

close

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

Overrides:
close in class ManagerDB