diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-11-17 14:32:16 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-11-17 14:32:16 +0100 |
commit | 39276e77092e8fd9c2b6e6ebd8863e5d2e1f00b2 (patch) | |
tree | 095465ff5a8b479cb69cf8551435288f79e32084 /server/getdata | |
parent | 69d26642da5ca087b5f3acb7dd77fbd0344f085a (diff) |
Remove obsolete getdata.
Diffstat (limited to 'server/getdata')
-rw-r--r-- | server/getdata/Makefile.am | 28 | ||||
-rw-r--r-- | server/getdata/getdata.cc | 192 |
2 files changed, 0 insertions, 220 deletions
diff --git a/server/getdata/Makefile.am b/server/getdata/Makefile.am deleted file mode 100644 index c0e6f09..0000000 --- a/server/getdata/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -bin_PROGRAMS = getdata convertdata - -getdata_LDADD = $(LD_EFENCE) $(PQXX_LIBS) $(CONFIG_LIBS) - -getdata_CXXFLAGS = $(PQXX_CXXFLAGS) $(CONFIG_CXXFLAGS) - -getdata_SOURCES = \ - getdata.cc - -convertdata_LDADD = $(LD_EFENCE) $(PQXX_LIBS) $(CONFIG_LIBS) - -convertdata_CXXFLAGS = $(PQXX_CXXFLAGS) $(CONFIG_CXXFLAGS) - -convertdata_SOURCES = \ - convertdata.cc - -EXTRA_DIST = - -################ -# Test Section # -################ - -TEST_SOURCE_DEPS = ${pracrod_SOURCES} ${EXTRA_DIST} -TEST_SCRIPT_DIR = $(top_srcdir)/../tools - -include ${TEST_SCRIPT_DIR}/Makefile.am.test - -include Makefile.am.test
\ No newline at end of file diff --git a/server/getdata/getdata.cc b/server/getdata/getdata.cc deleted file mode 100644 index 717d1a9..0000000 --- a/server/getdata/getdata.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ -/*************************************************************************** - * getdata.cc - * - * Tue Jan 18 08:11:53 CET 2011 - * Copyright 2011 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro 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 2 of the License, or - * (at your option) any later version. - * - * Pracro 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 Pracro; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include <string> -#include <pqxx/pqxx> -#include <stdlib.h> -/* -Commits: - patientid | template | version | timestamp | uid | status - -Transactions: - macro | version | timestamp | user | uid | cid - -Fields: - transaction | name | value -*/ - -#define SEP "\t" - -std::string escape(std::string str) -{ - std::string out = "\""; - std::string::iterator i = str.begin(); - while(i != str.end()) { - if(*i == '\"') out += "''"; - else out += *i; - i++; - } - out += "\""; - return out; -} - -int main() -{ - std::vector<std::string> fields; - fields.push_back("visus.egen_korr.mangler.odxt"); - fields.push_back("visus.egen_korr.kontrast.odxt"); - fields.push_back("visus.egen_korr.snellen.odxt"); - fields.push_back("visus.egen_korr.etdrs.odxt"); - fields.push_back("visus.egen_korr.korr.sf.odxt"); - fields.push_back("visus.egen_korr.korr.cyl.odxt"); - fields.push_back("visus.egen_korr.korr.grader.odxt"); - fields.push_back("visus.egen_korr.st_hul.odxt"); - fields.push_back("visus.egen_korr.st_hul.snellen.odxt"); - fields.push_back("visus.egen_korr.st_hul.etdrs.odxt"); - fields.push_back("visus.egen_korr.mangler.osin"); - fields.push_back("visus.egen_korr.kontrast.osin"); - fields.push_back("visus.egen_korr.snellen.osin"); - fields.push_back("visus.egen_korr.etdrs.osin"); - fields.push_back("visus.egen_korr.korr.sf.osin"); - fields.push_back("visus.egen_korr.korr.cyl.osin"); - fields.push_back("visus.egen_korr.korr.grader.osin"); - fields.push_back("visus.egen_korr.st_hul.osin"); - fields.push_back("visus.egen_korr.st_hul.snellen.osin"); - fields.push_back("visus.egen_korr.st_hul.etdrs.osin"); - fields.push_back("visus.egen_korr.ou"); - fields.push_back("visus.egen_korr.kontrast.ou"); - fields.push_back("visus.egen_korr.snellen.ou"); - fields.push_back("visus.egen_korr.etdrs.ou"); - - std::string like = "ref"; - - std::string host = "localhost"; - std::string port = "5432"; - std::string user = "pracro"; - std::string password = "pracro"; - std::string dbname = "pracro"; - - std::string cs = "host="+host+" port="+port+ - " user="+user+" password="+password+" dbname="+dbname; - - pqxx::connection conn(cs); - pqxx::work W(conn); - - - - std::map<std::string, int> fieldnames; - int idx = 0; - pqxx::result Rf = W.exec("SELECT DISTINCT name FROM fields ORDER BY name;"); - pqxx::result::const_iterator rfi = Rf.begin(); - for(unsigned int r = 0; r < Rf.size(); r++) { - pqxx::result::tuple tuple = Rf.at(r); - std::string name = tuple.at(0).c_str(); - fieldnames[name] = idx; - idx++; - } - - printf("patientid"SEP); - printf("template"SEP); - printf("macro"SEP); - printf("version"SEP); - printf("timestamp"SEP); - printf("user"SEP); - printf("uid"SEP); - std::map<std::string, int>::iterator i = fieldnames.begin(); - while(i != fieldnames.end()) { - printf("%s"SEP, i->first.c_str()); - i++; - } - printf("\n"); - - pqxx::result R = W.exec("SELECT * FROM transactions WHERE template LIKE '"+like+"%';"); - - pqxx::result::const_iterator ri = R.begin(); - for(unsigned int r = 0; r < R.size(); r++) { - - pqxx::result::tuple tuple = R.at(r); - - std::string patientid = tuple.at(PATIENTID).c_str(); - std::string macro = tuple.at(MACRO).c_str(); - std::string version = tuple.at(VERSION).c_str(); - std::string timestamp = tuple.at(TIMESTAMP).c_str(); - std::string user = tuple.at(USER).c_str(); - std::string uid = tuple.at(UID).c_str(); - std::string templ = tuple.at(TEMPLATE).c_str(); - - pqxx::result Rf = W.exec("SELECT * FROM fields WHERE transaction="+uid+";"); - - std::vector<std::string> values; - values.insert(values.begin(), fieldnames.size(), ""); - pqxx::result::const_iterator rfi = Rf.begin(); - for(unsigned int r = 0; r < Rf.size(); r++) { - pqxx::result::tuple tuple = Rf.at(r); - - std::string name = tuple.at(NAME).c_str(); - std::string value = tuple.at(VALUE).c_str(); - values[fieldnames[name]] = value; - } - - printf("%s"SEP, escape(patientid).c_str()); - printf("%s"SEP, escape(templ).c_str()); - printf("%s"SEP, escape(macro).c_str()); - printf("%s"SEP, escape(version).c_str()); - time_t t = atol(timestamp.c_str()); - printf("%s"SEP, escape(ctime(&t)).c_str()); - printf("%s"SEP, escape(user).c_str()); - printf("%s"SEP, escape(uid).c_str()); - std::vector<std::string>::iterator vi = values.begin(); - while(vi != values.end()) { - printf("%s"SEP, escape(*vi).c_str()); - vi++; - } - printf("\n"); - - } - - return 0; -} - - - - - - - -#ifdef TEST_GETDATA -//deps: -//cflags: -//libs: -#include "test.h" - -TEST_BEGIN; - -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_GETDATA*/ |