#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) |
std::string | name () |
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 () |
Definition at line 157 of file OraDatabaseSchema.h.
ora::OraNamingServiceTable::OraNamingServiceTable | ( | coral::ISchema & | dbSchema | ) | [explicit] |
Definition at line 1092 of file OraDatabaseSchema.cc.
: INamingServiceTable( dbSchema ){ }
ora::OraNamingServiceTable::~OraNamingServiceTable | ( | ) | [virtual] |
Definition at line 1096 of file OraDatabaseSchema.cc.
{ }
std::string & ora::OraNamingServiceTable::containerIdColumn | ( | ) | [static] |
Definition at line 1082 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 1107 of file OraDatabaseSchema.cc.
References python::IdGenerator::schema, and ora::throwException().
{ if( 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() ) ); schema().createTable( descr ); }
void ora::OraNamingServiceTable::drop | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 1129 of file OraDatabaseSchema.cc.
References python::IdGenerator::schema.
bool ora::OraNamingServiceTable::eraseAllNames | ( | ) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1155 of file OraDatabaseSchema.cc.
References python::IdGenerator::schema.
bool ora::OraNamingServiceTable::eraseObjectName | ( | const std::string & | name | ) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1147 of file OraDatabaseSchema.cc.
References python::IdGenerator::schema.
{ coral::AttributeList whereData; whereData.extend<std::string>( objectNameColumn() ); whereData.begin()->data<std::string>() = name; std::string condition = objectNameColumn() + " = :" + objectNameColumn(); return schema().tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0; }
bool ora::OraNamingServiceTable::exists | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 1103 of file OraDatabaseSchema.cc.
References python::IdGenerator::schema.
bool ora::OraNamingServiceTable::getAllNames | ( | std::vector< std::string > & | destination | ) | [virtual] |
Implements ora::INamingServiceTable.
Definition at line 1249 of file OraDatabaseSchema.cc.
References mergeVDriftHistosByStation::name, o2o::query, run_regression::ret, and python::IdGenerator::schema.
{ bool ret = false; coral::ITable& containerTable = 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 1223 of file OraDatabaseSchema.cc.
References mergeVDriftHistosByStation::name, o2o::query, run_regression::ret, and python::IdGenerator::schema.
{ bool ret = false; coral::ITable& containerTable = 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 1191 of file OraDatabaseSchema.cc.
References mergeVDriftHistosByStation::name, o2o::query, run_regression::ret, and python::IdGenerator::schema.
{ bool ret = false; coral::ITable& containerTable = 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 1161 of file OraDatabaseSchema.cc.
References o2o::query, run_regression::ret, and python::IdGenerator::schema.
{ bool ret = false; coral::ITable& containerTable = 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 1087 of file OraDatabaseSchema.cc.
{ static std::string s_column("ITEM_ID"); return s_column; }
std::string ora::OraNamingServiceTable::name | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 1099 of file OraDatabaseSchema.cc.
{ return tableName(); }
std::string & ora::OraNamingServiceTable::objectNameColumn | ( | ) | [static] |
Definition at line 1077 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 1133 of file OraDatabaseSchema.cc.
References python::IdGenerator::schema.
{ 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 = schema().tableHandle( tableName() ); containerTable.dataEditor().insertRow( dataToInsert ); }
std::string & ora::OraNamingServiceTable::tableName | ( | ) | [static] |
Definition at line 1072 of file OraDatabaseSchema.cc.
{ static std::string s_table("ORA_NAMING_SERVICE" ); return s_table; }