+ UPDATEDB(insert);
+
+ // Store DB id of newly created node;
+ long lastrow = mDB->lastRowId();
+ std::stringstream ri;
+ ri << mDB->lastRowId();
+ n->SetAttribute("ID",ri.str());
+ }
+ //======================================================================
+
+ //======================================================================
+ /// Graft the branch defined by the attributes to the parent
+ void SQLiteTreeHandler::DBGraftToParent( tree::Node* parent,
+ const AttributeMapType& attr)
+ {
+ // std::cout <<"Grafting to parent '"<<parent->GetLabel()
+ // <<"'"<<std::endl;
+
+ for (int level = parent->GetLevel()+1;
+ level < GetTree().GetNumberOfLevels();
+ level++)
+ {
+ // Create Node
+ tree::Node* child = new tree::Node(parent,attr);
+ GetNumberOfChildren(parent);
+ child->SetChildrenLoaded(true);
+ // std::cout<<"Number of children "<<parent->GetNumberOfChildren()<<std::endl;
+
+ // 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++;
+ */
+ }
+ }
+ //======================================================================