diff options
| -rw-r--r-- | client/macro.cc | 4 | ||||
| -rw-r--r-- | client/macro.h | 2 | ||||
| -rw-r--r-- | client/macrowindow.cc | 18 | ||||
| -rw-r--r-- | client/macrowindow.h | 4 | ||||
| -rw-r--r-- | client/mainwindow.cc | 28 | ||||
| -rw-r--r-- | client/mainwindow.h | 6 | ||||
| -rw-r--r-- | client/netcom.cc | 8 | ||||
| -rw-r--r-- | client/netcom.h | 4 | ||||
| -rw-r--r-- | client/pracro.cc | 21 | ||||
| -rw-r--r-- | server/src/Makefile.am | 2 | ||||
| -rw-r--r-- | server/src/journal_commit.cc | 34 | ||||
| -rw-r--r-- | server/src/journal_commit.h | 2 | ||||
| -rw-r--r-- | server/src/macrotool_dump.cc | 26 | ||||
| -rw-r--r-- | server/src/saxparser.cc | 8 | ||||
| -rw-r--r-- | server/src/server.cc | 28 | ||||
| -rw-r--r-- | server/src/template.h | 8 | ||||
| -rw-r--r-- | server/src/templateheaderparser.cc | 2 | ||||
| -rw-r--r-- | server/src/templateparser.cc | 33 | ||||
| -rw-r--r-- | server/src/templateparser.h | 4 | ||||
| -rw-r--r-- | server/src/transaction.h | 4 | ||||
| -rw-r--r-- | server/src/transactionparser.cc | 10 | ||||
| -rw-r--r-- | server/xml/templates/amd_behandling.xml | 6 | ||||
| -rw-r--r-- | server/xml/templates/amd_forunders.xml | 4 | ||||
| -rw-r--r-- | server/xml/templates/amd_kontrolunders.xml | 6 | ||||
| -rw-r--r-- | server/xml/templates/example.xml | 4 | ||||
| -rw-r--r-- | server/xml/templates/test.xml | 4 | 
26 files changed, 137 insertions, 143 deletions
diff --git a/client/macro.cc b/client/macro.cc index 2777cf5..7a1b51b 100644 --- a/client/macro.cc +++ b/client/macro.cc @@ -53,7 +53,7 @@ void Macro::update(QDomNode &n)    iscompleted = xml_elem.attribute("completed", "false") == "true";  } -void Macro::init(QBoxLayout *layout, Macros ¯os, bool initialising, NetCom &netcom, QString course) +void Macro::init(QBoxLayout *layout, Macros ¯os, bool initialising, NetCom &netcom, QString templ)  {    QDomElement xml_elem = node.toElement(); @@ -89,7 +89,7 @@ void Macro::init(QBoxLayout *layout, Macros ¯os, bool initialising, NetCom &    //  if(macros.find(name) == macros.end()) {    if(window == NULL) { -    window = new MacroWindow(netcom, node, course, !isstatic, iscompact); +    window = new MacroWindow(netcom, node, templ, !isstatic, iscompact);      /*      QWidget *edge = new QWidget(); diff --git a/client/macro.h b/client/macro.h index 610d3b2..20a4e14 100644 --- a/client/macro.h +++ b/client/macro.h @@ -46,7 +46,7 @@ public:    Macro() {}    Macro(QDomNode &node); -  void init(QBoxLayout *layout, Macros ¯os, bool initialising, NetCom &netcom, QString course); +  void init(QBoxLayout *layout, Macros ¯os, bool initialising, NetCom &netcom, QString templ);    void update(QDomNode &node); diff --git a/client/macrowindow.cc b/client/macrowindow.cc index a96964b..7173e2a 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -44,13 +44,13 @@ extern QString user;  extern QString host;  extern quint16 port; -MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString course, +MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString templ,                           bool collapsed, bool compact)    : Collapser(), netcom(n)  {    waschanged = false; -  this->course = course; +  this->templ = templ;    setCollapsedWidget(new ResumeWidget(compact)); @@ -149,7 +149,7 @@ bool MacroWindow::doCommit()    // If all entries passed validation, continue commit    if(faulty == 0) { -    netcom.send(widgets, course, macro, version); +    netcom.send(widgets, templ, macro, version);      emit updateOnCommit();      setCollapsed(true);      return true; @@ -222,7 +222,7 @@ void MacroWindow::cont(QString name)      // FIXME: Hack to prevent XML clotching.      // The server could not differentiate the commit and the request. -    // TODO: Where to get the course var?? +    // TODO: Where to get the template var??      //    new_macro("example", macro);      //    close();    } else { @@ -249,7 +249,7 @@ void MacroWindow::cont_nocommit(QString name)      // FIXME: Hack to prevent XML clotching.      // The server could not differentiate the commit and the request. -    // TODO: Where to get the course var?? +    // TODO: Where to get the template var??      //    new_macro("example", macro);      //    close();    } else { @@ -305,7 +305,7 @@ void MacroWindow::expandWrapper()    luaprograms.clear();    waschanged = false; -  QDomDocument xml_doc = netcom.send(course, macro); +  QDomDocument xml_doc = netcom.send(templ, macro);    //    // TODO: This is where the dependency checking should occur. @@ -313,9 +313,9 @@ void MacroWindow::expandWrapper()    // Initiate the new macro window with the xml document and push    //  it to the window list -  QDomNodeList courses = xml_doc.documentElement().childNodes(); -  QDomNode coursenode = courses.at(0); // There can be only one! (Swush, flomp) -  QDomNodeList macronodes = coursenode.childNodes(); +  QDomNodeList templates = xml_doc.documentElement().childNodes(); +  QDomNode templatenode = templates.at(0); // There can be only one! (Swush, flomp) +  QDomNodeList macronodes = templatenode.childNodes();    for(int j = 0; j < macronodes.count(); j++) {      QDomNode macronode = macronodes.at(j); diff --git a/client/macrowindow.h b/client/macrowindow.h index fad467b..51a675e 100644 --- a/client/macrowindow.h +++ b/client/macrowindow.h @@ -47,7 +47,7 @@ class MacroWindow : public Collapser  {  Q_OBJECT  public: -  MacroWindow(NetCom &netcom, QDomNode &xml_doc, QString course, +  MacroWindow(NetCom &netcom, QDomNode &xml_doc, QString templ,                bool collapsed = true, bool compact = false);    ~MacroWindow(); @@ -97,7 +97,7 @@ private:    QVector< Widget* > widgets;    QVector< Widget* > auxwidgets;    QString macro; -  QString course; +  QString templ;    QString version;    QWidget *mainwidget;    ResumeWidget *resumewidget; diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 14ed60b..beef88c 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -40,7 +40,7 @@  #include "macrodrawer.h" -MainWindow::MainWindow(QString cpr, QString course, QString host, quint16 port, QString user) +MainWindow::MainWindow(QString cpr, QString templ, QString host, quint16 port, QString user)    : QMainWindow(0, Qt::WindowContextHelpButtonHint),      netcom(host, port, user, cpr)  { @@ -58,7 +58,7 @@ MainWindow::MainWindow(QString cpr, QString course, QString host, quint16 port,    s->setWidgetResizable(true);    w->setLayout(new QVBoxLayout()); -  this->course = course; +  this->templ = templ;    setStatusBar(status); @@ -93,15 +93,15 @@ void MainWindow::init()    initialising = false;  } -void MainWindow::updateCourseHeaders(QDomNode coursenode) +void MainWindow::updateTemplateHeaders(QDomNode templatenode)  { -  QDomElement course_elem = coursenode.toElement(); -  QString course_title = course_elem.attribute("title"); -  QString course_name = course_elem.attribute("name"); +  QDomElement template_elem = templatenode.toElement(); +  QString template_title = template_elem.attribute("title"); +  QString template_name = template_elem.attribute("name");    if(!header) {      header = new QLabel(); -    header->setText(course_title); +    header->setText(template_title);      QFont headerfont = header->font();      headerfont.setBold(true);      headerfont.setPointSize(headerfont.pointSize() + 4); @@ -110,20 +110,20 @@ void MainWindow::updateCourseHeaders(QDomNode coursenode)      w->layout()->addWidget(header);    } -  statusBar()->showMessage(course_title + " (" + course_name + ")"); +  statusBar()->showMessage(template_title + " (" + template_name + ")");  }  void MainWindow::update()  { -  QDomDocument xml_doc = netcom.send(course); +  QDomDocument xml_doc = netcom.send(templ); -  QDomNodeList courses = xml_doc.documentElement().childNodes(); -  QDomNode coursenode = courses.at(0); // There can be only one! (Swush, flomp) +  QDomNodeList templates = xml_doc.documentElement().childNodes(); +  QDomNode templatenode = templates.at(0); // There can be only one! (Swush, flomp) -  updateCourseHeaders(coursenode); +  updateTemplateHeaders(templatenode); -  QDomNodeList macronodes = coursenode.childNodes(); +  QDomNodeList macronodes = templatenode.childNodes();    for(int j = 0; j < macronodes.count(); j++) {      QDomNode macronode = macronodes.at(j); @@ -165,7 +165,7 @@ void MainWindow::update()      Macros::iterator i = macros.begin();      while(i != macros.end()) {        Macro ¯o = i.value(); -      macro.init((QBoxLayout*)w->layout(), macros, initialising, netcom, course); +      macro.init((QBoxLayout*)w->layout(), macros, initialising, netcom, templ);        if(macro.window != NULL) {          // Remove old connection (if any), to avoid multiple connections.          disconnect(macro.window, SIGNAL(updateOnCommit()), this, SLOT(update())); diff --git a/client/mainwindow.h b/client/mainwindow.h index d60db9d..e19b070 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -39,7 +39,7 @@  class MainWindow : public QMainWindow {  Q_OBJECT  public: -  MainWindow(QString cpr, QString course, QString host, quint16 port, QString user); +  MainWindow(QString cpr, QString templ, QString host, quint16 port, QString user);    ~MainWindow();    void closeEvent(QCloseEvent *event); @@ -48,9 +48,9 @@ public slots:    void update();  private: -  void updateCourseHeaders(QDomNode coursenode); +  void updateTemplateHeaders(QDomNode templatenode); -  QString course; +  QString templ;    NetCom netcom;    //  QMap< QString, MacroWindow* > macros; diff --git a/client/netcom.cc b/client/netcom.cc index 38b8b48..0da19f8 100644 --- a/client/netcom.cc +++ b/client/netcom.cc @@ -46,7 +46,7 @@ NetCom::~NetCom()    socket.disconnectFromHost();  } -QDomDocument NetCom::send(QString course, QString macro) +QDomDocument NetCom::send(QString templ, QString macro)  {    printf("Socket state: %d\n", socket.state());    if(socket.state() != 3) printf("Socket state not connected: %s\n", socket.errorString().toStdString().c_str()); @@ -66,7 +66,7 @@ QDomDocument NetCom::send(QString course, QString macro)    doc.appendChild(pracro_elem);    QDomElement request_elem = doc.createElement("request"); -  request_elem.setAttribute("course", course); +  request_elem.setAttribute("template", templ);    if(macro != "") request_elem.setAttribute("macro", macro);    pracro_elem.appendChild(request_elem); @@ -96,7 +96,7 @@ void NetCom::readyRead()    buffer.append(socket.readAll());  } -void NetCom::send(QVector< Widget* > widgets, QString course, QString macro, QString version) +void NetCom::send(QVector< Widget* > widgets, QString templ, QString macro, QString version)  {    printf("Socket state: %d\n", socket.state());    if(socket.state() != 3) printf("Socket state not connected: %s\n", socket.errorString().toStdString().c_str()); @@ -115,7 +115,7 @@ void NetCom::send(QVector< Widget* > widgets, QString course, QString macro, QSt    doc.appendChild(pracro_elem);    QDomElement commit_elem = doc.createElement("commit"); -  commit_elem.setAttribute("course", course); +  commit_elem.setAttribute("template", templ);    commit_elem.setAttribute("macro", macro);    commit_elem.setAttribute("version", version);    pracro_elem.appendChild(commit_elem); diff --git a/client/netcom.h b/client/netcom.h index 13f3ac8..8cccaa9 100644 --- a/client/netcom.h +++ b/client/netcom.h @@ -41,8 +41,8 @@ public:    NetCom(QString host, quint16 port, QString user, QString cpr);    ~NetCom(); -  QDomDocument send(QString course, QString macro = ""); -  void send(QVector< Widget* > widgets, QString course, QString macro, QString version); +  QDomDocument send(QString templ, QString macro = ""); +  void send(QVector< Widget* > widgets, QString templ, QString macro, QString version);  public slots:    void readyRead(); diff --git a/client/pracro.cc b/client/pracro.cc index 93c9429..6d9c574 100644 --- a/client/pracro.cc +++ b/client/pracro.cc @@ -38,7 +38,7 @@  #define CPR_DEFAULT ""  #define MACRO_DEFAULT "" -#define COURSE_DEFAULT "" +#define TEMPLATE_DEFAULT ""  #define USER_DEFAULT "testuser"  #define CONFIG_DEFAULT "pracro.ini" @@ -58,11 +58,11 @@ static void print_usage()    printf("  -m, --macro MACRO         Requests macro MACRO from the Pracro \n"           "                            Server, defaults to \""MACRO_DEFAULT"\".\n");    */ -  printf("  -c, --course COURSE       Requests course COURSE from the Pracro \n" -         "                            Server, defaults to \""COURSE_DEFAULT"\".\n"); +  printf("  -t, --template TEMPLATE   Requests template TEMPLATE from the Pracro \n" +         "                            Server, defaults to \""TEMPLATE_DEFAULT"\".\n");    printf("  -C, --cpr CPR             Defines the cpr for use with the macro,\n"           "                            defaults to \""CPR_DEFAULT"\".\n"); -  printf("  -C, --config FILE         The configfile to use. Default is \""CONFIG_DEFAULT"\"\n"); +  printf("  -c, --config FILE         The configfile to use. Default is \""CONFIG_DEFAULT"\"\n");    printf("  -u, -U, --user USER       Defines the requesting user(not the patient),\n"           "                            defaults to \""USER_DEFAULT"\"\n");    //  printf("  -t, --test macro          Run client in testmode, i.e. run without contactig any\n" @@ -89,7 +89,7 @@ int main(int argc, char *argv[])    QApplication app(argc, argv);    QString macro = MACRO_DEFAULT; -  QString course = COURSE_DEFAULT; +  QString templ = TEMPLATE_DEFAULT;    QStringList args = app.arguments();    QStringList::iterator arg = args.begin(); @@ -115,15 +115,16 @@ int main(int argc, char *argv[])        macro = getParam(args, arg);      }      */ -    else if(*arg == "--course" || -            *arg == "-c") { -      course = getParam(args, arg); +    else if(*arg == "--template" || +            *arg == "-t") { +      templ = getParam(args, arg);      }      else if(*arg == "--cpr" ||              *arg == "-C") {        cpr = getParam(args, arg);       } -    else if(*arg == "--config") { +    else if(*arg == "--config" || +            *arg == "-c") {        config = getParam(args, arg);       }      else { @@ -146,7 +147,7 @@ int main(int argc, char *argv[])    translator.load("pracro_dk");    app.installTranslator(&translator); -  MainWindow mainwindow(cpr, course, host, port, user); +  MainWindow mainwindow(cpr, templ, host, port, user);    mainwindow.show();    int ret = app.exec(); diff --git a/server/src/Makefile.am b/server/src/Makefile.am index 5516458..c8e1c51 100644 --- a/server/src/Makefile.am +++ b/server/src/Makefile.am @@ -225,6 +225,8 @@ test_macroparser: $(TEST_MACROPARSER_FILES)  TEST_SERVER_FILES = \  	server.cc \  	templateparser.cc \ +	templatelist.cc \ +	templateheaderparser.cc \  	queryparser.cc \  	queryhandlerpentominos.cc \  	journal_commit.cc \ diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc index 4992545..21d40c3 100644 --- a/server/src/journal_commit.cc +++ b/server/src/journal_commit.cc @@ -207,46 +207,46 @@ JournalWriter::JournalWriter(std::string host, unsigned short int port)  }  void JournalWriter::addEntry(Transaction &transaction, Commit &commit, -                             std::string resume, std::string course) +                             std::string resume, std::string templname)  { -  TemplateParser tp(course); +  TemplateParser tp(templname);    tp.parse();    Template *templ = tp.getTemplate();    size_t index = 0; -  std::vector< Macro >::iterator i = templ->course.macros.begin(); -  while(i != templ->course.macros.end()) { +  std::vector< Macro >::iterator i = templ->macros.begin(); +  while(i != templ->macros.end()) {      Macro &m = *i;      if(commit.macro == m.attributes["name"]) break;      index++;      i++;    } -  if(index >= templ->course.macros.size()) { -    PRACRO_ERR(journal, "Could not find macro %s in course %s\n", -                 commit.macro.c_str(), course.c_str()); +  if(index >= templ->macros.size()) { +    PRACRO_ERR(journal, "Could not find macro %s in template %s\n", +                 commit.macro.c_str(), templname.c_str());      //      return;    } else { -    PRACRO_DEBUG(journal, "Found macro %s as index %u in course %s\n", -                 commit.macro.c_str(), index, course.c_str()); +    PRACRO_DEBUG(journal, "Found macro %s as index %u in template %s\n", +                 commit.macro.c_str(), index, templname.c_str());    }    // 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()); +  PRACRO_DEBUG(journal, "addEntry: template(%s)\n", templname.c_str()); -  // Add the course resume as the header (ie. first entry) of the journal entry. -  if(entrylist.size() == 0 && course != "") { -    std::string course_resume = templ->course.attributes["resume"]; +  // Add the template resume as the header (ie. first entry) of the journal entry. +  if(entrylist.size() == 0 && templname != "") { +    std::string template_resume = templ->attributes["resume"]; -    PRACRO_DEBUG(journal, "CourseResume: %s\n", course_resume.c_str()); +    PRACRO_DEBUG(journal, "TemplateResume: %s\n", template_resume.c_str()); -    if(course_resume != "") { +    if(template_resume != "") {        ResumeEntry re; -      re.resume = course_resume; -      re.macro = "course_header";  +      re.resume = template_resume; +      re.macro = "template_header";         entrylist[-1] = re; // Make sure it comes first.      }    } diff --git a/server/src/journal_commit.h b/server/src/journal_commit.h index 0565f34..9122703 100644 --- a/server/src/journal_commit.h +++ b/server/src/journal_commit.h @@ -43,7 +43,7 @@ public:    JournalWriter(std::string host, unsigned short int port);    void addEntry(Transaction &transaction, Commit &commit, -                std::string resume, std::string course_resume); +                std::string resume, std::string template_resume);    void commit(); diff --git a/server/src/macrotool_dump.cc b/server/src/macrotool_dump.cc index 3f9cfd7..71bc690 100644 --- a/server/src/macrotool_dump.cc +++ b/server/src/macrotool_dump.cc @@ -89,14 +89,14 @@ static std::map<std::string, struct _macro> macroList()    std::vector<std::string> templatefiles = getTemplates();    std::vector<std::string>::iterator tfs = templatefiles.begin();    while(tfs != templatefiles.end()) { -    std::string course = tfs->substr(0, tfs->length() - 4); -    TemplateParser parser(course); +    std::string templ = tfs->substr(0, tfs->length() - 4); +    TemplateParser parser(templ);      parser.parse();      Template *t = parser.getTemplate(); -    std::vector<Macro>::iterator ms = t->course.macros.begin(); -    while(ms != t->course.macros.end()) { +    std::vector<Macro>::iterator ms = t->macros.begin(); +    while(ms != t->macros.end()) {        if(ms->attributes.find("header") == ms->attributes.end()) -        macros[ms->attributes["name"]].templates.insert(course); +        macros[ms->attributes["name"]].templates.insert(templ);        ms++;      }      tfs++; @@ -154,20 +154,20 @@ static std::map<std::string, struct _template> templateList()    std::vector<std::string> templatefiles = getTemplates();    std::vector<std::string>::iterator tfs = templatefiles.begin();    while(tfs != templatefiles.end()) { -    std::string course = tfs->substr(0, tfs->length() - 4); -    TemplateParser parser(course); +    std::string templ = tfs->substr(0, tfs->length() - 4); +    TemplateParser parser(templ);      parser.parse();      Template *t = parser.getTemplate(); -    std::string key = t->course.attributes["name"]; +    std::string key = t->attributes["name"];      templates[key].file = *tfs; -    templates[key].name = t->course.attributes["name"]; -    templates[key].title = t->course.attributes["title"]; -    templates[key].version = t->course.attributes["version"]; +    templates[key].name = t->attributes["name"]; +    templates[key].title = t->attributes["title"]; +    templates[key].version = t->attributes["version"]; -    std::vector<Macro>::iterator ms = t->course.macros.begin(); -    while(ms != t->course.macros.end()) { +    std::vector<Macro>::iterator ms = t->macros.begin(); +    while(ms != t->macros.end()) {        if(ms->attributes.find("header") == ms->attributes.end())          templates[key].macros.push_back(ms->attributes["name"]);        ms++; diff --git a/server/src/saxparser.cc b/server/src/saxparser.cc index ee03de1..8455593 100644 --- a/server/src/saxparser.cc +++ b/server/src/saxparser.cc @@ -182,7 +182,7 @@ unsigned int SAXParser::usedBytes()  static char xml[] =  "<?xml version='1.0' encoding='UTF-8'?>\n"  "<pracro version=\"1.0\" user=\"testuser\" cpr=\"1505050505\">\n" -" <commit version=\"\" macro=\"referral\" course=\"amd_forunders\">\n" +" <commit version=\"\" macro=\"referral\" template=\"amd_forunders\">\n"  "  <field value=\"Some docs\" name=\"referral.doctor\"/>\n"  "  <field value=\"DIMS\" name=\"referral.diagnosecode\"/>\n"  "  <field value=\"Avs\" name=\"referral.diagnose\"/>\n" @@ -193,7 +193,7 @@ static char xml[] =  static char xml_notrailingwhitespace[] =  "<?xml version='1.0' encoding='UTF-8'?>\n"  "<pracro version=\"1.0\" user=\"testuser\" cpr=\"1505050505\">\n" -" <commit version=\"\" macro=\"referral\" course=\"amd_forunders\">\n" +" <commit version=\"\" macro=\"referral\" template=\"amd_forunders\">\n"  "  <field value=\"Some docs\" name=\"referral.doctor\"/>\n"  "  <field value=\"DIMS\" name=\"referral.diagnosecode\"/>\n"  "  <field value=\"Avs\" name=\"referral.diagnose\"/>\n" @@ -204,14 +204,14 @@ static char xml_notrailingwhitespace[] =  static char xml_fail[] =  "<?xml version='1.0' encoding='UTF-8'?>\n"  "<pracro version=\"1.0\" user\"testuser\" cpr=\"1505050505\">\n" -" <request macro=\"test\" course=\"test\"/>\n" +" <request macro=\"test\" template=\"test\"/>\n"  "</pracro>\n"    ;  static char xml_fail2[] =  "<?xml version='1.0' encoding='UTF-8'?>\n"  "<pracro version=\"1.0\" user\"testuser\" cpr=\"1505050505\">\n" -" <request macro=\"test\" course=\"test\"/>\n" +" <request macro=\"test\" template=\"test\"/>\n"  "</pracro>\n"  "this is junk\n"    ; diff --git a/server/src/server.cc b/server/src/server.cc index 924ad84..f75aeab 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -63,13 +63,13 @@ static std::string error_box(std::string message)    std::string errorbox =      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"      "<pracro version=\"1.0\">\n" -    "  <course name=\"error\">\n" +    "  <template name=\"error\">\n"      "    <macro name=\"error\" static=\"true\">\n"      "      <window caption=\"ERROR!\" layout=\"vbox\" name=\"error\">\n"      "        <textedit name=\"errorlabel\" value=\"" + message + "\"/>\n"      "      </window>\n"      "    </macro>\n" -    "  </course>\n" +    "  </template>\n"      "</pracro>\n";    return errorbox;  } @@ -77,7 +77,7 @@ static std::string error_box(std::string message)  class NotFoundException : public Exception {  public:    NotFoundException(Request &r) -  : Exception("Macro " + r.macro + " not found in course " + r.course) {} +  : Exception("Macro " + r.macro + " not found in template " + r.templ) {}  }; @@ -99,7 +99,7 @@ static std::string handleCommits(Transaction *transaction, Database &db,      db.commitTransaction(transaction->user, transaction->cpr, *macro, commit.fields);      if(resume != "") { -      journalwriter.addEntry(*transaction, commit, resume, commit.course); +      journalwriter.addEntry(*transaction, commit, resume, commit.templ);      }      i++; @@ -122,26 +122,26 @@ static std::string handleRequest(Transaction *transaction,    while(i != transaction->requests.end()) {      Request &request = *i; -    PRACRO_DEBUG(server, "Handling request - macro: %s, course: %s\n", -                 request.macro.c_str(), request.course.c_str()); +    PRACRO_DEBUG(server, "Handling request - macro: %s, template: %s\n", +                 request.macro.c_str(), request.templ.c_str());      // Read and parse the template file. -    TemplateParser tp(templatelist.getLatestVersion(request.course)); +    TemplateParser tp(templatelist.getLatestVersion(request.templ));      tp.parse();      Template *templ = tp.getTemplate(); -    answer += "  <course name=\""; -    answer += templ->course.attributes["name"]; +    answer += "  <template name=\""; +    answer += templ->attributes["name"];      answer += "\" title=\""; -    answer += templ->course.attributes["title"]; +    answer += templ->attributes["title"];      answer += "\">\n";      bool foundmacro = false;      // Generate the macro and return it to the client -    std::vector< Macro >::iterator mi2 = templ->course.macros.begin(); -    while(mi2 != templ->course.macros.end()) { +    std::vector< Macro >::iterator mi2 = templ->macros.begin(); +    while(mi2 != templ->macros.end()) {        Macro ¯o = (*mi2);        if(macro.isHeader) { @@ -244,7 +244,7 @@ static std::string handleRequest(Transaction *transaction,      if(foundmacro == false && request.macro != "")        throw NotFoundException(request); -    answer += "  </course>\n"; +    answer += "  </template>\n";      i++;    } @@ -432,7 +432,7 @@ bool pracro_is_running = true;  char request[] =     "<?xml version='1.0' encoding='UTF-8'?>\n"    "<pracro cpr=\"2003791613\" version=\"1.0\">\n" -  "  <request macro=\"example\" course=\"example\"/>\n" +  "  <request macro=\"example\" template=\"example\"/>\n"    "</pracro>\n";  int main() diff --git a/server/src/template.h b/server/src/template.h index ac5900f..c14577e 100644 --- a/server/src/template.h +++ b/server/src/template.h @@ -68,15 +68,9 @@ public:    bool isHeader;  }; -class Course { -public: -  std::vector< Macro > macros; -  std::map< std::string, std::string > attributes; -}; -  class Template {  public: -  Course course; +  std::vector< Macro > macros;    std::map< std::string, std::string > attributes;  }; diff --git a/server/src/templateheaderparser.cc b/server/src/templateheaderparser.cc index ee93381..8b0f162 100644 --- a/server/src/templateheaderparser.cc +++ b/server/src/templateheaderparser.cc @@ -95,7 +95,7 @@ TemplateHeaderParser::~TemplateHeaderParser()  void TemplateHeaderParser::startTag(std::string name, std::map< std::string, std::string> attributes)  {    // Create template and enable parsing of queries, maps and window -  if(name == "course") { +  if(name == "template") {      assert(!t); // A Template has already been allocated, cannot create template!      t = new Template();      t->attributes = attributes; diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index 8ddf6d2..62be9c7 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -63,7 +63,7 @@ TemplateParser::TemplateParser(std::string templatefile)    t = new Template();    current_macro = NULL; -  file = templatefile;//Conf::xml_basedir + "/templates/" + course + ".xml"; +  file = templatefile;    PRACRO_DEBUG(macro, "Using template file: %s\n", file.c_str()); @@ -84,20 +84,20 @@ void TemplateParser::characterData(std::string &data)  void TemplateParser::startTag(std::string name, std::map< std::string, std::string> attributes)  {    // Enable macro parsing -  if(name == "course") { -    if(state != UNDEFINED) error("course found not a root node."); -    state = COURSE; +  if(name == "template") { +    if(state != UNDEFINED) error("Template found not a root node."); +    state = TEMPLATE; -    assert(t); // A Template has not yet been allocated, cannot create course! +    assert(t); // A Template has not yet been allocated, cannot create template! -    t->course.attributes = attributes; +    t->attributes = attributes;      return;    }    // Create macro and enable parsing of queries, maps and window    if(name == "macro" || name == "header") { -    if(state != COURSE) error("macro found outside course."); +    if(state != TEMPLATE) error("macro found outside template.");      state = MACRO;      assert(t); // A Template has not yet been allocated, cannot create macro! @@ -105,8 +105,8 @@ void TemplateParser::startTag(std::string name, std::map< std::string, std::stri      Macro m;      m.attributes = attributes;      m.isHeader = name == "header"; -    t->course.macros.push_back(m); -    current_macro = &(t->course.macros.back()); +    t->macros.push_back(m); +    current_macro = &(t->macros.back());      return;    } @@ -116,10 +116,10 @@ void TemplateParser::startTag(std::string name, std::map< std::string, std::stri  void TemplateParser::endTag(std::string name)  { -  if(name == "course") state = UNDEFINED; +  if(name == "template") state = UNDEFINED;    if(name == "macro" || name == "header") {      current_macro = NULL; -    state = COURSE; +    state = TEMPLATE;    }  } @@ -173,16 +173,13 @@ int main()      Template *t = parser.getTemplate(); -    printf("[Template]:\n"); -    print_attributes("\t-", t->attributes); - -    printf("\t[Course]:\n"); -    print_attributes("\t\t-", t->course.attributes); +    printf("\t[Template]:\n"); +    print_attributes("\t\t-", t->attributes);      printf("\t\t[Macros]:\n"); -    std::vector< Macro >::iterator i = t->course.macros.begin(); +    std::vector< Macro >::iterator i = t->macros.begin(); -    while(i != t->course.macros.end()) { +    while(i != t->macros.end()) {        printf("\t\t\t[Macro]:\n");        print_attributes("\t\t\t\t-", (*i).attributes); diff --git a/server/src/templateparser.h b/server/src/templateparser.h index 845e605..61f4d0b 100644 --- a/server/src/templateparser.h +++ b/server/src/templateparser.h @@ -32,13 +32,13 @@  typedef enum {    UNDEFINED, -  COURSE, +  TEMPLATE,    MACRO,  } ParserState;  class TemplateParser : public SAXParser {  public: -  TemplateParser(std::string course); +  TemplateParser(std::string templ);    ~TemplateParser();    void characterData(std::string &data); diff --git a/server/src/transaction.h b/server/src/transaction.h index 07f7e10..2cca49c 100644 --- a/server/src/transaction.h +++ b/server/src/transaction.h @@ -34,7 +34,7 @@  class Request {  public:    std::string macro; -  std::string course; +  std::string templ;  };  typedef std::vector< Request > Requests; @@ -42,7 +42,7 @@ typedef std::map< std::string, std::string > Fields;  class Commit {  public: -  std::string course; +  std::string templ;    std::string macro;    std::string version;    Fields fields; diff --git a/server/src/transactionparser.cc b/server/src/transactionparser.cc index 3135929..d4f7c76 100644 --- a/server/src/transactionparser.cc +++ b/server/src/transactionparser.cc @@ -78,14 +78,14 @@ void TransactionParser::startTag(std::string name, std::map< std::string, std::s    if(name == "request") {      Request r; -    r.course = attributes["course"]; +    r.templ = attributes["template"];      r.macro = attributes["macro"];      transaction->requests.push_back(r);    }    if(name == "commit") {      Commit c; -    c.course = attributes["course"]; +    c.templ = attributes["template"];      c.macro = attributes["macro"];      c.version = attributes["version"];      transaction->commits.push_back(c); @@ -124,14 +124,14 @@ static char xml_minimal[] =  static char xml_request[] =  "<?xml version='1.0' encoding='UTF-8'?>\n"  "<pracro version=\"1.0\" user=\"testuser\" cpr=\"1505050505\">\n" -" <request macro=\"test\" course=\"test\"/>\n" +" <request macro=\"test\" template=\"test\"/>\n"  "</pracro>\n"    ;  static char xml_commit[] =  "<?xml version='1.0' encoding='UTF-8'?>\n"  "<pracro version=\"1.0\" user=\"testuser\" cpr=\"1505050505\">\n" -" <commit version=\"\" macro=\"referral\" course=\"amd_forunders\" >\n" +" <commit version=\"\" macro=\"referral\" template=\"amd_forunders\" >\n"  "  <field value=\"Some docs\" name=\"referral.doctor\"/>\n"  "  <field value=\"DIMS\" name=\"referral.diagnosecode\"/>\n"  "  <field value=\"Avs\" name=\"referral.diagnose\"/>\n" @@ -142,7 +142,7 @@ static char xml_commit[] =  static char xml_fail[] =  "<?xml version='1.0' encoding='UTF-8'?>\n"  "<pracro version=\"1.0\" user=\"testuser\" cpr=\"1505050505\">\n" -" <request macro=\"test course=\"test\"/>\n" +" <request macro=\"test template=\"test\"/>\n"  "</pracro>\n"    ; diff --git a/server/xml/templates/amd_behandling.xml b/server/xml/templates/amd_behandling.xml index 7be6361..58393b3 100644 --- a/server/xml/templates/amd_behandling.xml +++ b/server/xml/templates/amd_behandling.xml @@ -1,6 +1,6 @@  <?xml version='1.0' encoding='UTF-8'?> -<course name="amd_behandling" version="1.0" title="AMD behandling" -	resume="Behandling af AMD med Lucentis"> +<template name="amd_behandling" version="1.0" title="AMD behandling" +					resume="Behandling af AMD med Lucentis">    <macro name="header" static="true"/>    <header caption="Behandling"/> @@ -8,5 +8,5 @@    <macro name="5steps"/>    <macro name="amdprocedure"/> -</course> +</template> diff --git a/server/xml/templates/amd_forunders.xml b/server/xml/templates/amd_forunders.xml index 9201e3f..31f7d7e 100644 --- a/server/xml/templates/amd_forunders.xml +++ b/server/xml/templates/amd_forunders.xml @@ -1,5 +1,5 @@  <?xml version='1.0' encoding='UTF-8'?> -<course name="amd_forunders" version="1.0" title="AMD forundersøgelse"> +<template name="amd_forunders" version="1.0" title="AMD forundersøgelse">    <macro name="header" static="true"/>    <macro name="referral"/> @@ -35,4 +35,4 @@    <macro name="amdindication" requires="referral"/>    <macro name="amdconsent" requires="referral" compact="true"/> -</course> +</template> diff --git a/server/xml/templates/amd_kontrolunders.xml b/server/xml/templates/amd_kontrolunders.xml index 2606743..818c472 100644 --- a/server/xml/templates/amd_kontrolunders.xml +++ b/server/xml/templates/amd_kontrolunders.xml @@ -1,6 +1,6 @@  <?xml version='1.0' encoding='UTF-8'?> -<course name="amd_kontrolunders" version="1.0" title="AMD kontrolundersøgelse" -	resume="Kontrolundersøgelse i AMD forløb"> +<template name="amd_kontrolunders" version="1.0" title="AMD kontrolundersøgelse" +					resume="Kontrolundersøgelse i AMD forløb">    <macro name="header" static="true"/>    <header caption="Anamnese"/> @@ -33,4 +33,4 @@    <macro name="amdtreatmentindication"/>    <macro name="amdconsent" compact="true"/> -</course> +</template> diff --git a/server/xml/templates/example.xml b/server/xml/templates/example.xml index b6a3f6d..23e54a3 100644 --- a/server/xml/templates/example.xml +++ b/server/xml/templates/example.xml @@ -1,6 +1,6 @@  <?xml version='1.0' encoding='UTF-8'?> -<course name="example" version="1.0" title="Example template"> +<template name="example" version="1.0" title="Example template">  	<header caption="Some header caption"/>    <macro name="example"/>    <macro name="example" requires="someothermacro"/> -</course> +</template> diff --git a/server/xml/templates/test.xml b/server/xml/templates/test.xml index dd4c093..0947bec 100644 --- a/server/xml/templates/test.xml +++ b/server/xml/templates/test.xml @@ -1,5 +1,5 @@  <?xml version='1.0' encoding='UTF-8'?> -<course name="test" version="1.0"> +<template name="test" version="1.0">    <macro name="test_resume"/>    <macro name="test_button"/>    <macro name="test_radiobuttons"/> @@ -11,4 +11,4 @@    <macro name="test_combobox"/>    <macro name="test_checkbox"/>    <macro name="test_altcombobox"/> -</course> +</template>  | 
