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 Attributes | Private Attributes
cond::DbSession Class Reference

#include <DbSession.h>

Public Member Functions

const std::string & blobStreamingService () const
 
std::string classNameForItem (const std::string &objectId)
 
void close ()
 
const DbConnectionconnection () const
 
const std::string & connectionString () const
 
bool createDatabase ()
 
 DbSession ()
 
 DbSession (const DbConnection &connection)
 
 DbSession (const DbSession &rhs)
 
bool deleteMapping (const std::string &mappingVersion)
 
bool deleteObject (const std::string &objectId)
 
void flush ()
 
ora::Object getObject (const std::string &objectId)
 
template<typename T >
boost::shared_ptr< TgetTypedObject (const std::string &objectId)
 
bool importMapping (const std::string &sourceConnectionString, const std::string &contName)
 
std::string importObject (cond::DbSession &fromDatabase, const std::string &objectId)
 
bool isOldSchema ()
 
bool isOpen () const
 
bool isTransactional () const
 
coral::ISchema & nominalSchema ()
 
void open (const std::string &connectionString, bool readOnly=false)
 
void open (const std::string &connectionString, const std::string &role, bool readOnly=false)
 
void open (boost::shared_ptr< coral::ISessionProxy > &coralSession, const std::string &connectionString, const std::string &schemaName="")
 
void openReadOnly (const std::string &connectionString, const std::string &id)
 
DbSessionoperator= (const DbSession &rhs)
 
coral::ISchema & schema (const std::string &schemaName)
 
ora::Databasestorage ()
 
template<typename T >
std::string storeObject (const T *object, const std::string &containerName)
 
std::string storeObject (const ora::Object &objectRef, const std::string &containerName)
 
DbTransactiontransaction ()
 
template<typename T >
bool updateObject (const T *object, const std::string &objectId)
 
virtual ~DbSession ()
 

Static Public Attributes

static const char * CHANGE_SCHEMA_VERSION = "2.0.0"
 
static const char * COND_SCHEMA_VERSION = "2.0.0"
 

Private Attributes

boost::shared_ptr< SessionImplm_implementation
 

Detailed Description

Definition at line 31 of file DbSession.h.

Constructor & Destructor Documentation

DbSession::DbSession ( )

Definition at line 139 of file DbSession.cc.

