edu.jhu.tmaj.beans.dynamic
Class DynamicJBean

java.lang.Object
  extended by edu.jhu.tmaj.beans.JBean
      extended by edu.jhu.tmaj.beans.dynamic.DynamicJBean
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable
Direct Known Subclasses:
ScoredImageBean, SpecimenBean, TissueDiagnosisBean

public abstract class DynamicJBean
extends JBean

A JBean that represents a DynamicTable, such as Specimens. Additional support in this class is provided to handle the Dynamic fields.

See Also:
Serialized Form

Field Summary
(package private)  DynamicMetaData dynamicMetaData
          The DynamicMetaData tells which types have which dynamic fields, and which fields are enumerated.
 
Fields inherited from class edu.jhu.tmaj.beans.JBean
staticMetaData
 
Constructor Summary
DynamicJBean(StaticMetaData staticMetaData, DynamicMetaData dynamicMetaData)
           
 
Method Summary
 void addDynamicValue(int fieldID, DynamicValue dynamicValue)
          Adds dynamic data to this Bean from a record in a Dynamic-Data table, such as TissueDiagnosisData
 void createFromSwingMap(java.util.Map<DatabaseField,java.lang.Object> columnField_value)
          Creates this Bean, both the static and dynamic part, from a Map obtained from a JTable.
protected  java.util.List<JBean> getBeanList(Search search)
          Returns a List of Beans from a Search.
 java.util.List<DatabaseField> getColumnIdentifiers(Search search, java.util.List<JBean> beanList)
          Returns a List of ColumnIdentifiers based on a Search and the list of Beans generated.
