]> Creatis software - creaImageIO.git/blob - src/creaImageIOTreeHandlerImageAdder.cpp
ce619c3424fd943e928f40ad8c7920f1a09030df
[creaImageIO.git] / src / creaImageIOTreeHandlerImageAdder.cpp
1 #include <creaImageIOTreeHandlerImageAdder.h>
2 #include <creaImageIOSystem.h>
3 #include <boost/filesystem.hpp>
4 #include <boost/algorithm/string.hpp>
5 #include <boost/utility.hpp>
6
7
8 namespace fs = boost::filesystem;
9 using boost::filesystem::path;
10 using boost::next;
11 using boost::prior;
12
13
14 using namespace crea;
15 using namespace boost;
16
17 namespace creaImageIO
18 {
19   //====================================================================
20   // Ctor
21   TreeHandlerImageAdder::TreeHandlerImageAdder(TreeHandler* tree)
22     : mTreeHandler(tree)
23   {
24   }
25   // Dtor
26   TreeHandlerImageAdder::~TreeHandlerImageAdder()
27   {
28   }
29   //====================================================================
30
31   //====================================================================
32   void TreeHandlerImageAdder::ConnectProgressObserver(ProgressCallbackType callback)
33   {
34     mProgressSignal.connect(callback);
35   }
36   //====================================================================
37
38   //=====================================================================
39   bool TreeHandlerImageAdder::IsHandledFile( const std::string& filename)
40   {
41     return (mReader.CanRead(filename));
42   }
43   //=====================================================================
44
45   //=====================================================================
46   void TreeHandlerImageAdder::AddFiles( const std::vector<std::string>& filenames)
47   {
48     mProgress.Reset();
49         
50     unsigned int nbf = filenames.size(); 
51     std::vector<std::string>::const_iterator i;
52         mSynchronizer->GetList(mCurrentDB);
53     for (i=filenames.begin();i!=filenames.end();++i)
54       {
55         
56         mProgress.IncNumberScannedFiles();
57         if (IsHandledFile(*i)) 
58           {
59             mProgress.IncNumberHandledFiles();
60                 if(mSynchronizer->isIndexed(*i))
61                 {
62                         mSynchronizer->InsertAddOp((*i),"0","1",mCurrentDB);
63                         std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",(*i),mCurrentDB);
64                         std::stringstream removedOn;
65                         removedOn<<time(0);
66                         mSynchronizer->InsertIgnoreFile(addKey,(*i),"0",removedOn.str(),mCurrentDB);
67                         AddFile(*i);
68                 }
69           }
70         mProgressSignal(mProgress);
71         if (mProgress.GetStop()) break;
72       }
73   }
74   //=====================================================================
75
76   //=====================================================================
77   void TreeHandlerImageAdder::AddDirectory( const std::string& directory,
78                                             bool recurse)
79   {
80     mProgress.Reset();
81         std::stringstream files;
82         
83         std::stringstream rec;
84         rec<<recurse;
85         mSynchronizer->InsertAddOp(directory,rec.str(),"0",mCurrentDB);
86         std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory,mCurrentDB);
87         mTreeHandler->BeginTransaction();
88         mSynchronizer->GetList(mCurrentDB);
89         AddDirectoryRecursor( directory, recurse, addKey );
90         //DicomImageScanner sc;
91         //AddDirectoryRecursorScanner(directory, recurse, addKey, sc, false );
92         
93         int nFiles=GetProgress().GetNumberAddedFiles();
94         files<<nFiles;
95         mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",files.str(),"ADD_KEY",addKey,mCurrentDB);
96         mTreeHandler->EndTransaction();
97     GimmickDebugMessage(3,mProgress<<std::endl);
98   }
99
100   //=====================================================================
101   void TreeHandlerImageAdder::AddFile( const std::string& filename )
102   {
103     GimmickDebugMessage(4,"Adding '"<<filename<<"'"<<std::endl);
104     std::map< std::string, std::string>  attr;
105     mTreeHandler->GetTree().GetDescriptor().BuildAttributeMap(attr);
106
107         
108     mReader.ReadAttributes(filename,attr);
109         //// TO DO Create a function to test if the SOP Instance ID (0008,0018) is not already on DB
110         //// test befor if this attr is present on DB if not don't perform the test!!!
111         //bool bSOPIID = false;
112         //std::map<std::string, std::string>::iterator it_att = attr.begin();
113         //for(; it_att != attr.end(); it_att++)
114         //{
115         //      if (it_att->first == "D0008_0018")
116         //      {
117         //              bSOPIID = mTreeHandler->TestSOPIID(it_attr->second);
118         //              break;
119         //      }
120         //}
121         //if(bSOPIID)
122         //      return;
123
124     int lev = mTreeHandler->AddBranch(attr);
125
126     // update the progress according to lev
127     if (lev<mTreeHandler->GetTree().GetNumberOfLevels())
128       mProgress.IncNumberAddedFiles();
129   }
130   //=====================================================================
131
132   void TreeHandlerImageAdder::RemoveFile( tree::Node* node)
133   {
134                 int n=node->GetNumberOfChildren();
135                 if(n>0)
136                 {
137                         RemoveFiles(node->GetChildrenList());
138                 }
139                 else
140                 {
141                 remove(node);
142         }
143   }
144
145   //=====================================================================
146
147   void TreeHandlerImageAdder::RemoveFiles(const std::vector<tree::Node*>& nodes)
148   {
149           std::vector<tree::Node*>::const_iterator it;
150           for(it=nodes.begin();it!=nodes.end();++it)
151           {
152                 int n=(*it)->GetNumberOfChildren();
153                 if(n>0)
154                 {
155                         RemoveFiles((*it)->GetChildrenList());
156                 }
157                 else
158                 {
159                 remove(*it);
160                 }
161         
162           }
163   }
164
165
166   void  TreeHandlerImageAdder::remove( tree::Node* i_node)
167   {
168          std::string path=i_node->GetAttribute("FullFileName");
169                   //Gets the add key
170                   std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","IGNORED_FILES","PATH",path,mCurrentDB);
171                   //Gets the number of files added
172                   int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",addKey,mCurrentDB)).c_str());
173                   files=files-1;
174                   std::stringstream out;
175                   out<<files;
176                   //Sets the new number of files
177                   mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",addKey,mCurrentDB);
178                   //Sets the file as removed
179                   mSynchronizer->SetAttribute("REMOVE","IGNORED_FILES","1","PATH = '"+path+"' AND ADD_KEY",addKey,mCurrentDB);
180   }
181  
182   
183   //=======================================================================
184     //=====================================================================
185 #if defined(USE_GDCM2)
186  
187   void TreeHandlerImageAdder::AddDirectoryRecursorScanner(const std::string &dirpath, 
188                                                    bool recursive,const std::string &addKey, DicomImageScanner i_sc, bool b_loaded)
189   {
190     GimmickDebugMessage(4,"Scanning '"<<dirpath<<"'"<<std::endl);
191     mProgress.IncNumberScannedDirs();
192
193     if ( !fs::exists( dirpath ) ) return;
194         time_t lastModif=fs::last_write_time(dirpath);
195
196                         
197         
198                 std::map< std::string, std::string>  attr;
199                 mTreeHandler->GetTree().GetDescriptor().BuildAttributeMap(attr);
200                 std::string path = dirpath.c_str();
201                 i_sc.addDirectory(path, attr);
202         
203
204     fs::directory_iterator end_itr; // default construction yields past-the-end
205     for ( fs::directory_iterator itr( dirpath );
206           itr != end_itr;
207           ++itr )
208         {
209         
210                 // If is directory & recurse : do recurse
211         if ( fs::is_directory(itr->status()) )
212           {
213             if (recursive) 
214                 {
215                         AddDirectoryRecursorScanner( itr->string(), recursive, addKey, i_sc, true);
216                 }
217           }
218         else 
219           {
220                 std::string parent_id;
221                 // tTest if directory (and only it) exists or not.
222                 bool valid = mSynchronizer->isIndexed(itr->string());//true;//=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0),mCurrentDB);
223                 if(valid)
224                 {
225                         std::string path(itr->string());
226                         mProgress.IncNumberScannedFiles();
227                         boost::algorithm::replace_all( path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
228                         i_sc.ReadAttributes(itr->string(),attr);
229                 //      mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
230                         mTreeHandler->AddBranch(attr);
231                         mProgress.IncNumberHandledFiles();
232                         std::stringstream removedOn;
233                         removedOn<<time(0);
234                         mSynchronizer->InsertIgnoreFile(addKey, path,"0",removedOn.str(),mCurrentDB);
235
236                         
237                         mProgressSignal(mProgress);
238                         if (mProgress.GetStop()) 
239                         {
240                         //itr = end_itr;
241                         break;
242                         }
243                 }
244                         
245                 }
246         }
247         }
248 #endif
249  //=====================================================================
250   void TreeHandlerImageAdder::AddDirectoryRecursor(const std::string &dirpath, 
251                                                    bool recursive,
252                                                    const std::string &addKey)
253   {
254     GimmickDebugMessage(4,"Scanning '"<<dirpath<<"'"<<std::endl);
255     mProgress.IncNumberScannedDirs();
256
257     if ( !fs::exists( dirpath ) ) return;
258         time_t lastModif=fs::last_write_time(dirpath);
259
260         
261     fs::directory_iterator end_itr; // default construction yields past-the-end
262     for ( fs::directory_iterator itr( dirpath );
263           itr != end_itr;
264           ++itr )
265         {
266         // If is directory & recurse : do recurse
267         if ( fs::is_directory(itr->status()) )
268           {
269             if (recursive) 
270                 {
271                         AddDirectoryRecursor( itr->string(), recursive, addKey);
272                 }
273           }
274         else 
275           {
276                 std::string parent_id;
277                 // tTest if directory (and only it) exists or not.
278                 bool valid = mSynchronizer->isIndexed(itr->string());//true;//=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0),mCurrentDB);
279                 if(valid)
280                 {
281                         mProgress.IncNumberScannedFiles();
282                         if (IsHandledFile(itr->string()))
283                         {
284                         mProgress.IncNumberHandledFiles();
285                         AddFile( itr->string() );
286                         //mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
287                         std::stringstream removedOn;
288                         removedOn<<time(0);
289                         mSynchronizer->InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str(),mCurrentDB);
290                         }
291                         
292                         mProgressSignal(mProgress);
293                         if (mProgress.GetStop()) 
294                         {
295                         //itr = end_itr;
296                         break;
297                         }
298                         
299                 }
300           }
301       }
302         
303   }
304   //=======================================================================
305   
306
307   //=======================================================================
308
309   void TreeHandlerImageAdder::CheckSyncDirectory(const std::string &dirpath, 
310                                                                                                 bool recursive, 
311                                                                                                 bool repair,
312                                                                                                 bool checkAttributes,
313                                                                                                 std::vector<std::string> &i_ignorefiles,
314                                                                                                 std::vector<std::string> & attsModified,
315                                                                                                 std::vector<std::string> & newfiles)
316   {
317     if ( !fs::exists( dirpath ) ) return;
318     fs::directory_iterator end_itr; // default construction yields past-the-end
319                           
320     for ( fs::directory_iterator itr( dirpath ); itr != end_itr; ++itr ) 
321         {
322         // If is directory & recurse : do recurse
323         if ( fs::is_directory(itr->status()) )
324         {
325             if (recursive)
326                         {
327                 CheckSyncDirectory( itr->string(), recursive, repair, checkAttributes, i_ignorefiles, attsModified, newfiles);
328                         }
329         }
330         else
331         {
332             if (IsHandledFile(itr->string()))
333             {
334                 bool bfound = false;
335                 for(std::vector<std::string>::iterator it_new = i_ignorefiles.begin(); it_new < i_ignorefiles.end(); ++it_new)
336                 {
337                                         if((*it_new) == itr->string())
338                     {
339                         bfound = true;
340                                                 //Additional checking of attributes
341                                                 if(checkAttributes)
342                                                 {
343                                                         CheckAttributes(repair,(*it_new),attsModified);
344                                                 }
345                         i_ignorefiles.erase(it_new);
346                         break;
347                     }
348                                 }
349                                 if(!bfound && i_ignorefiles.size()>0 )
350                 {
351                     newfiles.push_back( itr->string() );
352                 }
353                         }
354                 }
355          }
356   } 
357
358   //=======================================================================
359   
360   //=======================================================================
361
362   std::string TreeHandlerImageAdder::Synchronize(bool repair, bool checkAttributes)
363   {
364           std::vector<AddList> fileList;
365           std::vector<std::string> ignoreList;
366           std::vector<std::string> newFiles;
367           std::vector<std::string> attsModified;
368           std::stringstream mess;
369           std::vector<AddList>::iterator iter;
370
371           //Gets the list of added files
372           mSynchronizer->GetFileList(fileList,mCurrentDB);
373
374           std::vector<std::string>::iterator i;
375           //Actions to take if the user doesn't want to repair
376           if(!repair)
377           {
378                 //Iterates to see if they are in sync
379                 for(iter=fileList.begin();iter!=fileList.end();++iter)
380                 {
381                         mSynchronizer->GetIgnoredFiles((*iter).key,ignoreList);
382                         bool rec=true;
383                         if((*iter).recursive=="0"){rec=false;}
384                         CheckSyncDirectory((*iter).path,rec,repair,checkAttributes,ignoreList,attsModified,newFiles);
385                 }
386
387                 //Add to message the result of new found files
388                 mess<<"New Files Found: "<<newFiles.size()<<std::endl;
389                 if(newFiles.size()>0)
390                 {
391                         mess<<"Filenames: "<<std::endl;
392                         for(i=newFiles.begin();i!=newFiles.end();++i)
393                         {
394                                 mess<<*i<<std::endl;
395                         }
396                 }
397
398                 //Add to message the result of missing files
399                 mess<<"Missing Files: "<<ignoreList.size()<<std::endl;
400                 if(ignoreList.size()>0)
401                 {
402                         mess<<"Filenames: "<<std::endl;
403                         for(i=ignoreList.begin();i!=ignoreList.end();++i)
404                         {
405                                 mess<<*i<<std::endl;
406                         }
407                 }
408
409                 //In the case that the user wants to check the attributes...
410                 if(checkAttributes)
411                 {
412                         //... add to message the result of files that have been changed.
413                         mess<<"Files with different attributes: "<<attsModified.size()<<std::endl;
414                         if(attsModified.size()>0)
415                         {
416                                 mess<<"Filenames: "<<std::endl;
417                                 for(i=attsModified.begin();i!=attsModified.end();++i)
418                                 {
419                                         mess<<*i<<std::endl;
420                                 }
421                         }
422                 }
423                 
424           }
425
426           //Actions to take if the user wants to repair
427           else
428           {
429                   int nf=0;
430                 //Iterates to see if they are in sync
431                 for(iter=fileList.begin();iter!=fileList.end();++iter)
432                 {
433                         mSynchronizer->GetIgnoredFiles((*iter).key,ignoreList);
434                         bool rec=true;
435                         if((*iter).recursive=="0"){rec=false;}
436                         CheckSyncDirectory((*iter).path,rec,repair,checkAttributes,ignoreList,attsModified,newFiles);
437
438                         //For the new files, add them
439                         for (i=newFiles.begin();i!=newFiles.end();++i)
440                         {
441                         if (IsHandledFile(*i)) 
442                         {
443                                 std::stringstream removedOn;
444                                 removedOn<<time(0);
445                                 mSynchronizer->InsertIgnoreFile((*iter).key,(*i),"0",removedOn.str(),mCurrentDB);
446                                 //Gets the number of files added
447                                 int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",(*iter).key,mCurrentDB)).c_str());
448                                 files=files+1;
449                                 std::stringstream out;
450                                 out<<files;
451                                 //Sets the new number of files
452                                 mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",(*iter).key,mCurrentDB);
453                                 AddFile(*i);
454                         }
455                         }
456                         nf+=newFiles.size();
457                         newFiles.clear();
458
459                 }
460                 //Reports number of added files
461                 mess<<"Files Added: "<<nf<<std::endl;
462                 
463                 //Removes the necessary files and reports the results
464                 if(ignoreList.size()>0)
465                 {
466                         tree::Node* node;
467                         mTreeHandler->LoadChildren(NULL,4);
468                         for(i=ignoreList.begin();i!=ignoreList.end();++i)
469                         {
470                                 FindNode(mTreeHandler->GetTree().GetChildrenList()[0],3,"FullFileName",*i,node);
471                                 RemoveFile(node);
472                                 mTreeHandler->Remove(node);
473                         }
474                 }
475                 mess<<"Files Removed: "<<ignoreList.size()<<std::endl;
476                 //In the case that the user wants to check the attributes...
477                 if(checkAttributes)
478                 {
479                         //... add to message the result of files that were modified.
480                         mess<<"Files Modified: "<<attsModified.size()<<std::endl;
481                 }
482           }
483           return mess.str();
484
485   }
486   //=======================================================================
487
488   void TreeHandlerImageAdder::CheckAttributes(bool repair, std::string& file, std::vector<std::string>& attsModified)
489   {
490           std::map< std::string, std::string>  attr;
491           mTreeHandler->GetTree().GetDescriptor().BuildAttributeMap(attr);
492       mReader.ReadAttributes(file,attr);
493           tree::LevelDescriptor::AttributeDescriptorListType adl= mTreeHandler->GetTree().GetAttributeDescriptorList(mTreeHandler->GetTree().GetNumberOfLevels()-1);    
494           tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
495           for (a = adl.begin();a!=adl.end();++a)
496           {
497            std::string databaseVal;
498            mTreeHandler->GetAttribute("Image","FullFileName",file,a->GetKey(),databaseVal);
499            std::string fileVal=attr.find(a->GetKey())->second;
500            if ( a->GetFlags()==0 && databaseVal == fileVal) 
501             {
502                         if(repair)
503                         {
504                                 mTreeHandler->SetAttribute("Image",a->GetKey(),fileVal,"FullFileName", file);   
505                         }
506                         attsModified.push_back(file);
507             }
508                 
509           }
510           
511   }
512
513   //=======================================================================
514
515
516   void TreeHandlerImageAdder::FindNode(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node)
517   {
518           if(level>1)
519           {
520                   std::vector<tree::Node*>::iterator iter;
521                   for(iter=parent->GetChildrenList().begin();iter!=parent->GetChildrenList().end();++iter)
522                   {
523                           FindNode(*iter,level-1,searchParam,searchVal,node);
524                   }
525           }
526           else
527           {
528                   if(parent->GetAttribute(searchParam).compare(searchVal)==0)
529                   {
530                           node=parent;
531                   }
532
533           }
534   }
535   
536   void TreeHandlerImageAdder::SaveAs(const std::vector<std::string>& filenames, std::vector<vtkImageData *> i_images)
537   {
538           std::vector<std::string>::const_iterator it_file = filenames.begin();
539           std::vector<vtkImageData *>::iterator it_image = i_images.begin();
540         /*  mWriter.CanWrite(".jpeg");
541           for(; it_file != filenames.end(); ++it_file, ++it_image)
542                   mWriter.WriteImage(it_file->c_str(), (vtkImageData &)it_image);*/
543   }
544
545   //=======================================================================
546   void TreeHandlerImageAdder::FindNodePartial(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node)
547   {
548           if(level>1)
549           {
550                   std::vector<tree::Node*>::iterator iter;
551                   for(iter=parent->GetChildrenList().begin();iter!=parent->GetChildrenList().end() && node==0 ;++iter)
552                   {
553                           FindNodePartial(*iter,level-1,searchParam,searchVal,node);
554                   }
555           }
556           else
557           {
558                   if(parent->GetAttribute(searchParam).find(searchVal)<9000)
559                   {
560                           node=parent;
561                           return;
562                   }
563
564           }
565   }
566   
567   //=======================================================================
568
569   void TreeHandlerImageAdder::CopyFiles(const std::vector<std::string>& filenames, const std::string directory  )
570   {
571           std::vector<std::string>::const_iterator i;
572           if(!boost::filesystem::exists(directory))
573           {
574           boost::filesystem::create_directory(boost::filesystem::path(directory));
575           mSynchronizer->InsertAddOp(directory,"0","0",mCurrentDB);
576           }
577           std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory,mCurrentDB);
578           size_t last;
579           std::vector<std::string> newNames;
580           for(i=filenames.begin();i!=filenames.end();++i)
581           {
582                   std::string dir=directory.c_str();
583                   if(boost::filesystem::exists(*i) && (*i).find(dir)==std::string::npos)
584                   {
585                   std::string path=*i;
586                   last=(*i).find_last_of('/');
587                   std::string f="\\"+(*i).substr(last+1);
588         
589                   int p=1;
590                   std::stringstream out;
591                   out<<directory<<f;
592                   while(boost::filesystem::exists(out.str()))
593                   {
594                           out.str("");
595                           out<<directory<<f.substr(0,f.size()-4)<<"("<<p<<")"<<f.substr(f.size()-4);
596                           p++;
597                   }
598                   std::string result=out.str();
599                   boost::filesystem::copy_file((*i),result);
600
601                   //To update image database
602                   mTreeHandler->SetAttribute("Image","FullFileName",result,"FullFileName", (*i));
603                   
604                   //To update maintenance database
605                   //1.Add the new path and increase number of children on new operation.
606                   std::stringstream removedOn;
607                   removedOn<<time(0);
608                   //Inserts the file
609                   mSynchronizer->InsertIgnoreFile(addKey, result,"0",removedOn.str(),mCurrentDB);
610                   //Gets the number of files added
611                   int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",addKey,mCurrentDB)).c_str());
612                   files=files+1;
613                   std::stringstream fil;
614                   fil<<files;
615                   //Sets the new number of files
616                   mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",fil.str(),"ADD_KEY",addKey,mCurrentDB);
617                   fil.str("");
618
619                   //2.Set the old path as removed and decrease number of children on old operation.
620                   //Gets the old add key
621                   std::string oldAddKey=mSynchronizer->GetAttribute("ADD_KEY","IGNORED_FILES","PATH",path,mCurrentDB);
622                   //Sets the file as removed
623                   mSynchronizer->SetAttribute("REMOVE","IGNORED_FILES","1","PATH = '"+path+"' AND ADD_KEY",oldAddKey,mCurrentDB);
624                   //Gets the number of files added
625                   files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",oldAddKey,mCurrentDB)).c_str());
626                   files=files-1;
627                   fil<<files;
628                   //Sets the new number of files
629                   mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",fil.str(),"ADD_KEY",oldAddKey,mCurrentDB);
630                   
631                   }
632
633           }
634   }
635
636   //=======================================================================
637
638   void TreeHandlerImageAdder::DeleteDriveFromMainDB(const std::string& drive)
639   {
640           //Delete from local database and others
641           tree::Node* node=0;
642           mTreeHandler->LoadChildren(NULL,4);
643           FindNodePartial(mTreeHandler->GetTree().GetChildrenList()[0],3,"FullFileName",drive,node);
644           while(node!=0)
645           {
646           mTreeHandler->Remove(node);
647           node=0;
648           mTreeHandler->LoadChildren(NULL,4);
649           FindNodePartial(mTreeHandler->GetTree().GetChildrenList()[0],3,"FullFileName",drive,node); 
650           }
651   }
652
653    //=======================================================================
654
655   void TreeHandlerImageAdder::DeleteDriveFromOtherDB(const std::string& drive)
656   {
657           //Delete from maintenance
658           mSynchronizer->RemoveEntries("ADD_OPS", "PATH", "LIKE", drive+"%");
659           mSynchronizer->RemoveEntries("IGNORED_FILES", "PATH", "LIKE", drive+"%");
660   }
661
662   //=======================================================================
663   void TreeHandlerImageAdder::EditField(tree::Node* node, const std::string& name, const std::string& key, const std::string& val)
664   {
665           node->SetAttribute(key,val);
666           mTreeHandler->SetAttribute(node,key,val);
667   }
668
669   //=======================================================================
670   void TreeHandlerImageAdder::GetAttributes(const std::vector<std::string>& params, 
671           const std::string& filename, 
672           std::vector<std::string>& results)
673   {
674           std::vector<std::string>::const_iterator i;
675           std::string result;
676           for(i=params.begin();i!=params.end();i++)
677           {
678                   mTreeHandler->GetAttribute("Image","FullFileName",filename,*i,result);
679                   results.push_back(result);
680           }
681   }
682
683   //=======================================================================
684   const std::string TreeHandlerImageAdder::isAttributeExist(const std::string i_attr)
685   {
686           return mTreeHandler->GetTree().isAttributeExist(i_attr);
687   }
688
689 }