test
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::OraSequenceTable Class Reference

#include <OraDatabaseSchema.h>

Inheritance diagram for ora::OraSequenceTable:
ora::ISequenceTable ora::IDatabaseTable

Public Member Functions

bool add (const std::string &sequenceName)
 
void create ()
 
void drop ()
 
void erase (const std::string &sequenceName)
 
bool exists ()
 
bool getLastId (const std::string &sequenceName, int &lastId)
 
std::string name ()
 
 OraSequenceTable (coral::ISchema &dbSchema)
 
 OraSequenceTable (const std::string &tableName, coral::ISchema &dbSchema)
 
void sinchronize (const std::string &sequenceName, int lastValue)
 
virtual ~OraSequenceTable ()
 
- Public Member Functions inherited from ora::ISequenceTable
 ISequenceTable (coral::ISchema &schema)
 
virtual ~ISequenceTable ()
 
- 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 sequenceNameColumn ()
 
static std::string sequenceValueColumn ()
 
static std::string tableName ()
 

Private Attributes

std::string m_tableName
 

Detailed Description

Definition at line 30 of file OraDatabaseSchema.h.

Constructor & Destructor Documentation

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

Definition at line 129 of file OraDatabaseSchema.cc.

129  :
131  m_tableName( tableName() ){
132 }
static std::string tableName()
coral::ISchema & schema()
ISequenceTable(coral::ISchema &schema)
ora::OraSequenceTable::OraSequenceTable ( const std::string &  tableName,
coral::ISchema &  dbSchema 
)

Definition at line 134 of file OraDatabaseSchema.cc.

135  :
137  m_tableName( tname ){
138 }
static char const * tname
Definition: GTSchema.h:13
coral::ISchema & schema()
ISequenceTable(coral::ISchema &schema)
ora::OraSequenceTable::~OraSequenceTable ( )
virtual

Definition at line 140 of file OraDatabaseSchema.cc.

140  {
141 }

Member Function Documentation

bool ora::OraSequenceTable::add ( const std::string &  sequenceName)
virtual

Implements ora::ISequenceTable.

Definition at line 144 of file OraDatabaseSchema.cc.

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

144  {
145  // Create the entry in the table
146  coral::AttributeList insertData;
147  insertData.extend<std::string>(sequenceNameColumn());
148  insertData.extend<int>(sequenceValueColumn());
149  coral::AttributeList::iterator iAttribute = insertData.begin();
150  iAttribute->data< std::string >() = sequenceName;
151  ++iAttribute;
152  iAttribute->data< int >() = -1;
153  schema().tableHandle( name() ).dataEditor().insertRow( insertData );
154  return true;
155 }
static std::string sequenceNameColumn()
static std::string sequenceValueColumn()
coral::ISchema & schema()
void ora::OraSequenceTable::create ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 209 of file OraDatabaseSchema.cc.

References idDealer::description, mergeVDriftHistosByStation::name, python.IdGenerator::schema, and ora::throwException().

209  {
210  if( schema().existsTable( name() )){
211  throwException( "ORA database sequence table already exists in this schema.",
212  "OraSequenceTable::create");
213  }
214 
215  coral::TableDescription description( "OraDb" );
216  description.setName( name() );
217 
218  description.insertColumn( sequenceNameColumn(), coral::AttributeSpecification::typeNameForType<std::string>() );
219  description.setNotNullConstraint( sequenceNameColumn() );
220 
221  description.insertColumn( sequenceValueColumn(),coral::AttributeSpecification::typeNameForType<int>() );
222  description.setNotNullConstraint( sequenceValueColumn() );
223 
224  description.setPrimaryKey( std::vector< std::string >( 1, sequenceNameColumn() ) );
225  schema().createTable( description );
226 }
static std::string sequenceNameColumn()
static std::string sequenceValueColumn()
tuple description
Definition: idDealer.py:66
coral::ISchema & schema()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void ora::OraSequenceTable::drop ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 228 of file OraDatabaseSchema.cc.

References mergeVDriftHistosByStation::name, and python.IdGenerator::schema.

