cmu.survey.data.sql
Class DataTableModelSQL

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by cmu.survey.data.DataTableModel
          extended by cmu.survey.data.sql.DataTableModelSQL
All Implemented Interfaces:
FilterChangedListener, java.io.Serializable, javax.swing.table.TableModel
Direct Known Subclasses:
DataTableModelMySQL

public abstract class DataTableModelSQL
extends DataTableModel
implements FilterChangedListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class cmu.survey.data.DataTableModel
DataTableModel.DataTableModelGUIListener, DataTableModel.Results
 
Field Summary
protected static boolean CheckWhetherColumnNamesAreValid
          This could be turned off if we trust our caller, if the implementing GUI is good enough, since the implementing GUI should be testing all of this.
protected  VectorDataSet<Filter<?>> filters
           
protected  java.util.Vector<OrderBy> orderBys
           
protected  java.sql.ResultSet resultSet
           
protected  java.lang.String sqlOrderBy
           
protected  java.lang.String sqlWhere
          This variable is primarily the table, and is most often the table, but sometimes it becomes the "From" clause in SQL.
 
Fields inherited from class cmu.survey.data.DataTableModel
COLUMN_TYPES, COLUMN_TYPES_READABLE, holdFiredTableChangeEvents, INTEGER_TYPE_READABLE, levelOfEventsHeld, thisDataTableModel
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DataTableModelSQL(DataTableModelSingularInfo singularInfo)
           
 
Method Summary
 boolean addFilter(Filter<?> filter)
           
 boolean addOrderBy(OrderBy orderBy)
          Adds OrderBy to the list at the highest-priority slot (0 in the Vector returned by getOrderBys()).
 boolean deleteAllRows()
          This is an optimization of the superclass's deleteAllRows() that uses SQL to accomplish the same thing -- probably quicker.
 void deleteColumn(java.lang.String columnName)
           
protected abstract  void deleteColumnNoRefresh(java.lang.String columnName)
           
 void deleteColumns(int[] columnIndexes)
           
 void filterChanged(Filter filter)
           
protected abstract  void filtersWereChanged()
          Called after the Filters are changed.
protected abstract  DatabaseQuery getDatabaseQuery()
           
 VectorDataSet<Filter<?>> getFilters()
           
protected abstract  java.lang.String getFilterWhereAsSQLWhere()
           
 java.util.List<OrderBy> getOrderBys()
           
 java.lang.String getSQLOrderBy()
           
 java.lang.String getSQLWhere()
           
protected abstract  void orderBysWereChanged()
           
 void removeAllFilters()
           
 void removeAllOrderBys()
           
protected  void removeColumnFromPlaces(java.lang.String columnName)
          Removes a column from Filters and from OrderBys, after it's been deleted.
 boolean removeFilter(Filter<?> filter)
           
 boolean removeOrderBy(OrderBy orderBy)
           
 void setFilters(VectorDataSet<Filter<?>> filters)
           
 void setSQLOrderBy(java.lang.String sqlOrderBy)
           
 void setSQLWhere(java.lang.String sqlWhere)
           
protected abstract  void sqlOrderByWasChanged()
           
protected abstract  void sqlTableNameWasChanged()
          Called after the sql table name was changed.
protected abstract  void sqlWhereWasChanged()
           
 
Methods inherited from class cmu.survey.data.DataTableModel
addGUIListener, addOneLock, addTableModelListener, addUndoableEditListener, changeColumnClass, changeColumnClass, close, deleteColumn, deleteDataBits, deleteRow, deleteRowProtected, deleteRows, finalize, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, fireUndoableEdit, getColumnClass, getColumnIndex, getColumnIndexes, getColumnName, getColumnNames, getColumnTypeReadable, getCount, getCount, getForwardOnlyData, getInvalidColumnNameMessage, getMax, getPrimaryKey, getSingularInfo, getTableFormat, getTableName, getTableStorage, hasPrimaryKey, isColumnNullable, isEditable, isLocked, isMakingUndoableEdits, isValidColumnName, newColumn, newColumn, newColumn, newColumnAfter, newColumnAfter, newColumnAfter, newColumnBefore, newRow, newRow, newRow, newRow, newRows, refresh, removeGUIListener, removeOneLock, removeTableModelListener, removeUndoableEditListener, renameColumn, renameColumn, reorderColumn, reorderColumn, resetPrimaryKeyColumnIndex, saveDataBits, saveDataBits, setValueAt, setValueAtGetErrors, setValueAtProtected, setValuesAt, setValuesAt, tableWasRenamedTo
 
