cmu.survey.editor.data.table
Class DataBitStorageTable

java.lang.Object
  extended by cmu.survey.editor.data.table.DataBitStorageTable
All Implemented Interfaces:
DataBitStorage
Direct Known Subclasses:
DataBitStorageSQL

public abstract class DataBitStorageTable
extends java.lang.Object
implements DataBitStorage


Nested Class Summary
static class DataBitStorageTable.AuxillaryOptionTableFormatClass
           
static class DataBitStorageTable.QuestionsTableFormatClass
           
static class DataBitStorageTable.RepeatedMeasureAnswerTableFormatClass
           
static class DataBitStorageTable.RepeatedMeasureTableFormatClass
           
static class DataBitStorageTable.SurveyPagesTableFormatClass
           
 
Field Summary
protected static java.lang.String[] ALL_REQUIRED_TABLES
          The list of all tables that are required for making a survey.
protected static java.lang.String[] ALL_USED_TABLES
          The list of all tables used for storing questions, etc.
static java.lang.String AuxillaryOptionsTable
           
static java.lang.String ChoicesTable
           
static java.lang.String defaultAnswersTable
           
static java.lang.String PagesOfQuestionsTable
           
static java.lang.String QuestionsTable
           
static java.lang.String SurveyPagesTableName
           
 
Fields inherited from interface cmu.survey.editor.data.DataBitStorage
CANNOT_CHECK, DEFAULT_USERS_TABLE_NAME, ERROR_FIXABLE, ERROR_FIXABLE_CREATE, ERROR_NOT_FIXABLE, ERROR_USER_FIXABLE, IS_GOOD, OPERATION_FAILED, OPERATION_PARTIALLY_SUCCEEDED, OPERATION_SUCCEEDED
 
Constructor Summary
DataBitStorageTable(TableStorage tableStorage)
           
 
Method Summary
 void close()
           
protected abstract  boolean couldCreateNewSurveyInDatabase()
           
 int createNewSurveyInDatabase()
          Fix a broken table by creating the survey database into this database.
 boolean deleteAuxillaryOption(AuxillaryOptionDataBitTable opt)
           
 boolean deleteDataBits(DataTableModel table, java.lang.Integer id, java.lang.String idFieldName)
           
static boolean errorCanBeFixedBySystem(int error)
           
 java.util.Vector<DataTableModel> getAllPossibleAnswerTableModels()
           
 java.util.Vector<java.lang.String> getAllPossibleAnswerTables()
           
 DataTableModel getAnswersTable()
           
 DataTableModel getAnswersTable(java.util.Vector<java.lang.Integer> userIDs)
           
static TableFormat getAnswersTableFormat(java.lang.String tableName)
           
 DataTableModel getAnswersTableNamed(java.lang.String answersTableName)
          Gets a table formatted for answers.
 java.util.Vector<AuxillaryOptionDataBitTable> getAuxillaryOptions(IntegerDataBit questionID)
           
 DataTableModel getAuxillaryOptionsTable()
           
static TableFormat getAuxillaryOptionsTableFormat()
           
abstract  ChoicesDataBitSet getChoices(IntegerDataBit questionID, StringDataBit choicesType, IntegerDataBit numberOfChoices)
           
protected  IntegerDataBit getIntegerBitFrom(ForwardOnlyData data, java.lang.String name)
           
 AuxillaryOptionDataBitTable getNewAuxillaryOption(IntegerDataBit questionID)
           
 OneChoiceDataBitSetStub getNewChoice()
           
 QuestionDataBitSet getNewQuestion()
           
abstract  QuestionDataBitSetTable getNewQuestionStub()
           
protected abstract  PageTable getPage(ForwardOnlyData data)
           
 Page getPage(int id)
           
 java.util.Vector<Page> getPages(java.lang.String pageName)
          Gets all pages by this name -- since it's possible that there are multiple pages by the same name.
 DataTableModel getPagesOfQuestionsTable()
           
static TableFormat getPagesOfQuestionsTableFormat()
           
abstract  QuestionDataBitSetTable getQuestion(int questionID)
           
 DataTableModel getQuestionsTable()
           
static TableFormat getQuestionsTableFormat()
           
 DataTableModel getRepeatedMeasuresTableNamed(java.lang.String repeatedMeasuresTableName)
          Get a table formatted for storing repeated measures (NOT an answers table for repeated measures, but for the list of repeated measures).
static DataBitStorageTable.RepeatedMeasureTableFormatClass getRepeatedMeasureTableFormat(java.lang.String tableName)
           
protected  StringDataBit getStringBitFrom(ForwardOnlyData data, java.lang.String name)
           
 Survey getSurvey()
          If it returns null, the database is in an old format of the survey tool or does not have a survey in the database, or is not a valid database, etc.
 DataTableModel getSurveyPagesTable()
           
