Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

creaImageIO::SQLiteTreeHandler Class Reference
[Model]

Concrete TreeHandler which manages a Tree stored in a sqlite database. More...

#include <creaImageIOSQLiteTreeHandler.h>

Inheritance diagram for creaImageIO::SQLiteTreeHandler:
Inheritance graph
[legend]
Collaboration diagram for creaImageIO::SQLiteTreeHandler:
Collaboration graph
[legend]

List of all members.

Public Types

typedef
tree::Node::AttributeMapType 
AttributeMapType
 ====================================================================

Public Member Functions

 SQLiteTreeHandler (const std::string &filename)
 Ctor with database file name.
virtual ~SQLiteTreeHandler ()
 Dtor.
const std::string & GetFileName () const
 Returns the sqlite db file name.
virtual bool IsReadable ()
 Is the 'source' readable ?
virtual bool IsWritable ()
 Is the 'source' writable ?
virtual bool Open (bool writable=false)
 Opens an existing 'source'.
virtual bool Close ()
 Closes the 'source'.
virtual bool Create (bool writable=false)
 Creates a new 'source'.
virtual bool Destroy ()
 Destroys the 'source'.
virtual void BeginTransaction ()
 Begins a transaction.
virtual void EndTransaction ()
 Commits results and ends transaction.
virtual unsigned int GetNumberOfChildren (tree::Node *n)
 Returns the number of children of the Node *WITHOUT LOADING THEM*.
virtual void GetAttribute (std::string levelDescriptor, std::string searchParam, std::string searchVal, std::string key, std::string &result)
 Returns the attribute requested. Useful for synchronization.
virtual int LoadChildren (tree::Node *parent, int maxlevel)
 Recursively loads the children of node 'parent' until maxlevel.
virtual void UnLoad (tree::Node *n)
 Unloads the Node and its descendants.
virtual void GetTopLevelNodeId (const std::string &searchParam, const std::string &searchValue, std::string &parent_id)
 ====================================================================
virtual int AddBranch (const AttributeMapType &attr)
 ====================================================================
virtual bool Remove (tree::Node *)
 Removes the node and its descendants.
virtual bool SetAttribute (tree::Node *, const std::string &key, const std::string &value)
 Sets an attribute of a Node.
virtual void SetAttribute (const std::string &levelDescriptor, const std::string &key, const std::string &value, const std::string &searchParam, const std::string &searchVal)
 Sets an attribute.
virtual void DeleteTuple (std::string levelDescriptor, std::string key, std::string value)
 Deletes a tuple.
virtual void RemoveEntries (const std::string i_table, const std::string i_attribute, const std::string i_operand, const std::string i_val)
void getAllAttributes (std::string i_filename, std::map< std::string, std::string > &i_results)
 get all attributes from database for a given file
void GetAttributes (std::string name, std::string i_id, std::string i_value, tree::LevelDescriptor::AttributeDescriptorListType i_attr, std::vector< std::string > &i_results)
 get selected attributes from database for a given file
void GetUpLevelNodeId (int level, const std::string &searchParam, const std::string &searchValue, std::string &parent_id)
 get Id for the up level node
tree::TreeGetTree ()
 Returns the Tree handled.
const tree::TreeGetTree () const
 Returns the Tree handled (const).

Protected Member Functions

bool DBOpen ()
 Open the database.
bool DBImportTreeDescription ()
 Import the Tree::Description from database (verifies the structure).
bool DBCreate ()
 Creates a new database on disk and the tables.
void SQLAppendAttributesDefinition (int level, std::string &s)
 Appends to string s the SQL command to create the attributes of a given level.
tree::NodeDBGetParent (const AttributeMapType &attr)
 Returns the parent to which the branch defined by the attributes.
int DBLoadChildren (tree::Node *parent, int numberoflevels=1)
 Loads the children of Node parent.
void SQLAppendAttributesValues (tree::Node *n, std::string &s)
 Appends to string s the SQL command to set the attributes values.
void DBGraftToParent (tree::Node *parent, const AttributeMapType &attr)
 Graft the branch defined by the attributes to the parent.
bool DBSetAttribute (tree::Node *, const std::string &key, const std::string &value)
 Sets an attribute of a Node and updates the database.
void DBSetAttribute (const std::string &levelDescriptor, const std::string &key, const std::string &value, const std::string &searchParam, const std::string &searchVal)
 Sets an attribute and updates the database.
void DBInsert (tree::Node *n)
 Inserts the Node in the database.
void DBDelete (std::string levelDescriptor, std::string key, std::string value)
 Deletes the tuple that matches the value specified in the given key and that belongs to the given level.
void DBRecursiveRemoveNode (tree::Node *node)
 Recursively Removes the nodes whose parent is given as a parameter.
void DBRecursiveRemoveNode (int level, std::string parentId)
 Recursively Removes the nodes found in the given level with the given parent id.

Private Member Functions

void SetWritable (bool w)
bool GetWritable () const
const std::string convert (const std::string &i_word)

Private Attributes

CppSQLite3DBmDB
 The DB.
std::string mFileName
 The physical location associated to the DicomDatabase (directory, db file...).
bool mWritable
 Is the DB writable ?
bool mIsAdding

Detailed Description

Concrete TreeHandler which manages a Tree stored in a sqlite database.

Definition at line 18 of file creaImageIOSQLiteTreeHandler.h.


Member Typedef Documentation

====================================================================

Definition at line 123 of file creaImageIOTreeHandler.h.


Constructor & Destructor Documentation

creaImageIO::SQLiteTreeHandler::SQLiteTreeHandler ( const std::string &  filename  ) 

Ctor with database file name.

Definition at line 23 of file creaImageIOSQLiteTreeHandler.cpp.

References mDB, and mIsAdding.

    : mFileName(filename)
  {
    mDB = new CppSQLite3DB;
        mIsAdding=false;
    //GimmickMessage(1,"SQLite version : "                 <<std::string(mDB->SQLiteVersion())<< std::endl);
  }

creaImageIO::SQLiteTreeHandler::~SQLiteTreeHandler (  )  [virtual]

Dtor.

Definition at line 33 of file creaImageIOSQLiteTreeHandler.cpp.

References mDB.

  {
    delete mDB;
  }


Member Function Documentation