Methods inherited from class javax.swing.table.AbstractTableModel
findColumn, fireTableChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
getColumnCount, getRowCount, getValueAt
 

Field Detail

resultSet

protected java.sql.ResultSet resultSet

sqlWhere

protected java.lang.String sqlWhere
This variable is primarily the table, and is most often the table, but sometimes it becomes the "From" clause in SQL.


sqlOrderBy

protected java.lang.String sqlOrderBy

filters

protected VectorDataSet<Filter<?>> filters

orderBys

protected java.util.Vector<OrderBy> orderBys

CheckWhetherColumnNamesAreValid

protected static final boolean CheckWhetherColumnNamesAreValid
This could be turned off if we trust our caller, if the implementing GUI is good enough, since the implementing GUI should be testing all of this.

See Also:
Constant Field Values
Constructor Detail

DataTableModelSQL

public DataTableModelSQL(DataTableModelSingularInfo singularInfo)
Method Detail

getSQLOrderBy

public java.lang.String getSQLOrderBy()
Returns:
Returns the sqlOrderBy.

setSQLOrderBy

public void setSQLOrderBy(java.lang.String sqlOrderBy)
Parameters:
sqlOrderBy - The sqlOrderBy to set.

setSQLWhere

public void setSQLWhere(java.lang.String sqlWhere)

getSQLWhere

public java.lang.String getSQLWhere()

filtersWereChanged

protected abstract void filtersWereChanged()
Called after the Filters are changed.


orderBysWereChanged

protected abstract void orderBysWereChanged()

sqlTableNameWasChanged

protected abstract void sqlTableNameWasChanged()
Called after the sql table name was changed.


sqlOrderByWasChanged

protected abstract void sqlOrderByWasChanged()

sqlWhereWasChanged

protected abstract void sqlWhereWasChanged()

getFilterWhereAsSQLWhere

protected abstract java.lang.String getFilterWhereAsSQLWhere()

getDatabaseQuery

protected abstract DatabaseQuery getDatabaseQuery()

deleteAllRows

public boolean deleteAllRows()
This is an optimization of the superclass's deleteAllRows() that uses SQL to accomplish the same thing -- probably quicker.

Overrides:
deleteAllRows in class DataTableModel
Returns:

addFilter

public boolean addFilter(Filter<?> filter)
Specified by:
addFilter in class DataTableModel
Returns:
true if the filter was added, false if the filter's column name was invalid and the filter was not added.

removeFilter

public boolean removeFilter(Filter<?> filter)
Specified by:
removeFilter in class DataTableModel

removeAllFilters

public void removeAllFilters()
Specified by:
removeAllFilters in class DataTableModel

getFilters

public VectorDataSet<Filter<?>> getFilters()
Specified by:
getFilters in class DataTableModel

setFilters

public void setFilters(VectorDataSet<Filter<?>> filters)
Specified by:
setFilters in class DataTableModel

addOrderBy

public boolean addOrderBy(OrderBy orderBy)
Description copied from class: DataTableModel
Adds OrderBy to the list at the highest-priority slot (0 in the Vector returned by getOrderBys()).

Specified by:
addOrderBy in class DataTableModel
Parameters:
orderBy - a direction to order the columns
Returns:

removeOrderBy

public boolean removeOrderBy(OrderBy orderBy)
Specified by:
removeOrderBy in class DataTableModel

removeAllOrderBys

public void removeAllOrderBys()
Specified by:
removeAllOrderBys in class DataTableModel

getOrderBys

public java.util.List<OrderBy> getOrderBys()
Specified by:
getOrderBys in class DataTableModel
Returns:
Vector of OrderBy in order from highest priority to lowest priority

filterChanged

public void filterChanged(Filter filter)
Specified by:
filterChanged in interface FilterChangedListener

removeColumnFromPlaces

protected void removeColumnFromPlaces(java.lang.String columnName)
Removes a column from Filters and from OrderBys, after it's been deleted.


deleteColumnNoRefresh

protected abstract void deleteColumnNoRefresh(java.lang.String columnName)
                                       throws FailedRequest
Throws:
FailedRequest

deleteColumn

public void deleteColumn(java.lang.String columnName)
                  throws FailedRequest
Specified by:
deleteColumn in class DataTableModel
Throws:
FailedRequest

deleteColumns

public void deleteColumns(int[] columnIndexes)
                   throws FailedRequest
Specified by:
deleteColumns in class DataTableModel
Throws:
FailedRequest