13 #include "RelationalAccess/ISessionProxy.h"
20 std::size_t pos=userconnect.find_first_of(
':');
21 if( pos!=std::string::npos ){
22 protocol=userconnect.substr(0,pos);
23 std::size_t
p=protocol.find_first_of(
'_');
24 if(p!=std::string::npos){
25 protocol=protocol.substr(0,p);
31 (*ptr).initialize(connection);
64 throw cond::Exception(
"DbSession::open: cannot open session. Underlying connection is closed.");
66 boost::shared_ptr<ora::ConnectionPool> connPool =
connection->connectionPool();
70 if(!blobStreamer)
throw cond::Exception(
"DbSession::open: cannot find required plugin. No instance of ora::IBlobStreamingService has been loaded..");
71 database->configuration().setBlobStreamingService( blobStreamer );
76 std::string connStr = (*technologyProxy).getRealConnectString( connectionString );
77 database->connect( connStr, role, readOnly );
88 throw cond::Exception(
"DbSession::open: cannot open session. Underlying connection is closed.");
90 boost::shared_ptr<ora::ConnectionPool> connPool =
connection->connectionPool();
94 if(!blobStreamer)
throw cond::Exception(
"DbSession::open: cannot find required plugin. No instance of ora::IBlobStreamingService has been loaded..");
95 database->configuration().setBlobStreamingService( blobStreamer );
98 std::string connStr = (*technologyProxy).getRealConnectString(connectionString, transactionId);
105 void open( boost::shared_ptr<coral::ISessionProxy>& coralSession,
112 if(!blobStreamer)
throw cond::Exception(
"DbSession::open: cannot find required plugin. No instance of ora::IBlobStreamingService has been loaded..");
113 database->configuration().setBlobStreamingService( blobStreamer );
115 database->connect( coralSession, connectionString, schemaName );
144 m_implementation( new
SessionImpl ( connection ) ){
148 m_implementation( rhs.m_implementation ){
162 m_implementation->open( connectionString, emptyRole, readOnly );
167 m_implementation->open( connectionString, asRole, readOnly );
172 m_implementation->openReadOnly( connectionString,
id );
176 m_implementation->open( coralSession, connectionString, schemaName );
181 m_implementation->close();
185 return m_implementation->isOpen;
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();
195 return *(m_implementation->connection);
200 return m_implementation->technologyProxy->isTransactional();
205 return m_implementation->blobStreamingService;
210 if(!m_implementation->transaction.get())
211 throw cond::Exception(
"DbSession::transaction: cannot get transaction. Session has not been open.");
212 return *m_implementation->transaction;
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;
222 bool created =
false;
223 if ( !storage().exists() ){
225 storage().create(
std::string(COND_SCHEMA_VERSION) );
234 dbVer = storage().schemaVersion(
true );
240 return storage().storageAccessSession().get().schema( schemaName );
245 return storage().storageAccessSession().get().nominalSchema();
257 std::auto_ptr<cond::TechnologyProxy> technologyProxy =
buildTechnologyProxy(sourceConnectionString, *(m_implementation->connection));
258 utility.
importContainerSchema( (*technologyProxy).getRealConnectString( sourceConnectionString ), contName );
263 ora::OId oid = storage().insertItem( containerName,
object );
271 return storage().fetchItem( oid );
277 storage().erase( oid );
312 std::pair<std::string,int> oidData =
parseToken( poolToken );
313 if( oidData.first.empty() ){
314 throwException(
"Could not resolve Container name from token=\""+poolToken+
"\".",
"PoolTokenParser::parse");
PoolTokenParser(ora::Database &db)
boost::shared_ptr< SessionImpl > m_implementation
const std::string & connectionString() const
std::string write(const ora::OId &oid)
bool deleteObject(const std::string &objectId)
std::string classNameForItem(const std::string &objectId)
std::auto_ptr< cond::TechnologyProxy > buildTechnologyProxy(const std::string &userconnect, const DbConnection &connection)
static Version fromString(const std::string &versionString)
std::pair< std::string, int > parseToken(const std::string &objectId)
DbTransaction & transaction()
void open(const std::string &connectionString, bool readOnly=false)
const std::string & blobStreamingService() const
const std::string & name()
void openReadOnly(const std::string &connectionString, const std::string &id)
std::auto_ptr< DbConnection > connection
bool deleteMapping(const std::string &mappingVersion)
static std::string automaticContainerCreation()
coral::ISchema & schema(const std::string &schemaName)
static const char * CHANGE_SCHEMA_VERSION
SessionImpl(const DbConnection &connection)
const std::string & className()
std::auto_ptr< DbTransaction > transaction
static const char * COND_SCHEMA_VERSION
void importContainerSchema(const std::string &sourceConnectionString, const std::string &containerName)
Container containerHandle(const std::string &name)
std::auto_ptr< ora::Database > database
ora::OId parse(const std::string &poolToken)
bool isTransactional() const
static const Version & poolSchemaVersion()
bool importMapping(const std::string &sourceConnectionString, const std::string &contName)
DbSession & operator=(const DbSession &rhs)
std::auto_ptr< cond::TechnologyProxy > technologyProxy
std::string storeObject(const T *object, const std::string &containerName)
static const std::string COND_READER_ROLE
PoolTokenWriter(ora::Database &db)
std::string className(const std::string &poolToken)
void throwException(std::string const &message, std::string const &methodName)
Interface for a Streaming Service.
coral::ISchema & nominalSchema()
void openReadOnly(const std::string &connectionString, const std::string &transactionId)
std::string toString() const
std::string importObject(cond::DbSession &fromDatabase, const std::string &objectId)
std::string realClassName()
char data[epos_bytes_allocation]
volatile std::atomic< bool > shutdown_flag false
std::string const blobStreamingService
std::string writeToken(const std::string &containerName, int oid0, int oid1, const std::string &className)
ora::Object getObject(const std::string &objectId)
bool fromString(const std::string &s)
void eraseMapping(const std::string &mappingVersion)
ora::Database & storage()
T get(const Candidate &c)
void open(const std::string &connectionString, const std::string &role, bool readOnly)
void open(boost::shared_ptr< coral::ISessionProxy > &coralSession, const std::string &connectionString, const std::string &schemaName)
const DbConnection & connection() const