static TableFormat getSurveyPagesTableFormat()
           
 SurveyTable getSurveyTable()
          For those who know we're a DataBitStorageTable.
 DataTableModel getTableNamed(java.lang.String tableName)
           
 TableStorage getTableStorage()
           
 DataTableModel getUsersTable()
           
 boolean isOpen()
           
abstract  boolean isSameStorageAs(DataBitStorage storage)
           
 int isSurveyValid()
          This should be called first to check whether the survey is a recent one or not.
protected  void loadIntoNewAuxillaryOption(IntegerDataBit questionID, AuxillaryOptionDataBitTable auxOpt)
           
abstract  java.lang.Integer saveDataBits(java.util.List<? extends DataBit> dataBits, java.lang.String table, java.lang.Integer id, java.lang.String idFieldName)
          This should be replaced by DataTableModel.saveDataBits().
 boolean saveQuestionDataBits(QuestionDataBitSetTable q)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cmu.survey.editor.data.DataBitStorage
getNewPage
 

Field Detail

PagesOfQuestionsTable

public static final java.lang.String PagesOfQuestionsTable
See Also:
Constant Field Values

SurveyPagesTableName

public static final java.lang.String SurveyPagesTableName
See Also:
Constant Field Values

QuestionsTable

public static final java.lang.String QuestionsTable
See Also:
Constant Field Values

ChoicesTable

public static final java.lang.String ChoicesTable
See Also:
Constant Field Values

AuxillaryOptionsTable

public static final java.lang.String AuxillaryOptionsTable
See Also:
Constant Field Values

ALL_USED_TABLES

protected static final java.lang.String[] ALL_USED_TABLES
The list of all tables used for storing questions, etc. This is the list that should be ignored when looking for user-editable tables, or answers tables.


ALL_REQUIRED_TABLES

protected static final java.lang.String[] ALL_REQUIRED_TABLES
The list of all tables that are required for making a survey. I.e. Ones that aren't always used, but sometimes used, like "Emails" (which is automatically created only if you write an email) are not included in this list.


defaultAnswersTable

public static final java.lang.String defaultAnswersTable
See Also:
Constant Field Values
Constructor Detail

DataBitStorageTable

public DataBitStorageTable(TableStorage tableStorage)
Method Detail

getSurveyPagesTableFormat

public static TableFormat getSurveyPagesTableFormat()

getPagesOfQuestionsTableFormat

public static TableFormat getPagesOfQuestionsTableFormat()

getAuxillaryOptionsTableFormat

public static TableFormat getAuxillaryOptionsTableFormat()

getAnswersTableFormat

public static TableFormat getAnswersTableFormat(java.lang.String tableName)

getRepeatedMeasureTableFormat

public static DataBitStorageTable.RepeatedMeasureTableFormatClass getRepeatedMeasureTableFormat(java.lang.String tableName)

getQuestionsTableFormat

public static TableFormat getQuestionsTableFormat()

getQuestionsTable

public DataTableModel getQuestionsTable()

getPagesOfQuestionsTable

public DataTableModel getPagesOfQuestionsTable()

getSurveyPagesTable

public DataTableModel getSurveyPagesTable()

getUsersTable

public DataTableModel getUsersTable()
Specified by:
getUsersTable in interface DataBitStorage

getAnswersTable

public DataTableModel getAnswersTable()
Specified by:
getAnswersTable in interface DataBitStorage

getAuxillaryOptionsTable

public DataTableModel getAuxillaryOptionsTable()

getAnswersTable

public DataTableModel getAnswersTable(java.util.Vector<java.lang.Integer> userIDs)
Specified by:
getAnswersTable in interface DataBitStorage

getAllPossibleAnswerTables

public java.util.Vector<java.lang.String> getAllPossibleAnswerTables()
Specified by:
getAllPossibleAnswerTables in interface DataBitStorage

getAllPossibleAnswerTableModels

public java.util.Vector<DataTableModel> getAllPossibleAnswerTableModels()
Specified by:
getAllPossibleAnswerTableModels in interface DataBitStorage

getAnswersTableNamed

public DataTableModel getAnswersTableNamed(java.lang.String answersTableName)
Description copied from interface: DataBitStorage
Gets a table formatted for answers. If the table does not exist, the table will be created.

Specified by:
getAnswersTableNamed in interface DataBitStorage
Returns:

getRepeatedMeasuresTableNamed

public DataTableModel getRepeatedMeasuresTableNamed(java.lang.String repeatedMeasuresTableName)
Description copied from interface: DataBitStorage
Get a table formatted for storing repeated measures (NOT an answers table for repeated measures, but for the list of repeated measures).

