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 Member Functions | 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 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)
 
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 Member Functions

std::string storeObject (const ora::Object &objectRef, const std::string &containerName)
 

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 124 of file DbSession.cc.

124  :
125  m_implementation( new SessionImpl ){
126 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
DbSession::DbSession ( const DbConnection connection)
explicit

Definition at line 128 of file DbSession.cc.

128  :
129  m_implementation( new SessionImpl ( connection ) ){
130 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
DbSession::DbSession ( const DbSession rhs)

Definition at line 132 of file DbSession.cc.

132  :
133  m_implementation( rhs.m_implementation ){
134 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
DbSession::~DbSession ( )
virtual

Definition at line 136 of file DbSession.cc.

136  {
137 }

Member Function Documentation

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

Definition at line 184 of file DbSession.cc.

185 {
186  return m_implementation->blobStreamingService;
187 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
std::string DbSession::classNameForItem ( const std::string &  objectId)

Definition at line 277 of file DbSession.cc.

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

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

277  {
278  ora::OId oid;
279  oid.fromString( objectId );
280  std::string ret("");
281  if( !oid.isInvalid() ){
283  ret = cont.className();
284  }
285  return ret;
286 }
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:272
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:198
void DbSession::close ( void  )
cond::DbConnection const & DbSession::connection ( ) const

Definition at line 175 of file DbSession.cc.

175  {
176  return *(m_implementation->connection);
177 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
const std::string & DbSession::connectionString ( ) const

Definition at line 169 of file DbSession.cc.

Referenced by PCLMetadataWriter::endRun(), and popcon::PopCon::initialize().

169  {
170  if(!m_implementation->database.get())
171  throw cond::Exception("DbSession::connectionString: cannot get connection string. Session has not been open.");
172  return m_implementation->database->connectionString();
173 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
bool DbSession::createDatabase ( )

Definition at line 206 of file DbSession.cc.

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

206  {
207  bool created = false;
208  if ( !storage().exists() ){
209  created = true;
210  storage().create( std::string(COND_SCHEMA_VERSION) );
211  }
212  return created;
213 }
bool create(std::string userSchemaVersion=std::string(""))
Definition: Database.cc:135
static const char * COND_SCHEMA_VERSION
Definition: DbSession.h:33
ora::Database & storage()
Definition: DbSession.cc:198
bool DbSession::deleteMapping ( const std::string &  mappingVersion)

Definition at line 233 of file DbSession.cc.

References ora::DatabaseUtility::eraseMapping().

233  {
234  ora::DatabaseUtility utility = storage().utility();
235  utility.eraseMapping( mappingVersion );
236  return true;
237 }
DatabaseUtility utility()
Definition: Database.cc:377
void eraseMapping(const std::string &mappingVersion)
ora::Database & storage()
Definition: DbSession.cc:198
bool DbSession::deleteObject ( const std::string &  objectId)

Definition at line 259 of file DbSession.cc.

References ora::OId::fromString().

Referenced by TestFunct::DropItem().

259  {
260  ora::OId oid;
261  oid.fromString( objectId );
262  storage().erase( oid );
263  storage().flush();
264  return true;
265 }
void flush()
Definition: Database.cc:320
Definition: OId.h:8
void erase(const OId &oid)
Definition: Database.cc:314
bool fromString(const std::string &s)
Definition: OId.cc:64
ora::Database & storage()
Definition: DbSession.cc:198
void DbSession::flush ( )

Definition at line 288 of file DbSession.cc.

288  {
289  storage().flush();
290 }
void flush()
Definition: Database.cc:320
ora::Database & storage()
Definition: DbSession.cc:198
ora::Object DbSession::getObject ( const std::string &  objectId)

Definition at line 253 of file DbSession.cc.

References ora::OId::fromString().

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

253  {
254  ora::OId oid;
255  oid.fromString( objectId );
256  return storage().fetchItem( oid );
257 }
Definition: OId.h:8
Object fetchItem(const OId &oid)
Definition: Database.cc:294
bool fromString(const std::string &s)
Definition: OId.cc:64
ora::Database & storage()
Definition: DbSession.cc:198
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 239 of file DbSession.cc.

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

240  {
241  ora::DatabaseUtility utility = storage().utility();
242  std::auto_ptr<cond::TechnologyProxy> technologyProxy = buildTechnologyProxy(sourceConnectionString, *(m_implementation->connection));
243  utility.importContainerSchema( (*technologyProxy).getRealConnectString( sourceConnectionString ), contName );
244  return true;
245 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
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:377
ora::Database & storage()
Definition: DbSession.cc:198
std::string DbSession::importObject ( cond::DbSession fromDatabase,
const std::string &  objectId 
)

Definition at line 267 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, and storage().

267  {
268  ora::OId oid;
269  oid.fromString( objectId );
270  ora::Object data = fromDatabase.getObject( objectId );
271  ora::Container cont = fromDatabase.storage().containerHandle( oid.containerId() );
272  std::string ret = storeObject( data, cont.name() );
273  data.destruct();
274  return ret;
275 }
const std::string & name()
Definition: Container.cc:71
Definition: OId.h:8
Container containerHandle(const std::string &name)
Definition: Database.cc:272
int containerId() const
Definition: OId.cc:50
std::string storeObject(const T *object, const std::string &containerName)
Definition: DbSession.h:131
int cont
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
ora::Object getObject(const std::string &objectId)
Definition: DbSession.cc:253
bool fromString(const std::string &s)
Definition: OId.cc:64
void destruct()
Definition: Object.cc:63
ora::Database & storage()
Definition: DbSession.cc:198
bool DbSession::isOldSchema ( )

Definition at line 215 of file DbSession.cc.

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

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

216 {
217  ora::Version dbVer = storage().schemaVersion();
218  if (dbVer == ora::Version::poolSchemaVersion()) return true;
219  dbVer = storage().schemaVersion( true );
220  return dbVer < ora::Version::fromString( std::string( CHANGE_SCHEMA_VERSION ) );
221 }
static Version fromString(const std::string &versionString)
Definition: Version.cc:24
ora::Version schemaVersion(bool userSchema=false)
Definition: Database.cc:183
static const char * CHANGE_SCHEMA_VERSION
Definition: DbSession.h:34
static Version & poolSchemaVersion()
Definition: Version.cc:11
ora::Database & storage()
Definition: DbSession.cc:198
bool DbSession::isOpen ( ) const

Definition at line 165 of file DbSession.cc.

165  {
166  return m_implementation->isOpen;
167 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
bool DbSession::isTransactional ( ) const

Definition at line 180 of file DbSession.cc.

180  {
181  return m_implementation->technologyProxy->isTransactional();
182 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
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 150 of file DbSession.cc.

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

151 {
152  m_implementation->open( connectionString, asRole, readOnly );
153 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
const std::string & connectionString() const
Definition: DbSession.cc:169
void DbSession::openReadOnly ( const std::string &  connectionString,
const std::string &  id 
)

Definition at line 155 of file DbSession.cc.

Referenced by CondDBESSource::CondDBESSource(), and CondDBESSource::setIntervalFor().

156 {
157  m_implementation->openReadOnly( connectionString, id );
158 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
const std::string & connectionString() const
Definition: DbSession.cc:169
cond::DbSession & DbSession::operator= ( const DbSession rhs)

Definition at line 139 of file DbSession.cc.

References m_implementation.

139  {
140  if(this!=&rhs) m_implementation = rhs.m_implementation;
141  return *this;
142 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
coral::ISchema & DbSession::schema ( const std::string &  schemaName)
ora::Database & DbSession::storage ( )

Definition at line 198 of file DbSession.cc.

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

198  {
199  if(!m_implementation->connection.get() || !m_implementation->connection->isOpen())
200  throw cond::Exception("DbSession::storage: cannot access the storage. Underlying connection is closed.");
201  if(!m_implementation->database.get())
202  throw cond::Exception("DbSession::storage: cannot access the database. Session has not been open.");
203  return *m_implementation->database;
204 }
boost::shared_ptr< SessionImpl > m_implementation
Definition: DbSession.h:100
template<typename T >
std::string DbSession::storeObject ( const T object,
const std::string &  containerName 
)
inline

Definition at line 131 of file DbSession.h.

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

Referenced by cond::insertIOV(), cond::service::GetTokenFromPointer< T >::operator()(), cond::AlignSplitIOV::processPayloadContainer(), l1t::WriterProxyT< Record, Type >::save(), TestFunct::Write(), l1t::DataWriter::writeKeyList(), and TestFunct::WriteWithIOV().

132  {
133  std::string ret("");
134  if( object ){
135  ora::OId oid = storage().insert( containerName, *object );
136  storage().flush();
137  ret = oid.toString();
138  }
139  return ret;
140  }
void flush()
Definition: Database.cc:320
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:198
std::string DbSession::storeObject ( const ora::Object objectRef,
const std::string &  containerName 
)
private

Definition at line 247 of file DbSession.cc.

References ora::OId::toString().

247  {
248  ora::OId oid = storage().insertItem( containerName, object );
249  storage().flush();
250  return oid.toString();
251 }
void flush()
Definition: Database.cc:320
Definition: OId.h:8
OId insertItem(const std::string &containerName, const Object &data)
Definition: Database.cc:299
std::string toString() const
Definition: OId.cc:58
ora::Database & storage()
Definition: DbSession.cc:198
cond::DbTransaction & DbSession::transaction ( )
template<typename T >
bool DbSession::updateObject ( const T object,
const std::string &  objectId 
)
inline

Definition at line 142 of file DbSession.h.

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

Referenced by cond::updateIOV().

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

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 100 of file DbSession.h.

Referenced by operator=().