diff options
author | deva <deva> | 2009-05-11 11:57:50 +0000 |
---|---|---|
committer | deva <deva> | 2009-05-11 11:57:50 +0000 |
commit | 1435d2c664f1c7696cbde2b41df6362f99d1df2c (patch) | |
tree | 302e686f55fc59ae28229df9c705c49d5c8a4dd8 /server/src | |
parent | 9b5c88df87d285995fd0c483de369cd7854893b1 (diff) |
New 'header' in each journal commit, taken from the course.
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/journal_commit.cc | 27 | ||||
-rw-r--r-- | server/src/journal_commit.h | 2 | ||||
-rw-r--r-- | server/src/server.cc | 3 | ||||
-rw-r--r-- | server/src/transaction.h | 1 | ||||
-rw-r--r-- | server/src/transactionparser.cc | 1 |
5 files changed, 30 insertions, 4 deletions
diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc index ce99b63..accf839 100644 --- a/server/src/journal_commit.cc +++ b/server/src/journal_commit.cc @@ -49,6 +49,9 @@ #include <time.h> #include <errno.h> +#include "template.h" +#include "templateparser.h" + /** * Remove all spaces, tabs and newline trailing the string. */ @@ -194,12 +197,32 @@ JournalWriter::JournalWriter(std::string host, unsigned short int port) this->port = port; } -void JournalWriter::addEntry(Transaction &transaction, Commit &commit, std::string resume) +void JournalWriter::addEntry(Transaction &transaction, Commit &commit, + std::string resume, std::string course) { // First run - initialize username and cpr. if(currentuser == "" && entrylist.size() == 0) currentuser = transaction.user; if(currentcpr == "" && entrylist.size() == 0) currentcpr = transaction.cpr; + PRACRO_DEBUG(journal, "addEntry: course(%s)\n", course.c_str()); + + // Add the course resume as the header (ie. first entry) of the journal entry. + if(entrylist.size() == 0 && course != "") { + TemplateParser tp(course); + tp.parse(); + Template *templ = tp.getTemplate(); + std::string course_resume = templ->course.attributes["resume"]; + + PRACRO_DEBUG(journal, "CourseResume: %s\n", course_resume.c_str()); + + if(course_resume != "") { + ResumeEntry re; + re.resume = course_resume; + re.macro = "course_header"; + entrylist.push_back(re); + } + } + // Test if the username or the cpr has changed... if so, commit and clear the list. if(currentuser != transaction.user || currentcpr != transaction.cpr) { this->commit(); @@ -244,6 +267,8 @@ void JournalWriter::commit() i++; } + if(resume == "") return; + // Connect to praxisuploadserver and commit all resumes in one bulk. journal_commit(currentcpr.c_str(), currentuser.c_str(), host.c_str(), port, diff --git a/server/src/journal_commit.h b/server/src/journal_commit.h index 387eab6..0f8ae57 100644 --- a/server/src/journal_commit.h +++ b/server/src/journal_commit.h @@ -42,7 +42,7 @@ class JournalWriter { public: JournalWriter(std::string host, unsigned short int port); - void addEntry(Transaction &transaction, Commit &commit, std::string resume); + void addEntry(Transaction &transaction, Commit &commit, std::string resume, std::string course_resume); void commit(); diff --git a/server/src/server.cc b/server/src/server.cc index 4a17954..a0dbaa4 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -102,14 +102,13 @@ static std::string handleTransaction(Transaction *transaction, commit.fields["journal.resume"] = resume; db->commitTransaction(transaction->user, transaction->cpr, *macro, commit.fields); - bool store_in_journal = true; // We always need to store in journal! // macro->resume.attributes.find("store_in_journal") != macro->resume.attributes.end() && // macro->resume.attributes["store_in_journal"] == "true"; if(resume != "" && store_in_journal) { - journalwriter.addEntry(*transaction, commit, resume); + journalwriter.addEntry(*transaction, commit, resume, commit.course); /* journal_commit(transaction->cpr.c_str(), transaction->user.c_str(), Conf::journal_commit_addr.c_str(), Conf::journal_commit_port, diff --git a/server/src/transaction.h b/server/src/transaction.h index 0e61ea0..07f7e10 100644 --- a/server/src/transaction.h +++ b/server/src/transaction.h @@ -42,6 +42,7 @@ typedef std::map< std::string, std::string > Fields; class Commit { public: + std::string course; std::string macro; std::string version; Fields fields; diff --git a/server/src/transactionparser.cc b/server/src/transactionparser.cc index 78c9b21..9e3d952 100644 --- a/server/src/transactionparser.cc +++ b/server/src/transactionparser.cc @@ -61,6 +61,7 @@ void TransactionParser::startTag(std::string name, std::map< std::string, std::s if(name == "commit") { Commit c; + c.course = attributes["course"]; c.macro = attributes["macro"]; c.version = attributes["version"]; transaction->commits.push_back(c); |