]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOTreeHandlerImageAdder.cpp
Added functionality of timestamp and maintenance databases when using multiple sources
[creaImageIO.git] / src2 / creaImageIOTreeHandlerImageAdder.cpp
index 22c727b87d83ae02b21b47dbff5e85d6646baa66..2d6ab3a40f0e6a7960d16d0174dd6d8ad57580a1 100644 (file)
@@ -50,16 +50,16 @@ namespace creaImageIO
     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);
@@ -77,13 +77,13 @@ namespace creaImageIO
        
        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);
   }
 
@@ -115,16 +115,16 @@ namespace creaImageIO
                {
                  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);
                }
   }
 
@@ -144,16 +144,16 @@ namespace creaImageIO
                {
                   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);
                }
        
          }
@@ -186,7 +186,7 @@ namespace creaImageIO
        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();
@@ -198,7 +198,7 @@ namespace creaImageIO
                        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()) 
@@ -279,7 +279,7 @@ namespace creaImageIO
          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
@@ -348,19 +348,19 @@ namespace creaImageIO
                        //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);
                        }
                        }