- return 0;
- }
- //=====================================================================
-
- //=====================================================================
- std::string SQLiteTreeHandler::DBGetNodeId(Node* node,
- const std::string& parent_id)
- {
- // std::cout << "SQLiteTreeHandler::DBGetNodeId('"<<node->GetLabel()
- // <<"','"<<parent_id<<"')"
- // <<std::endl;
- msw[2].Resume();
- int type = node->GetType();
-
- std::string table = SQLiteTreeHandlerStructure::Table(type);
- std::string where = "WHERE ";
-
- if (type!=Node::Patient)
- {
- where += "PARENT_ID='" + parent_id
- //node->GetFieldValue("PARENT_ID")
- + "' AND ";
- }
-
- for (int i=0;i<SQLiteTreeHandlerStructure::NbQueryFields(type);i++)
- {
- where += SQLiteTreeHandlerStructure::QueryField(type,i).key + "='"
- + node->GetFieldValue(SQLiteTreeHandlerStructure::QueryField(type,i).key) + "' ";
- if (i<SQLiteTreeHandlerStructure::NbQueryFields(type)-1)
- where += "AND ";
- }
-
- std::string query = "SELECT ID FROM " + table + " " + where + ";";
- // std::cout << "** SQL = '"<<query<<"'"<<std::endl;
- CppSQLite3Query q;
- QUERYDB(query,q);
-
- if (!q.eof())
- {
-
- // std::cout << " - Node exists " << std::endl;
- std::string id = q.getStringField(0);
- // std::cout << " id = '"<<id<<"'"<<std::endl;
- msw[2].Pause();
- return id;
- }
- msw[2].Pause();
- return "";
- }
- //=====================================================================
-
-
-
- //=====================================================================
- Node* SQLiteTreeHandler::GetNodeFromTypeId(Node::Type type,
- const std::string& id)
- {
- // std::cout << "GetNodeFromTypeId("<<type<<","<<id<<")"<<std::endl;
-
- TypeId ti;
- ti.type = type;
- ti.id = id;
-
- TypeIdToNodeMapType::iterator i = mTypeIdToNodeMap.find(ti);
- if (i == mTypeIdToNodeMap.end())
- {
-
- std::cout << "Internal error : mTypeIdToNodeMap does not contain key"
- << std::endl;
- creaError("Internal error : mTypeIdToNodeMap does not contain key");
- // }
- }
-
- // std::cout << " ** Node = "<<i->second<<std::endl;
- return i->second;
- }
-
- //=====================================================================
-
- //=====================================================================
- bool SQLiteTreeHandler::Remove(Node* node)
- {
-
- //DBRecursiveRemoveNode(node);
-
- // std::cout << "DELETE"<<std::endl;
- if (node->GetParent())
- {
- node->GetParent()->RemoveChildrenFromList(node);