Specified by:
getRepeatedMeasuresTableNamed in interface DataBitStorage
Returns:

getTableNamed

public DataTableModel getTableNamed(java.lang.String tableName)
Specified by:
getTableNamed in interface DataBitStorage

createNewSurveyInDatabase

public int createNewSurveyInDatabase()
Description copied from interface: DataBitStorage
Fix a broken table by creating the survey database into this database. This assumes the pre-req that you've called the isSurveyValid() method and gotten a ERROR_FIXABLE_CREATE as a response. If you haven't checked, it might not be possible, and if it's not possible, this will return false, perhaps gracefully or not.

Specified by:
createNewSurveyInDatabase in interface DataBitStorage
Returns:
OPERATION_SUCCEEDED, OPERATION_FAILED, or OPERATION_PARTIALLY_SUCCEEDED

errorCanBeFixedBySystem

public static boolean errorCanBeFixedBySystem(int error)

getIntegerBitFrom

protected IntegerDataBit getIntegerBitFrom(ForwardOnlyData data,
                                           java.lang.String name)
                                    throws FailedRequest
Throws:
FailedRequest

getStringBitFrom

protected StringDataBit getStringBitFrom(ForwardOnlyData data,
                                         java.lang.String name)
                                  throws FailedRequest
Throws:
FailedRequest

isSameStorageAs

public abstract boolean isSameStorageAs(DataBitStorage storage)

getQuestion

public abstract QuestionDataBitSetTable getQuestion(int questionID)

getPage

protected abstract PageTable getPage(ForwardOnlyData data)

getPages

public java.util.Vector<Page> getPages(java.lang.String pageName)
Description copied from interface: DataBitStorage
Gets all pages by this name -- since it's possible that there are multiple pages by the same name.

Specified by:
getPages in interface DataBitStorage
Returns:

getPage

public Page getPage(int id)
Specified by:
getPage in interface DataBitStorage

getSurvey

public Survey getSurvey()
Description copied from interface: DataBitStorage
If it returns null, the database is in an old format of the survey tool or does not have a survey in the database, or is not a valid database, etc.

Specified by:
getSurvey in interface DataBitStorage
Returns:
the whole Survey

getSurveyTable

public SurveyTable getSurveyTable()
For those who know we're a DataBitStorageTable.

Returns:

getTableStorage

public TableStorage getTableStorage()
Specified by:
getTableStorage in interface DataBitStorage

couldCreateNewSurveyInDatabase

protected abstract boolean couldCreateNewSurveyInDatabase()

getNewQuestion

public QuestionDataBitSet getNewQuestion()
Specified by:
getNewQuestion in interface DataBitStorage

getNewQuestionStub

public abstract QuestionDataBitSetTable getNewQuestionStub()

getAuxillaryOptions

public java.util.Vector<AuxillaryOptionDataBitTable> getAuxillaryOptions(IntegerDataBit questionID)

getNewAuxillaryOption

public AuxillaryOptionDataBitTable getNewAuxillaryOption(IntegerDataBit questionID)

loadIntoNewAuxillaryOption

protected void loadIntoNewAuxillaryOption(IntegerDataBit questionID,
                                          AuxillaryOptionDataBitTable auxOpt)

getChoices

public abstract ChoicesDataBitSet getChoices(IntegerDataBit questionID,
                                             StringDataBit choicesType,
                                             IntegerDataBit numberOfChoices)

getNewChoice

public OneChoiceDataBitSetStub getNewChoice()

deleteDataBits

public boolean deleteDataBits(DataTableModel table,
                              java.lang.Integer id,
                              java.lang.String idFieldName)

deleteAuxillaryOption

public boolean deleteAuxillaryOption(AuxillaryOptionDataBitTable opt)

saveDataBits

public abstract java.lang.Integer saveDataBits(java.util.List<? extends DataBit> dataBits,
                                               java.lang.String table,
                                               java.lang.Integer id,
                                               java.lang.String idFieldName)
This should be replaced by DataTableModel.saveDataBits().

Parameters:
dataBits -
table -
id -
idFieldName -
Returns:

saveQuestionDataBits

public boolean saveQuestionDataBits(QuestionDataBitSetTable q)

isSurveyValid

public int isSurveyValid()
Description copied from interface: DataBitStorage
This should be called first to check whether the survey is a recent one or not.

Specified by:
isSurveyValid in interface DataBitStorage
Returns:
ERROR_FIXABLE_CREATE, ERROR_NOT_FIXABLE, or IS_GOOD.

isOpen

public boolean isOpen()
Specified by:
isOpen in interface DataBitStorage

close

public void close()