From 1435d2c664f1c7696cbde2b41df6362f99d1df2c Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 11 May 2009 11:57:50 +0000 Subject: New 'header' in each journal commit, taken from the course. --- server/src/journal_commit.cc | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'server/src/journal_commit.cc') 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 #include +#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, -- cgit v1.2.3