creaImageIO_lib
|
Concrete TreeHandler which manages a Tree stored in a sqlite database. More...
#include <creaImageIOSQLiteTreeHandler.h>
Public Types | |
typedef tree::Node::AttributeMapType | AttributeMapType |
==================================================================== More... | |
Public Member Functions | |
SQLiteTreeHandler (const std::string &filename) | |
Ctor with database file name. More... | |
virtual | ~SQLiteTreeHandler () |
Dtor. More... | |
const std::string & | GetFileName () const |
Returns the sqlite db file name. More... | |
virtual bool | IsReadable () |
Is the 'source' readable ? More... | |
virtual bool | IsWritable () |
Is the 'source' writable ? More... | |
virtual bool | Open (bool writable=false) |
Opens an existing 'source'. More... | |
virtual bool | Close () |
Closes the 'source'. More... | |
virtual bool | Create (bool writable=false) |
Creates a new 'source'. More... | |
virtual bool | Destroy () |
Destroys the 'source'. More... | |
virtual void | BeginTransaction () |
Begins a transaction. More... | |
virtual void | EndTransaction () |
Commits results and ends transaction. More... | |
virtual unsigned int | GetNumberOfChildren (tree::Node *n) |
Returns the number of children of the Node WITHOUT LOADING THEM More... | |
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. More... | |
virtual int | LoadChildren (tree::Node *parent, int maxlevel) |
Recursively loads the children of node 'parent' until maxlevel. More... | |
virtual void | UnLoad (tree::Node *n) |
Unloads the Node and its descendants. More... | |
virtual void | GetTopLevelNodeId (const std::string &searchParam, const std::string &searchValue, std::string &parent_id) |
==================================================================== More... | |
virtual int | AddBranch (const AttributeMapType &attr) |
==================================================================== More... | |
virtual bool | Remove (tree::Node *) |
Removes the node and its descendants. More... | |
virtual bool | SetAttribute (tree::Node *, const std::string &key, const std::string &value) |
Sets an attribute of a Node. More... | |
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. More... | |
virtual void | DeleteTuple (std::string levelDescriptor, std::string key, std::string value) |
Deletes a tuple. More... | |
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 More... | |
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 More... | |
void | GetUpLevelNodeId (int level, const std::string &searchParam, const std::string &searchValue, std::string &parent_id) |
get Id for the up level node More... | |
tree::Tree & | GetTree () |
Returns the Tree handled. More... | |
const tree::Tree & | GetTree () const |
Returns the Tree handled (const) More... | |
Protected Member Functions | |
bool | DBOpen () |
Open the database. More... | |
bool | DBImportTreeDescription () |
Import the Tree::Description from database (verifies the structure) More... | |
bool | DBCreate () |
Creates a new database on disk and the tables. More... | |
void | SQLAppendAttributesDefinition (int level, std::string &s) |
Appends to string s the SQL command to create the attributes of a given level. More... | |
tree::Node * | DBGetParent (const AttributeMapType &attr) |
Returns the parent to which the branch defined by the attributes. More... | |
int | DBLoadChildren (tree::Node *parent, int numberoflevels=1) |
Loads the children of Node parent. More... | |
void | SQLAppendAttributesValues (tree::Node *n, std::string &s) |
Appends to string s the SQL command to set the attributes values. More... | |
void | DBGraftToParent (tree::Node *parent, const AttributeMapType &attr) |
Graft the branch defined by the attributes to the parent. More... | |
bool | DBSetAttribute (tree::Node *, const std::string &key, const std::string &value) |
Sets an attribute of a Node and updates the database. More... | |
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. More... | |
void | DBInsert (tree::Node *n) |
Inserts the Node in the database. More... | |
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. More... | |
void | DBRecursiveRemoveNode (tree::Node *node) |
Recursively Removes the nodes whose parent is given as a parameter. More... | |
void | DBRecursiveRemoveNode (int level, std::string parentId) |
Recursively Removes the nodes found in the given level with the given parent id. More... | |
Private Member Functions | |
void | SetWritable (bool w) |
bool | GetWritable () const |
const std::string | convert (const std::string &i_word) |
Private Attributes | |
CppSQLite3DB * | mDB |
The DB. More... | |
std::string | mFileName |
The physical location associated to the DicomDatabase (directory, db file...) More... | |
bool | mWritable |
Is the DB writable ? More... | |
bool | mIsAdding |
Concrete TreeHandler which manages a Tree stored in a sqlite database.
Definition at line 46 of file creaImageIOSQLiteTreeHandler.h.
|
inherited |
====================================================================
Definition at line 150 of file creaImageIOTreeHandler.h.
creaImageIO::SQLiteTreeHandler::SQLiteTreeHandler | ( | const std::string & | filename | ) |
Ctor with database file name.
Definition at line 51 of file creaImageIOSQLiteTreeHandler.cpp.
References mDB, and mIsAdding.
|
virtual |
|
virtual |
====================================================================
Adds a branch in the tree with the attributes provided
Reimplemented from creaImageIO::TreeHandler.
Definition at line 125 of file creaImageIOSQLiteTreeHandler.cpp.
References DBGetParent(), DBGraftToParent(), and creaImageIO::tree::Node::GetLevel().
|
virtual |
Begins a transaction.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 1122 of file creaImageIOSQLiteTreeHandler.cpp.
References UPDATEDB.
|
virtual |
Closes the 'source'.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 91 of file creaImageIOSQLiteTreeHandler.cpp.
|
private |
Definition at line 1136 of file creaImageIOSQLiteTreeHandler.cpp.
Referenced by DBSetAttribute().
|
virtual |
Creates a new 'source'.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 81 of file creaImageIOSQLiteTreeHandler.cpp.
References DBCreate(), and SetWritable().
Referenced by creaImageIO::Gimmick::createDB().
|
protected |
Creates a new database on disk and the tables.
Definition at line 293 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().
|
protected |
Deletes the tuple that matches the value specified in the given key and that belongs to the given level.
Definition at line 895 of file creaImageIOSQLiteTreeHandler.cpp.
References GimmickDebugMessage, and UPDATEDB.
Referenced by DBRecursiveRemoveNode(), and DeleteTuple().
|
protected |
Returns the parent to which the branch defined by the attributes.
Definition at line 620 of file creaImageIOSQLiteTreeHandler.cpp.
References DBLoadChildren(), creaImageIO::tree::Node::GetChildrenList(), creaImageIO::TreeHandler::GetTree(), and creaImageIO::tree::Tree::GetTree().
Referenced by AddBranch().
|
protected |
Graft the branch defined by the attributes to the parent.
Definition at line 750 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().
|
protected |
Import the Tree::Description from database (verifies the structure)
Definition at line 444 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().
|
protected |
Inserts the Node in the database.
Definition at line 728 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().
|
protected |
Loads the children of Node parent.
If children not loaded : do it and recurse
Definition at line 649 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().
|
protected |
Open the database.
Definition at line 258 of file creaImageIOSQLiteTreeHandler.cpp.
References DBImportTreeDescription(), CppSQLite3Exception::errorCode(), CppSQLite3Exception::errorMessage(), CppSQLite3DB::execDML(), GetFileName(), GimmickDebugMessage, GimmickError, GimmickMessage, mDB, and CppSQLite3DB::open().
Referenced by Open().
|
protected |
Recursively Removes the nodes whose parent is given as a parameter.
Definition at line 835 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().
|
protected |
Recursively Removes the nodes found in the given level with the given parent id.
Definition at line 860 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.
|
protected |
Sets an attribute of a Node and updates the database.
Sets an attribute of a Node.
Definition at line 789 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().
|
protected |
Sets an attribute and updates the database.
Sets an attribute of a Node.
Definition at line 813 of file creaImageIOSQLiteTreeHandler.cpp.
References UPDATEDB.
|
virtual |
Deletes a tuple.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 191 of file creaImageIOSQLiteTreeHandler.cpp.
References DBDelete().
|
virtual |
Destroys the 'source'.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 99 of file creaImageIOSQLiteTreeHandler.cpp.
|
virtual |
Commits results and ends transaction.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 1130 of file creaImageIOSQLiteTreeHandler.cpp.
References UPDATEDB.
|
virtual |
get all attributes from database for a given file
Implements creaImageIO::TreeHandler.
Definition at line 980 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().
|
virtual |
Returns the attribute requested. Useful for synchronization.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 907 of file creaImageIOSQLiteTreeHandler.cpp.
References CppSQLite3Query::eof(), CppSQLite3Query::getStringField(), CppSQLite3Query::nextRow(), CppSQLite3Query::numFields(), and QUERYDB.
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 1019 of file creaImageIOSQLiteTreeHandler.cpp.
References CppSQLite3Query::eof(), CppSQLite3Query::getStringField(), CppSQLite3Query::nextRow(), CppSQLite3Query::numFields(), and QUERYDB.
Referenced by getAllAttributes().
|
inline |
Returns the sqlite db file name.
Definition at line 58 of file creaImageIOSQLiteTreeHandler.h.
References mFileName.
Referenced by DBCreate(), and DBOpen().
|
virtual |
Returns the number of children of the Node WITHOUT LOADING THEM
Reimplemented from creaImageIO::TreeHandler.
Definition at line 941 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().
|
virtual |
====================================================================
Returns the top level node id for the given search param and search value
Reimplemented from creaImageIO::TreeHandler.
Definition at line 1072 of file creaImageIOSQLiteTreeHandler.cpp.
References creaImageIO::tree::Tree::GetNumberOfLevels(), creaImageIO::TreeHandler::GetTree(), and GetUpLevelNodeId().
|
inlineinherited |
Returns the Tree handled.
Definition at line 63 of file creaImageIOTreeHandler.h.
References creaImageIO::TreeHandler::mTree.
Referenced by creaImageIO::TreeHandlerImageAdder::AddFile(), creaImageIO::Synchronizer::AttributesMatch(), creaImageIO::TreeHandlerImageAdder::CheckAttributes(), creaImageIO::WxTreeView::CreateCtrl(), creaImageIO::Gimmick::createDB(), creaImageIO::WxGimmickView::CreateTreeView(), DBCreate(), DBGetParent(), DBGraftToParent(), DBImportTreeDescription(), DBInsert(), DBLoadChildren(), DBRecursiveRemoveNode(), DBSetAttribute(), creaImageIO::TreeHandlerImageAdder::DeleteDriveFromMainDB(), getAllAttributes(), creaImageIO::WxTreeView::GetAttributes(), GetNumberOfChildren(), GetTopLevelNodeId(), GetUpLevelNodeId(), creaImageIO::TreeHandlerImageAdder::isAttributeExist(), LoadChildren(), creaImageIO::WxTreeView::OnDumpTags(), creaImageIO::WxTreeView::OnEditField(), creaImageIO::WxTreeView::OnLocalCopy(), creaImageIO::Gimmick::Print(), creaImageIO::WxTreeView::RemoveSelected(), SetAttribute(), SQLAppendAttributesDefinition(), creaImageIO::TreeHandlerImageAdder::Synchronize(), and creaImageIO::WxTreeView::WxTreeView().
|
inlineinherited |
Returns the Tree handled (const)
Definition at line 65 of file creaImageIOTreeHandler.h.
References creaImageIO::TreeHandler::mTree.
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 1048 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().
|
inlineprivate |
|
inlinevirtual |
Is the 'source' readable ?
Reimplemented from creaImageIO::TreeHandler.
Definition at line 64 of file creaImageIOSQLiteTreeHandler.h.
|
inlinevirtual |
Is the 'source' writable ?
Reimplemented from creaImageIO::TreeHandler.
Definition at line 66 of file creaImageIOSQLiteTreeHandler.h.
|
virtual |
Recursively loads the children of node 'parent' until maxlevel.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 107 of file creaImageIOSQLiteTreeHandler.cpp.
References DBLoadChildren(), creaImageIO::TreeHandler::GetTree(), and creaImageIO::tree::Tree::GetTree().
|
virtual |
Opens an existing 'source'.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 72 of file creaImageIOSQLiteTreeHandler.cpp.
References DBOpen(), and SetWritable().
Referenced by creaImageIO::Gimmick::createDB().
|
virtual |
Removes the node and its descendants.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 136 of file creaImageIOSQLiteTreeHandler.cpp.
References DBRecursiveRemoveNode(), creaImageIO::tree::Node::GetLevel(), creaImageIO::tree::Node::GetParent(), creaImageIO::tree::Node::RemoveChildrenFromList(), and SetAttribute().
|
virtual |
Reimplemented from creaImageIO::TreeHandler.
Definition at line 1111 of file creaImageIOSQLiteTreeHandler.cpp.
References UPDATEDB.
|
virtual |
Sets an attribute of a Node.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 171 of file creaImageIOSQLiteTreeHandler.cpp.
References DBSetAttribute(), creaImageIO::TreeHandler::GetTree(), and creaImageIO::tree::Tree::GetTree().
Referenced by creaImageIO::Gimmick::createDB(), DBGraftToParent(), and Remove().
|
virtual |
Sets an attribute.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 181 of file creaImageIOSQLiteTreeHandler.cpp.
References DBSetAttribute().
|
inlineprivate |
|
protected |
Appends to string s the SQL command to create the attributes of a given level.
Definition at line 426 of file creaImageIOSQLiteTreeHandler.cpp.
References creaImageIO::tree::Tree::GetAttributeDescriptorList(), and creaImageIO::TreeHandler::GetTree().
Referenced by DBCreate().
|
protected |
Appends to string s the SQL command to set the attributes values.
Definition at line 587 of file creaImageIOSQLiteTreeHandler.cpp.
References creaImageIO::tree::Node::GetAttributeMap(), GimmickMessage, and creaImageIO::SQLformat().
Referenced by DBInsert().
|
virtual |
Unloads the Node and its descendants.
Reimplemented from creaImageIO::TreeHandler.
Definition at line 119 of file creaImageIOSQLiteTreeHandler.cpp.
|
private |
The DB.
Definition at line 258 of file creaImageIOSQLiteTreeHandler.h.
Referenced by DBCreate(), DBImportTreeDescription(), DBInsert(), DBOpen(), SQLiteTreeHandler(), and ~SQLiteTreeHandler().
|
private |
The physical location associated to the DicomDatabase (directory, db file...)
Definition at line 260 of file creaImageIOSQLiteTreeHandler.h.
Referenced by GetFileName().
|
private |
Definition at line 265 of file creaImageIOSQLiteTreeHandler.h.
Referenced by SQLiteTreeHandler().
|
private |
Is the DB writable ?
Definition at line 262 of file creaImageIOSQLiteTreeHandler.h.
Referenced by GetWritable(), and SetWritable().