228  {
229  schema().dropIfExistsTable( name() );
230 }
coral::ISchema & schema()
void ora::OraSequenceTable::erase ( const std::string &  sequenceName)
virtual

Implements ora::ISequenceTable.

Definition at line 193 of file OraDatabaseSchema.cc.

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

193  {
194  coral::AttributeList whereData;
195  whereData.extend<std::string>(sequenceNameColumn());
196  whereData[ sequenceNameColumn() ].data<std::string>() = sequenceName;
197  std::string whereClause( sequenceNameColumn() + " = :" + sequenceNameColumn() );
198  schema().tableHandle( name() ).dataEditor().deleteRows( whereClause, whereData );
199 }
static std::string sequenceNameColumn()
coral::ISchema & schema()
bool ora::OraSequenceTable::exists ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 205 of file OraDatabaseSchema.cc.

References mergeVDriftHistosByStation::name, and python.IdGenerator::schema.

205  {
206  return schema().existsTable( name() );
207 }
coral::ISchema & schema()
bool ora::OraSequenceTable::getLastId ( const std::string &  sequenceName,
int &  lastId 
)
virtual

Implements ora::ISequenceTable.

Definition at line 158 of file OraDatabaseSchema.cc.

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

159  {
160  std::auto_ptr< coral::IQuery > query( schema().tableHandle( name() ).newQuery() );
161  query->limitReturnedRows( 1, 0 );
162  query->addToOutputList( sequenceValueColumn() );
163  query->defineOutputType( sequenceValueColumn(), coral::AttributeSpecification::typeNameForType<int>() );
164  query->setForUpdate();
165  std::string whereClause( sequenceNameColumn() + " = :" + sequenceNameColumn() );
166  coral::AttributeList rowData;
167  rowData.extend<std::string>(sequenceNameColumn());
168  rowData.begin()->data< std::string >() = sequenceName;
169  query->setCondition( whereClause, rowData );
170  coral::ICursor& cursor = query->execute();
171  if ( cursor.next() ) {
172  lastId = cursor.currentRow().begin()->data<int >();
173  return true;
174  }
175  return false;
176 }
static std::string sequenceNameColumn()
static std::string sequenceValueColumn()
coral::ISchema & schema()
tuple query
Definition: o2o.py:269
std::string ora::OraSequenceTable::name ( )
virtual
std::string ora::OraSequenceTable::sequenceNameColumn ( )
static

Definition at line 119 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

119  {
120  static const std::string s_column("NAME");
121  return s_column;
122 }
std::string ora::OraSequenceTable::sequenceValueColumn ( )
static

Definition at line 124 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

124  {
125  static const std::string s_column("VALUE");
126  return s_column;
127 }
void ora::OraSequenceTable::sinchronize ( const std::string &  sequenceName,
int  lastValue 
)
virtual

Implements ora::ISequenceTable.

Definition at line 178 of file OraDatabaseSchema.cc.

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

179  {
180  coral::AttributeList updateData;
181  updateData.extend<std::string>(sequenceNameColumn());
182  updateData.extend<int>(sequenceValueColumn());
183  std::string setClause( sequenceValueColumn() + " = :" + sequenceValueColumn() );
184  std::string whereClause( sequenceNameColumn() + " = :" + sequenceNameColumn() );
185  // Increment the oid in the database as well
186  coral::AttributeList::iterator iAttribute = updateData.begin();
187  iAttribute->data< std::string >() = sequenceName;
188  ++iAttribute;
189  iAttribute->data< int >() = lastValue;
190  schema().tableHandle( name() ).dataEditor().updateRows( setClause,whereClause,updateData );
191 }
static std::string sequenceNameColumn()
static std::string sequenceValueColumn()
coral::ISchema & schema()
std::string ora::OraSequenceTable::tableName ( )
static

Definition at line 114 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

114  {
115  static const std::string s_name("ORA_SEQUENCE");
116  return s_name;
117 }

Member Data Documentation

std::string ora::OraSequenceTable::m_tableName
private

Definition at line 49 of file OraDatabaseSchema.h.