CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions
ora::OraNamingServiceTable Class Reference

#include <OraDatabaseSchema.h>

Inheritance diagram for ora::OraNamingServiceTable:
ora::INamingServiceTable ora::IDatabaseTable

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 ()
 
- Public Member Functions inherited from ora::INamingServiceTable
 INamingServiceTable (coral::ISchema &schema)
 
virtual ~INamingServiceTable ()
 
- Public Member Functions inherited from ora::IDatabaseTable
 IDatabaseTable (coral::ISchema &schema)
 
coral::ISchema & schema ()
 
virtual void setAccessPermission (const std::string &principal, bool forWrite)
 
virtual ~IDatabaseTable ()
 

Static Public Member Functions

static std::string containerIdColumn ()
 
static std::string itemIdColumn ()
 
static std::string objectNameColumn ()
 
static std::string tableName ()
 

Detailed Description

Definition at line 157 of file OraDatabaseSchema.h.

Constructor & Destructor Documentation

ora::OraNamingServiceTable::OraNamingServiceTable ( coral::ISchema &  dbSchema)
explicit

Definition at line 1092 of file OraDatabaseSchema.cc.

1092  :
1093  INamingServiceTable( dbSchema ){
1094 }
INamingServiceTable(coral::ISchema &schema)
ora::OraNamingServiceTable::~OraNamingServiceTable ( )
virtual

Definition at line 1096 of file OraDatabaseSchema.cc.

1096  {
1097 }

Member Function Documentation

std::string ora::OraNamingServiceTable::containerIdColumn ( )
static

Definition at line 1082 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1082  {
1083  static const std::string s_column("CONTAINER_ID");
1084  return s_column;
1085 }
void ora::OraNamingServiceTable::create ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 1107 of file OraDatabaseSchema.cc.

References python.IdGenerator::schema, and ora::throwException().

1107  {
1108  if( schema().existsTable( tableName() )){
1109  throwException( "ORA naming service table already exists in this schema.",
1110  "OraNameTable::create");
1111  }
1112 
1113  coral::TableDescription descr( "OraDb" );
1114  descr.setName( tableName() );
1115  descr.insertColumn( objectNameColumn(),
1116  coral::AttributeSpecification::typeNameForType<std::string>() );
1117  descr.insertColumn( containerIdColumn(),
1118  coral::AttributeSpecification::typeNameForType<int>() );
1119  descr.insertColumn( itemIdColumn(),
1120  coral::AttributeSpecification::typeNameForType<int>() );
1121  descr.setNotNullConstraint( objectNameColumn() );
1122  descr.setNotNullConstraint( containerIdColumn() );
1123  descr.setNotNullConstraint( itemIdColumn() );
1124  descr.setPrimaryKey( std::vector<std::string>( 1, objectNameColumn() ) );
1125 
1126  schema().createTable( descr );
1127 }
static std::string objectNameColumn()
static std::string tableName()
static std::string containerIdColumn()
static std::string itemIdColumn()
coral::ISchema & schema()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void ora::OraNamingServiceTable::drop ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 1129 of file OraDatabaseSchema.cc.

References python.IdGenerator::schema.

1129  {
1130  schema().dropIfExistsTable( tableName() );
1131 }
static std::string tableName()
coral::ISchema & schema()
bool ora::OraNamingServiceTable::eraseAllNames ( )
virtual

Implements ora::INamingServiceTable.

Definition at line 1155 of file OraDatabaseSchema.cc.

References python.IdGenerator::schema, and AlCaHLTBitMon_QueryRunRegistry::string.

1155  {
1156  std::string condition("");
1157  coral::AttributeList whereData;
1158  return schema().tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1159 }
static std::string tableName()
coral::ISchema & 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, and AlCaHLTBitMon_QueryRunRegistry::string.

1147  {
1148  coral::AttributeList whereData;
1149  whereData.extend<std::string>( objectNameColumn() );
1150  whereData.begin()->data<std::string>() = name;
1151  std::string condition = objectNameColumn() + " = :" + objectNameColumn();
1152  return schema().tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1153 }
static std::string objectNameColumn()
static std::string tableName()
coral::ISchema & schema()
bool ora::OraNamingServiceTable::exists ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 1103 of file OraDatabaseSchema.cc.

References python.IdGenerator::schema.

1103  {
1104  return schema().existsTable( tableName() );
1105 }
static std::string tableName()
coral::ISchema & 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, python.IdGenerator::schema, and AlCaHLTBitMon_QueryRunRegistry::string.

1249  {
1250  bool ret = false;
1251  coral::ITable& containerTable = schema().tableHandle( tableName() );
1252  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1253  coral::AttributeList outputBuffer;
1254  outputBuffer.extend<std::string>( objectNameColumn() );
1255  query->defineOutput( outputBuffer );
1256  query->addToOutputList( objectNameColumn() );
1257  coral::ICursor& cursor = query->execute();
1258  while ( cursor.next() ) {
1259  ret = true;
1260  const coral::AttributeList& row = cursor.currentRow();
1261  std::string name = row[ objectNameColumn() ].data< std::string >();
1262  destination.push_back( name );
1263  }
1264  return ret;
1265 }
static std::string objectNameColumn()
static std::string tableName()
coral::ISchema & schema()
tuple query
Definition: o2o.py:269
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, python.IdGenerator::schema, and AlCaHLTBitMon_QueryRunRegistry::string.

1224  {
1225  bool ret = false;
1226  coral::ITable& containerTable = schema().tableHandle( tableName() );
1227  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1228  coral::AttributeList outputBuffer;
1229  outputBuffer.extend<std::string>( objectNameColumn() );
1230  query->defineOutput( outputBuffer );
1231  query->addToOutputList( objectNameColumn() );
1232  std::ostringstream condition;
1233  condition << containerIdColumn()<<"= :"<< containerIdColumn();
1234  coral::AttributeList condData;
1235  condData.extend<int>( containerIdColumn() );
1236  coral::AttributeList::iterator iAttribute = condData.begin();
1237  iAttribute->data< int >() = contId;
1238  query->setCondition( condition.str(), condData );
1239  coral::ICursor& cursor = query->execute();
1240  while ( cursor.next() ) {
1241  ret = true;
1242  const coral::AttributeList& row = cursor.currentRow();
1243  std::string name = row[ objectNameColumn() ].data< std::string >();
1244  destination.push_back( name );
1245  }
1246  return ret;
1247 }
static std::string objectNameColumn()
static std::string tableName()
static std::string containerIdColumn()
coral::ISchema & schema()
tuple query
Definition: o2o.py:269
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, python.IdGenerator::schema, and AlCaHLTBitMon_QueryRunRegistry::string.

1193  {
1194  bool ret = false;
1195  coral::ITable& containerTable = schema().tableHandle( tableName() );
1196  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1197  coral::AttributeList outputBuffer;
1198  outputBuffer.extend<std::string>( objectNameColumn() );
1199  query->defineOutput( outputBuffer );
1200  query->addToOutputList( objectNameColumn() );
1201  std::ostringstream condition;
1202  condition << containerIdColumn()<<"= :"<< containerIdColumn();
1203  condition << " AND ";
1204  condition << itemIdColumn()<<"= :"<< itemIdColumn();
1205  coral::AttributeList condData;
1206  condData.extend<int>( containerIdColumn() );
1207  condData.extend<int>( itemIdColumn() );
1208  coral::AttributeList::iterator iAttribute = condData.begin();
1209  iAttribute->data< int >() = contId;
1210  ++iAttribute;
1211  iAttribute->data< int >() = itemId;
1212  query->setCondition( condition.str(), condData );
1213  coral::ICursor& cursor = query->execute();
1214  while ( cursor.next() ) {
1215  ret = true;
1216  const coral::AttributeList& row = cursor.currentRow();
1217  std::string name = row[ objectNameColumn() ].data< std::string >();
1218  destination.push_back( name );
1219  }
1220  return ret;
1221 }
static std::string objectNameColumn()
static std::string tableName()
static std::string containerIdColumn()
static std::string itemIdColumn()
coral::ISchema & schema()
tuple query
Definition: o2o.py:269
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, python.IdGenerator::schema, and AlCaHLTBitMon_QueryRunRegistry::string.

1162  {
1163  bool ret = false;
1164  coral::ITable& containerTable = schema().tableHandle( tableName() );
1165  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1166  coral::AttributeList outputBuffer;
1167  outputBuffer.extend<int>( containerIdColumn() );
1168  outputBuffer.extend<int>( itemIdColumn() );
1169  query->defineOutput( outputBuffer );
1170  query->addToOutputList( containerIdColumn() );
1171  query->addToOutputList( itemIdColumn() );
1172  std::ostringstream condition;
1173  condition << objectNameColumn()<<"= :"<< objectNameColumn();
1174  coral::AttributeList condData;
1175  condData.extend<std::string>( objectNameColumn() );
1176  coral::AttributeList::iterator iAttribute = condData.begin();
1177  iAttribute->data< std::string >() = name;
1178  query->setCondition( condition.str(), condData );
1179  coral::ICursor& cursor = query->execute();
1180  while ( cursor.next() ) {
1181  ret = true;
1182  const coral::AttributeList& row = cursor.currentRow();
1183  int containerId = row[ containerIdColumn() ].data< int >();
1184  int itemId = row[ itemIdColumn() ].data< int >();
1185  destination.first = containerId;
1186  destination.second = itemId;
1187  }
1188  return ret;
1189 }
static std::string objectNameColumn()
static std::string tableName()
static std::string containerIdColumn()
static std::string itemIdColumn()
coral::ISchema & schema()
tuple query
Definition: o2o.py:269
std::string ora::OraNamingServiceTable::itemIdColumn ( )
static

Definition at line 1087 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1087  {
1088  static const std::string s_column("ITEM_ID");
1089  return s_column;
1090 }
std::string ora::OraNamingServiceTable::name ( )
virtual
std::string ora::OraNamingServiceTable::objectNameColumn ( )
static

Definition at line 1077 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1077  {
1078  static const std::string s_column("OBJECT_NAME");
1079  return s_column;
1080 }
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, and AlCaHLTBitMon_QueryRunRegistry::string.

1135  {
1136  coral::AttributeList dataToInsert;
1137  dataToInsert.extend<std::string>( objectNameColumn() );
1138  dataToInsert.extend<int>( containerIdColumn());
1139  dataToInsert.extend<int>( itemIdColumn());
1140  dataToInsert[ objectNameColumn() ].data<std::string>() = name;
1141  dataToInsert[ containerIdColumn() ].data<int>() = contId;
1142  dataToInsert[ itemIdColumn() ].data<int>() = itemId;
1143  coral::ITable& containerTable = schema().tableHandle( tableName() );
1144  containerTable.dataEditor().insertRow( dataToInsert );
1145 }
static std::string objectNameColumn()
static std::string tableName()
static std::string containerIdColumn()
static std::string itemIdColumn()
coral::ISchema & schema()
std::string ora::OraNamingServiceTable::tableName ( )
static

Definition at line 1072 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1072  {
1073  static const std::string s_table("ORA_NAMING_SERVICE" );
1074  return s_table;
1075 }