int creaImageIO::SQLiteTreeHandler::AddBranch ( const AttributeMapType attr  )  [virtual]

====================================================================

Adds a branch in the tree with the attributes provided

Reimplemented from creaImageIO::TreeHandler.

Definition at line 97 of file creaImageIOSQLiteTreeHandler.cpp.

References DBGetParent(), DBGraftToParent(), and creaImageIO::tree::Node::GetLevel().

  {
    tree::Node* parent = DBGetParent(attr);
    DBGraftToParent(parent,attr);
    return (parent->GetLevel()+1);
          
  }

Here is the call graph for this function:

void creaImageIO::SQLiteTreeHandler::BeginTransaction (  )  [virtual]

Begins a transaction.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 1094 of file creaImageIOSQLiteTreeHandler.cpp.

References UPDATEDB.

    {
                std::stringstream out;
                out<<"begin transaction;";
        UPDATEDB(out.str());
        }

bool creaImageIO::SQLiteTreeHandler::Close (  )  [virtual]

Closes the 'source'.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 63 of file creaImageIOSQLiteTreeHandler.cpp.

  {
    return true;
  }

const std::string creaImageIO::SQLiteTreeHandler::convert ( const std::string &  i_word  )  [private]

Definition at line 1108 of file creaImageIOSQLiteTreeHandler.cpp.

Referenced by DBSetAttribute().

  {
          std::string temp = i_word;
          boost::algorithm::replace_all(temp,"'","''");
          return temp.c_str();
  }

Here is the caller graph for this function:

bool creaImageIO::SQLiteTreeHandler::Create ( bool  writable = false  )  [virtual]

Creates a new 'source'.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 53 of file creaImageIOSQLiteTreeHandler.cpp.

References DBCreate(), and SetWritable().

