]> Creatis software - creaImageIO.git/commitdiff
Export corrections
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Tue, 26 Jan 2010 12:55:27 +0000 (12:55 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Tue, 26 Jan 2010 12:55:27 +0000 (12:55 +0000)
src2/creaImageIOSynchron.cpp
src2/creaImageIOSynchron.h
src2/creaImageIOTreeHandlerImageAdder.cpp

index 3e78951163b0c2659d9c6caff04d154154fe4faa..0955ffaee260161d386f73b4391d220c5e3c314d 100644 (file)
@@ -387,14 +387,41 @@ namespace creaImageIO
     // @param : the add key
     //@result : list (path) of ignore files
     /////////////////////////////////////////////////////////////////////////////////////////////////
-    void Synchronizer::GetList()
+       void Synchronizer::GetList(const std::string i_db)
     {
-       mList.clear();
+               mList.clear();
         std::vector<std::string> i_names;
-       std::string query = "SELECT PATH, REMOVE FROM IGNORED_FILES";
-       CppSQLite3Query res;
+               std::vector<std::string> keys;
+               CppSQLite3Query res;
+               std::string query ="SELECT ADD_KEY, REFERENCEDDB FROM  ADD_OPS";
+               QUERYSYNCDB(query, res);
+               keys.clear();
+               while (!res.eof())
+        {
+                       std::string key(res.getStringField(0));
+                       std::string db(res.getStringField(1));
+                       if (db == i_db)
+                       {
+                               keys.push_back(key);
+                       }
+                       res.nextRow();
+               }
+               query = "SELECT PATH, REMOVE FROM IGNORED_FILES WHERE";
+               if(keys.size() > 0)
+               {
+                       for (int i=0; i < keys.size(); i++)
+                       {
+                               query += " ADD_KEY = " + keys[i];
+                               query += " AND";
+                       }
+                       query = query.substr(0,query.size() - 4);
+               }
+               else 
+               {
+                       query += " ADD_KEY = -1";
+               }
         QUERYSYNCDB(query, res);
-       while (!res.eof())
+               while (!res.eof())
         {
                std::string file(res.getStringField(0));
                std::string ignore(res.getStringField(1));
index fde9f2d21afb090d69978ab69cbe375f54667b97..ab101f6902728a3c545abefc648ef7e71a4916c7 100644 (file)
@@ -103,7 +103,7 @@ namespace creaImageIO
                                                                                const std::string& searchValue, 
                                                                                const std::string& refdb);
                          // Get the List of indexed files (removed or not)
-                         void GetList();
+                         void GetList(const std::string i_db);
                          // Test to not if a file is indexed on db or not
                          bool isIndexed(const std::string filename);
                          // List of all indexed files
index 290da65474741d59812ad591a705f3445e1601e6..9c2d2974702b55b2895a509e36996d8c863e678d 100644 (file)
@@ -48,7 +48,7 @@ namespace creaImageIO
        
     unsigned int nbf = filenames.size(); 
     std::vector<std::string>::const_iterator i;
-       mSynchronizer->GetList();
+       mSynchronizer->GetList(mCurrentDB);
     for (i=filenames.begin();i!=filenames.end();++i)
       {
        
@@ -84,7 +84,7 @@ namespace creaImageIO
        mSynchronizer->InsertAddOp(directory,rec.str(),"0",mCurrentDB);
        std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory,mCurrentDB);
        mTreeHandler->BeginTransaction();
-       mSynchronizer->GetList();
+       mSynchronizer->GetList(mCurrentDB);
        AddDirectoryRecursor( directory, recurse, addKey );
        
        int nFiles=GetProgress().GetNumberAddedFiles();
@@ -101,7 +101,22 @@ namespace creaImageIO
     std::map< std::string, std::string>  attr;
     mTreeHandler->GetTree().GetDescriptor().BuildAttributeMap(attr);
 
+       
     mReader.ReadAttributes(filename,attr);
+       //// TO DO Create a function to test if the SOP Instance ID (0008,0018) is not already on DB
+       //// test befor if this attr is present on DB if not don't perform the test!!!
+       //bool bSOPIID = false;
+       //std::map<std::string, std::string>::iterator it_att = attr.begin();
+       //for(; it_att != attr.end(); it_att++)
+       //{
+       //      if (it_att->first == "D0008_0018")
+       //      {
+       //              bSOPIID = mTreeHandler->TestSOPIID(it_attr->second);
+       //              break;
+       //      }
+       //}
+       //if(bSOPIID)
+       //      return;
 
     int lev = mTreeHandler->AddBranch(attr);