query<<"DELETE FROM "<<levelDescriptor<<" WHERE "<<key<<"='"<<value<<"';";
UPDATEDB(query.str());
- GimmickMessage(1," Deleting: Query: "<<query.str()<<std::endl);
+ GimmickDebugMessage(2," Deleting: Query: "<<query.str()<<std::endl);
}
return nb;
}
+ //=====================================================================
+ void SQLiteTreeHandler::GetTopLevelNodeId(const std::string& searchParam, const std::string& searchValue, std::string& parent_id)
+ {
+ int level=GetTree().GetNumberOfLevels()-1;
+ std::string sp=searchParam.c_str();
+ std::string sv=searchValue.c_str();
+
+ while(level>1)
+ {
+ std::stringstream out;
+ std::stringstream results;
+ out<<"SELECT PARENT_ID FROM "<<GetTree().GetLevelDescriptor(level).GetName();
+ out<<" WHERE "<<sp<<"='"<<sv<<"'";
+ CppSQLite3Query q;
+ QUERYDB(out.str(),q);
+
+
+ while (!q.eof())
+ {
+ for (int fld = 0; fld < q.numFields(); fld++)
+ {
+ results<<q.getStringField(fld);
+ }
+ q.nextRow();
+ }
+ level=level-1;
+ sp="ID";
+ sv=results.str();
+ }
+ parent_id=sv;
+
+ }
+
/*
//=====================================================================
bool SQLiteTreeHandler::DBInsert(Node* alien_node,
// WITHOUT altering the source, e.g. the database
virtual void UnLoad(tree::Node* n);
///====================================================================
-
+
+ //====================================================================
+ /// Returns the top level node id for the given search param and search value
+ virtual void GetTopLevelNodeId(const std::string& searchParam,
+ const std::string& searchValue,
+ std::string& parent_id);
+ ///====================================================================
//====================================================================
// WRITE METHODS : WORK ONLY IN WRITE MODE
command += ",\nPATH text";
command += ",\nLastModified datetext";
command += ",\nLastRead datetext";
+ command += ",\nTopLevelNodeId text";
command += ",\nconstraint FK_PARENT foreign key (PARENT_ID) references ";
command += "FILES";
command += "(ID) on delete restrict on update restrict";
const std::string& searchParam,
const std::string& searchValue)
{
+ std::string av=attValue.c_str();
+ std::string sv=searchValue.c_str();
+ CleanName(av);
+ CleanName(sv);
+
std::string sql = "UPDATE FILES SET ";
sql += attName;
sql += " = '";
- sql += attValue;
+ sql += av;
sql += "' WHERE ";
sql += searchParam;
sql += " = '";
- sql += searchValue;
+ sql += sv;
sql += "'";
UPDATETIMESTAMPDB(sql);
}
{
RemoveFile(searchAtt,node->GetAttribute("FullFileName"));
}
+ else
+ {
+ DBRemove("TopLevelNodeId",node->GetAttribute("ID"));
+ }
}
virtual void UnLoad(tree::Node* n) { return; }
//====================================================================
+ //====================================================================
+ /// Returns the top level node id for the given search param and search value
+ virtual void GetTopLevelNodeId(const std::string& searchParam,
+ const std::string& searchValue,
+ std::string& parent_id){ return; }
+ ///====================================================================
+
//====================================================================
// WRITE METHODS : WORK ONLY IN WRITE MODE
std::vector<std::string>::const_iterator i;
for (i=filenames.begin();i!=filenames.end();++i)
{
-
+ mTimestampHandler->AddFile((*i), fs::last_write_time(*i), time(0));
mProgress.IncNumberScannedFiles();
if (IsHandledFile(*i))
{
}
else
{
+ std::string parent_id;
bool valid=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0));
if(valid)
{
{
mProgress.IncNumberHandledFiles();
AddFile( itr->string() );
+ mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
+ mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",itr->string());
}
mProgressSignal(mProgress);
if (mProgress.GetStop())
break;
}
}
+ mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",dirpath);
}
}