<< QSqlField("description", QVariant::String));
Event::Event() :
- mRoomId( 0 )
+ room_(NULL)
{
}
return load(query);
}
-QString Event::room()
+Room* Event::room()
{
- if ( mRoomName.isEmpty() )
+ if (room_ == NULL)
{
QSqlQuery query;
- // TODO: conference ID isn't used here
- query.prepare("SELECT name FROM room WHERE id = :roomId");
- query.bindValue(":roomId", roomId());
- query.exec();
- // TODO: handle qeury error
- //qDebug() << query.lastError();
- if(query.next())
- mRoomName = query.record().value("name").toString();
- else
- mRoomName = QString("not-available");
- }
- return mRoomName;
-}
-
-int Event::roomId()
-{
- if ( mRoomId == 0 )
- {
- QSqlQuery query;
- query.prepare("SELECT xid_room FROM event_room WHERE xid_event = :id");
+ query.prepare("SELECT xid_room FROM event_room WHERE xid_event = :id AND xid_conference = :conf");
query.bindValue(":id", id());
+ query.bindValue(":conf", conferenceId());
if (!query.isActive())
if (!query.exec())
throw OrmSqlException(query.lastError().text());
qDebug() << "No room found for event id: " << id();
throw OrmNoObjectException();
}
- mRoomId = query.record().value("xid_room").toInt();
+ int id = query.record().value("xid_room").toInt();
+ room_ = new Room(Room::retrieve(id));
}
- return mRoomId;
+ return room_;
+}
+
+QString Event::roomName()
+{
+ return room()->name();
+}
+
+int Event::roomId()
+{
+ return room()->id();
}
QStringList Event::persons()
{
QSqlQuery query;
// TODO: conference ID isn't used here
- query.prepare("SELECT person.name FROM person INNER JOIN event_person ON person.id = event_person.xid_person AND event_person.xid_event = :id");
+ query.prepare("SELECT person.name FROM person INNER JOIN event_person ON person.id = event_person.xid_person AND event_person.xid_event = :id AND event_person.xid_conference = :conf");
query.bindValue(":id", id());
+ query.bindValue(":conf", conferenceId());
query.exec();
// TODO: handle qeury error
//qDebug() << query.lastError();