Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

AnnotationTableSetRepository.h

Go to the documentation of this file.
00001 #ifndef Impala_Persistency_AnnotationTableSetRepository_h
00002 #define Impala_Persistency_AnnotationTableSetRepository_h
00003 
00004 #include "Persistency/RepositoryDispatcher.h"
00005 #include "Persistency/RepositoryStub.h"
00006 #include "Core/Table/AnnotationTableSet.h"
00007 #include "Persistency/AnnotationTableSetLocator.h"
00008 #include "Persistency/KeywordListRepository.h"
00009 #include "Persistency/AnnotationTableRepository.h"
00010 
00011 namespace Impala
00012 {
00013 namespace Persistency
00014 {
00015 
00016 
00017 class AnnotationTableSetRepository
00018     : public RepositoryDispatcher<AnnotationTableSetLocator,
00019                                   Core::Table::AnnotationTableSet,
00020                                   RepositoryStub,
00021                                   RepositoryStub>
00022 {
00023 public:
00024 
00025     typedef Core::Table::AnnotationTableSet AnnotationTableSet;
00026     typedef Core::Table::AnnotationTable AnnotationTable;
00027     typedef Core::Table::KeywordList KeywordList;
00028 
00029     bool
00030     Exists(const AnnotationTableSetLocator& loc)
00031     {
00032         KeywordListLocator keyListLoc(loc, loc.GetConceptSet());
00033         if (!KeywordListRepository().Exists(keyListLoc))
00034             return false;
00035         KeywordList keyList = *(KeywordListRepository().Get(keyListLoc));
00036 
00037         int nrFound = 0;
00038         AnnotationTableLocator tabLoc(loc, loc.GetQuidClass(),
00039                                       loc.GetConceptSet(), "dummy");
00040         for (int i=0 ; i<keyList.size() ; i++)
00041         {
00042             tabLoc.SetKeyword(keyList[i]);
00043             if (AnnotationTableRepository().Exists(tabLoc))
00044                 nrFound++;
00045         }
00046         if (nrFound == 0)
00047             return false;
00048         return true;
00049     }
00050 
00051     AnnotationTableSet*
00052     Get(const AnnotationTableSetLocator& loc)
00053     {
00054         KeywordListLocator keyListLoc(loc, loc.GetConceptSet());
00055         KeywordList keyList = *(KeywordListRepository().Get(keyListLoc));
00056         if (keyList.size() == 0)
00057         {
00058             ILOG_ERROR("Could find keywords");
00059             return 0;
00060         }
00061 
00062         AnnotationTableSet* res = new AnnotationTableSet();
00063         int nrFound = 0;
00064         AnnotationTableLocator tabLoc(loc, loc.GetQuidClass(),
00065                                       loc.GetConceptSet(), "dummy");
00066         for (int i=0 ; i<keyList.size() ; i++)
00067         {
00068             tabLoc.SetKeyword(keyList[i]);
00069             AnnotationTable* table = AnnotationTableRepository().Get(tabLoc);
00070             if (table)
00071                 nrFound++;
00072             else
00073                 table = new AnnotationTable(keyList[i], 0);
00074             res->Add(table);
00075         }
00076         if (nrFound == 0)
00077             ILOG_ERROR("No tables found");
00078         return res;
00079     }
00080 
00081     void
00082     Add(const AnnotationTableSetLocator& loc, AnnotationTableSet* tSet)
00083     {
00084         KeywordListLocator keyListLoc(loc, loc.GetConceptSet());
00085         if (!KeywordListRepository().Exists(keyListLoc))
00086         {
00087             KeywordList keys = tSet->GetLabels();
00088             KeywordListRepository().Add(keyListLoc, &keys);
00089         }
00090         for (int i=0 ; i<tSet->Size() ; i++)
00091         {
00092             AnnotationTable* tab = tSet->GetTable(i);
00093             if (tab->Size() == 0)
00094                 continue;
00095             int qClass = tab->GetQuidClass();
00096             //if (qClass != loc.GetQuidClass())
00097             //    ILOG_WARN("Table and Locator have different QuidClass");
00098             AnnotationTableLocator tabLoc(loc, qClass, loc.GetConceptSet(),
00099                                           tab->GetLabel());
00100             AnnotationTableRepository().Add(tabLoc, tab);
00101         }
00102     }
00103 
00104 };
00105 
00106 } // namespace Persistency
00107 } // namespace Impala
00108 
00109 #endif

Generated on Fri Mar 19 09:31:42 2010 for ImpalaSrc by  doxygen 1.5.1