#include #include #include #include #include #include "JDB/JDB.hh" #include "JDB/JSelector.hh" #include "JDB/JSelectorSupportkit.hh" #include "JDB/JDBToolkit.hh" #include "JDB/JPersons.hh" #include "JDB/JSonSupportkit.hh" #include "JSon/JSon.hh" #include "JSon/JSupport.hh" #include "JLang/JPredicate.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to extract persons from database. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JServer server; string usr; string pwd; string cookie; set filter; int debug; try { JParser<> zap("Auxiliary program to extract persons from database."); zap['s'] = make_field(server) = getServernames(); zap['u'] = make_field(usr) = ""; zap['!'] = make_field(pwd) = ""; zap['C'] = make_field(cookie) = ""; zap['F'] = make_field(filter) = JPARSER::initialised(); zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } try { JDB::reset(usr, pwd, cookie); typedef vector person_typeA; typedef vector person_typeB; person_typeA personA; person_typeB personB; { ResultSet& rs = getResultSet(JPersons::getName()); for (JPersons object; rs >> object; ) { personA.push_back(object); } rs.Close(); } { json js; to_json(js, APIV2::JPerson::getName()); personB = js[Data_t].get(); } for (const auto& person : personA) { if (filter.count(person.OID) == 0) { ASSERT(find_if(personB.begin(), personB.end(), make_predicate(&APIV2::JPerson::OID, person.OID)) != personB.end(), person.OID << ' ' << person.NAME << ' ' << person.SURNAME); } } for (const auto& person : personB) { if (filter.count(person.OID) == 0 && person.Name != "" && person.Name[0] != '~' && person.Name[0] != '-') { ASSERT(find_if(personA.begin(), personA.end(), make_predicate(&JPersons::OID, person.OID)) != personA.end(), person.OID << ' ' << person.Name << ' ' << person.Surname); } } } catch(const exception& error) { FATAL(error.what() << endl); } return 0; }