Skip to content
Permalink
Browse files

oracle provider: refactor uri handling in oracle provider (followup d…

  • Loading branch information
jef-n committed Mar 23, 2016
1 parent cf22cab commit 8fdf48507b55066dff98c38ae46a755a7ec2c221
@@ -40,11 +40,7 @@ void QgsOracleColumnTypeThread::run()
{
mStopped = false;

QgsDataSourceURI uri = QgsOracleConn::connUri( mName );
QString conninfo = uri.connectionInfo();
if ( uri.hasParam( "dbworkspace" ) )
conninfo += " dbworkspace=" + uri.param( "dbworkspace" );

QString conninfo = QgsOracleConn::toPoolName( QgsOracleConn::connUri( mName ) );
QgsOracleConn *conn = QgsOracleConnPool::instance()->acquireConnection( conninfo );
if ( !conn )
{
@@ -33,10 +33,7 @@ const int QgsOracleConn::sGeomTypeSelectLimit = 100;

QgsOracleConn *QgsOracleConn::connectDb( QgsDataSourceURI uri )
{
QString conninfo = uri.connectionInfo();
if ( uri.hasParam( "dbworkspace" ) )
conninfo += " dbworkspace=" + uri.param( "dbworkspace" );

QString conninfo = toPoolName( uri );
if ( sConnections.contains( conninfo ) )
{
QgsDebugMsg( QString( "Using cached connection for %1" ).arg( conninfo ) );
@@ -143,6 +140,14 @@ QgsOracleConn::~QgsOracleConn()
mDatabase.close();
}

QString QgsOracleConn::toPoolName( QgsDataSourceURI uri )
{
QString conninfo = uri.connectionInfo();
if ( uri.hasParam( "dbworkspace" ) )
conninfo += " dbworkspace=" + uri.param( "dbworkspace" );
return conninfo;
}

QString QgsOracleConn::connInfo()
{
return sConnections.key( this, QString::null );
@@ -160,6 +160,7 @@ class QgsOracleConn : public QObject
static bool onlyExistingTypes( QString theConnName );
static void deleteConnection( QString theConnName );
static QString databaseName( QString database, QString host, QString port );
static QString toPoolName( QgsDataSourceURI uri );

operator QSqlDatabase() { return mDatabase; }

@@ -30,7 +30,7 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource* sour
, mRewind( false )
, mExpressionCompiled( false )
{
mConnection = QgsOracleConnPool::instance()->acquireConnection( mSource->mUri.connectionInfo() );
mConnection = QgsOracleConnPool::instance()->acquireConnection( QgsOracleConn::toPoolName( mSource->mUri ) );
if ( !mConnection )
{
close();
@@ -143,7 +143,7 @@ void QgsOracleNewConnection::on_btnConnect_clicked()
if ( !txtWorkspace->text().isEmpty() )
uri.setParam( "dbworkspace", txtWorkspace->text() );

QgsOracleConn *conn = QgsOracleConnPool::instance()->acquireConnection( uri.connectionInfo() );
QgsOracleConn *conn = QgsOracleConnPool::instance()->acquireConnection( QgsOracleConn::toPoolName( uri ) );

if ( conn )
{
@@ -70,7 +70,7 @@ QgsOracleProvider::QgsOracleProvider( QString const & uri )
mRequestedGeomType = mUri.wkbType();
mUseEstimatedMetadata = mUri.useEstimatedMetadata();

mConnection = QgsOracleConn::connectDb( mUri.connectionInfo() );
mConnection = QgsOracleConn::connectDb( mUri );
if ( !mConnection )
{
return;
@@ -518,7 +518,7 @@ void QgsOracleSourceSelect::on_btnConnect_clicked()
QgsDataSourceURI uri = QgsOracleConn::connUri( cmbConnections->currentText() );

mIsConnected = true;
mTablesTreeDelegate->setConnectionInfo( uri.connectionInfo() );
mTablesTreeDelegate->setConnectionInfo( uri );

mColumnTypeThread = new QgsOracleColumnTypeThread( cmbConnections->currentText(),
uri.useEstimatedMetadata(),
@@ -674,7 +674,7 @@ void QgsOracleSourceSelect::loadTableFromCache()


mIsConnected = true;
mTablesTreeDelegate->setConnectionInfo( uri.connectionInfo() );
mTablesTreeDelegate->setConnectionInfo( uri );

finishList();
}
@@ -62,7 +62,7 @@ class QgsOracleSourceSelectDelegate : public QItemDelegate
QgsOracleConn* conn() const
{
if ( !mConn )
setConn( QgsOracleConn::connectDb( mConnInfo ) );
setConn( QgsOracleConnPool::instance()->acquireConnection( QgsOracleConn::toPoolName( mConnInfo ) ) );
return mConn;
}

@@ -273,8 +273,7 @@ void _testTableCache()

// fetch

QgsDataSourceURI uri = QgsOracleConn::connUri( connName );
QgsOracleConn* c = QgsOracleConnectionPool::instance()->acquireConnection( uri.connectionInfo() );
QgsOracleConn* c = QgsOracleConnectionPool::instance()->acquireConnection( QgsOracleConn::toPoolName( QgsOracleConn::connUri( connName ) ) );
if ( !c )
return;

0 comments on commit 8fdf485

Please sign in to comment.
You can’t perform that action at this time.