00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00023 #include "dbListManager.h"
00024 sql * initDB();
00025
00026 int main(int argc, char *argv[])
00027 {
00028 bool details = false;
00029 if (argc > 1)
00030 if (argv[1][0] == 't')
00031 details = true;
00032
00033 try
00034 {
00035 sql * myDBConn = initDB();
00036 dbListManager allLists = dbListManager(myDBConn);
00037 allLists.dump(details);
00038
00039 QList<Institute * > * instList = allLists.getInstituteList();
00040 QList<Programme * > * progList = allLists.getProgrammeList();
00041 QList<Programme * > * selectProgList = allLists.getProgrammeList(instList->at(15));
00042 QList<Module * > * selectModuleList = allLists.getModuleList(selectProgList->at(2));
00043 for (int i = 0; i < instList->size(); i++)
00044 {
00045 std::cout << i << ":" << instList->at(i)->getDescription().toStdString() <<"\n";
00046 }
00047 for (int i = 0; i < progList->size(); i++)
00048 {
00049 std::cout << i << ":" << progList->at(i)->getDescription().toStdString() <<"\n";
00050 }
00051 std::cout << "selectProgList:["<< selectProgList->size() << "]\n";
00052 for (int i = 0; i < selectProgList->size(); i++)
00053 {
00054 std::cout << i << ":" << selectProgList->at(i)->getDescription().toStdString() <<"\n";
00055 }
00056 std::cout << "selectModuleList:["<< selectModuleList->size() << "]\n";
00057 for (int i = 0; i < selectModuleList->size(); i++)
00058 {
00059 std::cout << i << ":" << selectModuleList->at(i)->getDescription().toStdString() <<"\n";
00060 }
00061
00062 }
00063 catch (sqlE &e)
00064 {
00065 QString errMsg = "Please record this error & inform the system administrator.\nThe program is about to close.\nSorry it didn't work out.\nThe error is:\n" + e.getErrorMessage();
00066 std::cout << errMsg.toStdString();
00067 }
00068
00069 }
00070
00071
00072 sql * initDB()
00073 {
00074 QSettings settings("RUB","RUBic");
00075 settings.beginGroup("Database");
00076 QString username = settings.value ("UserName").toString();
00077 QString host = settings.value ("Host").toString();
00078 QString db = settings.value ("dbName").toString();
00079 QString type = settings.value ("dbType").toString();
00080 settings.endGroup();
00081
00082 QString password ("");
00083 password = settings.value ("Password").toString();
00084 return new sql(username, db, password, *sql::DefaultConnectionName, host, type);
00085 }