139  :
140  m_implementation( new SessionImpl ){
141 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
DbSession::DbSession ( const DbConnection connection)
explicit

Definition at line 143 of file DbSession.cc.

143  :
144  m_implementation( new SessionImpl ( connection ) ){
145 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
DbSession::DbSession ( const DbSession rhs)

Definition at line 147 of file DbSession.cc.

147  :
148  m_implementation( rhs.m_implementation ){
149 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
DbSession::~DbSession ( )
virtual

Definition at line 151 of file DbSession.cc.

151  {
152 }

Member Function Documentation

const std::string & DbSession::blobStreamingService ( ) const

Definition at line 203 of file DbSession.cc.

204 {
205  return m_implementation->blobStreamingService;
206 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
std::string DbSession::classNameForItem ( const std::string &  objectId)

Definition at line 296 of file DbSession.cc.

References ora::Container::className(), cont, ora::OId::containerId(), ora::OId::fromString(), ora::OId::isInvalid(), run_regression::ret, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::ExportIOVUtilities::execute(), cond::AlignSplitIOV::execute(), and cond::persistency::OraPayloadTable::getType().

296  {
297  ora::OId oid;
298  oid.fromString( objectId );
299  std::string ret("");
300  if( !oid.isInvalid() ){
302  ret = cont.className();
303  }
304  return ret;
305 }
bool isInvalid() const
Definition: OId.cc:80
Definition: OId.h:8
const std::string & className()
Definition: Container.cc:75
Container containerHandle(const std::string &name)
Definition: Database.cc:275
int containerId() const
Definition: OId.cc:50
int cont
bool fromString(const std::string &s)
Definition: OId.cc:64
ora::Database & storage()
Definition: DbSession.cc:217
void DbSession::close ( void  )
cond::DbConnection const & DbSession::connection ( ) const

Definition at line 194 of file DbSession.cc.

194  {
195  return *(m_implementation->connection);
196 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
const std::string & DbSession::connectionString ( ) const

Definition at line 188 of file DbSession.cc.

188  {
189  if(!m_implementation->database.get())
190  throw cond::Exception("DbSession::connectionString: cannot get connection string. Session has not been open.");
191  return m_implementation->database->connectionString();
192 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
bool DbSession::createDatabase ( )

Definition at line 225 of file DbSession.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::persistency::OraIOVSchema::create(), cond::AlignSplitIOV::processPayloadContainer(), TestFunct::Write(), and TestFunct::WriteWithIOV().

225  {
226  bool created = false;
227  if ( !storage().exists() ){
228  created = true;
230  }
231  return created;
232 }
bool create(std::string userSchemaVersion=std::string(""))
Definition: Database.cc:138
static const char * COND_SCHEMA_VERSION
Definition: DbSession.h:33
ora::Database & storage()
Definition: DbSession.cc:217
bool DbSession::deleteMapping ( const std::string &  mappingVersion)

Definition at line 252 of file DbSession.cc.

References ora::DatabaseUtility::eraseMapping().

252  {
253  ora::DatabaseUtility utility = storage().utility();
254  utility.eraseMapping( mappingVersion );
255  return true;
256 }
DatabaseUtility utility()
Definition: Database.cc:380
void eraseMapping(const std::string &mappingVersion)
ora::Database & storage()
Definition: DbSession.cc:217
bool DbSession::deleteObject ( const std::string &  objectId)

Definition at line 278 of file DbSession.cc.

References ora::OId::fromString().

Referenced by TestFunct::DropItem().

278  {
279  ora::OId oid;
280  oid.fromString( objectId );
281  storage().erase( oid );
282  storage().flush();
283  return true;
284 }
void flush()
Definition: Database.cc:323
Definition: OId.h:8
void erase(const OId &oid)
Definition: Database.cc:317
bool fromString(const std::string &s)
Definition: OId.cc:64
ora::Database & storage()
Definition: DbSession.cc:217
void DbSession::flush ( )

Definition at line 307 of file DbSession.cc.

Referenced by cond::persistency::OraPayloadTable::insertIfNew().

307  {
308  storage().flush();
309 }
void flush()
Definition: Database.cc:323
ora::Database & storage()
Definition: DbSession.cc:217
ora::Object DbSession::getObject ( const std::string &  objectId)

Definition at line 272 of file DbSession.cc.

References ora::OId::fromString().

Referenced by importObject(), cond::PayLoadInspector< DataT >::load(), and cond::persistency::OraPayloadTable::select().

272  {
273  ora::OId oid;
274  oid.fromString( objectId );
275  return storage().fetchItem( oid );
276 }
Definition: OId.h:8
Object fetchItem(const OId &oid)
Definition: Database.cc:297
bool fromString(const std::string &s)
Definition: OId.cc:64
ora::Database & storage()
Definition: DbSession.cc:217
template<typename T >
boost::shared_ptr< T > DbSession::getTypedObject ( const std::string &  objectId)
inline
bool DbSession::importMapping ( const std::string &  sourceConnectionString,
const std::string &  contName 
)

Definition at line 258 of file DbSession.cc.

References cond::buildTechnologyProxy(), and ora::DatabaseUtility::importContainerSchema().

259  {
260  ora::DatabaseUtility utility = storage().utility();
261  std::auto_ptr<cond::TechnologyProxy> technologyProxy = buildTechnologyProxy(sourceConnectionString, *(m_implementation->connection));
262  utility.importContainerSchema( (*technologyProxy).getRealConnectString( sourceConnectionString ), contName );
263  return true;
264 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
std::auto_ptr< cond::TechnologyProxy > buildTechnologyProxy(const std::string &userconnect, const DbConnection &connection)
Definition: DbSession.cc:17
void importContainerSchema(const std::string &sourceConnectionString, const std::string &containerName)
DatabaseUtility utility()
Definition: Database.cc:380
ora::Database & storage()
Definition: DbSession.cc:217
std::string DbSession::importObject ( cond::DbSession fromDatabase,
const std::string &  objectId 
)

Definition at line 286 of file DbSession.cc.

References cont, ora::Database::containerHandle(), ora::OId::containerId(), data, ora::Object::destruct(), ora::OId::fromString(), getObject(), ora::Container::name(), run_regression::ret, storage(), and AlCaHLTBitMon_QueryRunRegistry::string.

286  {
287  ora::OId oid;
288  oid.fromString( objectId );
289  ora::Object data = fromDatabase.getObject( objectId );
290  ora::Container cont = fromDatabase.storage().containerHandle( oid.containerId() );
291  std::string ret = storeObject( data, cont.name() );
292  data.destruct();
293  return ret;
294 }
const std::string & name()
Definition: Container.cc:71
Definition: OId.h:8
Container containerHandle(const std::string &name)
Definition: Database.cc:275
int containerId() const
Definition: OId.cc:50
std::string storeObject(const T *object, const std::string &containerName)
Definition: DbSession.h:132
int cont
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
ora::Object getObject(const std::string &objectId)
Definition: DbSession.cc:272
bool fromString(const std::string &s)
Definition: OId.cc:64
void destruct()
Definition: Object.cc:72
ora::Database & storage()
Definition: DbSession.cc:217
bool DbSession::isOldSchema ( )

Definition at line 234 of file DbSession.cc.

References ora::Version::fromString(), ora::Version::poolSchemaVersion(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::insertIOV(), cond::loadIOV(), cond::IOVProxyData::refresh(), and cond::updateIOV().

235 {
236  ora::Version dbVer = storage().schemaVersion();
237  if (dbVer == ora::Version::poolSchemaVersion()) return true;
238  dbVer = storage().schemaVersion( true );
240 }
static Version fromString(const std::string &versionString)
Definition: Version.cc:21
ora::Version schemaVersion(bool userSchema=false)
Definition: Database.cc:186
static const char * CHANGE_SCHEMA_VERSION
Definition: DbSession.h:34
static const Version & poolSchemaVersion()
Definition: Version.cc:11
ora::Database & storage()
Definition: DbSession.cc:217
bool DbSession::isOpen ( ) const

Definition at line 184 of file DbSession.cc.

184  {
185  return m_implementation->isOpen;
186 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
bool DbSession::isTransactional ( ) const

Definition at line 199 of file DbSession.cc.

199  {
200  return m_implementation->technologyProxy->isTransactional();
201 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
coral::ISchema & DbSession::nominalSchema ( )
void DbSession::open ( const std::string &  connectionString,
bool  readOnly = false 
)
void DbSession::open ( const std::string &  connectionString,
const std::string &  role,
bool  readOnly = false 
)

Definition at line 165 of file DbSession.cc.

Referenced by Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::importConfig().

166 {
167  m_implementation->open( connectionString, asRole, readOnly );
168 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
const std::string & connectionString() const
Definition: DbSession.cc:188
void DbSession::open ( boost::shared_ptr< coral::ISessionProxy > &  coralSession,
const std::string &  connectionString,
const std::string &  schemaName = "" 
)

Definition at line 175 of file DbSession.cc.

Referenced by Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::importConfig().

175  {
176  m_implementation->open( coralSession, connectionString, schemaName );
177 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
const std::string & connectionString() const
Definition: DbSession.cc:188
void DbSession::openReadOnly ( const std::string &  connectionString,
const std::string &  id 
)

Definition at line 170 of file DbSession.cc.

171 {
172  m_implementation->openReadOnly( connectionString, id );
173 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
const std::string & connectionString() const
Definition: DbSession.cc:188
cond::DbSession & DbSession::operator= ( const DbSession rhs)

Definition at line 154 of file DbSession.cc.

References m_implementation.

154  {
155  if(this!=&rhs) m_implementation = rhs.m_implementation;
156  return *this;
157 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
coral::ISchema & DbSession::schema ( const std::string &  schemaName)
ora::Database & DbSession::storage ( )

Definition at line 217 of file DbSession.cc.

Referenced by cond::ExportIOVUtilities::execute(), cond::persistency::OraIOVSchema::exists(), getTypedObject(), importObject(), cond::insertIOV(), cond::loadIOV(), cond::IOVProxyData::refresh(), storeObject(), cond::updateIOV(), and updateObject().

217  {
218  if(!m_implementation->connection.get() || !m_implementation->connection->isOpen())
219  throw cond::Exception("DbSession::storage: cannot access the storage. Underlying connection is closed.");
220  if(!m_implementation->database.get())
221  throw cond::Exception("DbSession::storage: cannot access the database. Session has not been open.");
222  return *m_implementation->database;
223 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
template<typename T >
std::string DbSession::storeObject ( const T object,
const std::string &  containerName 
)
inline

Definition at line 132 of file DbSession.h.

References ora::Database::flush(), ora::Database::insert(), run_regression::ret, storage(), AlCaHLTBitMon_QueryRunRegistry::string, and ora::OId::toString().

Referenced by cond::persistency::OraPayloadTable::insertIfNew(), cond::insertIOV(), cond::AlignSplitIOV::processPayloadContainer(), TestFunct::Write(), and TestFunct::WriteWithIOV().

133  {
134  std::string ret("");
135  if( object ){
136  ora::OId oid = storage().insert( containerName, *object );
137  storage().flush();
138  ret = oid.toString();
139  }
140  return ret;
141  }
void flush()
Definition: Database.cc:323
OId insert(const std::string &containerName, const T &data)
Definition: OId.h:8
std::string toString() const
Definition: OId.cc:58
ora::Database & storage()
Definition: DbSession.cc:217
std::string DbSession::storeObject ( const ora::Object objectRef,
const std::string &  containerName 
)

Definition at line 266 of file DbSession.cc.

References ora::OId::toString().

266  {
267  ora::OId oid = storage().insertItem( containerName, object );
268  storage().flush();
269  return oid.toString();
270 }
void flush()
Definition: Database.cc:323
Definition: OId.h:8
OId insertItem(const std::string &containerName, const Object &data)
Definition: Database.cc:302
std::string toString() const
Definition: OId.cc:58
ora::Database & storage()
Definition: DbSession.cc:217
cond::DbTransaction & DbSession::transaction ( )

Definition at line 208 of file DbSession.cc.

Referenced by cond::BasePayloadProxy::BasePayloadProxy(), cond::persistency::OraTransaction::commit(), cond::CondDB::commitTransaction(), l1t::OMDSReader::connect(), cond::ExportIOVUtilities::execute(), cond::AlignSplitIOV::execute(), FillInfoPopConSourceHandler::getNewObjects(), DTLVStatusHandler::getNewObjects(), DTHVStatusHandler::getNewObjects(), cond::RDBMS::globalTag(), cond::persistency::OraTransaction::isActive(), cond::KeyList::load(), cond::BasePayloadProxy::loadIov(), cond::BasePayloadProxy::loadTag(), cond::BasePayloadProxy::make(), l1t::OMDSReader::OMDSReader(), cond::PayLoadInspector< DataT >::plot(), cond::BasePayloadProxy::refresh(), cond::persistency::OraTransaction::rollback(), cond::CondDB::startReadOnlyTransaction(), cond::persistency::SessionImpl::startTransaction(), cond::CondDB::startTransaction(), cond::PayLoadInspector< DataT >::summary(), and cond::PayLoadInspector< DataT >::trend_plot().

209 {
210  if(!m_implementation->connection.get() || !m_implementation->connection->isOpen())
211  throw cond::Exception("DbSession::transaction: cannot open transaction. Underlying connection is closed.");
212  if(!m_implementation->transaction.get())
213  throw cond::Exception("DbSession::transaction: cannot get transaction. Session has not been open.");
214  return *m_implementation->transaction;
215 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:101
template<typename T >
bool DbSession::updateObject ( const T object,
const std::string &  objectId 
)
inline

Definition at line 143 of file DbSession.h.

References ora::Database::flush(), ora::OId::fromString(), run_regression::ret, storage(), and ora::Database::update().

Referenced by cond::updateIOV().

144  {
145  bool ret = false;
146  if( object ){
147  ora::OId oid;
148  oid.fromString( objectId );
149  storage().update( oid, *object );
150  storage().flush();
151  ret = true;
152  }
153  return ret;
154  }
void flush()
Definition: Database.cc:323
Definition: OId.h:8
void update(const OId &oid, const T &data)
Definition: Database.h:244
bool fromString(const std::string &s)
Definition: OId.cc:64
ora::Database & storage()
Definition: DbSession.cc:217

Member Data Documentation

const char * DbSession::CHANGE_SCHEMA_VERSION = "2.0.0"
static

Definition at line 34 of file DbSession.h.

const char * DbSession::COND_SCHEMA_VERSION = "2.0.0"
static

Definition at line 33 of file DbSession.h.

Referenced by cond::IOVSchemaUtility::createIOVContainer().

boost::shared_ptr<SessionImpl> cond::DbSession::m_implementation
private

Definition at line 101 of file DbSession.h.

Referenced by operator=().