X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOSynchron.cpp;h=74e9e98ced8fc532e9c0843a593098db249dce02;hb=e88bcb692a9d4bcc2ce1618a27d4fcb275a32a70;hp=9ec4bae4d3fcf4b7b68469d0f88debe0158c16ec;hpb=7ae1412df3d682f639683e751f46a3f07be16d0b;p=creaImageIO.git diff --git a/src2/creaImageIOSynchron.cpp b/src2/creaImageIOSynchron.cpp index 9ec4bae..74e9e98 100644 --- a/src2/creaImageIOSynchron.cpp +++ b/src2/creaImageIOSynchron.cpp @@ -11,7 +11,7 @@ namespace creaImageIO { //===================================================================== - #define QUERYSYNCDB(QUER,RES) \ + #define QUERYSYNCDB(QUER,RES) \ try \ { \ RES = mDB->execQuery(QUER.c_str()); \ @@ -23,7 +23,7 @@ namespace creaImageIO << e.errorMessage() ); \ } //===================================================================== - #define UPDATESYNCDB(UP) \ + #define UPDATESYNCDB(UP) \ try \ { \ mDB->execDML(UP.c_str()); \ @@ -72,7 +72,7 @@ namespace creaImageIO } } // get the ADD operations List - UpdateAddList(); + //UpdateAddList(pathDB); } //===================================================================== @@ -87,6 +87,7 @@ namespace creaImageIO command += ",\nPATH text"; command += ",\nRECURSIVE boolean"; command += ",\nFILES_ADDED int"; + command += ",\nREFERENCEDDB text"; command += "\n)"; UPDATESYNCDB(command); @@ -117,9 +118,9 @@ namespace creaImageIO } //===================================================================== - void Synchronizer::GetFileList(std::vector & list) + void Synchronizer::GetFileList(std::vector & list, const std::string& refdb) { - CleanList(); + CleanList(refdb); list=mAddList; } @@ -130,9 +131,9 @@ namespace creaImageIO } //===================================================================== - void Synchronizer::UpdateAddList() + void Synchronizer::UpdateAddList(const std::string& refdb) { - std::string query = "SELECT * FROM ADD_OPS"; + std::string query = "SELECT * FROM ADD_OPS WHERE REFERENCEDDB = '"+refdb+"';"; CppSQLite3Query res; QUERYSYNCDB(query, res); while (!res.eof()) @@ -145,7 +146,7 @@ namespace creaImageIO ///////////////////////////////////////////////////////////////////////////////////////////////// // remove an entry of the DB - //@param i_table : table where do the remove + //@param i_table : table where to do the remove // @param i_key : the add_key reference (one entry to remove for ADD_OP table, many for IGNORED_FILES table //@result : - ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -155,14 +156,33 @@ namespace creaImageIO UPDATESYNCDB(query); } + ///////////////////////////////////////////////////////////////////////////////////////////////// + // remove several entries of the DB + // @param i_table : table where to do the remove + // @param i_attribute: attribute to match + // @param i_operand : operand to use + // @param i_val : the reference + //@result : - + ///////////////////////////////////////////////////////////////////////////////////////////////// + void Synchronizer::RemoveEntries(const std::string i_table, + const std::string i_attribute, + const std::string i_operand, + const std::string i_val) + { + std::stringstream query; + query<<"DELETE FROM "<::iterator it_add = mAddList.begin(); for(;it_add