summaryrefslogtreecommitdiff
path: root/server/src/database.h
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/database.h')
-rw-r--r--server/src/database.h44
1 files changed, 27 insertions, 17 deletions
diff --git a/server/src/database.h b/server/src/database.h
index f3b42e2..fe644bc 100644
--- a/server/src/database.h
+++ b/server/src/database.h
@@ -42,23 +42,24 @@ public:
std::string _passwd, std::string _dbname);
~Database();
- std::string sessionId()
+ std::string newSessionId()
{
- if(dao && sessionid == "") {
- sessionid = dao->newSessionId();
+ if(dao) {
+ return dao->newSessionId();
}
- return sessionid;
+ return "";
}
-
+ /*
void setSessionId(std::string sessionid)
{
this->sessionid = sessionid;
}
-
+ */
// Make a commit to the db
void commitTransaction(Transaction &transaction,
Commit &commit,
Macro &macro,
+ std::string sessionid,
time_t now = time(NULL))
{
if(!dao) return;
@@ -67,13 +68,14 @@ public:
DEBUG(db, "%s, %s, %s,...\n",
transaction.user.c_str(), transaction.cpr.c_str(),
macro.attributes["name"].c_str());
- dao->commitTransaction(sessionId(), transaction, commit, macro, now);
+ dao->commitTransaction(sessionid, transaction, commit, macro, now);
mutex.unlock();
}
// Get a list of values from the db
Values getValues(std::string patientid,
Fieldnames &fieldnames,
+ std::string sessionid,
time_t oldest = 0)
{
if(!dao) return Values();
@@ -89,6 +91,7 @@ public:
// Check if a macro has been committed.
bool checkMacro(std::string patientid,
std::string macro,
+ std::string sessionid,
time_t oldest = 0)
{
DEBUG(db, "%s, %s, %ld\n",
@@ -101,7 +104,8 @@ public:
}
// Get latest resume of a given macro
- std::string getResume(std::string patientid, Macro &macro, time_t oldest)
+ std::string getResume(std::string patientid, Macro &macro,
+ time_t oldest, std::string sessionid)
{
DEBUG(db, "%s, %s, %ld\n",
patientid.c_str(), macro.attributes["name"].c_str(), oldest);
@@ -144,22 +148,22 @@ public:
return fieldnames;
}
- void commit()
+ void commit(std::string sessionid)
{
if(!dao || sessionid == "") return;
- return dao->commit(sessionId());
+ return dao->commit(sessionid);
}
- void nocommit()
+ void nocommit(std::string sessionid)
{
if(!dao || sessionid == "") return;
- return dao->nocommit(sessionId());
+ return dao->nocommit(sessionid);
}
- void discard()
+ void discard(std::string sessionid)
{
if(!dao || sessionid == "") return;
- return dao->discard(sessionId());
+ return dao->discard(sessionid);
}
std::string serialise()
@@ -174,16 +178,22 @@ public:
return dao->restore(data);
}
- bool active()
+ bool active(std::string sessionid)
{
if(!dao || sessionid == "") return false;
- return dao->active(sessionId());
+ return dao->active(sessionid);
+ }
+
+ void setActive(std::string sessionid, bool val)
+ {
+ if(dao && sessionid != "") {
+ dao->setActive(sessionid, val);
+ }
}
private:
PracroDAO *dao;
Mutex mutex;
- std::string sessionid;
};
#endif/*__PRACRO_DATABASE_H__*/