cmu.survey.editor.data.sql
Class DataBitStorageSQL

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

public class DataBitStorageSQL
extends DataBitStorageTable


Nested Class Summary
 
Nested classes/interfaces inherited from class cmu.survey.editor.data.table.DataBitStorageTable
DataBitStorageTable.AuxillaryOptionTableFormatClass, DataBitStorageTable.QuestionsTableFormatClass, DataBitStorageTable.RepeatedMeasureAnswerTableFormatClass, DataBitStorageTable.RepeatedMeasureTableFormatClass, DataBitStorageTable.SurveyPagesTableFormatClass
 
Field Summary
 
Fields inherited from class cmu.survey.editor.data.table.DataBitStorageTable
ALL_REQUIRED_TABLES, ALL_USED_TABLES, AuxillaryOptionsTable, ChoicesTable, defaultAnswersTable, PagesOfQuestionsTable, QuestionsTable, 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
DataBitStorageSQL(TableStorageMySQL sqlStorage)
           
 
Method Summary
 boolean backupToFile(java.io.File file, java.lang.String mysqldumpLocation)
           
protected  boolean couldCreateNewSurveyInDatabase()
           
 int createNewSurveyInDatabase()
          Fix a broken table by creating the survey database into this database.
 boolean deleteDataBits(java.lang.String table, java.lang.Integer id, java.lang.String idFieldName)
          TODO replace this with the superclass's deleteDataBits which passes in a table too.
 ChoicesDataBitSetSQL getChoices(IntegerDataBit questionID, StringDataBit choicesType, IntegerDataBit numberOfChoices)
           
 PageTable getNewPage()
           
 QuestionDataBitSetTable getNewQuestionStub()
           
protected  PageTable getPage(ForwardOnlyData data)
          It's possible to have multiple pages by the same name.
 QuestionDataBitSetTable getQuestion(int questionID)
           
 boolean isSameStorageAs(DataBitStorage storage)
           
static void main(java.lang.String[] args)
           
 boolean saveChoices(ChoicesDataBitSetSQL choicesSet)
           
 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().
 
Methods inherited from class cmu.survey.editor.data.table.DataBitStorageTable
close, deleteAuxillaryOption, deleteDataBits, errorCanBeFixedBySystem, getAllPossibleAnswerTableModels, getAllPossibleAnswerTables, getAnswersTable, getAnswersTable, getAnswersTableFormat, getAnswersTableNamed, getAuxillaryOptions, getAuxillaryOptionsTable, getAuxillaryOptionsTableFormat, getIntegerBitFrom, getNewAuxillaryOption, getNewChoice, getNewQuestion, getPage, getPages, getPagesOfQuestionsTable, getPagesOfQuestionsTableFormat, getQuestionsTable, getQuestionsTableFormat, getRepeatedMeasuresTableNamed, getRepeatedMeasureTableFormat, getStringBitFrom, getSurvey, getSurveyPagesTable, getSurveyPagesTableFormat, getSurveyTable, getTableNamed, getTableStorage, getUsersTable, isOpen, isSurveyValid, loadIntoNewAuxillaryOption, saveQuestionDataBits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataBitStorageSQL

public DataBitStorageSQL(TableStorageMySQL sqlStorage)
Method Detail

getNewQuestionStub

public QuestionDataBitSetTable getNewQuestionStub()
Specified by:
getNewQuestionStub in class DataBitStorageTable

getQuestion

public QuestionDataBitSetTable getQuestion(int questionID)
Specified by:
getQuestion in class DataBitStorageTable

getChoices

public ChoicesDataBitSetSQL getChoices(IntegerDataBit questionID,
                                       StringDataBit choicesType,
                                       IntegerDataBit numberOfChoices)
Specified by:
getChoices in class DataBitStorageTable

getNewPage

public PageTable getNewPage()

couldCreateNewSurveyInDatabase

protected boolean couldCreateNewSurveyInDatabase()
Specified by:
couldCreateNewSurveyInDatabase in class DataBitStorageTable

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
Overrides:
createNewSurveyInDatabase in class DataBitStorageTable
Returns:
OPERATION_SUCCEEDED, OPERATION_FAILED, or OPERATION_PARTIALLY_SUCCEEDED

getPage

protected PageTable getPage(ForwardOnlyData data)
It's possible to have multiple pages by the same name. It's strongly discouraged!! It should be made impossible in the UI.

Specified by:
getPage in class DataBitStorageTable
Parameters:
pageName -
Returns:

deleteDataBits

public boolean deleteDataBits(java.lang.String table,
                              java.lang.Integer id,
                              java.lang.String idFieldName)
TODO replace this with the superclass's deleteDataBits which passes in a table too.


saveDataBits

public java.lang.Integer saveDataBits(java.util.List<? extends DataBit> dataBits,
                                      java.lang.String table,
                                      java.lang.Integer id,
                                      java.lang.String idFieldName)
Description copied from class: DataBitStorageTable
This should be replaced by DataTableModel.saveDataBits().

Specified by:
saveDataBits in class DataBitStorageTable
Returns:

saveChoices

public boolean saveChoices(ChoicesDataBitSetSQL choicesSet)

backupToFile

public boolean backupToFile(java.io.File file,
                            java.lang.String mysqldumpLocation)
Parameters:
file -
mysqldumpLocation -

isSameStorageAs

public boolean isSameStorageAs(DataBitStorage storage)
Specified by:
isSameStorageAs in class DataBitStorageTable

main

public static void main(java.lang.String[] args)
                 throws java.lang.Throwable
Throws:
java.lang.Throwable