Ignore:
Timestamp:
09/27/17 22:36:57 (5 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master
Children:
15d41d9
Parents:
9782bbb
git-author:
Philipp Spitzer <philipp@…> (09/27/17 22:35:59)
git-committer:
Philipp Spitzer <philipp@…> (09/27/17 22:36:57)
Message:

The ID of an event is checked now when importing the XML file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sql/schedulexmlparser.cpp

    r9782bbb r01d1452  
    3737    ParseException(const QString& message): std::runtime_error(message.toStdString()) {}
    3838};
     39
     40
     41void checkEvent(QHash<QString,QString>& event) {
     42    QString event_id = event["id"];
     43    if (event_id.trimmed().isEmpty()) throw ParseException(QObject::tr("The ID of event '%1' is missing.").arg(event["title"]));
     44    bool ok;
     45    event_id.toInt(&ok);
     46    if (!ok) throw ParseException(QObject::tr("The ID '%2' of event '%1' is not numeric.").arg(event["title"]).arg(event_id));
     47}
    3948
    4049
     
    116125                        // process event's nodes
    117126                        QHash<QString,QString> event;
    118                         event["id"] = eventElement.attribute("id");;
     127                        event["id"] = eventElement.attribute("id");
    119128                        event["conference_id"] = QString::number(conferenceId, 10);
    120129                        QTime event_start = QTime::fromString(eventElement.firstChildElement("start").text(), sqlEngine->TIME_FORMAT);
     
    140149                        event["abstract"] = eventElement.firstChildElement("abstract").text(); // string
    141150                        event["description"] = eventElement.firstChildElement("description").text(); // string
     151                        checkEvent(event);
    142152                        sqlEngine->addEventToDB(event);
    143153                        // process persons' nodes
Note: See TracChangeset for help on using the changeset viewer.