/* # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image # pour la Santé) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton # Previous Authors : Laurent Guigues, Jean-Pierre Roux # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-B # license as circulated by CEA, CNRS and INRIA at the following URL # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # or in the file LICENSE.txt. # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ #include #include #include "CppSQLite3.h" #include #include #include #include namespace creaImageIO { using namespace tree; //============================================================= TimestampDatabaseHandler::TimestampDatabaseHandler(const std::string& filename) : mFileName(filename) { mDB = new CppSQLite3DB; GimmickMessage(1,"SQLite version : " <SQLiteVersion())<< std::endl); } //============================================================= //============================================================= TimestampDatabaseHandler::~TimestampDatabaseHandler() { delete mDB; } //============================================================= //===================================================================== bool TimestampDatabaseHandler::Open() { return DBOpen(); } //===================================================================== bool TimestampDatabaseHandler::Create() { return DBCreate(); } //===================================================================== //===================================================================== bool TimestampDatabaseHandler::Close() { return true; } //===================================================================== //===================================================================== bool TimestampDatabaseHandler::Destroy() { return false; } //===================================================================== // SQLite DB specific methods //===================================================================== //===================================================================== #define QUERYTIMESTAMPDB(QUER,RES) \ try \ { \ GimmickMessage(2,"SQL query: '"<execQuery(QUER.c_str()); \ } \ catch (CppSQLite3Exception& e) \ { \ GimmickError("SQLite query '"<execDML(UP.c_str()); \ } \ catch (CppSQLite3Exception& e) \ { \ GimmickError("SQLite update '"<open(GetFileName().c_str()); } catch (CppSQLite3Exception& e) { GimmickError("Opening '"<open(GetFileName().c_str()); } catch (CppSQLite3Exception& e) { GimmickError(e.errorCode() << ":" << e.errorMessage() <GetNumberOfChildren(); if(n>0) { std::vector children=node->GetChildrenList(); std::vector::iterator it; for(it=children.begin();it!=children.end();++it) { RemoveNode(searchAtt,(*it),refdb); } } else if(node->GetLevel()==3) { RemoveFile(searchAtt,node->GetAttribute("FullFileName"),refdb); } else { DBRemove("TopLevelNodeId",node->GetAttribute("ID"),refdb); } } //===================================================================== void TimestampDatabaseHandler::RemoveFile(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb ) { std::stringstream result; std::string sel="SELECT PARENT_ID FROM FILES WHERE "+searchAtt+"='"+searchVal+"' AND REFERENCEDDB='"+refdb+"';"; CppSQLite3Query q; QUERYTIMESTAMPDB(sel,q); while (!q.eof()) { for (int fld = 0; fld < q.numFields(); fld++) { result<