-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.h
119 lines (81 loc) · 4.12 KB
/
database.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/********************************************************************************************************************************************************
* @file database.h
*
* @Copyright (C) 2022 i-trace.org
*
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
* iTrace Infrastructure is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* iTrace Infrastructure is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
********************************************************************************************************************************************************/
#ifndef DATABASE_H
#define DATABASE_H
#include <QString>
#include <QVector>
#include <QVariant>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <sqlite3.h>
#include "gaze.h"
#include <iostream>
class Database {
public:
Database();
Database(QString);
void close();
bool isDatabaseOpen();
void importExistingDatabase(QString);
bool fileExists(const QString&);
bool participantExists(const QString&);
bool calibrationExists(const QString&);
bool pluginResponseExists(const QString&);
void startTransaction();
void commit();
void insertCalibration(QString);
void insertCalibrationPoint(QString,QString,QString,QString);
void insertCalibrationSample(QString,QString,QString,QString,QString,QString,QString);
void insertFile(QString,QString,QString,QString);
void insertFixation(QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString);
void insertFixationGaze(QString,QString);
void insertFixationRun(QString,QString,QString,QString);
void insertGaze(QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString);
void insertIDEContext(QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString,QString);
void insertParticipant(QString,QString);
void insertSession(QString,QString,QString,QString,QString,QString,QString,QString,QString,QString);
void insertWebContext(QString,QString,QString,QString,QString);
QVector<QString> getSessions();
QVector<QString> getAllIDEContextIDs();
QVector<QVector<QString>> getGazesForSyntacticMapping(QString,bool);
QVector<QVector<QString>> getGazesForSourceMapping(QString,bool);
QVector<QString> getGazeTargetsFromSession(QString);
QVector<Gaze> getGazesFromSessionAndTarget(QString,QString);
QVector<std::pair<QString,QString>> getFilesViewed();
QString getSessionFromParticipantAndTask(QString,QString);
void updateGazeWithSyntacticInfo(QString,QString,QString);
void updateGazeWithTokenInfo(QString,QString,QString);
QString queryUpdateGazeWithSyntacticInfo(QString,QString,QString);
QString queryUpdateGazeWithTokenInfo(QString,QString,QString);
QVector<QVector<QString>> runFilterQuery(QString);
void executeLongUpdateQuery(QString);
private:
sqlite3* db;
QString file_path;
bool open = false;
};
/*class Database {
public:
QString checkAndReturnError();
void startTransaction();
void commit();
void executeLongQuery(QString);
QVector<QString> getAllIDEContextIDs();
QVector<QString> getFixationRunIDs();
QVector<QVector<QString>> getFixationsFromRunID(QString);
QString getUpdateGazeWithSyntacticInfoQuery(QString,QString,QString);
QString getUpdateGazeWithTokenInfoQuery(QString,QString,QString);
private:
QSqlDatabase db;
QString file_path;
};*/
#endif // DATABASE_H