#include <DbSession.h>
Public Member Functions | |
const std::string & | blobStreamingService () const |
std::string | classNameForItem (const std::string &objectId) |
void | close () |
const DbConnection & | connection () const |
const std::string & | connectionString () const |
bool | createDatabase () |
DbSession (const DbConnection &connection) | |
DbSession (const DbSession &rhs) | |
DbSession () | |
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< T > | getTypedObject (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) |
DbSession & | operator= (const DbSession &rhs) |
coral::ISchema & | schema (const std::string &schemaName) |
ora::Database & | storage () |
template<typename T > | |
std::string | storeObject (const T *object, const std::string &containerName) |
DbTransaction & | transaction () |
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< SessionImpl > | m_implementation |
Definition at line 31 of file DbSession.h.
DbSession::DbSession | ( | ) |
Definition at line 101 of file DbSession.cc.
: m_implementation( new SessionImpl ){ }
DbSession::DbSession | ( | const DbConnection & | connection | ) | [explicit] |
Definition at line 105 of file DbSession.cc.
: m_implementation( new SessionImpl ( connection ) ){ }
DbSession::DbSession | ( | const DbSession & | rhs | ) |
Definition at line 109 of file DbSession.cc.
: m_implementation( rhs.m_implementation ){ }
DbSession::~DbSession | ( | ) | [virtual] |
Definition at line 113 of file DbSession.cc.
{ }
const std::string & DbSession::blobStreamingService | ( | ) | const |
Definition at line 156 of file DbSession.cc.
{ return m_implementation->blobStreamingService; }
std::string DbSession::classNameForItem | ( | const std::string & | objectId | ) |
Definition at line 249 of file DbSession.cc.
References ora::Container::className(), cont, ora::OId::containerId(), ora::OId::fromString(), ora::OId::isInvalid(), and runTheMatrix::ret.
Referenced by cond::ExportIOVUtilities::execute(), and cond::AlignSplitIOV::execute().
{ ora::OId oid; oid.fromString( objectId ); std::string ret(""); if( !oid.isInvalid() ){ ora::Container cont = storage().containerHandle( oid.containerId() ); ret = cont.className(); } return ret; }
void DbSession::close | ( | void | ) |
Definition at line 132 of file DbSession.cc.
Referenced by cond::CondDB::closeSession(), DTLVStatusHandler::getNewObjects(), DTKeyedConfigHandler::getNewObjects(), DTUserKeyedConfigHandler::getNewObjects(), FillInfoPopConSourceHandler::getNewObjects(), DTHVStatusHandler::getNewObjects(), cond::PayLoadInspector< DataT >::summary(), cond::PayLoadInspector< DataT >::trend_plot(), and l1t::DataManager::~DataManager().
{ m_implementation->close(); }
cond::DbConnection const & DbSession::connection | ( | ) | const |
Definition at line 147 of file DbSession.cc.
{ return *(m_implementation->connection); }
const std::string & DbSession::connectionString | ( | ) | const |
Definition at line 141 of file DbSession.cc.
{ if(!m_implementation->database.get()) throw cond::Exception("DbSession::connectionString: cannot get connection string. Session has not been open."); return m_implementation->database->connectionString(); }
bool DbSession::createDatabase | ( | ) |
Definition at line 178 of file DbSession.cc.
Referenced by cond::AlignSplitIOV::processPayloadContainer(), TestFunct::Write(), and TestFunct::WriteWithIOV().
{ bool created = false; if ( !storage().exists() ){ created = true; storage().create( std::string(COND_SCHEMA_VERSION) ); } return created; }
bool DbSession::deleteMapping | ( | const std::string & | mappingVersion | ) |
Definition at line 205 of file DbSession.cc.
References ora::DatabaseUtility::eraseMapping().
{ ora::DatabaseUtility utility = storage().utility(); utility.eraseMapping( mappingVersion ); return true; }
bool DbSession::deleteObject | ( | const std::string & | objectId | ) |
Definition at line 231 of file DbSession.cc.
References ora::OId::fromString().
Referenced by TestFunct::DropItem().
void DbSession::flush | ( | ) |
Definition at line 260 of file DbSession.cc.
ora::Object DbSession::getObject | ( | const std::string & | objectId | ) |
Definition at line 225 of file DbSession.cc.
References ora::OId::fromString().
Referenced by importObject(), and cond::PayLoadInspector< DataT >::load().
{ ora::OId oid; oid.fromString( objectId ); return storage().fetchItem( oid ); }
boost::shared_ptr< T > DbSession::getTypedObject | ( | const std::string & | objectId | ) | [inline] |
Definition at line 125 of file DbSession.h.
References ora::Database::fetch(), ora::OId::fromString(), and storage().
Referenced by cond::PayloadRef< std::vector< cond::Time_t > >::load(), cond::KeyList::load(), cond::loadIOV(), cond::PayLoadInspector< DataT >::plot(), cond::AlignSplitIOV::processPayloadContainer(), TestFunct::Read(), l1t::DataWriter::readObject(), TestFunct::ReadWithIOV(), popcon::PopConSourceHandler< T >::Ref::Ref(), cond::IOVProxyData::refresh(), cond::PayLoadInspector< DataT >::summary(), and cond::PayLoadInspector< DataT >::trend_plot().
{ ora::OId oid; oid.fromString( objectId ); return storage().fetch<T>( oid ); }
bool DbSession::importMapping | ( | const std::string & | sourceConnectionString, |
const std::string & | contName | ||
) |
Definition at line 211 of file DbSession.cc.
References cond::buildTechnologyProxy(), and ora::DatabaseUtility::importContainerSchema().
{ ora::DatabaseUtility utility = storage().utility(); std::auto_ptr<cond::TechnologyProxy> technologyProxy = buildTechnologyProxy(sourceConnectionString, *(m_implementation->connection)); utility.importContainerSchema( (*technologyProxy).getRealConnectString(), contName ); return true; }
std::string DbSession::importObject | ( | cond::DbSession & | fromDatabase, |
const std::string & | objectId | ||
) |
Definition at line 239 of file DbSession.cc.
References cont, ora::Database::containerHandle(), ora::OId::containerId(), AlCaHLTBitMon_QueryRunRegistry::data, ora::Object::destruct(), ora::OId::fromString(), getObject(), ora::Container::name(), runTheMatrix::ret, and storage().
{ ora::OId oid; oid.fromString( objectId ); ora::Object data = fromDatabase.getObject( objectId ); ora::Container cont = fromDatabase.storage().containerHandle( oid.containerId() ); std::string ret = storeObject( data, cont.name() ); data.destruct(); return ret; }
bool DbSession::isOldSchema | ( | ) |
Definition at line 187 of file DbSession.cc.
References pat::helper::ParametrizationHelper::fromString(), and ora::Version::poolSchemaVersion().
Referenced by cond::insertIOV(), cond::loadIOV(), cond::IOVProxyData::refresh(), and cond::updateIOV().
{ ora::Version dbVer = storage().schemaVersion(); if (dbVer == ora::Version::poolSchemaVersion()) return true; dbVer = storage().schemaVersion( true ); return dbVer < ora::Version::fromString( std::string( CHANGE_SCHEMA_VERSION ) ); }
bool DbSession::isOpen | ( | ) | const |
Definition at line 137 of file DbSession.cc.
{ return m_implementation->isOpen; }
bool DbSession::isTransactional | ( | ) | const |
Definition at line 152 of file DbSession.cc.
{ return m_implementation->technologyProxy->isTransactional(); }
coral::ISchema & DbSession::nominalSchema | ( | ) |
Definition at line 200 of file DbSession.cc.
Referenced by l1t::OMDSReader::basicQuery(), l1t::OMDSReader::basicQueryGenericKey(), l1t::OMDSReader::basicQueryView(), DTHVStatusHandler::checkForPeriod(), DTHVStatusHandler::checkNewData(), DTUserKeyedConfigHandler::chkConfigList(), DTKeyedConfigHandler::chkConfigList(), l1t::OMDSReader::columnNames(), l1t::OMDSReader::columnNamesView(), TestFunct::CreateMetaTable(), DTHVStatusHandler::createSnapshot(), DTHVStatusHandler::dumpHVAliases(), DTHVStatusHandler::dumpSnapshot(), DTHVStatusHandler::getChannelMap(), DTHVStatusHandler::getChannelSplit(), DTHVStatusHandler::getLayerSplit(), TestFunct::GetMetadata(), DTKeyedConfigHandler::getNewObjects(), DTUserKeyedConfigHandler::getNewObjects(), FillInfoPopConSourceHandler::getNewObjects(), TestFunct::Read(), DTHVStatusHandler::recoverSnapshot(), TestFunct::Write(), and TestFunct::WriteWithIOV().
{ return storage().storageAccessSession().get().nominalSchema(); }
void DbSession::open | ( | const std::string & | connectionString, |
bool | readOnly = false |
||
) |
Definition at line 121 of file DbSession.cc.
Referenced by CondDBESSource::CondDBESSource(), l1t::DataManager::connect(), CondDBESSource::fillTagCollectionFromDB(), cond::RDBMS::getDB(), HcalO2OManager::getListOfPoolIovs(), HcalO2OManager::getListOfPoolTags(), DTLVStatusHandler::getNewObjects(), DTKeyedConfigHandler::getNewObjects(), DTUserKeyedConfigHandler::getNewObjects(), FillInfoPopConSourceHandler::getNewObjects(), DTHVStatusHandler::getNewObjects(), cond::RDBMS::getReadOnlyDB(), cond::RDBMS::globalTag(), SiStripCoralIface::initialize(), L1ConfigOnlineProdBase< TRcd, TData >::L1ConfigOnlineProdBase(), cond::PayLoadInspector< DataT >::plot(), cond::service::PoolDBOutputService::PoolDBOutputService(), cond::PayLoadInspector< DataT >::summary(), and cond::PayLoadInspector< DataT >::trend_plot().
{ std::string emptyRole(""); m_implementation->open( connectionString, emptyRole, readOnly ); }
void DbSession::open | ( | const std::string & | connectionString, |
const std::string & | role, | ||
bool | readOnly = false |
||
) |
Definition at line 127 of file DbSession.cc.
{ m_implementation->open( connectionString, asRole, readOnly ); }
cond::DbSession & DbSession::operator= | ( | const DbSession & | rhs | ) |
Definition at line 116 of file DbSession.cc.
References m_implementation.
{ if(this!=&rhs) m_implementation = rhs.m_implementation; return *this; }
coral::ISchema & DbSession::schema | ( | const std::string & | schemaName | ) |
Definition at line 195 of file DbSession.cc.
Referenced by l1t::OMDSReader::basicQuery(), l1t::OMDSReader::basicQueryGenericKey(), l1t::OMDSReader::basicQueryView(), l1t::OMDSReader::columnNames(), l1t::OMDSReader::columnNamesView(), SiStripCoralIface::doNameQuery(), SiStripCoralIface::doQuery(), SiStripCoralIface::doSettingsQuery(), FillInfoPopConSourceHandler::getNewObjects(), and L1CaloHcalScaleConfigOnlineProd::newObject().
{ return storage().storageAccessSession().get().schema( schemaName ); }
ora::Database & DbSession::storage | ( | ) |
Definition at line 170 of file DbSession.cc.
Referenced by cond::ExportIOVUtilities::execute(), getTypedObject(), importObject(), cond::insertIOV(), cond::loadIOV(), cond::IOVProxyData::refresh(), storeObject(), cond::updateIOV(), and updateObject().
{ if(!m_implementation->connection.get() || !m_implementation->connection->isOpen()) throw cond::Exception("DbSession::storage: cannot access the storage. Underlying connection is closed."); if(!m_implementation->database.get()) throw cond::Exception("DbSession::storage: cannot access the database. Session has not been open."); return *m_implementation->database; }
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(), runTheMatrix::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().
std::string DbSession::storeObject | ( | const ora::Object & | objectRef, |
const std::string & | containerName | ||
) | [private] |
Definition at line 219 of file DbSession.cc.
References ora::OId::toString().
cond::DbTransaction & DbSession::transaction | ( | ) |
Definition at line 161 of file DbSession.cc.
Referenced by cond::BasePayloadProxy::BasePayloadProxy(), cond::CondDB::commitTransaction(), l1t::OMDSReader::connect(), cond::ExportIOVUtilities::execute(), cond::AlignSplitIOV::execute(), CondDBESSource::fillTagCollectionFromDB(), DTLVStatusHandler::getNewObjects(), DTKeyedConfigHandler::getNewObjects(), DTUserKeyedConfigHandler::getNewObjects(), FillInfoPopConSourceHandler::getNewObjects(), DTHVStatusHandler::getNewObjects(), cond::RDBMS::globalTag(), cond::KeyList::load(), cond::BasePayloadProxy::loadIov(), cond::BasePayloadProxy::loadTag(), cond::BasePayloadProxy::make(), l1t::OMDSReader::OMDSReader(), cond::PayLoadInspector< DataT >::plot(), cond::BasePayloadProxy::refresh(), cond::CondDB::startReadOnlyTransaction(), cond::CondDB::startTransaction(), cond::PayLoadInspector< DataT >::summary(), and cond::PayLoadInspector< DataT >::trend_plot().
{ if(!m_implementation->connection.get() || !m_implementation->connection->isOpen()) throw cond::Exception("DbSession::transaction: cannot open transaction. Underlying connection is closed."); if(!m_implementation->transaction.get()) throw cond::Exception("DbSession::transaction: cannot get transaction. Session has not been open."); return *m_implementation->transaction; }
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(), runTheMatrix::ret, storage(), and ora::Database::update().
Referenced by cond::updateIOV().
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=().