Referenced by creaImageIO::Gimmick::createDB().

  {
    //    std::cout << "***> SQLiteTreeHandler::New('"<<GetFileName()<<"')"<<std::endl;
    SetWritable(writable);
    return DBCreate();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool creaImageIO::SQLiteTreeHandler::DBCreate (  )  [protected]

Creates a new database on disk and the tables.

Definition at line 265 of file creaImageIOSQLiteTreeHandler.cpp.

References creaImageIO::tree::Descriptor::Add(), creaImageIO::tree::Tree::CopyAttributeDescriptorList(), DBInsert(), CppSQLite3Exception::errorCode(), CppSQLite3Exception::errorMessage(), CppSQLite3DB::execDML(), creaImageIO::tree::Tree::GetAttributeDescriptorList(), creaImageIO::tree::Tree::GetDescriptor(), GetFileName(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::tree::LevelDescriptor::GetName(), creaImageIO::tree::Tree::GetNumberOfLevels(), creaImageIO::TreeHandler::GetTree(), GimmickError, GimmickMessage, creaImageIO::tree::Node::InitializeAttributeMap(), mDB, CppSQLite3DB::open(), creaImageIO::tree::AttributeDescriptor::PRIVATE, creaImageIO::tree::Node::SetChildrenLoaded(), SQLAppendAttributesDefinition(), and UPDATEDB.

Referenced by Create().

  {
    GimmickMessage(1,"Creating SQLite database '"<<GetFileName()
                   <<"' ... "<<std::endl);

    if (boost::filesystem::exists(GetFileName())) 
      {
        GimmickError(GetFileName()<<"' : "
                     << "file already exists");
        return false;
      }
    
    // OPENING
    try
      {
        mDB->open(GetFileName().c_str());
      }
    catch (CppSQLite3Exception& e)
      {
        GimmickError(e.errorCode() << ":" 
                     << e.errorMessage() <<std::endl);
        return false;
      }
    mDB->execDML("pragma synchronous=off;");
     
    // CREATING TABLES
    
    std::string command;
    // Create LEVELS table
    command = "create table LEVELS\n";
    command += "( Name text )\n";
    UPDATEDB(command);
    int l;
    // Iterate the Levels
    for (l=0; l<GetTree().GetNumberOfLevels(); l++)
      {
        command = "INSERT INTO LEVELS (Name) VALUES ('";
        command += GetTree().GetLevelDescriptor(l).GetName();
        command += "')";
        UPDATEDB(command);
        
        // Create table of level (for level>0, i.e. not Root)
        if (l>=0)
          {
            command = "CREATE TABLE ";
            command += GetTree().GetLevelDescriptor(l).GetName();
            command += "\n(\nID INTEGER PRIMARY KEY";
            if (l>1) 
              {
                command += ",\nPARENT_ID int not null"; 
              }
            SQLAppendAttributesDefinition(l,command);
            if (l>1) 
              {
                command += ",\nconstraint FK_PARENT foreign key (PARENT_ID) references ";
                command += GetTree().GetLevelDescriptor(l-1).GetName();
                command += "(ID) on delete restrict on update restrict";
              }
            command += "\n)";
            UPDATEDB(command);
            
                GetTree().CopyAttributeDescriptorList(l);
            
            // Add Attribute 'ID' to Description
            GetTree().GetDescriptor().Add
              (AttributeDescriptor( "ID",
                                    "Database Identifier",
                                    0,0,
                                    AttributeDescriptor::PRIVATE
                                    ),l);
            
            if (l>1) 
              {
                // Add Attribute 'PARENT_ID' to Description
                GetTree().GetDescriptor().Add
                  (AttributeDescriptor( "PARENT_ID",
                                        "Database Parent Identifier",
                                        0,0,
                                        AttributeDescriptor::PRIVATE
                                        ),l);
              }
            
          }
        
        // Create table *_ATTRIBUTES
        
        command = "CREATE TABLE ";
        command += GetTree().GetLevelDescriptor(l).GetName();
        command += "_Attributes\n(\n";
        command += "Key text,\n";
        command += "Name text,\n";          
        command += "DicomGroup int,\n";
        command += "DicomElement int,\n";           
        command += "Flags int\n";           
        command += "\n)";
        UPDATEDB(command);

        // Fill the table *_ATTRIBUTES
        LevelDescriptor::AttributeDescriptorListType::const_iterator i;
        for (i  = GetTree().GetAttributeDescriptorList(l).begin();
             i != GetTree().GetAttributeDescriptorList(l).end();
             ++i)
          {
            
            std::stringstream insert;
            insert << "INSERT INTO "
                   << GetTree().GetLevelDescriptor(l).GetName()
                   << "_Attributes (Key,Name,DicomGroup,DicomElement,Flags) "
                   << "VALUES ('"
                   << i->GetKey() << "','"
                   << i->GetName() << "',"
                   << i->GetGroup() << ","
                   << i->GetElement() << ","
                   << i->GetFlags() << ");";
            UPDATEDB(insert.str());
          }

      } // For l=0...

    // Initialize the root attributes
    GetTree().InitializeAttributeMap();
    // Insert the root in the level 0 table 
    DBInsert(GetTree().GetTree());
    
    
    GetTree().SetChildrenLoaded(true);
    GimmickMessage(1,"Creating SQLite database '"<<GetFileName()
                   <<"' ... OK"<<std::endl);
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::DBDelete ( std::string  levelDescriptor,
std::string  key,
std::string  value 
) [protected]

Deletes the tuple that matches the value specified in the given key and that belongs to the given level.

Definition at line 867 of file creaImageIOSQLiteTreeHandler.cpp.

References GimmickDebugMessage, and UPDATEDB.

Referenced by DBRecursiveRemoveNode(), and DeleteTuple().

  {
       
    std::stringstream query;
        query<<"DELETE FROM "<<levelDescriptor<<" WHERE "<<key<<"='"<<value<<"';";
 
    UPDATEDB(query.str());
        GimmickDebugMessage(2," Deleting: Query: "<<query.str()<<std::endl);
  }

Here is the caller graph for this function:

tree::Node * creaImageIO::SQLiteTreeHandler::DBGetParent ( const AttributeMapType attr  )  [protected]

Returns the parent to which the branch defined by the attributes.

Definition at line 592 of file creaImageIOSQLiteTreeHandler.cpp.

References DBLoadChildren(), creaImageIO::tree::Node::GetChildrenList(), creaImageIO::tree::Tree::GetTree(), and creaImageIO::TreeHandler::GetTree().

Referenced by AddBranch().

  {
    Node* parent = GetTree().GetTree();
    bool go_down;
    do 
      {
        go_down = false;
        // Load the children of the current parent
        DBLoadChildren(parent);
        // Iterate the children 
        tree::Node::ChildrenListType::const_iterator i;
        for (i = parent->GetChildrenList().begin();
             i!= parent->GetChildrenList().end();
             ++i)
          {
            if ( (*i)->Matches( attr ) ) 
              {
                go_down = true;
                parent = *i;
                break;
              }
          }     
      }
    while (go_down);
    return parent;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::DBGraftToParent ( tree::Node parent,
const AttributeMapType attr 
) [protected]

Graft the branch defined by the attributes to the parent.

Definition at line 722 of file creaImageIOSQLiteTreeHandler.cpp.

References DBInsert(), creaImageIO::tree::Node::GetAttribute(), creaImageIO::tree::Node::GetLevel(), GetNumberOfChildren(), creaImageIO::tree::Tree::GetNumberOfLevels(), creaImageIO::TreeHandler::GetTree(), creaImageIO::tree::Node::SetAttribute(), SetAttribute(), and creaImageIO::tree::Node::SetChildrenLoaded().

Referenced by AddBranch().

  {
    //    std::cout <<"Grafting to parent '"<<parent->GetLabel()
    //             <<"'"<<std::endl;

    for (int level = parent->GetLevel()+1;
         level < GetTree().GetNumberOfLevels();
         level++)
      {
        // Create Node
        tree::Node* child = new tree::Node(parent,attr);
        child->SetChildrenLoaded(true);
        if (level>1)
          {
            int nc = GetNumberOfChildren(parent)+1;
            
            //  std::cout<<"Number of children "<<parent->GetNumberOfChildren()<<std::endl;
            std::stringstream out;
            out << nc;
            SetAttribute(parent,"NumberOfChildren",out.str());
          }

        // Set PARENT_ID if necessary 
        if ( parent->GetLevel()>0 )
          child->SetAttribute("PARENT_ID",parent->GetAttribute("ID"));
        
        // Insert in DB
        DBInsert(child);
        
        // Down one level
        parent = child;
          }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool creaImageIO::SQLiteTreeHandler::DBImportTreeDescription (  )  [protected]

Import the Tree::Description from database (verifies the structure).

Definition at line 416 of file creaImageIOSQLiteTreeHandler.cpp.

References creaImageIO::tree::Descriptor::Add(), creaImageIO::tree::Descriptor::Clear(), creaImageIO::tree::Tree::CopyAttributeDescriptorList(), CppSQLite3Query::eof(), CppSQLite3Query::fieldName(), creaImageIO::tree::Tree::GetAttributeDescriptorList(), creaImageIO::tree::Tree::GetDescriptor(), CppSQLite3Query::getIntField(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::tree::LevelDescriptor::GetName(), CppSQLite3Query::getStringField(), creaImageIO::TreeHandler::GetTree(), GimmickMessage, mDB, CppSQLite3Query::nextRow(), CppSQLite3Query::numFields(), QUERYDB, CppSQLite3DB::tableExists(), and creaImageIO::tree::Node::UnsafeSetAttribute().

Referenced by DBOpen().

  {
    GimmickMessage(1,"Importing tree description for database ..."
                   <<std::endl);

    // Test table 'LEVELS' existence
    if ( ! mDB->tableExists("LEVELS") )
      {
        GimmickMessage(1,"!! ERROR : Table 'LEVELS' does not exist"
                       <<std::endl);
        return false;
      }

    tree::Descriptor& desc = GetTree().GetDescriptor();
    // clears the existing one
    desc.Clear();
     
    int nblevel = 0;
    std::string query = "SELECT * FROM LEVELS";
    CppSQLite3Query q;
    QUERYDB(query,q);

    while (!q.eof())
      {
        std::string name = q.getStringField(0);
        GimmickMessage(2," * Importing level '"<<name<<"'"<<std::endl);
        desc.Add(LevelDescriptor(name));
        nblevel++;
        q.nextRow();
      }   
    
    for (int level = 0; level < nblevel; ++level )
      {
        std::string table = GetTree().GetLevelDescriptor(level).GetName();
        table += "_Attributes";
        // Test table 'LEVELS' existence
        if ( ! mDB->tableExists(table.c_str()) )
          {
            GimmickMessage(1,"!! ERROR : Table '"<<table<<"' does not exist"
                           <<std::endl);
            return false;
          }
        
        std::string query = "SELECT * FROM ";
        query += table;
        CppSQLite3Query q;
        QUERYDB(query,q);
        
        GimmickMessage(2," * Level '"
                       <<GetTree().GetLevelDescriptor(level).GetName()
                       <<"'"<<std::endl);

        // Test that ID and PARENT_ID mandatory attributes exist
        bool ID_found = false;
        bool PARENT_ID_found = false;
        if (level==0) ID_found = true;
        if (level<=1) PARENT_ID_found = true;

        while (!q.eof())
          {
            std::string key(q.getStringField(0));
            std::string name(q.getStringField(1));
            GimmickMessage(2,"  - Importing attribute '"<<key<<"' '"<<name
                           <<"'"<<std::endl);
            desc.Add
              (AttributeDescriptor( key, // Key
                                    name, // Name
                                    q.getIntField(2), // Group
                                    q.getIntField(3), // Element 
                                    q.getIntField(4) // Flags
                                    ),level);
            if ( key == "ID" ) 
              {
                ID_found = true;
              }
            if ( key == "PARENT_ID" ) 
              {
                PARENT_ID_found = true;
              }
            q.nextRow();
          }
        
        if ( ! (ID_found || PARENT_ID_found ) )
          {
            GimmickMessage(1,"!! ERROR : Table '"<<table
                           <<"' does not contain mandatory attribute ID or PARENT_ID"
                           <<std::endl);
            return false;
 
          }
                 GetTree().CopyAttributeDescriptorList(level);
      }

        
    // Create the attributes table for Root (i.e. Tree)
    LevelDescriptor::AttributeDescriptorListType::const_iterator a;
    for (a = GetTree().GetAttributeDescriptorList(0).begin();
         a!= GetTree().GetAttributeDescriptorList(0).end();
         ++a)
      {

        GetTree().UnsafeSetAttribute( a->GetKey(), "" );
      }

    // Reading Root attributes
    // Query DB
    query = "SELECT * FROM ";
    query += GetTree().GetLevelDescriptor(0).GetName();
    QUERYDB(query,q);

    for (int fld = 0; fld < q.numFields(); fld++)
      {
        GetTree().UnsafeSetAttribute(q.fieldName(fld),
                                     q.getStringField(fld));        
      }

    GimmickMessage(1,"Importing tree description from database ... OK"
                   <<std::endl);
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::DBInsert ( tree::Node n  )  [protected]

Inserts the Node in the database.

Definition at line 700 of file creaImageIOSQLiteTreeHandler.cpp.

References creaImageIO::tree::Node::GetLabel(), creaImageIO::tree::Node::GetLevel(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::TreeHandler::GetTree(), GimmickMessage, CppSQLite3DB::lastRowId(), mDB, creaImageIO::tree::Node::SetAttribute(), SQLAppendAttributesValues(), and UPDATEDB.

Referenced by DBCreate(), and DBGraftToParent().

  {
    GimmickMessage(2,"Inserting in DB '"<<n->GetLabel()
                   <<"'"<<std::endl);
    std::string val;
    SQLAppendAttributesValues(n,val);
    std::string insert("INSERT INTO ");
    insert += GetTree().GetLevelDescriptor(n->GetLevel()).GetName();
    insert += " " + val + ";";

    UPDATEDB(insert);
        
    // Store DB id of newly created node;
    long lastrow = mDB->lastRowId();
    std::stringstream ri;
    ri << mDB->lastRowId();
    n->SetAttribute("ID",ri.str());
  }

Here is the call graph for this function:

Here is the caller graph for this function:

int creaImageIO::SQLiteTreeHandler::DBLoadChildren ( tree::Node parent,
int  numberoflevels = 1 
) [protected]

Loads the children of Node parent.

If children not loaded : do it and recurse

Definition at line 621 of file creaImageIOSQLiteTreeHandler.cpp.

References CppSQLite3Query::eof(), CppSQLite3Query::fieldName(), creaImageIO::tree::Node::GetAttribute(), creaImageIO::tree::Node::GetChildrenList(), creaImageIO::tree::Node::GetChildrenLoaded(), creaImageIO::tree::Node::GetLabel(), creaImageIO::tree::Node::GetLevel(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::tree::LevelDescriptor::GetName(), creaImageIO::tree::Tree::GetNumberOfLevels(), CppSQLite3Query::getStringField(), creaImageIO::TreeHandler::GetTree(), creaImageIO::tree::Node::GetTree(), GimmickDebugMessage, GimmickMessage, CppSQLite3Query::nextRow(), CppSQLite3Query::numFields(), QUERYDB, creaImageIO::tree::Node::SetChildrenLoaded(), and creaImageIO::tree::Node::UnsafeSetAttribute().

Referenced by DBGetParent(), and LoadChildren().

  {
    if (node->GetLevel()+1 >= node->GetTree()->GetNumberOfLevels() ) 
      return 0;

    GimmickMessage(2,"Loading children of '"<<node->GetLabel()
                   <<"'"<<std::endl);

    int nbloaded = 0;
    // If children loaded we do not have to do it but we need to recurse
    // in order to load the children's children if necessary, and so on...
    if (node->GetChildrenLoaded()) 
      {
        // Iterate the children 

        tree::Node::ChildrenListType::iterator i;
        for (i = node->GetChildrenList().begin();
             i!= node->GetChildrenList().end();
             ++i)
          {
            nbloaded += DBLoadChildren(*i,numberoflevels-1);
          }
        node->SetChildrenLoaded(true);
        return nbloaded;

      }
        else
        {

    // Query DB
    int level = node->GetLevel();
    std::string query = "SELECT * FROM ";
        
    query += GetTree().GetLevelDescriptor(level+1).GetName();
    if (level>0)
      {
        query += " WHERE PARENT_ID='" + node->GetAttribute("ID") 
          + "'";
      }
GimmickDebugMessage(1,                                  "query : '"                         <<query                                         <<std::endl);
    CppSQLite3Query q;
    QUERYDB(query,q);

        int p=0;
    while (!q.eof())
      {

        //      std::cout << "DBLoadCh : creating node level "<<level+1<<std::endl;

        nbloaded++;
        Node* n = new Node(node);
        for (int fld = 0; fld < q.numFields(); fld++)
          {
            n->UnsafeSetAttribute(q.fieldName(fld),q.getStringField(fld));          
          }

        // recurse 
        if ( numberoflevels != 1 ) 
          {
            //  msw[2].Pause();
            nbloaded += DBLoadChildren(n, numberoflevels-1);
            //      msw[2].Resume();
          }
        // next entry in db
        q.nextRow();
      }

    node->SetChildrenLoaded(true);
        
    
    //    msw[2].Pause();
    return nbloaded;
        }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool creaImageIO::SQLiteTreeHandler::DBOpen (  )  [protected]

Open the database.

Definition at line 230 of file creaImageIOSQLiteTreeHandler.cpp.

References DBImportTreeDescription(), CppSQLite3Exception::errorCode(), CppSQLite3Exception::errorMessage(), CppSQLite3DB::execDML(), GetFileName(), GimmickDebugMessage, GimmickError, GimmickMessage, mDB, and CppSQLite3DB::open().

Referenced by Open().

  {
    GimmickMessage(1,"Opening SQLite database '"<<GetFileName()
                   <<"' ... "<<std::endl);
    // OPENING FILE
    if (!boost::filesystem::exists(GetFileName())) 
      {
        return false;
      }

    try
      {
        mDB->open(GetFileName().c_str());
        mDB->execDML("pragma synchronous=off;");
      }
    catch (CppSQLite3Exception& e)
      {
        GimmickError("Opening '"<<GetFileName()<<"' : "
                     << e.errorCode() << ":" 
                     << e.errorMessage());
        return false;
      }
    // IMPORT TREE DESCRIPTION (AND TEST DB VALIDITY)
    if (!DBImportTreeDescription())
      {
        return false;
      }

    GimmickDebugMessage(1,"Opening SQLite database '"<<GetFileName()
                   <<"' ... OK"<<std::endl);
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::DBRecursiveRemoveNode ( tree::Node node  )  [protected]

Recursively Removes the nodes whose parent is given as a parameter.

Definition at line 807 of file creaImageIOSQLiteTreeHandler.cpp.

References creaImageIO::tree::Node::GetAttribute(), creaImageIO::tree::Node::GetChildrenList(), creaImageIO::tree::Node::GetLevel(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::tree::Node::GetNumberOfChildren(), creaImageIO::tree::Tree::GetNumberOfLevels(), creaImageIO::TreeHandler::GetTree(), and UPDATEDB.

Referenced by DBRecursiveRemoveNode(), and Remove().

  {
       
    std::string query = "DELETE FROM ";
        query += GetTree().GetLevelDescriptor(node->GetLevel()).GetName();
    query += " WHERE ID='"+ node->GetAttribute("ID") + "';";
        UPDATEDB(query);
        
        if(node->GetNumberOfChildren()!=0)
        {
                Node::ChildrenListType::iterator i;
                for (i  = node->GetChildrenList().begin();
                i != node->GetChildrenList().end();
                i++)
                {
                DBRecursiveRemoveNode((*i));
                }
        }
        else if(node->GetLevel()<GetTree().GetNumberOfLevels()-1)
        {
                DBRecursiveRemoveNode(node->GetLevel()+1,node->GetAttribute("ID"));
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::DBRecursiveRemoveNode ( int  level,
std::string  parentId 
) [protected]

Recursively Removes the nodes found in the given level with the given parent id.

Definition at line 832 of file creaImageIOSQLiteTreeHandler.cpp.

References DBDelete(), DBRecursiveRemoveNode(), CppSQLite3Query::eof(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::tree::LevelDescriptor::GetName(), creaImageIO::tree::Tree::GetNumberOfLevels(), CppSQLite3Query::getStringField(), creaImageIO::TreeHandler::GetTree(), CppSQLite3Query::nextRow(), CppSQLite3Query::numFields(), and QUERYDB.

  {
    std::stringstream out;
        std::stringstream result;
        out<<"SELECT ID FROM "<<GetTree().GetLevelDescriptor(level).GetName()<<" WHERE PARENT_ID='"<<parentId<<"'";
                
        CppSQLite3Query q;
        QUERYDB(out.str(),q);
        
        while (!q.eof())
          {
            for (int fld = 0; fld < q.numFields(); fld++)
              {
                          result<<q.getStringField(fld)<<"#";
              }
            q.nextRow();
          }
          std::string res=result.str();
          size_t ini=0;
          size_t fin=0;
          while(fin<res.size()-1)
          {
           fin=res.find('#',ini);
           DBDelete(GetTree().GetLevelDescriptor(level).GetName(),"ID",res.substr(ini,fin-ini));
          if(level<GetTree().GetNumberOfLevels()-1)
          {
                DBRecursiveRemoveNode(level+1,res.substr(ini,fin-ini));
          } 
           ini=fin+1;
          }
          
    
  }

Here is the call graph for this function:

bool creaImageIO::SQLiteTreeHandler::DBSetAttribute ( tree::Node n,
const std::string &  key,
const std::string &  value 
) [protected]

Sets an attribute of a Node and updates the database.

Sets an attribute of a Node.

Definition at line 761 of file creaImageIOSQLiteTreeHandler.cpp.

References convert(), creaImageIO::tree::Node::GetAttribute(), creaImageIO::tree::Node::GetLabel(), creaImageIO::tree::Node::GetLevel(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::TreeHandler::GetTree(), GimmickMessage, creaImageIO::tree::Node::SetAttribute(), and UPDATEDB.

Referenced by SetAttribute().

  {
    GimmickMessage(3,"Setting Attribute of '"<<n->GetLabel()<<
                   "' "<<key<<"='"<<value<<"'"<<std::endl);

    n->SetAttribute(key,value);
    std::string sql = "UPDATE ";
    sql += GetTree().GetLevelDescriptor(n->GetLevel()).GetName();
    sql += " SET ";
    sql += key;
    sql += " = '";
    sql += convert(value);
    sql += "' WHERE ID = '";
    sql += n->GetAttribute("ID");
        sql +="'";
    //    sql += " LIMIT 1";
    UPDATEDB(sql);
        return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::DBSetAttribute ( const std::string &  levelDescriptor,
const std::string &  key,
const std::string &  value,
const std::string &  searchParam,
const std::string &  searchVal 
) [protected]

Sets an attribute and updates the database.

Sets an attribute of a Node.

Definition at line 785 of file creaImageIOSQLiteTreeHandler.cpp.

References UPDATEDB.

  {

    std::string sql = "UPDATE ";
    sql += levelDescriptor;
    sql += " SET ";
    sql += key;
    sql += " = '";
    sql += value;
    sql += "' WHERE ";
        sql += searchParam;
        sql += " = '";
    sql += searchVal;
        sql += "'";
        std::cout<<sql<<std::endl;
    UPDATEDB(sql);
  }

void creaImageIO::SQLiteTreeHandler::DeleteTuple ( std::string  levelDescriptor,
std::string  key,
std::string  value 
) [virtual]

Deletes a tuple.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 163 of file creaImageIOSQLiteTreeHandler.cpp.

References DBDelete().

  {
    DBDelete(levelDescriptor,key,value);
  }

Here is the call graph for this function:

bool creaImageIO::SQLiteTreeHandler::Destroy (  )  [virtual]

Destroys the 'source'.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 71 of file creaImageIOSQLiteTreeHandler.cpp.

  {
    return false;
  }

void creaImageIO::SQLiteTreeHandler::EndTransaction (  )  [virtual]

Commits results and ends transaction.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 1102 of file creaImageIOSQLiteTreeHandler.cpp.

References UPDATEDB.

    {
       std::stringstream out;
                out<<"commit transaction;";
        UPDATEDB(out.str());
        }

void creaImageIO::SQLiteTreeHandler::getAllAttributes ( std::string  i_filename,
std::map< std::string, std::string > &  i_results 
) [virtual]

get all attributes from database for a given file

Implements creaImageIO::TreeHandler.

Definition at line 952 of file creaImageIOSQLiteTreeHandler.cpp.

References creaImageIO::tree::Tree::GetAttributeDescriptorList(), GetAttributes(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::tree::LevelDescriptor::GetName(), creaImageIO::tree::Tree::GetNumberOfLevels(), creaImageIO::TreeHandler::GetTree(), and GetUpLevelNodeId().

  {
          int level=GetTree().GetNumberOfLevels()-1;
          
          std::string search = i_filename;
          std::string param = "FullFileName";
          std::string name;

          std::string id;
          std::set<std::string> pid;
          std::vector<AttributeDescriptor> attr;
          std::vector<AttributeDescriptor>::iterator it_attr;
          std::vector<std::string> values;
          std::vector<std::string>::iterator it_val;
         


          
          while(level>1)
          {
                  attr = GetTree().GetAttributeDescriptorList(level,1);

                  name = GetTree().GetLevelDescriptor(level).GetName();
                  std::vector<std::string> values;
                  GetUpLevelNodeId(level, param,search,id);
                  GetAttributes(name, param,search,attr, values);
                  for(it_attr = attr.begin(), it_val = values.begin(); it_attr != attr.end(); it_attr++, it_val++)
                  {
                                        i_results[(*it_attr).GetKey()] = (*it_val).c_str();
                  }
                  search = id;
                  param = "ID";
                  level --;
          }
  }

Here is the call graph for this function:

void creaImageIO::SQLiteTreeHandler::GetAttribute ( std::string  levelDescriptor,
std::string  searchParam,
std::string  searchVal,
std::string  key,
std::string &  result 
) [virtual]

Returns the attribute requested. Useful for synchronization.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 879 of file creaImageIOSQLiteTreeHandler.cpp.

References CppSQLite3Query::eof(), CppSQLite3Query::getStringField(), CppSQLite3Query::nextRow(), CppSQLite3Query::numFields(), and QUERYDB.

  { 
        std::stringstream out;
        std::stringstream results;
        out<<"SELECT "<<key<<" FROM "<<levelDescriptor;
        if(searchParam!="")
        {
                out<<" WHERE "<<searchParam<<"='"<<searchVal<<"'";
        }
        
        CppSQLite3Query q;
        QUERYDB(out.str(),q);
        
        
        while (!q.eof())
          {
            for (int fld = 0; fld < q.numFields(); fld++)
              {
                          results<<q.getStringField(fld);
                          if(searchParam=="")
                          {
                                  results<<"#";
                          }
              }
            q.nextRow();
          }
        result=results.str();
      
  }

Here is the call graph for this function:

void creaImageIO::SQLiteTreeHandler::GetAttributes ( std::string  name,
std::string  i_id,
std::string  i_value,
tree::LevelDescriptor::AttributeDescriptorListType  i_attr,
std::vector< std::string > &  i_results 
)

get selected attributes from database for a given file

Definition at line 991 of file creaImageIOSQLiteTreeHandler.cpp.

References CppSQLite3Query::eof(), CppSQLite3Query::getStringField(), CppSQLite3Query::nextRow(), CppSQLite3Query::numFields(), and QUERYDB.

Referenced by getAllAttributes().

         {
                 //SELECT t1.ArtistName,CDs.Title FROM Artists t1, CDs WHERE t1.ArtistID=CDs.ArtistID    
                  std::stringstream out;
                  std::stringstream results;
                  out<<"SELECT ";
                  tree::LevelDescriptor::AttributeDescriptorListType::iterator it = i_attr.begin();
                  std::string query ="";
                  for(; it != i_attr.end(); it++)
                  {
                          query += (*it).GetKey();
                          query +=" ,";
                  }
                  query = query.substr(0, query.size()-1);
                  out << query;
                  out << "FROM "<<name;
                  out<<" WHERE "<<i_id <<"='"<<i_value<<"'";    
                  CppSQLite3Query q;
                  QUERYDB(out.str(),q);
                  while (!q.eof())
                  {
                        for (int fld = 0; fld < q.numFields(); fld++)
                        {
                                i_results.push_back(q.getStringField(fld));
                        }
                        q.nextRow();
                  }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& creaImageIO::SQLiteTreeHandler::GetFileName (  )  const [inline]

Returns the sqlite db file name.

Definition at line 30 of file creaImageIOSQLiteTreeHandler.h.

References mFileName.

Referenced by DBCreate(), and DBOpen().

{ return mFileName; }

Here is the caller graph for this function:

unsigned int creaImageIO::SQLiteTreeHandler::GetNumberOfChildren ( tree::Node n  )  [virtual]

Returns the number of children of the Node *WITHOUT LOADING THEM*.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 913 of file creaImageIOSQLiteTreeHandler.cpp.

References CppSQLite3Query::eof(), creaImageIO::tree::Node::GetAttribute(), CppSQLite3Query::getIntField(), creaImageIO::tree::Node::GetLevel(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::tree::LevelDescriptor::GetName(), creaImageIO::TreeHandler::GetTree(), CppSQLite3Query::nextRow(), CppSQLite3Query::numFields(), and QUERYDB.

Referenced by DBGraftToParent().

  { 
    // Query DB
    int nb=0;
    int level = n->GetLevel();

    if(level<GetTree().GetNumberOfLevels()&& level>0)
      {
        std::string query = "SELECT NumberOfChildren FROM ";
        query += GetTree().GetLevelDescriptor(level).GetName();
        if (level>0)
          {
            query += " WHERE ID='" + n->GetAttribute("ID") 
              + "'";
          }
        CppSQLite3Query q;
        QUERYDB(query,q);
        
        
        while (!q.eof())
          {
            for (int fld = 0; fld < q.numFields(); fld++)
              {
                nb=q.getIntField(fld);  
              }
            q.nextRow();
          }
      }
    /*
    if(nb==0)
      { 
        nb=1;
      }
    */
    return nb; 
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::GetTopLevelNodeId ( const std::string &  searchParam,
const std::string &  searchValue,
std::string &  parent_id 
) [virtual]

====================================================================

Returns the top level node id for the given search param and search value

*

Reimplemented from creaImageIO::TreeHandler.

Definition at line 1044 of file creaImageIOSQLiteTreeHandler.cpp.

References creaImageIO::tree::Tree::GetNumberOfLevels(), creaImageIO::TreeHandler::GetTree(), and GetUpLevelNodeId().

  {
          int level=GetTree().GetNumberOfLevels()-1;
          std::string sp=searchParam.c_str();
          std::string sv=searchValue.c_str();

          while(level>1)
          {
                GetUpLevelNodeId(level, sp, sv, parent_id);
                level--;
                sp = "ID";
                sv = parent_id;
          }
//              std::stringstream out;
//              std::stringstream results;
//              out<<"SELECT PARENT_ID FROM "<<GetTree().GetLevelDescriptor(level).GetName();
//              out<<" WHERE "<<sp<<"='"<<sv<<"'";      
//              CppSQLite3Query q;
//              QUERYDB(out.str(),q);
//              
//              
//              while (!q.eof())
//              {
//                      for (int fld = 0; fld < q.numFields(); fld++)
//                      {
//                              results<<q.getStringField(fld);
//                      }
//                      q.nextRow();
//              }*/
//              level=level-1;
//              sp="ID";
//              sv=results.str();
//        }
//        parent_id=sv;

  }

Here is the call graph for this function:

const tree::Tree& creaImageIO::TreeHandler::GetTree (  )  const [inline, inherited]

Returns the Tree handled (const).

Definition at line 38 of file creaImageIOTreeHandler.h.

References creaImageIO::TreeHandler::mTree.

{ return mTree; }

tree::Tree& creaImageIO::TreeHandler::GetTree (  )  [inline, inherited]
void creaImageIO::SQLiteTreeHandler::GetUpLevelNodeId ( int  level,
const std::string &  searchParam,
const std::string &  searchValue,
std::string &  parent_id 
)

get Id for the up level node

Definition at line 1020 of file creaImageIOSQLiteTreeHandler.cpp.

References CppSQLite3Query::eof(), creaImageIO::tree::Tree::GetLevelDescriptor(), creaImageIO::tree::LevelDescriptor::GetName(), CppSQLite3Query::getStringField(), creaImageIO::TreeHandler::GetTree(), CppSQLite3Query::nextRow(), CppSQLite3Query::numFields(), and QUERYDB.

Referenced by getAllAttributes(), and GetTopLevelNodeId().

   {
          std::string sp=searchParam.c_str();
          std::string sv=searchValue.c_str();
          std::stringstream out;
          std::stringstream results;
          out<<"SELECT PARENT_ID FROM "<<GetTree().GetLevelDescriptor(level).GetName();
          out<<" WHERE "<<sp<<"='"<<sv<<"'";    
          CppSQLite3Query q;
          QUERYDB(out.str(),q);
          while (!q.eof())
          {
                for (int fld = 0; fld < q.numFields(); fld++)
                {
                        results<<q.getStringField(fld);
                }
                q.nextRow();
          }
          parent_id = results.str();

  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool creaImageIO::SQLiteTreeHandler::GetWritable (  )  const [inline, private]

Definition at line 236 of file creaImageIOSQLiteTreeHandler.h.

References mWritable.

{ return mWritable; }

virtual bool creaImageIO::SQLiteTreeHandler::IsReadable (  )  [inline, virtual]

Is the 'source' readable ?

Reimplemented from creaImageIO::TreeHandler.

Definition at line 36 of file creaImageIOSQLiteTreeHandler.h.

{ return true; }

virtual bool creaImageIO::SQLiteTreeHandler::IsWritable (  )  [inline, virtual]

Is the 'source' writable ?

Reimplemented from creaImageIO::TreeHandler.

Definition at line 38 of file creaImageIOSQLiteTreeHandler.h.

{ return true; }

int creaImageIO::SQLiteTreeHandler::LoadChildren ( tree::Node parent,
int  maxlevel 
) [virtual]

Recursively loads the children of node 'parent' until maxlevel.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 79 of file creaImageIOSQLiteTreeHandler.cpp.

References DBLoadChildren(), creaImageIO::tree::Tree::GetTree(), and creaImageIO::TreeHandler::GetTree().

  {      
        //mDB->execDML("PRAGMA synchronous=ON ");
    if (parent==0) parent = GetTree().GetTree();
    return DBLoadChildren(parent,maxlevel);
  }

Here is the call graph for this function:

bool creaImageIO::SQLiteTreeHandler::Open ( bool  writable = false  )  [virtual]

Opens an existing 'source'.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 44 of file creaImageIOSQLiteTreeHandler.cpp.

References DBOpen(), and SetWritable().

Referenced by creaImageIO::Gimmick::createDB().

  {

          //sqlite3_exec(mDB, "PRAGMA synchronous=OFF ", NULL, 0, &errMsg); 
    SetWritable(writable);
    return DBOpen();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool creaImageIO::SQLiteTreeHandler::Remove ( tree::Node  )  [virtual]

Removes the node and its descendants.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 108 of file creaImageIOSQLiteTreeHandler.cpp.

References DBRecursiveRemoveNode(), creaImageIO::tree::Node::GetLevel(), creaImageIO::tree::Node::GetParent(), creaImageIO::tree::Node::RemoveChildrenFromList(), and SetAttribute().

   {
   DBRecursiveRemoveNode(node);
 
    //    std::cout << "DELETE"<<std::endl;
   bool remove=false;
   tree::Node* parent=node->GetParent();
    if (parent)
      {
        int nC = parent->RemoveChildrenFromList(node);
        if(nC>0 && parent->GetLevel()>0)
        {       
                std::stringstream out;
                out <<nC;
                SetAttribute(parent,"NumberOfChildren",out.str());
        }
        else
        {
                remove=true;
        }

      }
    delete node;
        if(remove&&parent->GetLevel()>0)
        {
                Remove(parent);
        }
    //    std::cout << "DELETE OK"<<std::endl;
    return true;
   }

Here is the call graph for this function:

void creaImageIO::SQLiteTreeHandler::RemoveEntries ( const std::string  i_table,
const std::string  i_attribute,
const std::string  i_operand,
const std::string  i_val 
) [virtual]

Reimplemented from creaImageIO::TreeHandler.

Definition at line 1083 of file creaImageIOSQLiteTreeHandler.cpp.

References UPDATEDB.

    {
        std::stringstream query;
                query<<"DELETE  FROM "<<i_table<<" WHERE "<<i_attribute<<" "<<i_operand<<" '"<<i_val<<"'";
        UPDATEDB(query.str());
        }

void creaImageIO::SQLiteTreeHandler::SetAttribute ( const std::string &  levelDescriptor,
const std::string &  key,
const std::string &  value,
const std::string &  searchParam,
const std::string &  searchVal 
) [virtual]

Sets an attribute.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 153 of file creaImageIOSQLiteTreeHandler.cpp.

References DBSetAttribute().

  {
        DBSetAttribute(levelDescriptor,key,value,searchParam, searchVal);
  }

Here is the call graph for this function:

bool creaImageIO::SQLiteTreeHandler::SetAttribute ( tree::Node n,
const std::string &  key,
const std::string &  value 
) [virtual]

Sets an attribute of a Node.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 143 of file creaImageIOSQLiteTreeHandler.cpp.

References DBSetAttribute(), creaImageIO::tree::Tree::GetTree(), and creaImageIO::TreeHandler::GetTree().

Referenced by creaImageIO::Gimmick::createDB(), DBGraftToParent(), and Remove().

  {
    if (n==0) n=GetTree().GetTree();
    return DBSetAttribute(n,key,value);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::SetWritable ( bool  w  )  [inline, private]

Definition at line 235 of file creaImageIOSQLiteTreeHandler.h.

References mWritable.

Referenced by Create(), and Open().

{ mWritable = w; }

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::SQLAppendAttributesDefinition ( int  level,
std::string &  s 
) [protected]

Appends to string s the SQL command to create the attributes of a given level.

Definition at line 398 of file creaImageIOSQLiteTreeHandler.cpp.

References creaImageIO::tree::Tree::GetAttributeDescriptorList(), and creaImageIO::TreeHandler::GetTree().

Referenced by DBCreate().

  {
    LevelDescriptor::AttributeDescriptorListType::const_iterator i;
    for (i  = GetTree().GetAttributeDescriptorList(level).begin();
         i != GetTree().GetAttributeDescriptorList(level).end();
         ++i)
      {
        //      if (i->second.flags==1) continue;
        s += ",\n";
        s += i->GetKey();
        s += " text";
      }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::SQLAppendAttributesValues ( tree::Node n,
std::string &  s 
) [protected]

Appends to string s the SQL command to set the attributes values.

Definition at line 559 of file creaImageIOSQLiteTreeHandler.cpp.

References creaImageIO::tree::Node::GetAttributeMap(), GimmickMessage, and creaImageIO::SQLformat().

Referenced by DBInsert().

  {
    GimmickMessage(4,"SQLAppendAttributesValues"<<std::endl);
    std::string atts="";
    std::string values="";
        std::string out ="";
    tree::Node::AttributeMapType::iterator i;
    for (i =  n->GetAttributeMap().begin();
         i != n->GetAttributeMap().end();
         i++)
      {
        if (i->first=="ID") 
          {
            continue;
          }

        atts += "'" + i->first + "'";
        SQLformat(i->second, out);
        values += "'" + out + "'"; 
        atts += ",";
        values += ",";
        GimmickMessage(4,"'"<<i->first<<"' = '"<<i->second<<"'"<<std::endl);
      }
    atts[atts.size()-1]=' ';
    values[values.size()-1]=' ';

    str = "("+atts+") VALUES ("+values+")";
    GimmickMessage(4,"Result = '"<<str<<"'"<<std::endl);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::SQLiteTreeHandler::UnLoad ( tree::Node n  )  [virtual]

Unloads the Node and its descendants.

Reimplemented from creaImageIO::TreeHandler.

Definition at line 91 of file creaImageIOSQLiteTreeHandler.cpp.

  {
  }


Member Data Documentation

The physical location associated to the DicomDatabase (directory, db file...).

Definition at line 232 of file creaImageIOSQLiteTreeHandler.h.

Referenced by GetFileName().

Definition at line 237 of file creaImageIOSQLiteTreeHandler.h.

Referenced by SQLiteTreeHandler().

Is the DB writable ?

Definition at line 234 of file creaImageIOSQLiteTreeHandler.h.

Referenced by GetWritable(), and SetWritable().


The documentation for this class was generated from the following files: