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 | Private Attributes
ora::CondMetadataTable Class Reference

#include <PoolDatabaseSchema.h>

Inheritance diagram for ora::CondMetadataTable:
ora::INamingServiceTable ora::IDatabaseTable

Public Member Functions

 CondMetadataTable (coral::ISchema &dbSchema, PoolDbCache &dbCache)
 
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 ()
 
void setObjectName (const std::string &name, int contId, int itemId)
 
virtual ~CondMetadataTable ()
 
- 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 objectNameColumn ()
 
static std::string tableName ()
 
static std::string timetypeColumn ()
 
static std::string tokenColumn ()
 

Private Attributes

PoolDbCachem_dbCache
 

Detailed Description

Definition at line 201 of file PoolDatabaseSchema.h.

Constructor & Destructor Documentation

ora::CondMetadataTable::CondMetadataTable ( coral::ISchema &  dbSchema,
PoolDbCache dbCache 
)

Definition at line 1168 of file PoolDatabaseSchema.cc.

1169  :
1170  INamingServiceTable( dbSchema ),
1171  m_dbCache( dbCache ){
1172 }
INamingServiceTable(coral::ISchema &schema)
ora::CondMetadataTable::~CondMetadataTable ( )
virtual

Definition at line 1174 of file PoolDatabaseSchema.cc.

1174  {
1175 }

Member Function Documentation

void ora::CondMetadataTable::create ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 1319 of file PoolDatabaseSchema.cc.

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

1319  {
1320  if( schema().existsTable( tableName() )){
1321  throwException( "Metadata table already exists in this schema.",
1322  "CondMetadataTable::create");
1323  }
1324  throwException( "Cond Metadata table cannot be created.","CondMetadataTable::create");
1325 }
coral::ISchema & schema()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
static std::string tableName()
void ora::CondMetadataTable::drop ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 1327 of file PoolDatabaseSchema.cc.

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

1327  {
1328  if( !schema().existsTable( tableName() )){
1329  throwException( "Metadata table does not exists in this schema.",
1330  "CondMetadataTable::drop");
1331  }
1332  throwException( "Cond Metadata table cannot be dropped.","CondMetadataTable::drop");
1333 }
coral::ISchema & schema()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
static std::string tableName()
bool ora::CondMetadataTable::eraseAllNames ( )
virtual

Implements ora::INamingServiceTable.

Definition at line 1200 of file PoolDatabaseSchema.cc.

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

1200  {
1201  std::string condition("");
1202  coral::AttributeList whereData;
1203  return schema().tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1204 }
coral::ISchema & schema()
static std::string tableName()
bool ora::CondMetadataTable::eraseObjectName ( const std::string &  name)
virtual

Implements ora::INamingServiceTable.

Definition at line 1192 of file PoolDatabaseSchema.cc.

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

1192  {
1193  coral::AttributeList whereData;
1194  whereData.extend<std::string>( objectNameColumn() );
1195  whereData.begin()->data<std::string>() = name;
1196  std::string condition = objectNameColumn() + " = :" + objectNameColumn();
1197  return schema().tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1198 }
static std::string objectNameColumn()
coral::ISchema & schema()
static std::string tableName()
bool ora::CondMetadataTable::exists ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 1315 of file PoolDatabaseSchema.cc.

References python.IdGenerator::schema.

1315  {
1316  return schema().existsTable( tableName() );
1317 }
coral::ISchema & schema()
static std::string tableName()
bool ora::CondMetadataTable::getAllNames ( std::vector< std::string > &  destination)
virtual

Implements ora::INamingServiceTable.

Definition at line 1292 of file PoolDatabaseSchema.cc.

References mergeVDriftHistosByStation::name, o2o::query, run_regression::ret, python.IdGenerator::schema, and AlCaHLTBitMon_QueryRunRegistry::string.

1292  {
1293 
1294  bool ret = false;
1295  coral::ITable& containerTable = schema().tableHandle( tableName() );
1296  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1297  coral::AttributeList outputBuffer;
1298  outputBuffer.extend<std::string>( objectNameColumn() );
1299  query->defineOutput( outputBuffer );
1300  query->addToOutputList( objectNameColumn() );
1301  coral::ICursor& cursor = query->execute();
1302  while ( cursor.next() ) {
1303  ret = true;
1304  const coral::AttributeList& row = cursor.currentRow();
1305  std::string name = row[ objectNameColumn() ].data< std::string >();
1306  destination.push_back( name );
1307  }
1308  return ret;
1309 }
string destination
static std::string objectNameColumn()
coral::ISchema & schema()
tuple query
Definition: o2o.py:269
static std::string tableName()
bool ora::CondMetadataTable::getNamesForContainer ( int  contId,
std::vector< std::string > &  destination 
)
virtual

Implements ora::INamingServiceTable.

Definition at line 1263 of file PoolDatabaseSchema.cc.

References ora::PoolDbCacheData::m_className, ora::PoolDbCacheData::m_name, mergeVDriftHistosByStation::name, o2o::query, run_regression::ret, python.IdGenerator::schema, AlCaHLTBitMon_QueryRunRegistry::string, and cond::writeTokenContainerFragment().

1264  {
1265 
1266  bool ret = false;
1267  coral::ITable& containerTable = schema().tableHandle( tableName() );
1268  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1269  coral::AttributeList outputBuffer;
1270  outputBuffer.extend<std::string>( objectNameColumn() );
1271  query->defineOutput( outputBuffer );
1272  query->addToOutputList( objectNameColumn() );
1273  std::ostringstream condition;
1274  condition << tokenColumn()<<" LIKE :"<< tokenColumn();
1275  ora::PoolDbCacheData& contData = m_dbCache.find( contId );
1276  std::string tokenFragment = cond::writeTokenContainerFragment( contData.m_name, contData.m_className )+"%";
1277  coral::AttributeList condData;
1278  condData.extend<std::string>( tokenColumn() );
1279  coral::AttributeList::iterator iAttribute = condData.begin();
1280  iAttribute->data< std::string >() = tokenFragment;
1281  query->setCondition( condition.str(), condData );
1282  coral::ICursor& cursor = query->execute();
1283  while ( cursor.next() ) {
1284  ret = true;
1285  const coral::AttributeList& row = cursor.currentRow();
1286  std::string name = row[ objectNameColumn() ].data< std::string >();
1287  destination.push_back( name );
1288  }
1289  return ret;
1290 }
string destination
std::string writeTokenContainerFragment(const std::string &containerName, const std::string &className)
Definition: PoolToken.cc:55
static std::string tokenColumn()
static std::string objectNameColumn()
PoolDbCacheData & find(int id)
coral::ISchema & schema()
tuple query
Definition: o2o.py:269
static std::string tableName()
bool ora::CondMetadataTable::getNamesForObject ( int  contId,
int  itemId,
std::vector< std::string > &  destination 
)
virtual

Implements ora::INamingServiceTable.

Definition at line 1234 of file PoolDatabaseSchema.cc.

References ora::PoolDbCacheData::m_className, ora::PoolDbCacheData::m_name, mergeVDriftHistosByStation::name, o2o::query, run_regression::ret, python.IdGenerator::schema, AlCaHLTBitMon_QueryRunRegistry::string, and cond::writeToken().

1236  {
1237  bool ret = false;
1238  coral::ITable& containerTable = schema().tableHandle( tableName() );
1239  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1240  coral::AttributeList outputBuffer;
1241  outputBuffer.extend<std::string>( objectNameColumn() );
1242  query->defineOutput( outputBuffer );
1243  query->addToOutputList( objectNameColumn() );
1244  std::ostringstream condition;
1245  condition << tokenColumn()<<"= :"<< tokenColumn();
1246  ora::PoolDbCacheData& contData = m_dbCache.find( contId );
1247  std::string token = cond::writeToken( contData.m_name, contId, itemId, contData.m_className );
1248  coral::AttributeList condData;
1249  condData.extend<std::string>( tokenColumn() );
1250  coral::AttributeList::iterator iAttribute = condData.begin();
1251  iAttribute->data< std::string >() = token;
1252  query->setCondition( condition.str(), condData );
1253  coral::ICursor& cursor = query->execute();
1254  while ( cursor.next() ) {
1255  ret = true;
1256  const coral::AttributeList& row = cursor.currentRow();
1257  std::string name = row[ objectNameColumn() ].data< std::string >();
1258  destination.push_back( name );
1259  }
1260  return ret;
1261 }
string destination
static std::string tokenColumn()
static std::string objectNameColumn()
PoolDbCacheData & find(int id)
coral::ISchema & schema()
tuple query
Definition: o2o.py:269
std::string writeToken(const std::string &containerName, int oid0, int oid1, const std::string &className)
Definition: PoolToken.cc:44
static std::string tableName()
bool ora::CondMetadataTable::getObjectByName ( const std::string &  name,
std::pair< int, int > &  destination 
)
virtual

Implements ora::INamingServiceTable.

Definition at line 1206 of file PoolDatabaseSchema.cc.

References cond::parseToken(), o2o::query, run_regression::ret, python.IdGenerator::schema, and AlCaHLTBitMon_QueryRunRegistry::string.

1207  {
1208  bool ret = false;
1209  coral::ITable& containerTable = schema().tableHandle( tableName() );
1210  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1211  coral::AttributeList outputBuffer;
1212  outputBuffer.extend<std::string>( tokenColumn() );
1213  query->defineOutput( outputBuffer );
1214  query->addToOutputList( tokenColumn() );
1215  std::ostringstream condition;
1216  condition << objectNameColumn()<<"= :"<< objectNameColumn();
1217  coral::AttributeList condData;
1218  condData.extend<std::string>( objectNameColumn() );
1219  coral::AttributeList::iterator iAttribute = condData.begin();
1220  iAttribute->data< std::string >() = name;
1221  query->setCondition( condition.str(), condData );
1222  coral::ICursor& cursor = query->execute();
1223  while ( cursor.next() ) {
1224  ret = true;
1225  const coral::AttributeList& row = cursor.currentRow();
1226  std::string token = row[ tokenColumn() ].data< std::string >();
1227  std::pair<std::string,int> tokData = cond::parseToken( token );
1228  destination.first = m_dbCache.idByName( tokData.first );
1229  destination.second = tokData.second;
1230  }
1231  return ret;
1232 }
std::pair< std::string, int > parseToken(const std::string &objectId)
Definition: PoolToken.cc:15
string destination
int idByName(const std::string &name)
static std::string tokenColumn()
static std::string objectNameColumn()
coral::ISchema & schema()
tuple query
Definition: o2o.py:269
static std::string tableName()
std::string ora::CondMetadataTable::name ( )
virtual
std::string ora::CondMetadataTable::objectNameColumn ( )
static

Definition at line 1153 of file PoolDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1153  {
1154  static const std::string s_column("NAME");
1155  return s_column;
1156 }
void ora::CondMetadataTable::setObjectName ( const std::string &  name,
int  contId,
int  itemId 
)
virtual

Implements ora::INamingServiceTable.

Definition at line 1177 of file PoolDatabaseSchema.cc.

References python.IdGenerator::schema, AlCaHLTBitMon_QueryRunRegistry::string, and cond::writeToken().

1178  {
1179  coral::AttributeList dataToInsert;
1180  dataToInsert.extend<std::string>( objectNameColumn() );
1181  dataToInsert.extend<std::string>( tokenColumn());
1182  dataToInsert.extend<int>( timetypeColumn());
1183  ora::PoolDbCacheData& contData = m_dbCache.find( contId );
1184  std::string token = cond::writeToken( contData.m_name, contId, itemId, contData.m_className );
1185  dataToInsert[ objectNameColumn() ].data<std::string>() = name;
1186  dataToInsert[ tokenColumn() ].data<std::string>() = token;
1187  dataToInsert[ timetypeColumn() ].data<int>() = -1; // is it fine ???
1188  coral::ITable& containerTable = schema().tableHandle( tableName() );
1189  containerTable.dataEditor().insertRow( dataToInsert );
1190 }
static std::string tokenColumn()
static std::string objectNameColumn()
PoolDbCacheData & find(int id)
static std::string timetypeColumn()
coral::ISchema & schema()
std::string writeToken(const std::string &containerName, int oid0, int oid1, const std::string &className)
Definition: PoolToken.cc:44
static std::string tableName()
std::string ora::CondMetadataTable::tableName ( )
static

Definition at line 1148 of file PoolDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1148  {
1149  static const std::string s_name("METADATA");
1150  return s_name;
1151 }
std::string ora::CondMetadataTable::timetypeColumn ( )
static

Definition at line 1163 of file PoolDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1163  {
1164  static const std::string s_column("TIMETYPE");
1165  return s_column;
1166 }
std::string ora::CondMetadataTable::tokenColumn ( )
static

Definition at line 1158 of file PoolDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

1158  {
1159  static const std::string s_column("TOKEN");
1160  return s_column;
1161 }

Member Data Documentation

PoolDbCache& ora::CondMetadataTable::m_dbCache
private

Definition at line 223 of file PoolDatabaseSchema.h.