SigPath

org.sigpath.task
Class DBTask

java.lang.Object
  extended by org.sigpath.task.DBTask
All Implemented Interfaces:
Task
Direct Known Subclasses:
SampleReviewData, TAddAlias, TAddChemicals, TAddConcentration, TAddModel, TAddPathway, TAddReactions, TCheckDBAlive, TCheckDeletePermission, TConfirmComponent, TConfirmReactions, TConvertChemical, TConvertSPIDsToBIDs, TConvertVMaxToKp, TCreateExternalReference, TCreateNewPendingList, TDeleteAlias, TDeleteExternalReference, TEditAlias, TEditExternalReference, TEditSigPathEntity, TExportBase, TExportModel, TExportModelReactionsFromSpids, TExportModifiedEntities, TGetAllPendingLists, TGetChemical, TGetConcentrations, TGetConcentrationsByReaction, TGetDBInfo, TGetFilteredUnitsNames, TGetKineticNames, TGetModel, TGetMoleculesFromReactions, TGetOrganismNames, TGetPathway, TGetPendingList, TGetRemoteSpidRange, TGetSigPathEntity, TGetSpidByDbAc, TGetSpidRange, TGetUsers, TGetXMLBindingsFromKinetic, TGetXMLKinetic, TImportBase, TImportModifiedEntities, TIndexModifiedChemicals, TLinkComponentsToReactions, TMarkSpidRange, TOrganismOptimizer, TPopulateBackwardReferences, TPopulateSigPathEntitySummary, TRemoveConcentration, TRemoveSigPathEntity, TSaveConcMeasurements, TSaveNamedChemicals, TSavePendingReviews, TSaveProteins, TSaveSmallMolecules, TScanEnzReactionsAndReactions, TSearchMolecules, TSearchTask, TUpdatePendingList, TUpdateSpidRange, TValidateSPE, TViewImage, TViewImageNone, TViewImageYFiles

public abstract class DBTask
extends Object
implements Task

Specifies a single atomic database operation. DBTask centralizes all transactions, logging, monitoring, and exception handling in one place. This frees the subclasses to focus on business logic.

Author:
Ethan Cerami

Field Summary
protected  SPDBManager dbManager
          The SigPath Database Manager.
protected  boolean embeddedTask
          Flag to denote embedded Tasks.
protected  EntityManager entityManager
          The SigPath Entity Manager.
protected  ValidationErrors errors
          Validation Errors for this task.
protected  FullTextSearchManager ftsm
          The SigPath FullTextSearchManager.
protected  ProgressListener progressListener
          ProgressListener for Monitoring Tasks.
protected  SigPathFactory sigpathFactory
          The SigPath factory.
protected  UnitManager unitManager
          The SigPath Unit Manager.
protected  UserManager userManager
          The SigPath User Manager.
protected  XDebug xdebug
          Live XDebug Object.
 
Constructor Summary
DBTask()
          Construct a new DBTask object.
DBTask(ValidationErrors errors)
          Construct a new DBTask object.
 
Method Summary
protected abstract  void _execute()
          Runs the actual database query(ies)/update(s).
 void close()
          Closes the dbmanager.
protected  void delete(Object object)
          Deletes a persistent object from the database.
 void execute(XDebug xd)
          Executes the database task.
 SPDBManager getDbManager()
          Gets the database manager associated with this task.
 ValidationErrors getErrors()
          Gets the ValidationErrors object for this task.
 boolean isEmbeddedTask()
          Determines if this task is embedded or not.
 boolean isTaskThrewException()
          Did this task's _execute method throw an exception?
protected  void reindex(SigPathEntity spe)
           
protected  void resolve(Object object)
          Resolves a persistent object.
 void setDbManager(SPDBManager dbManager)
          Sets the dbManager to be used for this task.
 void setEmbeddedTask(boolean embeddedTask)
          Indicate whether or not the task should be embedded.
 void setEmbeddedTask(SPDBManager dbManager)
          Indicate that the task should be embedded using the specified SPDBManager.
 void setObtainTransactionsFrom(SPDBManager dbManager)
          Instructs this task to use transactions from a given db manager.
 void setProgressListener(ProgressListener progressListener)
          Sets the Progress Listener.
protected  void setTaskThrewException(boolean taskThrewException)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbManager

