00001 #ifndef DATALOADER_H 00002 #define DATALOADER_H 00003 00004 #include <domain/invitation.h> 00005 #include <domain/reservation.h> 00006 #include <domain/schedule.h> 00007 00008 #include <controllerinterface.h> 00009 #include <domain/taskstates.h> 00010 00011 #include <QMap> 00012 #include <QMultiMap> 00013 #include <QDebug> 00014 00015 namespace domain 00016 { 00017 class User; 00018 class Task; 00019 class Resource; 00020 class Project; 00021 } 00022 class QDomElement; 00023 00024 namespace control 00025 { 00026 00037 class DataLoader : public ControllerInterface 00038 { 00039 Q_OBJECT 00040 Q_INTERFACES(control::ControllerInterface) 00041 00042 public: 00043 00044 QString description() const; 00045 QString name() const; 00046 DataType dataType() const; 00047 ActionType actionType() const; 00048 void init(domain::TaskManagerData* data, ui::UiInterface* ui, 00049 ControllerFactory* factory); 00050 00051 private: 00052 00053 void execute(); 00054 bool userIsValid() const; 00055 00056 struct TaskData 00057 { 00058 domain::TaskType* type; 00059 domain::User* user; 00060 QStringList subTasks; 00061 QList<domain::InvitationData> invitations; 00062 QList<domain::ReservationData> reservations; 00063 domain::TaskState::SettableState state; 00064 domain::Project* project; 00065 domain::Schedule schedule; 00066 QMap<QString, QVariant> fieldsMap; 00067 }; 00068 00069 QMap<QString, TaskData> taskData; 00070 QMap<QString, domain::Resource*> resourceRefs; 00071 QMap<QString, domain::Project*> projectRefs; 00072 QMap<QString, domain::Task*> taskRefs; 00073 QMap<QString, domain::User*> userRefs; 00074 QMultiMap<QString, QString> taskInvitees; 00075 QMultiMap<domain::User*, QMap<QString, QString> > userInvitees; 00076 00077 bool load(const QDomElement& root); 00078 bool loadProject(const QDomElement& project); 00079 bool loadProjects(const QDomElement& projects); 00080 bool loadResource(const QDomElement& resource); 00081 bool loadResources(const QDomElement& resources); 00082 bool loadUser(const QDomElement& user); 00083 bool loadTask(const QDomElement& task, domain::User* userPointer); 00084 bool loadTasks(const QDomElement& tasks, domain::User* userPointer); 00085 bool loadReservations(const QDomElement& reservations, 00086 const QString& taskRef); 00087 bool loadReservation(const QDomElement& reservation, 00088 const QString& taskRef); 00089 bool loadInvitations(); 00090 bool createTasks(); 00091 00092 ControllerInterface* themeLoader; 00093 }; 00094 00095 } 00096 00097 #endif