{
tree::Node* parent = DBGetParent(attr);
DBGraftToParent(parent,attr);
- if(parent->GetLevel()<GetTree().GetNumberOfLevels()-1&&parent->GetLevel()>0)
- {
- int nC=GetNumberOfChildren(parent);
- nC=nC+1;
- std::stringstream out;
- out <<nC;
- SetAttribute(parent,"NumberOfChildren",out.str());
- }
return (parent->GetLevel()+1);
}
{
// Create Node
tree::Node* child = new tree::Node(parent,attr);
- GetNumberOfChildren(parent);
child->SetChildrenLoaded(true);
- // std::cout<<"Number of children "<<parent->GetNumberOfChildren()<<std::endl;
+ if (level>1)
+ {
+ int nc = GetNumberOfChildren(parent)+1;
+
+ // std::cout<<"Number of children "<<parent->GetNumberOfChildren()<<std::endl;
+ std::stringstream out;
+ out << nc;
+ SetAttribute(parent,"NumberOfChildren",out.str());
+ }
// Set PARENT_ID if necessary
if ( parent->GetLevel()>0 )
//=====================================================================
unsigned int SQLiteTreeHandler::GetNumberOfChildren(tree::Node* n)
{
- // Query DB
- int nb=0;
+ // Query DB
+ int nb=0;
int level = n->GetLevel();
-
- if(level<GetTree().GetNumberOfLevels()&& level>0)
- {
- std::string query = "SELECT NumberOfChildren FROM ";
- query += GetTree().GetLevelDescriptor(level).GetName();
- if (level>0)
+
+ if(level<GetTree().GetNumberOfLevels()&& level>0)
{
- query += " WHERE ID='" + n->UnsafeGetAttribute("ID")
- + "'";
- }
- CppSQLite3Query q;
- QUERYDB(query,q);
+ std::string query = "SELECT NumberOfChildren FROM ";
+ query += GetTree().GetLevelDescriptor(level).GetName();
+ if (level>0)
+ {
+ query += " WHERE ID='" + n->UnsafeGetAttribute("ID")
+ + "'";
+ }
+ CppSQLite3Query q;
+ QUERYDB(query,q);
-
- while (!q.eof())
- {
- for (int fld = 0; fld < q.numFields(); fld++)
- {
- nb=q.getIntField(fld);
- }
- q.nextRow();
- }
- }
- if(nb==0){nb=1;}
+
+ while (!q.eof())
+ {
+ for (int fld = 0; fld < q.numFields(); fld++)
+ {
+ nb=q.getIntField(fld);
+ }
+ q.nextRow();
+ }
+ }
+ /*
+ if(nb==0)
+ {
+ nb=1;
+ }
+ */
return nb;
}