#include <OraDatabaseSchema.h>
Public Member Functions | |
void | create () |
void | drop () |
bool | eraseAllNames () |
bool | eraseObjectName (const std::string &name) |
bool | exists () |
bool | getAllNames (std::vector< std::string > &destination) |
bool | getNamesForContainer (int contId, std::vector< std::string > &destination) |
bool | getNamesForObject (int contId, int itemId, std::vector< std::string > &destination) |
bool | getObjectByName (const std::string &name, std::pair< int, int > &destination) |
OraNamingServiceTable (coral::ISchema &dbSchema) | |
void | setObjectName (const std::string &name, int contId, int itemId) |
virtual | ~OraNamingServiceTable () |
Static Public Member Functions | |
static std::string & | containerIdColumn () |
static std::string & | itemIdColumn () |
static std::string & | objectNameColumn () |
static std::string & | tableName () |
Private Attributes | |
coral::ISchema & | m_schema |
Definition at line 159 of file OraDatabaseSchema.h.
ora::OraNamingServiceTable::OraNamingServiceTable | ( | coral::ISchema & | dbSchema | ) | [explicit] |
Definition at line 1023 of file OraDatabaseSchema.cc.
: m_schema( dbSchema ){ }
ora::OraNamingServiceTable::~OraNamingServiceTable | ( | ) | [virtual] |
Definition at line 1026 of file OraDatabaseSchema.cc.
{ }
std::string & ora::OraNamingServiceTable::containerIdColumn | ( | ) | [static] |
Definition at line 1013 of file OraDatabaseSchema.cc.
{ static std::string s_column("CONTAINER_ID"); return s_column; }
void ora::OraNamingServiceTable::create | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 1033 of file OraDatabaseSchema.cc.
References asciidump::table, and ora::throwException().
{ if( m_schema.existsTable( tableName() )){ throwException( "ORA naming service table already exists in this schema.", "OraNameTable::create"); } coral::TableDescription descr( "OraDb" ); descr.setName( tableName() ); descr.insertColumn( objectNameColumn(), coral::AttributeSpecification::typeNameForType<std::string>() ); descr.insertColumn( containerIdColumn(), coral::AttributeSpecification::typeNameForType<int>() ); descr.insertColumn( itemIdColumn(), coral::AttributeSpecification::typeNameForType<int>() ); descr.setNotNullConstraint( objectNameColumn() ); descr.setNotNullConstraint( containerIdColumn() ); descr.setNotNullConstraint( itemIdColumn() ); descr.setPrimaryKey( std::vector<std::string>( 1, objectNameColumn() ) ); coral::ITable& table = m_schema.createTable( descr ); table.privilegeManager().grantToPublic( coral::ITablePrivilegeManager::Select ); }
void ora::OraNamingServiceTable::drop | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 1056 of file OraDatabaseSchema.cc.
bool ora::OraNamingServiceTable::eraseAllNames | ( | ) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1082 of file OraDatabaseSchema.cc.
bool ora::OraNamingServiceTable::eraseObjectName | ( | const std::string & | name | ) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1074 of file OraDatabaseSchema.cc.
{ coral::AttributeList whereData; whereData.extend<std::string>( objectNameColumn() ); whereData.begin()->data<std::string>() = name; std::string condition = objectNameColumn() + " = :" + objectNameColumn(); return m_schema.tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0; }
bool ora::OraNamingServiceTable::exists | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 1029 of file OraDatabaseSchema.cc.
bool ora::OraNamingServiceTable::getAllNames | ( | std::vector< std::string > & | destination | ) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1176 of file OraDatabaseSchema.cc.
References AlCaRecoCosmics_cfg::name, o2o::query, and runTheMatrix::ret.
{ bool ret = false; coral::ITable& containerTable = m_schema.tableHandle( tableName() ); std::auto_ptr<coral::IQuery> query( containerTable.newQuery()); coral::AttributeList outputBuffer; outputBuffer.extend<std::string>( objectNameColumn() ); query->defineOutput( outputBuffer ); query->addToOutputList( objectNameColumn() ); coral::ICursor& cursor = query->execute(); while ( cursor.next() ) { ret = true; const coral::AttributeList& row = cursor.currentRow(); std::string name = row[ objectNameColumn() ].data< std::string >(); destination.push_back( name ); } return ret; }
bool ora::OraNamingServiceTable::getNamesForContainer | ( | int | contId, |
std::vector< std::string > & | destination | ||
) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1150 of file OraDatabaseSchema.cc.
References AlCaRecoCosmics_cfg::name, o2o::query, and runTheMatrix::ret.
{ bool ret = false; coral::ITable& containerTable = m_schema.tableHandle( tableName() ); std::auto_ptr<coral::IQuery> query( containerTable.newQuery()); coral::AttributeList outputBuffer; outputBuffer.extend<std::string>( objectNameColumn() ); query->defineOutput( outputBuffer ); query->addToOutputList( objectNameColumn() ); std::ostringstream condition; condition << containerIdColumn()<<"= :"<< containerIdColumn(); coral::AttributeList condData; condData.extend<int>( containerIdColumn() ); coral::AttributeList::iterator iAttribute = condData.begin(); iAttribute->data< int >() = contId; query->setCondition( condition.str(), condData ); coral::ICursor& cursor = query->execute(); while ( cursor.next() ) { ret = true; const coral::AttributeList& row = cursor.currentRow(); std::string name = row[ objectNameColumn() ].data< std::string >(); destination.push_back( name ); } return ret; }
bool ora::OraNamingServiceTable::getNamesForObject | ( | int | contId, |
int | itemId, | ||
std::vector< std::string > & | destination | ||
) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1118 of file OraDatabaseSchema.cc.
References AlCaRecoCosmics_cfg::name, o2o::query, and runTheMatrix::ret.
{ bool ret = false; coral::ITable& containerTable = m_schema.tableHandle( tableName() ); std::auto_ptr<coral::IQuery> query( containerTable.newQuery()); coral::AttributeList outputBuffer; outputBuffer.extend<std::string>( objectNameColumn() ); query->defineOutput( outputBuffer ); query->addToOutputList( objectNameColumn() ); std::ostringstream condition; condition << containerIdColumn()<<"= :"<< containerIdColumn(); condition << " AND "; condition << itemIdColumn()<<"= :"<< itemIdColumn(); coral::AttributeList condData; condData.extend<int>( containerIdColumn() ); condData.extend<int>( itemIdColumn() ); coral::AttributeList::iterator iAttribute = condData.begin(); iAttribute->data< int >() = contId; ++iAttribute; iAttribute->data< int >() = itemId; query->setCondition( condition.str(), condData ); coral::ICursor& cursor = query->execute(); while ( cursor.next() ) { ret = true; const coral::AttributeList& row = cursor.currentRow(); std::string name = row[ objectNameColumn() ].data< std::string >(); destination.push_back( name ); } return ret; }
bool ora::OraNamingServiceTable::getObjectByName | ( | const std::string & | name, |
std::pair< int, int > & | destination | ||
) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1088 of file OraDatabaseSchema.cc.
References o2o::query, and runTheMatrix::ret.
{ bool ret = false; coral::ITable& containerTable = m_schema.tableHandle( tableName() ); std::auto_ptr<coral::IQuery> query( containerTable.newQuery()); coral::AttributeList outputBuffer; outputBuffer.extend<int>( containerIdColumn() ); outputBuffer.extend<int>( itemIdColumn() ); query->defineOutput( outputBuffer ); query->addToOutputList( containerIdColumn() ); query->addToOutputList( itemIdColumn() ); std::ostringstream condition; condition << objectNameColumn()<<"= :"<< objectNameColumn(); coral::AttributeList condData; condData.extend<std::string>( objectNameColumn() ); coral::AttributeList::iterator iAttribute = condData.begin(); iAttribute->data< std::string >() = name; query->setCondition( condition.str(), condData ); coral::ICursor& cursor = query->execute(); while ( cursor.next() ) { ret = true; const coral::AttributeList& row = cursor.currentRow(); int containerId = row[ containerIdColumn() ].data< int >(); int itemId = row[ itemIdColumn() ].data< int >(); destination.first = containerId; destination.second = itemId; } return ret; }
std::string & ora::OraNamingServiceTable::itemIdColumn | ( | ) | [static] |
Definition at line 1018 of file OraDatabaseSchema.cc.
{ static std::string s_column("ITEM_ID"); return s_column; }
std::string & ora::OraNamingServiceTable::objectNameColumn | ( | ) | [static] |
Definition at line 1008 of file OraDatabaseSchema.cc.
{ static std::string s_column("OBJECT_NAME"); return s_column; }
void ora::OraNamingServiceTable::setObjectName | ( | const std::string & | name, |
int | contId, | ||
int | itemId | ||
) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1060 of file OraDatabaseSchema.cc.
{ coral::AttributeList dataToInsert; dataToInsert.extend<std::string>( objectNameColumn() ); dataToInsert.extend<int>( containerIdColumn()); dataToInsert.extend<int>( itemIdColumn()); dataToInsert[ objectNameColumn() ].data<std::string>() = name; dataToInsert[ containerIdColumn() ].data<int>() = contId; dataToInsert[ itemIdColumn() ].data<int>() = itemId; coral::ITable& containerTable = m_schema.tableHandle( tableName() ); containerTable.dataEditor().insertRow( dataToInsert ); }
std::string & ora::OraNamingServiceTable::tableName | ( | ) | [static] |
Definition at line 1003 of file OraDatabaseSchema.cc.
{ static std::string s_table("ORA_NAMING_SERVICE" ); return s_table; }
coral::ISchema& ora::OraNamingServiceTable::m_schema [private] |
Definition at line 181 of file OraDatabaseSchema.h.