(package private)  java.lang.String getDynamicBaseSQL()
          Returns a SQL statement that will pull records from the DynamicData table (e.g.
 java.util.List<DynamicTField> getDynamicColumnIdentifiers(java.util.Set<java.lang.Integer> typeIDs)
          Returns the DynamicFields given the types.
 DynamicMetaData getDynamicMetaData()
          Returns the DynamicMetaData for this bean, which determines what the dynamic fields are, and what enumerations they have.
(package private)  java.lang.String getDynamicSQL(Search search)
          Returns a SQL statement that will pull records from the DynamicData table (e.g.
(package private) abstract  java.lang.String getDynamicTableName()
          Returns the name of the Table that contains the DynamicData for this Bean, for example, SpecimenData.
 java.util.List<PickListEnumeration> getEnumerations(DatabaseField field)
          Gets a list of enumerations for a given column.
 java.util.Map<DatabaseField,java.lang.Object> getSwingHash()
          Converts this Bean to a Map that makes it ready to be converted into a row into a JTable.
protected  java.lang.Object getSwingToBeanObject(DatabaseField columnField, java.lang.Object oldValue)
          Converts a value that would be found in a swing JTable into a value that is suitable for this JBean.
abstract  DatabaseField getTypeField()
          Returns the TField column where the type of this DynamicBean is put.
 java.lang.Integer getTypeID()
          Returns the type of this DynamicBean, which determines which dynamic-fields will be displayed.
 void insert()
          Performs an INSERT operation on the database with the data in this bean.
 boolean isEnumerated(DatabaseField field)
          Returns true if the field is enumerated (has a drop down box.) This DynamicMetaData is checked if the TField is a DynamicField, whereas the staticMetaData is checked if the TField is not a DynamicTField.
 void setTypeID(int typeID)
          Sets the Type of this DynamicBean.
 void syncDynamicData()
          Writes the dynamic data in this bean to the database.
 void update()
          Performs an UPDATE operation on the database with the data in this bean.
 
Methods inherited from class edu.jhu.tmaj.beans.JBean
compareTo, createFromResultSet, delete, equals, getAllStaticColumnIdentifiers, getBaseSQL, getBeanInDatabase, getBeanList, getClassForType, getDateField, getDefaultBeanObjectForType, getDefaultSwingObjectForType, getDoubleField, getFieldsArray, getFieldValue, getID_Bean_Map, getID, getIntegerField, getNewInstance, getNonNullString, getPrimaryKeyField, getPrimaryKeyName, getSelectResponse, getSQL, getStaticMetaData, getStringField, getTable, getTableName, getUserBean, getWhereClause, hashCode, setDoubleField, setID, setIntegerField, setUserBean, toString, verify
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dynamicMetaData

final DynamicMetaData dynamicMetaData
The DynamicMetaData tells which types have which dynamic fields, and which fields are enumerated.

Constructor Detail

DynamicJBean

public DynamicJBean(StaticMetaData staticMetaData,
                    DynamicMetaData dynamicMetaData)
Method Detail

getDynamicMetaData

public final DynamicMetaData getDynamicMetaData()
Returns the DynamicMetaData for this bean, which determines what the dynamic fields are, and what enumerations they have.


getColumnIdentifiers

public final java.util.List<DatabaseField> getColumnIdentifiers(Search search,
                                                                java.util.List<JBean> beanList)
Description copied from class: JBean
Returns a List of ColumnIdentifiers based on a Search and the list of Beans generated.

Overrides:
getColumnIdentifiers in class JBean

getDynamicColumnIdentifiers

public java.util.List<DynamicTField> getDynamicColumnIdentifiers(java.util.Set<java.lang.Integer> typeIDs)
Returns the DynamicFields given the types. Each type has zero or more dynamic fields.


isEnumerated

public final boolean isEnumerated(DatabaseField field)
Returns true if the field is enumerated (has a drop down box.) This DynamicMetaData is checked if the TField is a DynamicField, whereas the staticMetaData is checked if the TField is not a DynamicTField.

Overrides:
isEnumerated in class JBean

getSwingHash

public final java.util.Map<DatabaseField,java.lang.Object> getSwingHash()
Converts this Bean to a Map that makes it ready to be converted into a row into a JTable. Summary: Bean -> Swing

Overrides:
getSwingHash in class JBean

getEnumerations

public final java.util.List<PickListEnumeration> getEnumerations(DatabaseField field)
Gets a list of enumerations for a given column. If the column is not enumerated, a list of 0 elements would be returned. If the TField supplied is a DynamicTField, this would mean the field is dynamic and thus DynamicMetaData is checked for the enumerations, instead of StaticMetaData.

Overrides:
getEnumerations in class JBean

getDynamicBaseSQL

final java.lang.String getDynamicBaseSQL()
Returns a SQL statement that will pull records from the DynamicData table (e.g. SpecimenData) without the WHERE clause.


getDynamicSQL

java.lang.String getDynamicSQL(Search search)
Returns a SQL statement that will pull records from the DynamicData table (e.g. SpecimenData)


getBeanList

protected final java.util.List<JBean> getBeanList(Search search)
                                           throws java.sql.SQLException
Description copied from class: JBean
Returns a List of Beans from a Search.

Overrides:
getBeanList in class JBean
Throws:
java.sql.SQLException

syncDynamicData

public final void syncDynamicData()
                           throws java.sql.SQLException
Writes the dynamic data in this bean to the database.

Throws:
java.sql.SQLException

createFromSwingMap

public final void createFromSwingMap(java.util.Map<DatabaseField,java.lang.Object> columnField_value)
Creates this Bean, both the static and dynamic part, from a Map obtained from a JTable.

Overrides:
createFromSwingMap in class JBean
Parameters:
columnField_value - A map where the keys are the columns in the Swing table, and the values are the data the user put in.

addDynamicValue

public final void addDynamicValue(int fieldID,
                                  DynamicValue dynamicValue)
Adds dynamic data to this Bean from a record in a Dynamic-Data table, such as TissueDiagnosisData


insert

public void insert()
            throws java.sql.SQLException
Performs an INSERT operation on the database with the data in this bean. In addition, the DynamicData table (e.g. SpecimenData) is updated with the dynamic Data.

Overrides:
insert in class JBean
Throws:
java.sql.SQLException

update

public final void update()
                  throws java.sql.SQLException
Performs an UPDATE operation on the database with the data in this bean. In addition, the DynamicData table (e.g. SpecimenData) is updated with the dynamic Data.

Overrides:
update in class JBean
Throws:
java.sql.SQLException

getSwingToBeanObject

protected final java.lang.Object getSwingToBeanObject(DatabaseField columnField,
                                                      java.lang.Object oldValue)
Converts a value that would be found in a swing JTable into a value that is suitable for this JBean. In the JBean, a DynamicColumn can only hold 2 values: Either the EnumID if the dynamic-column is enumerated, or the typed-in String if the dynamic-column is not enumerated.

Overrides:
getSwingToBeanObject in class JBean

setTypeID

public final void setTypeID(int typeID)
Sets the Type of this DynamicBean. The type will determine which dynamic fields will be displayed for this Bean.


getTypeID

public final java.lang.Integer getTypeID()
Returns the type of this DynamicBean, which determines which dynamic-fields will be displayed.


getTypeField

public abstract DatabaseField getTypeField()
Returns the TField column where the type of this DynamicBean is put.


getDynamicTableName

abstract java.lang.String getDynamicTableName()
Returns the name of the Table that contains the DynamicData for this Bean, for example, SpecimenData.