+ for (int level = parent->GetLevel()+1;
+ level < GetTree().GetNumberOfLevels();
+ level++)
+ {
+ // Create Node
+ tree::Node* child = new tree::Node(parent,attr);
+
+ // Set PARENT_ID if necessary
+ if ( parent->GetLevel()>0 )
+ child->SetAttribute("PARENT_ID",parent->GetAttribute("ID"));
+
+ // Insert in DB
+ DBInsert(child);
+ /*
+ std::string val;
+ SQLAppendAttributesValues(child,val);
+ std::string insert("INSERT INTO ");
+ insert += GetTree().GetLevelDescriptor(child->GetLevel()).GetName();
+ insert += " " + val + ";";
+ UPDATEDB(insert);
+
+ // Store DB id of newly created node;
+ long lastrow = mDB->lastRowId();
+ std::stringstream ri;
+ ri << mDB->lastRowId();
+ child->SetAttribute("ID",ri.str());
+ */
+ // Down one level
+ parent = child;
+
+ /*
+ // Insert in TypeId map
+ TypeId ti;
+ ti.type = node->GetType();
+ ti.id = node_id;
+ mTypeIdToNodeMap[ti] = node;
+ // std::cout << "== Insert TypeId ("<<ti.type<<","<<ti.id<<")"<<std::endl;
+ //
+ msw[2].Pause();
+
+ if (node->GetType()==Node::Patient) summary.added_patients++;
+ if (node->GetType()==Node::Study) summary.added_studies++;
+ if (node->GetType()==Node::Series) summary.added_series++;
+ if (node->GetType()==Node::Image) summary.added_images++;
+ */
+ }
+ }
+ //======================================================================
+
+
+ //=====================================================================
+ /// Sets an attribute of a Node
+ bool SQLiteTreeHandler::DBSetAttribute(tree::Node* n,
+ const std::string& key,
+ const std::string& value)
+ {
+ GimmickMessage(3,"Setting Attribute of '"<<n->GetLabel()<<
+ "' "<<key<<"='"<<value<<"'"<<std::endl);
+
+ n->SetAttribute(key,value);
+ std::string sql = "UPDATE ";
+ sql += GetTree().GetLevelDescriptor(n->GetLevel()).GetName();
+ sql += " SET ";
+ sql += key;
+ sql += "='";
+ sql += value;
+ sql += "' WHERE ID=";
+ sql += n->GetAttribute("ID");
+ // sql += " LIMIT 1";
+ UPDATEDB(sql);
+ }
+ //=====================================================================