]> Creatis software - creaImageIO.git/blob - src/creaImageIOTreeHandlerImageAdder.cpp
*** empty log message ***
[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
226                         mProgress.IncNumberScannedFiles();
227                         boost::algorithm::replace_all( itr->string(),
228                                     INVALID_FILE_SEPARATOR , 
229                                    VALID_FILE_SEPARATOR);
230                         i_sc.ReadAttributes(itr->string(),attr);
231                 //      mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
232                         mTreeHandler->AddBranch(attr);
233                         mProgress.IncNumberHandledFiles();
234                         std::stringstream removedOn;
235                         removedOn<<time(0);
236                         mSynchronizer->InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str(),mCurrentDB);
237
238                         
239                         mProgressSignal(mProgress);
240                         if (mProgress.GetStop()) 
241                         {
242                         //itr = end_itr;
243                         break;
244                         }
245                 }
246                         
247                 }
248         }
249         }
250 #endif
251  //=====================================================================
252   void TreeHandlerImageAdder::AddDirectoryRecursor(const std::string &dirpath, 
253                                                    bool recursive,
254                                                    const std::string &addKey)
255   {
256     GimmickDebugMessage(4,"Scanning '"<<dirpath<<"'"<<std::endl);
257     mProgress.IncNumberScannedDirs();
258
259     if ( !fs::exists( dirpath ) ) return;
260         time_t lastModif=fs::last_write_time(dirpath);
261
262         
263     fs::directory_iterator end_itr; // default construction yields past-the-end
264     for ( fs::directory_iterator itr( dirpath );
265           itr != end_itr;
266           ++itr )
267         {
268         // If is directory & recurse : do recurse
269         if ( fs::is_directory(itr->status()) )
270           {
271             if (recursive) 
272                 {
273                         AddDirectoryRecursor( itr->string(), recursive, addKey);
274                 }
275           }
276         else 
277           {
278                 std::string parent_id;
279                 // tTest if directory (and only it) exists or not.
280                 bool valid = mSynchronizer->isIndexed(itr->string());//true;//=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0),mCurrentDB);
281                 if(valid)
282                 {
283                         mProgress.IncNumberScannedFiles();
284                         if (IsHandledFile(itr->string()))
285                         {
286                         mProgress.IncNumberHandledFiles();
287                         AddFile( itr->string() );
288                         //mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
289                         std::stringstream removedOn;
290                         removedOn<<time(0);
291                         mSynchronizer->InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str(),mCurrentDB);
292                         }
293                         
294                         mProgressSignal(mProgress);
295                         if (mProgress.GetStop()) 
296                         {
297                         //itr = end_itr;
298                         break;
299                         }
300                         
301                 }
302           }
303       }
304         
305   }
306   //=======================================================================
307   
308
309   //=======================================================================
310
311   void TreeHandlerImageAdder::CheckSyncDirectory(const std::string &dirpath, 
312                                                                                                 bool recursive, 
313                                                                                                 bool repair,
314                                                                                                 bool checkAttributes,
315                                                                                                 std::vector<std::string> &i_ignorefiles,
316                                                                                                 std::vector<std::string> & attsModified,
317                                                                                                 std::vector<std::string> & newfiles)
318   {
319     if ( !fs::exists( dirpath ) ) return;
320     fs::directory_iterator end_itr; // default construction yields past-the-end
321                           
322     for ( fs::directory_iterator itr( dirpath ); itr != end_itr; ++itr ) 
323         {
324         // If is directory & recurse : do recurse
325         if ( fs::is_directory(itr->status()) )
326         {
327             if (recursive)
328                         {
329                 CheckSyncDirectory( itr->string(), recursive, repair, checkAttributes, i_ignorefiles, attsModified, newfiles);
330                         }
331         }
332         else
333         {
334             if (IsHandledFile(itr->string()))
335             {
336                 bool bfound = false;
337                 for(std::vector<std::string>::iterator it_new = i_ignorefiles.begin(); it_new < i_ignorefiles.end(); ++it_new)
338                 {
339                                         if((*it_new) == itr->string())
340                     {
341                         bfound = true;
342                                                 //Additional checking of attributes
343                                                 if(checkAttributes)
344                                                 {
345                                                         CheckAttributes(repair,(*it_new),attsModified);
346                                                 }
347                         i_ignorefiles.erase(it_new);
348                         break;
349                     }
350                                 }
351                                 if(!bfound && i_ignorefiles.size()>0 )
352                 {
353                     newfiles.push_back( itr->string() );
354                 }
355                         }
356                 }
357          }
358   } 
359
360   //=======================================================================
361   
362   //=======================================================================
363
364   std::string TreeHandlerImageAdder::Synchronize(bool repair, bool checkAttributes)
365   {
366           std::vector<AddList> fileList;
367           std::vector<std::string> ignoreList;
368           std::vector<std::string> newFiles;
369           std::vector<std::string> attsModified;
370           std::stringstream mess;
371           std::vector<AddList>::iterator iter;
372
373           //Gets the list of added files
374           mSynchronizer->GetFileList(fileList,mCurrentDB);
375
376           std::vector<std::string>::iterator i;
377           //Actions to take if the user doesn't want to repair
378           if(!repair)
379           {
380                 //Iterates to see if they are in sync
381                 for(iter=fileList.begin();iter!=fileList.end();++iter)
382                 {
383                         mSynchronizer->GetIgnoredFiles((*iter).key,ignoreList);
384                         bool rec=true;
385                         if((*iter).recursive=="0"){rec=false;}
386                         CheckSyncDirectory((*iter).path,rec,repair,checkAttributes,ignoreList,attsModified,newFiles);
387                 }
388
389                 //Add to message the result of new found files
390                 mess<<"New Files Found: "<<newFiles.size()<<std::endl;
391                 if(newFiles.size()>0)
392                 {
393                         mess<<"Filenames: "<<std::endl;
394                         for(i=newFiles.begin();i!=newFiles.end();++i)
395                         {
396                                 mess<<*i<<std::endl;
397                         }
398                 }
399
400                 //Add to message the result of missing files
401                 mess<<"Missing Files: "<<ignoreList.size()<<std::endl;
402                 if(ignoreList.size()>0)
403                 {
404                         mess<<"Filenames: "<<std::endl;
405                         for(i=ignoreList.begin();i!=ignoreList.end();++i)
406                         {
407                                 mess<<*i<<std::endl;
408                         }
409                 }
410
411                 //In the case that the user wants to check the attributes...
412                 if(checkAttributes)
413                 {
414                         //... add to message the result of files that have been changed.
415                         mess<<"Files with different attributes: "<<attsModified.size()<<std::endl;
416                         if(attsModified.size()>0)
417                         {
418                                 mess<<"Filenames: "<<std::endl;
419                                 for(i=attsModified.begin();i!=attsModified.end();++i)
420                                 {
421                                         mess<<*i<<std::endl;
422                                 }
423                         }
424                 }
425                 
426           }
427
428           //Actions to take if the user wants to repair
429           else
430           {
431                   int nf=0;
432                 //Iterates to see if they are in sync
433                 for(iter=fileList.begin();iter!=fileList.end();++iter)
434                 {
435                         mSynchronizer->GetIgnoredFiles((*iter).key,ignoreList);
436                         bool rec=true;
437                         if((*iter).recursive=="0"){rec=false;}
438                         CheckSyncDirectory((*iter).path,rec,repair,checkAttributes,ignoreList,attsModified,newFiles);
439
440                         //For the new files, add them
441                         for (i=newFiles.begin();i!=newFiles.end();++i)
442                         {
443                         if (IsHandledFile(*i)) 
444                         {
445                                 std::stringstream removedOn;
446                                 removedOn<<time(0);
447                                 mSynchronizer->InsertIgnoreFile((*iter).key,(*i),"0",removedOn.str(),mCurrentDB);
448                                 //Gets the number of files added
449                                 int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",(*iter).key,mCurrentDB)).c_str());
450                                 files=files+1;
451                                 std::stringstream out;
452                                 out<<files;
453                                 //Sets the new number of files
454                                 mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",(*iter).key,mCurrentDB);
455                                 AddFile(*i);
456                         }
457                         }
458                         nf+=newFiles.size();
459                         newFiles.clear();
460
461                 }
462                 //Reports number of added files
463                 mess<<"Files Added: "<<nf<<std::endl;
464                 
465                 //Removes the necessary files and reports the results
466                 if(ignoreList.size()>0)
467                 {
468                         tree::Node* node;
469                         mTreeHandler->LoadChildren(NULL,4);
470                         for(i=ignoreList.begin();i!=ignoreList.end();++i)
471                         {
472                                 FindNode(mTreeHandler->GetTree().GetChildrenList()[0],3,"FullFileName",*i,node);
473                                 RemoveFile(node);
474                                 mTreeHandler->Remove(node);
475                         }
476                 }
477                 mess<<"Files Removed: "<<ignoreList.size()<<std::endl;
478                 //In the case that the user wants to check the attributes...
479                 if(checkAttributes)
480                 {
481                         //... add to message the result of files that were modified.
482                         mess<<"Files Modified: "<<attsModified.size()<<std::endl;
483                 }
484           }
485           return mess.str();
486
487   }
488   //=======================================================================
489
490   void TreeHandlerImageAdder::CheckAttributes(bool repair, std::string& file, std::vector<std::string>& attsModified)
491   {
492           std::map< std::string, std::string>  attr;
493           mTreeHandler->GetTree().GetDescriptor().BuildAttributeMap(attr);
494       mReader.ReadAttributes(file,attr);
495           tree::LevelDescriptor::AttributeDescriptorListType adl= mTreeHandler->GetTree().GetAttributeDescriptorList(mTreeHandler->GetTree().GetNumberOfLevels()-1);    
496           tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
497           for (a = adl.begin();a!=adl.end();++a)
498           {
499            std::string databaseVal;
500            mTreeHandler->GetAttribute("Image","FullFileName",file,a->GetKey(),databaseVal);
501            std::string fileVal=attr.find(a->GetKey())->second;
502            if ( a->GetFlags()==0 && databaseVal == fileVal) 
503             {
504                         if(repair)
505                         {
506                                 mTreeHandler->SetAttribute("Image",a->GetKey(),fileVal,"FullFileName", file);   
507                         }
508                         attsModified.push_back(file);
509             }
510                 
511           }
512           
513   }
514
515   //=======================================================================
516
517
518   void TreeHandlerImageAdder::FindNode(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node)
519   {
520           if(level>1)
521           {
522                   std::vector<tree::Node*>::iterator iter;
523                   for(iter=parent->GetChildrenList().begin();iter!=parent->GetChildrenList().end();++iter)
524                   {
525                           FindNode(*iter,level-1,searchParam,searchVal,node);
526                   }
527           }
528           else
529           {
530                   if(parent->GetAttribute(searchParam).compare(searchVal)==0)
531                   {
532                           node=parent;
533                   }
534
535           }
536   }
537   
538   void TreeHandlerImageAdder::SaveAs(const std::vector<std::string>& filenames, std::vector<vtkImageData *> i_images)
539   {
540           std::vector<std::string>::const_iterator it_file = filenames.begin();
541           std::vector<vtkImageData *>::iterator it_image = i_images.begin();
542         /*  mWriter.CanWrite(".jpeg");
543           for(; it_file != filenames.end(); ++it_file, ++it_image)
544                   mWriter.WriteImage(it_file->c_str(), (vtkImageData &)it_image);*/
545   }
546
547   //=======================================================================
548   void TreeHandlerImageAdder::FindNodePartial(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node)
549   {
550           if(level>1)
551           {
552                   std::vector<tree::Node*>::iterator iter;
553                   for(iter=parent->GetChildrenList().begin();iter!=parent->GetChildrenList().end() && node==0 ;++iter)
554                   {
555                           FindNodePartial(*iter,level-1,searchParam,searchVal,node);
556                   }
557           }
558           else
559           {
560                   if(parent->GetAttribute(searchParam).find(searchVal)<9000)
561                   {
562                           node=parent;
563                           return;
564                   }
565
566           }
567   }
568   
569   //=======================================================================
570
571   void TreeHandlerImageAdder::CopyFiles(const std::vector<std::string>& filenames, const std::string directory  )
572   {
573           std::vector<std::string>::const_iterator i;
574           if(!boost::filesystem::exists(directory))
575           {
576           boost::filesystem::create_directory(boost::filesystem::path(directory));
577           mSynchronizer->InsertAddOp(directory,"0","0",mCurrentDB);
578           }
579           std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory,mCurrentDB);
580           size_t last;
581           std::vector<std::string> newNames;
582           for(i=filenames.begin();i!=filenames.end();++i)
583           {
584                   std::string dir=directory.c_str();
585                   if(boost::filesystem::exists(*i) && (*i).find(dir)==std::string::npos)
586                   {
587                   std::string path=*i;
588                   last=(*i).find_last_of('/');
589                   std::string f="\\"+(*i).substr(last+1);
590         
591                   int p=1;
592                   std::stringstream out;
593                   out<<directory<<f;
594                   while(boost::filesystem::exists(out.str()))
595                   {
596                           out.str("");
597                           out<<directory<<f.substr(0,f.size()-4)<<"("<<p<<")"<<f.substr(f.size()-4);
598                           p++;
599                   }
600                   std::string result=out.str();
601                   boost::filesystem::copy_file((*i),result);
602
603                   //To update image database
604                   mTreeHandler->SetAttribute("Image","FullFileName",result,"FullFileName", (*i));
605                   
606                   //To update maintenance database
607                   //1.Add the new path and increase number of children on new operation.
608                   std::stringstream removedOn;
609                   removedOn<<time(0);
610                   //Inserts the file
611                   mSynchronizer->InsertIgnoreFile(addKey, result,"0",removedOn.str(),mCurrentDB);
612                   //Gets the number of files added
613                   int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",addKey,mCurrentDB)).c_str());
614                   files=files+1;
615                   std::stringstream fil;
616                   fil<<files;
617                   //Sets the new number of files
618                   mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",fil.str(),"ADD_KEY",addKey,mCurrentDB);
619                   fil.str("");
620
621                   //2.Set the old path as removed and decrease number of children on old operation.
622                   //Gets the old add key
623                   std::string oldAddKey=mSynchronizer->GetAttribute("ADD_KEY","IGNORED_FILES","PATH",path,mCurrentDB);
624                   //Sets the file as removed
625                   mSynchronizer->SetAttribute("REMOVE","IGNORED_FILES","1","PATH = '"+path+"' AND ADD_KEY",oldAddKey,mCurrentDB);
626                   //Gets the number of files added
627                   files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",oldAddKey,mCurrentDB)).c_str());
628                   files=files-1;
629                   fil<<files;
630                   //Sets the new number of files
631                   mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",fil.str(),"ADD_KEY",oldAddKey,mCurrentDB);
632                   
633                   }
634
635           }
636   }
637
638   //=======================================================================
639
640   void TreeHandlerImageAdder::DeleteDriveFromMainDB(const std::string& drive)
641   {
642           //Delete from local database and others
643           tree::Node* node=0;
644           mTreeHandler->LoadChildren(NULL,4);
645           FindNodePartial(mTreeHandler->GetTree().GetChildrenList()[0],3,"FullFileName",drive,node);
646           while(node!=0)
647           {
648           mTreeHandler->Remove(node);
649           node=0;
650           mTreeHandler->LoadChildren(NULL,4);
651           FindNodePartial(mTreeHandler->GetTree().GetChildrenList()[0],3,"FullFileName",drive,node); 
652           }
653   }
654
655    //=======================================================================
656
657   void TreeHandlerImageAdder::DeleteDriveFromOtherDB(const std::string& drive)
658   {
659           //Delete from maintenance
660           mSynchronizer->RemoveEntries("ADD_OPS", "PATH", "LIKE", drive+"%");
661           mSynchronizer->RemoveEntries("IGNORED_FILES", "PATH", "LIKE", drive+"%");
662   }
663
664   //=======================================================================
665   void TreeHandlerImageAdder::EditField(tree::Node* node, const std::string& name, const std::string& key, const std::string& val)
666   {
667           node->SetAttribute(key,val);
668           mTreeHandler->SetAttribute(node,key,val);
669   }
670
671   //=======================================================================
672   void TreeHandlerImageAdder::GetAttributes(const std::vector<std::string>& params, 
673           const std::string& filename, 
674           std::vector<std::string>& results)
675   {
676           std::vector<std::string>::const_iterator i;
677           std::string result;
678           for(i=params.begin();i!=params.end();i++)
679           {
680                   mTreeHandler->GetAttribute("Image","FullFileName",filename,*i,result);
681                   results.push_back(result);
682           }
683   }
684
685   //=======================================================================
686   const std::string TreeHandlerImageAdder::isAttributeExist(const std::string i_attr)
687   {
688           return mTreeHandler->GetTree().isAttributeExist(i_attr);
689   }
690
691 }