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

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

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

292  {
293  ora::OId oid;
294  oid.fromString( objectId );
295  std::string ret("");
296  if( !oid.isInvalid() ){
298  ret = cont.realClassName();
299  }
300  return ret;
301 }
bool isInvalid() const
Definition: OId.cc:80
Definition: OId.h:8
Container containerHandle(const std::string &name)
Definition: Database.cc:275
int containerId() const
Definition: OId.cc:50
int cont
std::string realClassName()
Definition: Container.cc:79
bool fromString(const std::string &s)
Definition: OId.cc:64
ora::Database & storage()
Definition: DbSession.cc:215
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 221 of file DbSession.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

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

221  {
222  bool created = false;
223  if ( !storage().exists() ){
224  created = true;
226  }
227  return created;
228 }
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:215
bool DbSession::deleteMapping ( const std::string &  mappingVersion)

Definition at line 248 of file DbSession.cc.

References ora::DatabaseUtility::eraseMapping().

248  {
249  ora::DatabaseUtility utility = storage().utility();
250  utility.eraseMapping( mappingVersion );
251  return true;
252 }
DatabaseUtility utility()
Definition: Database.cc:380
void eraseMapping(const std::string &mappingVersion)
ora::Database & storage()
Definition: DbSession.cc:215
bool DbSession::deleteObject ( const std::string &  objectId)

Definition at line 274 of file DbSession.cc.

References ora::OId::fromString().

Referenced by TestFunct::DropItem().

274  {
275  ora::OId oid;
276  oid.fromString( objectId );
277  storage().erase( oid );
278  storage().flush();
279  return true;
280 }
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:215
void DbSession::flush ( )

Definition at line 303 of file DbSession.cc.

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

303  {
304  storage().flush();
305 }
void flush()
Definition: Database.cc:323
ora::Database & storage()
Definition: DbSession.cc:215
ora::Object DbSession::getObject ( const std::string &  objectId)

Definition at line 268 of file DbSession.cc.

References ora::OId::fromString().

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

268  {
269  ora::OId oid;
270  oid.fromString( objectId );
271  return storage().fetchItem( oid );
272 }
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:215
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 254 of file DbSession.cc.

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

255  {
256  ora::DatabaseUtility utility = storage().utility();
257  std::auto_ptr<cond::TechnologyProxy> technologyProxy = buildTechnologyProxy(sourceConnectionString, *(m_implementation->connection));
258  utility.importContainerSchema( (*technologyProxy).getRealConnectString( sourceConnectionString ), contName );
259  return true;
260 }
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:215
std::string DbSession::importObject ( cond::DbSession fromDatabase,
const std::string &  objectId 
)

Definition at line 282 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.

282  {
283  ora::OId oid;
284  oid.fromString( objectId );
285  ora::Object data = fromDatabase.getObject( objectId );
286  ora::Container cont = fromDatabase.storage().containerHandle( oid.containerId() );
287  std::string ret = storeObject( data, cont.name() );
288  data.destruct();
289  return ret;
290 }
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:268
bool fromString(const std::string &s)
Definition: OId.cc:64
void destruct()
Definition: Object.cc:81
ora::Database & storage()
Definition: DbSession.cc:215
bool DbSession::isOldSchema ( )

Definition at line 230 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().

231 {
232  ora::Version dbVer = storage().schemaVersion();
233  if (dbVer == ora::Version::poolSchemaVersion()) return true;
234  dbVer = storage().schemaVersion( true );
236 }
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:215
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 215 of file DbSession.cc.

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

215  {
216  if(!m_implementation->database.get())
217  throw cond::Exception("DbSession::storage: cannot access the database. Session has not been open.");
218  return *m_implementation->database;
219 }
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:215
std::string DbSession::storeObject ( const ora::Object objectRef,
const std::string &  containerName 
)

Definition at line 262 of file DbSession.cc.

References ora::OId::toString().

262  {
263  ora::OId oid = storage().insertItem( containerName, object );
264  storage().flush();
265  return oid.toString();
266 }
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:215
cond::DbTransaction & DbSession::transaction ( )
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:215

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=().