protected SPDBManager dbManager
The SigPath Database Manager.


ftsm

protected FullTextSearchManager ftsm
The SigPath FullTextSearchManager.


userManager

protected UserManager userManager
The SigPath User Manager.


entityManager

protected EntityManager entityManager
The SigPath Entity Manager.


sigpathFactory

protected SigPathFactory sigpathFactory
The SigPath factory.


unitManager

protected UnitManager unitManager
The SigPath Unit Manager.


xdebug

protected XDebug xdebug
Live XDebug Object.


embeddedTask

protected boolean embeddedTask
Flag to denote embedded Tasks.


progressListener

protected ProgressListener progressListener
ProgressListener for Monitoring Tasks.


errors

protected ValidationErrors errors
Validation Errors for this task.

Constructor Detail

DBTask

public DBTask()
Construct a new DBTask object.


DBTask

public DBTask(ValidationErrors errors)
Construct a new DBTask object.

Parameters:
errors - ValidationErrors object
Method Detail

getDbManager

public SPDBManager getDbManager()
Gets the database manager associated with this task.

Returns:

setDbManager

public void setDbManager(SPDBManager dbManager)
Sets the dbManager to be used for this task.

Parameters:
dbManager -

setObtainTransactionsFrom

public void setObtainTransactionsFrom(SPDBManager dbManager)
Instructs this task to use transactions from a given db manager. The task thereafter behaves as if it was embedded in another task: it will not begin or commit/abort transactions by itself. Instead, it expects an active transaction when its _execute() method is invoked. Set the database manager to use for this task.

Parameters:
dbManager - Manager of the

isEmbeddedTask

public boolean isEmbeddedTask()
Determines if this task is embedded or not.

Returns:
true if the task is embedded.

setEmbeddedTask

public void setEmbeddedTask(boolean embeddedTask)
Indicate whether or not the task should be embedded. An embedded task will not start a new transaction, but use the current active transaction.

Parameters:
embeddedTask - true if the task should not start a transaction

execute

public void execute(XDebug xd)
             throws SigPathDatabaseException
Executes the database task. If xdebug is set to null, a new XDebug object is automatically created.

Specified by:
execute in interface Task
Parameters:
xd - XDebug object for real-time debugging.
Throws:
SigPathDatabaseException - error connecting to database

isTaskThrewException

public boolean isTaskThrewException()
Did this task's _execute method throw an exception?

Returns:
True if this task _execute method threw an exception, False otherwise.

setTaskThrewException

protected void setTaskThrewException(boolean taskThrewException)

close

public void close()
           throws SigPathDatabaseException
Closes the dbmanager.

Throws:
SigPathDatabaseException

_execute

protected abstract void _execute()
                          throws SigPathDatabaseException
Runs the actual database query(ies)/update(s). Must be implemented by all subclasses.

Throws:
SigPathDatabaseException - error connecting to database

resolve

protected void resolve(Object object)
Resolves a persistent object.

Parameters:
object - Any persistent object

delete

protected void delete(Object object)
               throws SigPathDatabaseException
Deletes a persistent object from the database.

Parameters:
object - Any persistent object
Throws:
SigPathDatabaseException - Indicates Error Connecting to Database

reindex

protected void reindex(SigPathEntity spe)
                throws SigPathDatabaseException
Throws:
SigPathDatabaseException

setEmbeddedTask

public void setEmbeddedTask(SPDBManager dbManager)
Indicate that the task should be embedded using the specified SPDBManager. An embedded task will not start a new transaction, but use the current active transaction. This method should be called every time that a task is embedded in another task. Calling this method guarantees that the tasks operate in the same transaction. This method loads managers for the task, making it safe to use them before execute() is called on the task. This case occurs in the code base, for instance in TExportReaction.

Parameters:
dbManager - Database Manager to use for this task.

setProgressListener

public void setProgressListener(ProgressListener progressListener)
Sets the Progress Listener. Used to monitor long term tasks.

Parameters:
progressListener - Progress Listener Object

getErrors

public ValidationErrors getErrors()
Gets the ValidationErrors object for this task.

Returns:
ValidationErrors object containing errors for this task

SigPath

Copyright © 2002-2005 Institute for Computational Biomedicine, All Rights Reserved.