X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FcreaImageIOSQLiteTreeHandler.cpp;h=478a4be902ed9be5212ca07bf54166c49e2dce97;hb=a2c6ecf8db79b662d0405ee333da837b242b2c59;hp=627db08f7465afd4321302687a5d527d3affee6d;hpb=3a22e19184c369b130d4caa992a8e98e50c7a0ee;p=creaImageIO.git diff --git a/src/creaImageIOSQLiteTreeHandler.cpp b/src/creaImageIOSQLiteTreeHandler.cpp index 627db08..478a4be 100644 --- a/src/creaImageIOSQLiteTreeHandler.cpp +++ b/src/creaImageIOSQLiteTreeHandler.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "CppSQLite3.h" @@ -44,7 +43,8 @@ namespace creaImageIO //===================================================================== bool SQLiteTreeHandler::Open(bool writable) { - // std::cout << "***> SQLiteTreeHandler::Open('"<execDML("PRAGMA synchronous=ON "); if (parent==0) parent = GetTree().GetTree(); return DBLoadChildren(parent,maxlevel); } @@ -239,6 +240,7 @@ namespace creaImageIO try { mDB->open(GetFileName().c_str()); + mDB->execDML("pragma synchronous=off;"); } catch (CppSQLite3Exception& e) { @@ -283,7 +285,7 @@ namespace creaImageIO << e.errorMessage() <execDML("pragma synchronous=off;"); // CREATING TABLES @@ -321,6 +323,7 @@ namespace creaImageIO command += "\n)"; UPDATEDB(command); + GetTree().CopyAttributeDescriptorList(l); // Add Attribute 'ID' to Description GetTree().GetDescriptor().Add @@ -500,6 +503,7 @@ namespace creaImageIO return false; } + GetTree().CopyAttributeDescriptorList(level); } @@ -804,21 +808,10 @@ GimmickDebugMessage(1, "query : '" <GetLevel()).GetName(); - + query += GetTree().GetLevelDescriptor(node->GetLevel()).GetName(); query += " WHERE ID='"+ node->GetAttribute("ID") + "';"; - - UPDATEDB(query); - GimmickDebugMessage(2, - " Deleting '" - <GetLabel()<<"' with ID '" - <GetAttribute("ID") - <<"' in level "<< GetTree().GetLevelDescriptor(node->GetLevel()).GetName() - <GetNumberOfChildren()!=0) { Node::ChildrenListType::iterator i; @@ -954,36 +947,135 @@ GimmickDebugMessage(1, "query : '" < &i_results) { int level=GetTree().GetNumberOfLevels()-1; - std::string sp=searchParam.c_str(); - std::string sv=searchValue.c_str(); + + std::string search = i_filename; + std::string param = "FullFileName"; + std::string name; + + std::string id; + std::set pid; + std::vector attr; + std::vector::iterator it_attr; + std::vector values; + std::vector::iterator it_val; + + + while(level>1) { - std::stringstream out; - std::stringstream results; - out<<"SELECT PARENT_ID FROM "< values; + GetUpLevelNodeId(level, param,search,id); + GetAttributes(name, param,search,attr, values); + for(it_attr = attr.begin(), it_val = values.begin(); it_attr != attr.end(); it_attr++, it_val++) + { + i_results[(*it_attr).GetKey()] = (*it_val).c_str(); + } + search = id; + param = "ID"; + level --; + } + } + + +//===================================================================== +// get selected attributes from database for a given file + void SQLiteTreeHandler::GetAttributes(std::string name, std::string i_id, std::string i_value, tree::LevelDescriptor::AttributeDescriptorListType i_attr, std::vector &i_results) + { + //SELECT t1.ArtistName,CDs.Title FROM Artists t1, CDs WHERE t1.ArtistID=CDs.ArtistID + std::stringstream out; + std::stringstream results; + out<<"SELECT "; + tree::LevelDescriptor::AttributeDescriptorListType::iterator it = i_attr.begin(); + std::string query =""; + for(; it != i_attr.end(); it++) + { + query += (*it).GetKey(); + query +=" ,"; + } + query = query.substr(0, query.size()-1); + out << query; + out << "FROM "<1) + { + GetUpLevelNodeId(level, sp, sv, parent_id); + level--; + sp = "ID"; + sv = parent_id; } - parent_id=sv; +///* +// std::stringstream out; +// std::stringstream results; +// out<<"SELECT PARENT_ID FROM "<