- Timestamp:
- 01/21/10 13:54:58 (13 years ago)
- Branches:
- master, qt5
- Children:
- 606c155
- Parents:
- e662750
- Location:
- src/sql
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sql/schedulexmlparser.cpp
re662750 r72cd3af 82 82 // process event's nodes 83 83 QHash<QString,QString> event; 84 event["id"] = eventElement.attribute("id"); 85 event["conference_id"] = QString::number(conferenceID, 10);84 event["id"] = eventElement.attribute("id");; 85 event["conference_id"] = QString::number(conferenceID, 10); 86 86 event["start"] = eventElement.firstChildElement("start").text(); // time eg. 10:00 87 87 event["date"] = dayElement.attribute("date"); // date eg. 2009-02-07 … … 97 97 event["description"] = eventElement.firstChildElement("description").text(); // string 98 98 aDBEngine->addEventToDB(event); 99 100 99 // process persons' nodes 101 100 QList<QString> persons; 102 101 QDomElement personsElement = eventElement.firstChildElement("persons"); 103 102 QDomNodeList personList = personsElement.elementsByTagName("person"); 104 for (int i=0; i<personList.count(); i++) 105 { 103 for(int i = 0;i < personList.count();i++){ 106 104 QHash<QString,QString> person; 107 105 person["id"] = personList.at(i).toElement().attribute("id"); 108 106 person["name"] = personList.at(i).toElement().text(); 109 107 person["event_id"] = eventElement.attribute("id"); 110 person["conference_id"] = QString::number(conferenceID, 10);108 person["conference_id"] = QString::number(conferenceID, 10); 111 109 //qDebug() << "adding Person: " << person["name"]; 112 110 aDBEngine->addPersonToDB(person); 113 111 } 114 115 112 // process links' nodes 116 113 QDomElement linksElement = eventElement.firstChildElement("links"); 117 114 QDomNodeList linkList = linksElement.elementsByTagName("link"); 118 for (int i=0; i<linkList.count(); i++) 119 { 115 for(int i = 0;i < linkList.count();i++){ 120 116 QHash<QString,QString> link; 121 117 link["name"] = linkList.at(i).toElement().text(); 122 118 link["url"] = linkList.at(i).toElement().attribute("href"); 123 119 link["event_id"] = eventElement.attribute("id"); 124 link["conference_id"] = QString::number(conferenceID, 10);120 link["conference_id"] = QString::number(conferenceID, 10); 125 121 aDBEngine->addLinkToDB(link); 126 122 } 127 128 123 // emit signal to inform the user about the current status (how many events are parsed so far - expressed in %) 129 int status =currentEvent*100/totalEventsCount;130 emitprogressStatus(status);124 int status = currentEvent * 100 / totalEventsCount; 125 progressStatus(status); 131 126 } // parsing event elements 132 127 } -
src/sql/sql.pro
re662750 r72cd3af 7 7 8 8 # module dependencies 9 LIBS += -L$$DESTDIR -lmvc -lorm 10 INCLUDEPATH += ../mvc ../orm 9 11 DEPENDPATH += . 10 12 -
src/sql/sqlengine.cpp
re662750 r72cd3af 8 8 #include <QDir> 9 9 #include "sqlengine.h" 10 #include <track.h> 10 11 11 12 #include <QDebug> … … 89 90 if (db.isValid() && db.isOpen()) 90 91 { 91 // track has to be handled as the first, since it is necessary to get 92 // track ID from the TRACK table, or to create new TRACK record 93 // and get the ID from newly created record 94 QString queryExist = QString("SELECT id FROM track WHERE name='%1'").arg(aEvent["track"]); 95 QSqlQuery resultExist(queryExist,db); 96 // now we have to check whether TRACK record with 'name' exists or not, 97 // - if it doesn't exist yet, then we have to add that record to 'TRACK' table 98 // - if it exists, then we need to get its 'id' 99 int actId = -1; 100 if(resultExist.next()) // TRACK record with 'name' already exists: we need to get its 'id' 92 //insert event track to table 93 QString name = aEvent["track"]; 94 Track track; 95 int trackId; 96 try 101 97 { 102 actId = resultExist.value(0).toInt(); 98 track = Track::retrieveByName(name); 99 trackId = track.id(); 100 /*qDebug() << QString("DEBUG: Track %1 in DB").arg(name);*/ 103 101 } 104 else // TRACK record doesn't exist yet, need to create it 105 { 106 QString values = QString("'%1'").arg(aEvent["track"]); 107 QString query = QString("INSERT INTO track (name) VALUES (%1)").arg(values); 108 QSqlQuery result (query, db); 109 actId = result.lastInsertId().toInt(); // 'id' is assigned automatically 102 catch (OrmNoObjectException &e) { 103 track.setName(name); 104 trackId = track.insert(); 105 /*qDebug() << QString("DEBUG: Track %1 added to DB").arg(name);*/ 110 106 } 111 112 107 // The items of the Event are divided into the two tables EVENT and VIRTUAL_EVENT 113 108 // VIRTUAL_EVENT is for Full-Text-Serach Support … … 118 113 .arg(QString::number(startDateTime.toTime_t())) \ 119 114 .arg(-QTime::fromString(aEvent["duration"],TIME_FORMAT).secsTo(QTime(0,0))) \ 120 .arg( QString::number(actId)) \115 .arg(trackId) \ 121 116 .arg(aEvent["type"]) \ 122 117 .arg(aEvent["language"]) \ … … 236 231 query.exec("CREATE TABLE TRACK ( \ 237 232 id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , \ 238 name VARCHAR NOT NULL )");233 name VARCHAR UNIQUE NOT NULL )"); 239 234 240 235 query.exec("CREATE TABLE ROOM ( \
Note: See TracChangeset
for help on using the changeset viewer.