//Puts images
std::vector<vtkImageData*> images;
w.GetSelectedImages(images,output_dim);
+ std::cout<<images.size()<<std::endl;
crea::VtkBasicSlicer(images.front());
images.front()->Delete();
("print,p","Prints the local database tree (default=off)")
("file,f",po::value< vector<string> >(),"Adds the file to the local database")
("dir,d",po::value< vector<string> >(),"Adds the directory to the local database")
- ("sync,s","Synchronizes the local database with the files")
+ ("sync,s",po::value< vector<string> >(),"Synchronizes the local database with the files")
("recurse,r","Recurse into sub-directories (default=off)")
("repair,R","Repair the database (on synchronization) (default=off)")
("check,c","Check for attribute differences (on synchronization) (default=off)");
if (vm.count("sync")) {
bool rep=false;
bool chk=false;
+ std::vector<std::string> name=vm["sync"].as< vector<string> >();
std::stringstream out;
out<<vm.count("repair");
if(out.str().compare("1")==0){rep=true;}
std::stringstream out2;
out2<<vm.count("check");
if(out2.str().compare("1")==0){chk=true;}
- cout<<g.Synchronize(rep,chk)<<"\n";
+ cout<<g.Synchronize(name.front(),rep,chk)<<"\n";
}
g.Finalize();
}
{
GimmickMessage(2,"Adding files to '"<<d<<"'"<<std::endl);
+ mImageAdder.SetCurrentDatabase(d);
mImageAdder.SetTreeHandler(GetTreeHandler(d));
mImageAdder.SetTimestampHandler(mTimestampDatabase);
mImageAdder.SetSynchronizer(mSynchronizer);
<<recurse<<std::endl);
TreeHandler * handler=GetTreeHandler(d);
+ mImageAdder.SetCurrentDatabase(d);
mImageAdder.SetTreeHandler(handler);
mImageAdder.SetTimestampHandler(mTimestampDatabase);
mImageAdder.SetSynchronizer(mSynchronizer);
void Gimmick::RemoveFile(const std::string& d,
tree::Node* node)
{
+ mImageAdder.SetCurrentDatabase(d);
mImageAdder.SetSynchronizer(mSynchronizer);
- mTimestampDatabase->RemoveNode("PATH",node);
+ mTimestampDatabase->RemoveNode("PATH",node,d);
mImageAdder.RemoveFile(node);
}
//========================================================================
//========================================================================
- std::string Gimmick::Synchronize(bool repair, bool checkAttributes)
+ std::string Gimmick::Synchronize(const std::string& d, bool repair, bool checkAttributes)
{
- TreeHandler * handler=GetTreeHandler("Local database");
+ TreeHandler * handler=GetTreeHandler(d);
+ mImageAdder.SetCurrentDatabase(d);
mImageAdder.SetTreeHandler(handler);
mImageAdder.SetTimestampHandler(mTimestampDatabase);
mImageAdder.SetSynchronizer(mSynchronizer);
void RemoveFile(const std::string& d,
tree::Node* filename);
- ///Synchronizes the loaded data with the database. If remove is true the database will be updated, otherwise
+ ///Synchronizes the loaded data with the database d. If repair is true the database will be updated, otherwise
///only a warning sign will be issued
- std::string Synchronize(bool repair, bool checkAttributes);
+ std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
/// Prints the tree handled by the handler
void Print(const std::string& handler);
}
}
// get the ADD operations List
- UpdateAddList();
+ //UpdateAddList(pathDB);
}
//=====================================================================
command += ",\nPATH text";
command += ",\nRECURSIVE boolean";
command += ",\nFILES_ADDED int";
+ command += ",\nREFERENCEDDB text";
command += "\n)";
UPDATESYNCDB(command);
}
//=====================================================================
- void Synchronizer::GetFileList(std::vector<AddList> & list)
+ void Synchronizer::GetFileList(std::vector<AddList> & list, const std::string& refdb)
{
- CleanList();
+ CleanList(refdb);
list=mAddList;
}
}
//=====================================================================
- void Synchronizer::UpdateAddList()
+ void Synchronizer::UpdateAddList(const std::string& refdb)
{
- std::string query = "SELECT * FROM ADD_OPS";
+ std::string query = "SELECT * FROM ADD_OPS WHERE REFERENCEDDB = '"+refdb+"';";
CppSQLite3Query res;
QUERYSYNCDB(query, res);
while (!res.eof())
/////////////////////////////////////////////////////////////////////////////////////////////////
// clean DataBase if an operation has no child anymore
+ // @param refdb: the database segement to clean
// @result : -
/////////////////////////////////////////////////////////////////////////////////////////////////
- void Synchronizer::CleanList()
+ void Synchronizer::CleanList(const std::string& refdb)
{
mAddList.clear();
- UpdateAddList();
+ UpdateAddList(refdb);
std::vector<AddList>::iterator it_add = mAddList.begin();
for(;it_add <mAddList.end(); ++it_add)
{
}
}
mAddList.clear();
- UpdateAddList();
+ UpdateAddList(refdb);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// @param path: the path of the directory that was added
// @param recursive: shows if the action was called recursively or not
// @param nChildren: the number of files affected by the operation
+ // @param refdb: the referenced database
// @result : The operation has been added
/////////////////////////////////////////////////////////////////////////////////////////////////
- void Synchronizer::InsertAddOp(const std::string& path, const std::string& recursive, const std::string& nChildren)
+ void Synchronizer::InsertAddOp(const std::string& path, const std::string& recursive, const std::string& nChildren, const std::string& refdb)
{
std::string insert;
std::string pat=path.c_str();
CleanName(pat);
- insert="INSERT INTO ADD_OPS (PATH,RECURSIVE,FILES_ADDED) VALUES('";
+ insert="INSERT INTO ADD_OPS (PATH,RECURSIVE,FILES_ADDED,REFERENCEDDB) VALUES('";
insert+=pat+"','";
insert+=recursive+"',";
- insert+=nChildren+");";
+ insert+=nChildren+",'";
+ insert+=refdb+"');";
UPDATESYNCDB(insert);
}
// @result : The file has been inserted
/////////////////////////////////////////////////////////////////////////////////////////////////
- void Synchronizer::InsertIgnoreFile(const std::string& addKey, const std::string& path, const std::string& remove, const std::string& time)
+ void Synchronizer::InsertIgnoreFile(const std::string& addKey, const std::string& path, const std::string& remove, const std::string& time, const std::string& refdb )
{
std::string pat=path.c_str();
CleanName(pat);
- std::string id=GetAttribute("ID","IGNORED_FILES","PATH",pat);
+ std::string id=GetAttribute("ID","IGNORED_FILES","PATH",pat,refdb);
if(id.compare("")==0)
{
std::string insert;
else
{
//Gets the add key
- std::string ak=GetAttribute("ADD_KEY","IGNORED_FILES","ID",id);
- //Sets the new add key attribute for the file
- SetAttribute("ADD_KEY","IGNORED_FILES",addKey,"ID", id);
- //Sets the new remove attribute for the file
- SetAttribute("REMOVE","IGNORED_FILES",remove,"ID", id);
- //Sets the new time attribute for the file
- SetAttribute("TIME","IGNORED_FILES",time,"ID", id);
+ std::string ak=GetAttribute("ADD_KEY","IGNORED_FILES","ID",id,refdb);
+ //gets the parent database to check if the file has been added to the current database
+ std::string parentDB=GetAttribute("*","ADD_OPS","ADD_KEY",ak,refdb);
+ //If there is no such entry, add it
+ if(parentDB.compare("")==0)
+ {
+ std::string insert;
+ insert="INSERT INTO IGNORED_FILES (ADD_KEY,PATH,REMOVE,TIME) VALUES('";
+ insert+=addKey+"','";
+ insert+=pat+"','";
+ insert+=remove+"',";
+ insert+=time+");";
+ UPDATESYNCDB(insert);
+ }
+ else
+ {
+ //Sets the new add key attribute for the file
+ SetAttribute("ADD_KEY","IGNORED_FILES",addKey,"ID", id,refdb);
+ //Sets the new remove attribute for the file
+ SetAttribute("REMOVE","IGNORED_FILES",remove,"ID", id,refdb);
+ //Sets the new time attribute for the file
+ SetAttribute("TIME","IGNORED_FILES",time,"ID", id,refdb);
+ }
}
}
std::string Synchronizer::GetAttribute(const std::string& attribute,
const std::string& table,
const std::string& searchParam,
- const std::string& searchValue)
+ const std::string& searchValue,
+ const std::string& refdb)
{
std::stringstream query;
std::string result;
std::string sVal=searchValue.c_str();
CleanName(sVal);
- query<<"SELECT "<<attribute<<" FROM "<<table<<" WHERE "<<searchParam<<" = '"<<sVal<<"';";
+ query<<"SELECT "<<attribute<<" FROM "<<table<<" WHERE "<<searchParam<<" = '"<<sVal;
+ if(table.compare("ADD_OPS")==0)
+ {
+ query<<"' AND REFERENCEDDB = '"<<refdb<<"';";
+ }
+ else
+ {
+ query<<"';";
+ }
CppSQLite3Query res;
QUERYSYNCDB(query.str(), res);
while (!res.eof())
const std::string& table,
const std::string& value,
const std::string& searchParam,
- const std::string& searchValue)
+ const std::string& searchValue,
+ const std::string& refdb)
{
std::string val=value.c_str();
std::string sVal=searchValue.c_str();
sql += searchParam;
sql += " = '";
sql += sVal;
- sql += "'";
+ if(table.compare("ADD_OPS")==0)
+ {
+ sql += "' AND REFERENCEDDB = '";
+ sql += refdb;
+ }
+ sql += "';";
UPDATESYNCDB(sql);
}
}
\ No newline at end of file
void Initialize();
void InsertAddOp(const std::string& path,
const std::string& recursive,
- const std::string& nChildren);
+ const std::string& nChildren,
+ const std::string& refdb);
void InsertIgnoreFile(const std::string& addKey,
const std::string& path,
const std::string& remove,
- const std::string& time);
+ const std::string& time,
+ const std::string& refdb);
void RemoveEntry(const std::string i_table, const std::string i_key);
- void GetFileList(std::vector<AddList>& files);
+ void GetFileList(std::vector<AddList>& files , const std::string& refdb);
void GetIgnoredFiles(const std::string& key, std::vector<std::string> &ignoreList);
std::string GetAttribute(const std::string& attribute,
const std::string& table,
const std::string& searchParam,
- const std::string& searchValue);
+ const std::string& searchValue,
+ const std::string& refdb);
void SetAttribute(const std::string& attribute,
const std::string& table,
const std::string& value,
const std::string& searchParam,
- const std::string& searchValue);
+ const std::string& searchValue,
+ const std::string& refdb);
std::vector<AddList> mAddList;
std::vector<RemoveList> mIgnoreList;
private :
CppSQLite3DB* mDB;
std::string pathDB;
void CreateDB();
- void UpdateAddList();
- void CleanList();
+ void UpdateAddList(const std::string& refdb);
+ void CleanList(const std::string& refdb);
void CleanName(std::string& str) const;
std::vector<std::string> GetIgnoreList(const std::string &i_key);
command += ",\nLastModified datetext";
command += ",\nLastRead datetext";
command += ",\nTopLevelNodeId text";
+ command += ",\nReferencedDB text";
command += ",\nconstraint FK_PARENT foreign key (PARENT_ID) references ";
command += "FILES";
command += "(ID) on delete restrict on update restrict";
//=====================================================================
- void TimestampDatabaseHandler::CleanName(std::string& str) const
+ void TimestampDatabaseHandler::CleanPath(std::string& str) const
{
size_t pos;
do
}
while ((int)pos!=-1);
}
-
-
//=====================================================================
bool TimestampDatabaseHandler::AddDirectory(const std::string& parent,
const std::string& path,
const time_t lastModif,
- const time_t lastRead)
+ const time_t lastRead,
+ const std::string& refdb)
{
bool valid=false;
std::string par=parent.c_str();
std::string pat=path.c_str();
- CleanName(par);
- CleanName(pat);
+ CleanPath(par);
+ CleanPath(pat);
- std::string pathId=IsIndexed(pat);
+ std::string pathId=IsIndexed(pat,refdb);
//Case: It is a root parent
if(parent.compare("")==0)
{
if(pathId.compare("")==0)
{
- AddFile(pat,lastModif,lastRead);
+ AddFile(pat,lastModif,lastRead,refdb);
valid=true;
}
else
{
- valid=CheckTimestamp(pathId, lastModif);
+ valid=CheckTimestamp(pathId, lastModif, refdb);
}
}
else
{
- std::string parentId=IsIndexed(par);
+ std::string parentId=IsIndexed(par,refdb);
//Case: Parent is not in database
if(parentId.compare("")==0)
{
- AddFile(par,lastModif,lastRead);
- parentId=IsIndexed(par);
+ AddFile(par,lastModif,lastRead,refdb);
+ parentId=IsIndexed(par,refdb);
}
//Case path is not in database
if(pathId.compare("")==0)
{
- AddFile(parentId,pat,lastModif,lastRead);
+ AddFile(parentId,pat,lastModif,lastRead,refdb);
valid=true;
}
//Parent and path are in the database
else
{
SetAttribute("PARENT_ID",parentId,"ID", pathId);
- valid=CheckTimestamp(pathId, lastModif);
+ valid=CheckTimestamp(pathId, lastModif, refdb);
}
}
return valid;
//=====================================================================
- void TimestampDatabaseHandler::AddFile(const std::string& path, const time_t lastModif, const time_t lastRead)
+ void TimestampDatabaseHandler::AddFile(const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb)
{
std::stringstream out;
- out<<"INSERT INTO FILES (PARENT_ID,PATH,LastModified,LastRead) VALUES(0,'"<<path<<"',";
- out<<lastModif<<","<<lastRead<<");";
+ out<<"INSERT INTO FILES (PARENT_ID,PATH,LastModified,LastRead,ReferencedDB) VALUES(0,'"<<path<<"',";
+ out<<lastModif<<","<<lastRead<<",'"<<refdb<<"');";
UPDATETIMESTAMPDB(out.str());
}
void TimestampDatabaseHandler::AddFile(const std::string& parentId,
const std::string& path,
const time_t lastModif,
- const time_t lastRead)
+ const time_t lastRead,
+ const std::string& refdb)
{
std::stringstream out;
- out<<"INSERT INTO FILES (PARENT_ID,PATH,LastModified,LastRead) VALUES("<<parentId<<",'"<<path<<"',";
- out<<lastModif<<","<<lastRead<<");";
+ out<<"INSERT INTO FILES (PARENT_ID,PATH,LastModified,LastRead,ReferencedDB) VALUES("<<parentId<<",'"<<path<<"',";
+ out<<lastModif<<","<<lastRead<<",'"<<refdb<<"');";
UPDATETIMESTAMPDB(out.str());
}
//=====================================================================
- std::string TimestampDatabaseHandler::IsIndexed(const std::string& path)
+ std::string TimestampDatabaseHandler::IsIndexed(const std::string& path, const std::string& refdb)
{
std::stringstream out;
std::stringstream result;
- out<<"SELECT ID FROM FILES WHERE PATH='"<<path<<"'";
+ out<<"SELECT ID FROM FILES WHERE PATH='"<<path<<"' AND REFERENCEDDB='"<<refdb<<"';";
CppSQLite3Query q;
QUERYTIMESTAMPDB(out.str(),q);
{
std::string av=attValue.c_str();
std::string sv=searchValue.c_str();
- CleanName(av);
- CleanName(sv);
+ CleanPath(av);
+ CleanPath(sv);
std::string sql = "UPDATE FILES SET ";
sql += attName;
}
//=====================================================================
- void TimestampDatabaseHandler::RemoveNode(const std::string& searchAtt, const tree::Node* node)
+ void TimestampDatabaseHandler::RemoveNode(const std::string& searchAtt, const tree::Node* node, const std::string& refdb)
{
int n=node->GetNumberOfChildren();
if(n>0)
std::vector<tree::Node*>::iterator it;
for(it=children.begin();it!=children.end();++it)
{
- RemoveNode(searchAtt,(*it));
+ RemoveNode(searchAtt,(*it),refdb);
}
}
else if(node->GetLevel()==3)
{
- RemoveFile(searchAtt,node->GetAttribute("FullFileName"));
+ RemoveFile(searchAtt,node->GetAttribute("FullFileName"),refdb);
}
else
{
- DBRemove("TopLevelNodeId",node->GetAttribute("ID"));
+ DBRemove("TopLevelNodeId",node->GetAttribute("ID"),refdb);
}
}
//=====================================================================
- void TimestampDatabaseHandler::RemoveFile(const std::string& searchAtt, const std::string& searchVal)
+ void TimestampDatabaseHandler::RemoveFile(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb )
{
std::stringstream result;
- std::string sel="SELECT PARENT_ID FROM FILES WHERE "+searchAtt+"='"+searchVal+"'";
+ std::string sel="SELECT PARENT_ID FROM FILES WHERE "+searchAtt+"='"+searchVal+"' AND REFERENCEDDB='"+refdb+"';";
CppSQLite3Query q;
QUERYTIMESTAMPDB(sel,q);
}
q.nextRow();
}
- DBRemove(searchAtt,searchVal);
+ DBRemove(searchAtt,searchVal,refdb);
int nChildren=0;
sel="SELECT ID FROM FILES WHERE PARENT_ID='"+result.str()+"'";
{
if(!result.str().compare("0"))
{
- RemoveFile("ID",result.str());
+ RemoveFile("ID",result.str(),refdb);
}
else
{
- DBRemove("ID",result.str());
+ DBRemove("ID",result.str(),refdb);
}
}
}
//=====================================================================
- void TimestampDatabaseHandler::DBRemove(const std::string& searchAtt, const std::string& searchVal)
+ void TimestampDatabaseHandler::DBRemove(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb)
{
- std::string query = "DELETE FROM FILES WHERE "+searchAtt+"='"+ searchVal + "';";
+ std::string query = "DELETE FROM FILES WHERE "+searchAtt+"='"+ searchVal + "' AND REFERENCEDDB='"+refdb+"';";
UPDATETIMESTAMPDB(query);
}
//=====================================================================
- bool TimestampDatabaseHandler::CheckTimestamp(const std::string pathId, const time_t lastModif)
+ bool TimestampDatabaseHandler::CheckTimestamp(const std::string pathId, const time_t lastModif, const std::string& refdb)
{
- std::string sel="SELECT LastModified FROM FILES WHERE ID='"+pathId+"';";
+ std::string sel="SELECT LastModified FROM FILES WHERE ID='"+pathId+"' AND REFERENCEDDB='"+refdb+"';";
CppSQLite3Query q;
QUERYTIMESTAMPDB(sel,q);
double timestamp;
//====================================================================
//====================================================================
///Returns the id of the path if it's indexed, blank otherwise
- std::string IsIndexed(const std::string& path);
+ std::string IsIndexed(const std::string& path, const std::string& refdb);
///Sets the current path's parent
bool AddDirectory(const std::string& parent,
const std::string& path,
const time_t lastModif,
- const time_t lastRead);
+ const time_t lastRead,
+ const std::string& refdb);
///Adds a new file to the database without a parent
- void AddFile(const std::string& path, const time_t lastModif, const time_t lastRead);
+ void AddFile(const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
///Adds a new file to the database with a parent
- void AddFile(const std::string& parentId,const std::string& path, const time_t lastModif, const time_t lastRead);
+ void AddFile(const std::string& parentId,const std::string& path, const time_t lastModif, const time_t lastRead, const std::string& refdb);
///Sets the attribute to the value passed as parameter where the searchParameter is searchValue
void SetAttribute(const std::string& attName,
const std::string& attValue,
const std::string& searchParam,
const std::string& searchValue);
///Removes the given node
- void RemoveNode(const std::string& searchAtt, const tree::Node* node);
+ void RemoveNode(const std::string& searchAtt, const tree::Node* node, const std::string& refdb);
///Removes the filename with the given pathname
- void RemoveFile(const std::string& searchAtt, const std::string& searchVal);
+ void RemoveFile(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
///Cleans the path name
- void CleanName(std::string& str) const;
+ void CleanPath(std::string& str) const;
///Checks the timestamp in the database and compares it with the given one.
//If there is a difference, it will return false, otherwise it will return true.
- bool CheckTimestamp(const std::string pathId, const time_t lastModif);
+ bool CheckTimestamp(const std::string pathId, const time_t lastModif, const std::string& refdb);
//====================================================================
//======================================================================
//======================================================================
// Removes a file from the database
- void DBRemove(const std::string& searchAtt, const std::string& searchVal);
+ void DBRemove(const std::string& searchAtt, const std::string& searchVal, const std::string& refdb);
private:
/// The DB
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));
+ mTimestampHandler->AddFile((*i), fs::last_write_time(*i), time(0),mCurrentDB);
mProgress.IncNumberScannedFiles();
if (IsHandledFile(*i))
{
mProgress.IncNumberHandledFiles();
- mSynchronizer->InsertAddOp((*i),"0","1");
- std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",(*i));
+ mSynchronizer->InsertAddOp((*i),"0","1",mCurrentDB);
+ std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",(*i),mCurrentDB);
std::stringstream removedOn;
removedOn<<time(0);
- mSynchronizer->InsertIgnoreFile(addKey,(*i),"0",removedOn.str());
+ mSynchronizer->InsertIgnoreFile(addKey,(*i),"0",removedOn.str(),mCurrentDB);
AddFile(*i);
}
mProgressSignal(mProgress);
std::stringstream rec;
rec<<recurse;
- mSynchronizer->InsertAddOp(directory,rec.str(),"0");
- std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory);
+ mSynchronizer->InsertAddOp(directory,rec.str(),"0",mCurrentDB);
+ std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory,mCurrentDB);
AddDirectoryRecursor( directory, recurse, addKey );
int nFiles=GetProgress().GetNumberAddedFiles();
files<<nFiles;
- mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",files.str(),"ADD_KEY",addKey);
+ mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",files.str(),"ADD_KEY",addKey,mCurrentDB);
GimmickDebugMessage(3,mProgress<<std::endl);
}
{
std::string path=node->GetAttribute("FullFileName");
//Gets the add key
- std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","IGNORED_FILES","PATH",path);
+ std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","IGNORED_FILES","PATH",path,mCurrentDB);
//Gets the number of files added
- int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",addKey)).c_str());
+ int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",addKey,mCurrentDB)).c_str());
files=files-1;
std::stringstream out;
out<<files;
//Sets the new number of files
- mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",addKey);
+ mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",addKey,mCurrentDB);
//Sets the file as removed
- mSynchronizer->SetAttribute("REMOVE","IGNORED_FILES","1","PATH",path);
+ mSynchronizer->SetAttribute("REMOVE","IGNORED_FILES","1","PATH = '"+path+"' AND ADD_KEY",addKey,mCurrentDB);
}
}
{
std::string path=(*it)->GetAttribute("FullFileName");
//Gets the add key
- std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","IGNORED_FILES","PATH",path);
+ std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","IGNORED_FILES","PATH",path,mCurrentDB);
//Gets the number of files added
- int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",addKey)).c_str());
+ int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",addKey,mCurrentDB)).c_str());
files=files-1;
std::stringstream out;
out<<files;
//Sets the new number of files
- mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",addKey);
+ mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",addKey,mCurrentDB);
//Sets the file as removed
- mSynchronizer->SetAttribute("REMOVE","IGNORED_FILES","1","PATH",path);
+ mSynchronizer->SetAttribute("REMOVE","IGNORED_FILES","1","PATH = '"+path+"' AND ADD_KEY",addKey,mCurrentDB);
}
}
else
{
std::string parent_id;
- bool valid=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0));
+ bool valid=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0),mCurrentDB);
if(valid)
{
mProgress.IncNumberScannedFiles();
mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",itr->string());
std::stringstream removedOn;
removedOn<<time(0);
- mSynchronizer->InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str());
+ mSynchronizer->InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str(),mCurrentDB);
}
mProgressSignal(mProgress);
if (mProgress.GetStop())
std::vector<AddList>::iterator iter;
//Gets the list of added files
- mSynchronizer->GetFileList(fileList);
+ mSynchronizer->GetFileList(fileList,mCurrentDB);
std::vector<std::string>::iterator i;
//Actions to take if the user doesn't want to repair
//For the new files, add them
for (i=newFiles.begin();i!=newFiles.end();++i)
{
- mTimestampHandler->AddFile((*i), fs::last_write_time(*i), time(0));
+ mTimestampHandler->AddFile((*i), fs::last_write_time(*i), time(0),mCurrentDB);
if (IsHandledFile(*i))
{
std::stringstream removedOn;
removedOn<<time(0);
- mSynchronizer->InsertIgnoreFile((*iter).key,(*i),"0",removedOn.str());
+ mSynchronizer->InsertIgnoreFile((*iter).key,(*i),"0",removedOn.str(),mCurrentDB);
//Gets the number of files added
- int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",(*iter).key)).c_str());
+ int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",(*iter).key,mCurrentDB)).c_str());
files=files+1;
std::stringstream out;
out<<files;
//Sets the new number of files
- mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",(*iter).key);
+ mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",(*iter).key,mCurrentDB);
AddFile(*i);
}
}
void SetTimestampHandler(TimestampDatabaseHandler* tdh) { mTimestampHandler = tdh;}
/// Sets the synchronizer
void SetSynchronizer(Synchronizer* s){mSynchronizer=s;}
+ /// Sets the synchronizer
+ void SetCurrentDatabase(std::string cur){mCurrentDB=cur;}
//====================================================================
//====================================================================
TimestampDatabaseHandler* mTimestampHandler;
Synchronizer* mSynchronizer;
ImageReader mReader;
+ std::string mCurrentDB;
Progress mProgress;
ProgressSignalType mProgressSignal;
//=================================================
void WxGimmickView::AddIgnoreFile(tree::Node* toRemove)
{
- mGimmick->RemoveFile("Local database",toRemove);
- GetTreeViewMap()["Local database"]->UpdateLevel(1);
+ mGimmick->RemoveFile(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),toRemove);
+ GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->UpdateLevel(1);
}
//=================================================
bool checkAttributes=false;
if(sel==2 || sel==3){repair=true;}
if(sel==1 || sel==3){checkAttributes=true;}
- std::string mess=mGimmick->Synchronize(repair, checkAttributes);
+ std::string mess=mGimmick->Synchronize(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),repair, checkAttributes);
wxMessageBox(std2wx(mess),_T("Synchronization result"),wxOK,this);
- GetTreeViewMap()["Local database"]->UpdateLevel(1);
+ if(sel==2 || sel==3){
+ GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->UpdateLevel(1);
+ }
}
}