mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Osdu: get well paths from ddms instead of Osdu Storage api.
This commit is contained in:
@@ -195,17 +195,57 @@ void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QS
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& wellboreId )
|
||||
std::vector<OsduWellLog> RiaOsduConnector::requestWellLogsByWellboreIdBlocking( const QString& wellboreId )
|
||||
{
|
||||
requestWellboreTrajectoryByWellboreId( m_server, m_dataPartitionId, m_token, wellboreId );
|
||||
QString token = requestTokenBlocking();
|
||||
|
||||
QEventLoop loop;
|
||||
connect( this, SIGNAL( wellLogsFinished( const QString& ) ), &loop, SLOT( quit() ) );
|
||||
requestWellLogsByWellboreId( m_server, m_dataPartitionId, token, wellboreId );
|
||||
loop.exec();
|
||||
|
||||
return m_wellLogs[wellboreId];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::requestFileDownloadByFileId( const QString& fileId )
|
||||
void RiaOsduConnector::requestWellLogsByWellboreId( const QString& wellboreId )
|
||||
{
|
||||
requestFileDownloadByFileId( m_server, m_dataPartitionId, m_token, fileId );
|
||||
requestWellLogsByWellboreId( m_server, m_dataPartitionId, m_token, wellboreId );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server,
|
||||
const QString& dataPartitionId,
|
||||
const QString& token,
|
||||
const QString& wellboreId )
|
||||
{
|
||||
std::map<QString, QString> params;
|
||||
params["kind"] = WELL_LOG_KIND;
|
||||
params["limit"] = "10000";
|
||||
params["query"] = "data.WellboreID: \"" + wellboreId + "\"";
|
||||
|
||||
auto reply = makeSearchRequest( params, server, dataPartitionId, token );
|
||||
connect( reply,
|
||||
&QNetworkReply::finished,
|
||||
[this, reply, wellboreId]()
|
||||
{
|
||||
if ( reply->error() == QNetworkReply::NoError )
|
||||
{
|
||||
parseWellLogs( reply, wellboreId );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& wellboreId )
|
||||
{
|
||||
requestWellboreTrajectoryByWellboreId( m_server, m_dataPartitionId, m_token, wellboreId );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -233,30 +273,6 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser
|
||||
} );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::requestFileDownloadByFileId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fileId )
|
||||
{
|
||||
RiaLogging::info( "Requesting download of file id: " + fileId );
|
||||
QString url = constructFileDownloadUrl( server, fileId );
|
||||
|
||||
auto reply = makeDownloadRequest( url, dataPartitionId, token, CONTENT_TYPE_JSON );
|
||||
connect( reply,
|
||||
&QNetworkReply::finished,
|
||||
[this, reply, fileId]()
|
||||
{
|
||||
if ( reply->error() == QNetworkReply::NoError )
|
||||
{
|
||||
saveFile( reply, fileId );
|
||||
}
|
||||
else
|
||||
{
|
||||
RiaLogging::error( "File request for id " + fileId + " failed." + reply->errorString() );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -297,6 +313,14 @@ QString RiaOsduConnector::constructWellLogDownloadUrl( const QString& server, co
|
||||
return server + "/api/os-wellbore-ddms/ddms/v3/welllogs/" + wellLogId + "/data";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaOsduConnector::constructWellboreTrajectoriesDownloadUrl( const QString& server, const QString& wellboreTrajectoryId )
|
||||
{
|
||||
return server + "/api/os-wellbore-ddms/ddms/v3/wellboretrajectories/" + wellboreTrajectoryId + "/data";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -430,21 +454,10 @@ void RiaOsduConnector::parseWellTrajectory( QNetworkReply* reply, const QString&
|
||||
foreach ( const QJsonValue& value, resultsArray )
|
||||
{
|
||||
QJsonObject resultObj = value.toObject();
|
||||
QJsonObject dataObj = resultObj["data"].toObject();
|
||||
QJsonArray dataSets = dataObj["Datasets"].toArray();
|
||||
if ( dataSets.size() == 1 )
|
||||
{
|
||||
QString id = resultObj["id"].toString();
|
||||
QString kind = resultObj["kind"].toString();
|
||||
QString dataSetId = dataSets[0].toString();
|
||||
QString description = dataObj["Description"].toString();
|
||||
QString id = resultObj["id"].toString();
|
||||
QString kind = resultObj["kind"].toString();
|
||||
|
||||
m_wellboreTrajectories[wellboreId].push_back( OsduWellboreTrajectory{ id, kind, description, dataSetId, wellboreId } );
|
||||
}
|
||||
else if ( dataSets.size() > 1 )
|
||||
{
|
||||
RiaLogging::error( "Encountered dataset with more than on file: currently not supported." );
|
||||
}
|
||||
m_wellboreTrajectories[wellboreId].push_back( OsduWellboreTrajectory{ id, kind, wellboreId } );
|
||||
}
|
||||
|
||||
emit wellboreTrajectoryFinished( wellboreId );
|
||||
@@ -454,40 +467,27 @@ void RiaOsduConnector::parseWellTrajectory( QNetworkReply* reply, const QString&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::saveFile( QNetworkReply* reply, const QString& fileId )
|
||||
void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellboreId )
|
||||
{
|
||||
QByteArray result = reply->readAll();
|
||||
reply->deleteLater();
|
||||
|
||||
if ( reply->error() == QNetworkReply::NoError )
|
||||
{
|
||||
QEventLoop loop;
|
||||
QJsonDocument doc = QJsonDocument::fromJson( result );
|
||||
QJsonObject jsonObj = doc.object();
|
||||
QJsonArray resultsArray = jsonObj["results"].toArray();
|
||||
m_wellLogs.clear();
|
||||
foreach ( const QJsonValue& value, resultsArray )
|
||||
{
|
||||
QJsonObject resultObj = value.toObject();
|
||||
QString id = resultObj["id"].toString();
|
||||
QString kind = resultObj["kind"].toString();
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson( result );
|
||||
QJsonObject jsonObj = doc.object();
|
||||
m_wellLogs[wellboreId].push_back( OsduWellLog{ id, kind, wellboreId } );
|
||||
}
|
||||
|
||||
QString signedUrl = jsonObj["SignedUrl"].toString();
|
||||
|
||||
RiaFileDownloader* downloader = new RiaFileDownloader;
|
||||
QUrl url( signedUrl );
|
||||
QString filePath = "/tmp/" + generateRandomString( 30 ) + ".txt";
|
||||
|
||||
QString formattedJsonString = doc.toJson( QJsonDocument::Indented );
|
||||
|
||||
RiaLogging::info( QString( "File download: %1 => %2" ).arg( signedUrl ).arg( filePath ) );
|
||||
connect( this, SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), &loop, SLOT( quit() ) );
|
||||
connect( downloader,
|
||||
&RiaFileDownloader::done,
|
||||
[this, fileId, filePath]()
|
||||
{
|
||||
RiaLogging::info( QString( "Download complete %1 => %2" ).arg( fileId ).arg( filePath ) );
|
||||
emit( fileDownloadFinished( fileId, filePath ) );
|
||||
} );
|
||||
RiaLogging::info( "Starting download" );
|
||||
downloader->downloadFile( url, filePath );
|
||||
|
||||
downloader->deleteLater();
|
||||
loop.exec();
|
||||
emit wellLogsFinished( wellboreId );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,46 +620,11 @@ std::vector<OsduWellboreTrajectory> RiaOsduConnector::wellboreTrajectories( cons
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::fileDownloadComplete( const QString& fileId, const QString& filePath )
|
||||
std::pair<QByteArray, QString> RiaOsduConnector::requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId )
|
||||
{
|
||||
m_filePath = filePath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<QString, QString> RiaOsduConnector::requestFileContentsById( const QString& fileId )
|
||||
{
|
||||
if ( m_token.isEmpty() )
|
||||
{
|
||||
// TODO: improve this..
|
||||
QEventLoop loop;
|
||||
connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) );
|
||||
requestToken();
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
QEventLoop loop2;
|
||||
connect( this,
|
||||
SIGNAL( fileDownloadFinished( const QString&, const QString& ) ),
|
||||
this,
|
||||
SLOT( fileDownloadComplete( const QString&, const QString& ) ) );
|
||||
connect( this, SIGNAL( fileDownloadFinished( const QString&, const QString& ) ), &loop2, SLOT( quit() ) );
|
||||
|
||||
requestFileDownloadByFileId( m_server, m_dataPartitionId, m_token, fileId );
|
||||
loop2.exec();
|
||||
|
||||
QFile dataFile( m_filePath );
|
||||
|
||||
if ( !dataFile.open( QFile::ReadOnly ) )
|
||||
{
|
||||
return { "", "Unable to open file: " + m_filePath };
|
||||
}
|
||||
|
||||
QTextStream stream( &dataFile );
|
||||
auto fileContent = stream.readAll();
|
||||
|
||||
return { fileContent, "" };
|
||||
QString url = constructWellboreTrajectoriesDownloadUrl( m_server, wellboreTrajectoryId );
|
||||
RiaLogging::debug( "Wellbore trajectory URL: " + url );
|
||||
return requestParquetDataByUrl( url );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -667,37 +632,37 @@ std::pair<QString, QString> RiaOsduConnector::requestFileContentsById( const QSt
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<QByteArray, QString> RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId )
|
||||
{
|
||||
if ( m_token.isEmpty() )
|
||||
{
|
||||
// TODO: improve this..
|
||||
QEventLoop loop;
|
||||
connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) );
|
||||
requestToken();
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
QEventLoop loop2;
|
||||
connect( this,
|
||||
SIGNAL( wellLogDownloadFinished( const QByteArray&, const QString& ) ),
|
||||
this,
|
||||
SLOT( wellLogDownloadComplete( const QByteArray&, const QString& ) ) );
|
||||
connect( this, SIGNAL( wellLogDownloadFinished( const QByteArray&, const QString& ) ), &loop2, SLOT( quit() ) );
|
||||
|
||||
QString url = constructWellLogDownloadUrl( m_server, wellLogId );
|
||||
RiaLogging::debug( "Well log URL: " + url );
|
||||
|
||||
requestWellLog( url, m_dataPartitionId, m_token );
|
||||
loop2.exec();
|
||||
|
||||
return { m_wellLogContents, "" };
|
||||
return requestParquetDataByUrl( url );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::requestWellLog( const QString& url, const QString& dataPartitionId, const QString& token )
|
||||
std::pair<QByteArray, QString> RiaOsduConnector::requestParquetDataByUrl( const QString& url )
|
||||
{
|
||||
RiaLogging::info( "Requesting download of well log from: " + url );
|
||||
QString token = requestTokenBlocking();
|
||||
|
||||
QEventLoop loop;
|
||||
connect( this,
|
||||
SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ),
|
||||
this,
|
||||
SLOT( parquetDownloadComplete( const QByteArray&, const QString& ) ) );
|
||||
connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString& ) ), &loop, SLOT( quit() ) );
|
||||
|
||||
requestParquetData( url, m_dataPartitionId, token );
|
||||
loop.exec();
|
||||
|
||||
return { m_parquetData, "" };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token )
|
||||
{
|
||||
RiaLogging::info( "Requesting download of parquet from: " + url );
|
||||
|
||||
auto reply = makeDownloadRequest( url, dataPartitionId, token, CONTENT_TYPE_PARQUET );
|
||||
connect( reply,
|
||||
@@ -708,7 +673,7 @@ void RiaOsduConnector::requestWellLog( const QString& url, const QString& dataPa
|
||||
{
|
||||
QByteArray contents = reply->readAll();
|
||||
RiaLogging::info( QString( "Download succeeded: %1 bytes." ).arg( contents.length() ) );
|
||||
emit wellLogDownloadFinished( contents, "" );
|
||||
emit parquetDownloadFinished( contents, "" );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -720,7 +685,23 @@ void RiaOsduConnector::requestWellLog( const QString& url, const QString& dataPa
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaOsduConnector::wellLogDownloadComplete( const QByteArray& contents, const QString& url )
|
||||
void RiaOsduConnector::parquetDownloadComplete( const QByteArray& contents, const QString& url )
|
||||
{
|
||||
m_wellLogContents = contents;
|
||||
m_parquetData = contents;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaOsduConnector::requestTokenBlocking()
|
||||
{
|
||||
if ( m_token.isEmpty() )
|
||||
{
|
||||
QEventLoop loop;
|
||||
connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) );
|
||||
requestToken();
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
return m_token;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,13 @@ struct OsduWellboreTrajectory
|
||||
{
|
||||
QString id;
|
||||
QString kind;
|
||||
QString description;
|
||||
QString dataSetId;
|
||||
QString wellboreId;
|
||||
};
|
||||
|
||||
struct OsduWellLog
|
||||
{
|
||||
QString id;
|
||||
QString kind;
|
||||
QString wellboreId;
|
||||
};
|
||||
|
||||
@@ -53,17 +58,16 @@ public:
|
||||
const QString& clientId );
|
||||
~RiaOsduConnector() override;
|
||||
|
||||
void requestFieldsByName( const QString& token, const QString& fieldName );
|
||||
void requestFieldsByName( const QString& fieldName );
|
||||
void requestWellsByFieldId( const QString& fieldId );
|
||||
void requestWellboresByWellId( const QString& wellId );
|
||||
void requestWellboreTrajectoryByWellboreId( const QString& wellboreId );
|
||||
void requestFileDownloadByFileId( const QString& fileId );
|
||||
void requestWellLog( const QString& url, const QString& dataPartitionId, const QString& token );
|
||||
|
||||
std::pair<QString, QString> requestFileContentsById( const QString& fileId );
|
||||
void requestFieldsByName( const QString& token, const QString& fieldName );
|
||||
void requestFieldsByName( const QString& fieldName );
|
||||
void requestWellsByFieldId( const QString& fieldId );
|
||||
void requestWellboresByWellId( const QString& wellId );
|
||||
void requestWellboreTrajectoryByWellboreId( const QString& wellboreId );
|
||||
void requestWellLogsByWellboreId( const QString& wellboreId );
|
||||
std::vector<OsduWellLog> requestWellLogsByWellboreIdBlocking( const QString& wellboreId );
|
||||
|
||||
std::pair<QByteArray, QString> requestWellLogParquetDataById( const QString& wellLogId );
|
||||
std::pair<QByteArray, QString> requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId );
|
||||
|
||||
QString wellIdForWellboreId( const QString& wellboreId ) const;
|
||||
|
||||
@@ -74,6 +78,7 @@ public:
|
||||
std::vector<OsduWell> wells() const;
|
||||
std::vector<OsduWellbore> wellbores( const QString& wellId ) const;
|
||||
std::vector<OsduWellboreTrajectory> wellboreTrajectories( const QString& wellboreId ) const;
|
||||
std::vector<OsduWellLog> wellLogs( const QString& wellboreId ) const;
|
||||
|
||||
public slots:
|
||||
void requestToken();
|
||||
@@ -81,21 +86,23 @@ public slots:
|
||||
void parseWells( QNetworkReply* reply );
|
||||
void parseWellbores( QNetworkReply* reply, const QString& wellId );
|
||||
void parseWellTrajectory( QNetworkReply* reply, const QString& wellboreId );
|
||||
void saveFile( QNetworkReply* reply, const QString& fileId );
|
||||
void parseWellLogs( QNetworkReply* reply, const QString& wellboreId );
|
||||
|
||||
void accessGranted();
|
||||
void fileDownloadComplete( const QString& fileId, const QString& filePath );
|
||||
void wellLogDownloadComplete( const QByteArray&, const QString& url );
|
||||
void parquetDownloadComplete( const QByteArray&, const QString& url );
|
||||
|
||||
signals:
|
||||
void fileDownloadFinished( const QString& fileId, const QString& filePath );
|
||||
void wellLogDownloadFinished( const QByteArray& contents, const QString& url );
|
||||
void parquetDownloadFinished( const QByteArray& contents, const QString& url );
|
||||
void fieldsFinished();
|
||||
void wellsFinished();
|
||||
void wellboresFinished( const QString& wellId );
|
||||
void wellboreTrajectoryFinished( const QString& wellboreId );
|
||||
void wellLogsFinished( const QString& wellboreId );
|
||||
void tokenReady( const QString& token );
|
||||
|
||||
private:
|
||||
void requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token );
|
||||
|
||||
void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& dataPartitionId, const QString& contentType );
|
||||
|
||||
QNetworkReply* makeSearchRequest( const std::map<QString, QString>& parameters,
|
||||
@@ -112,7 +119,7 @@ private:
|
||||
const QString& dataPartitionId,
|
||||
const QString& token,
|
||||
const QString& wellboreId );
|
||||
void requestFileDownloadByFileId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fileId );
|
||||
void requestWellLogsByWellboreId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellboreId );
|
||||
|
||||
static QString generateRandomString( int length = 20 );
|
||||
static QString constructSearchUrl( const QString& server );
|
||||
@@ -120,6 +127,11 @@ private:
|
||||
static QString constructAuthUrl( const QString& authority );
|
||||
static QString constructTokenUrl( const QString& authority );
|
||||
static QString constructWellLogDownloadUrl( const QString& server, const QString& wellLogId );
|
||||
static QString constructWellboreTrajectoriesDownloadUrl( const QString& server, const QString& wellboreTrajectoryId );
|
||||
|
||||
std::pair<QByteArray, QString> requestParquetDataByUrl( const QString& url );
|
||||
|
||||
QString requestTokenBlocking();
|
||||
|
||||
QOAuth2AuthorizationCodeFlow* m_osdu;
|
||||
QNetworkAccessManager* m_networkAccessManager;
|
||||
@@ -135,13 +147,14 @@ private:
|
||||
std::vector<OsduWell> m_wells;
|
||||
std::map<QString, std::vector<OsduWellbore>> m_wellbores;
|
||||
std::map<QString, std::vector<OsduWellboreTrajectory>> m_wellboreTrajectories;
|
||||
QString m_filePath;
|
||||
QByteArray m_wellLogContents;
|
||||
std::map<QString, std::vector<OsduWellLog>> m_wellLogs;
|
||||
QByteArray m_parquetData;
|
||||
|
||||
static inline const QString FIELD_KIND = "osdu:wks:master-data--Field:1.0.0";
|
||||
static inline const QString WELL_KIND = "osdu:wks:master-data--Well:1.*.*";
|
||||
static inline const QString WELLBORE_KIND = "osdu:wks:master-data--Wellbore:1.*.*";
|
||||
static inline const QString WELLBORE_TRAJECTORY_KIND = "osdu:wks:work-product-component--WellboreTrajectory:1.*.*";
|
||||
static inline const QString WELL_LOG_KIND = "osdu:wks:work-product-component--WellLog:1.*.*";
|
||||
|
||||
static inline const QString CONTENT_TYPE_JSON = "application/json";
|
||||
static inline const QString CONTENT_TYPE_PARQUET = "application/x-parquet";
|
||||
|
||||
@@ -74,17 +74,9 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked )
|
||||
RimOilField* oilField = project->activeOilField();
|
||||
if ( !oilField ) return;
|
||||
|
||||
RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences();
|
||||
RiaOsduConnector* osduConnector = app->makeOsduConnector();
|
||||
|
||||
const QString server = osduPreferences->server();
|
||||
const QString dataParitionId = osduPreferences->dataPartitionId();
|
||||
const QString authority = osduPreferences->authority();
|
||||
const QString scopes = osduPreferences->scopes();
|
||||
const QString clientId = osduPreferences->clientId();
|
||||
|
||||
RiaOsduConnector osduConnector( RiuMainWindow::instance(), server, dataParitionId, authority, scopes, clientId );
|
||||
|
||||
RiuWellImportWizard wellImportwizard( wellPathsFolderPath, &osduConnector, app->project()->wellPathImport(), RiuMainWindow::instance() );
|
||||
RiuWellImportWizard wellImportwizard( wellPathsFolderPath, osduConnector, app->project()->wellPathImport(), RiuMainWindow::instance() );
|
||||
|
||||
if ( QDialog::Accepted == wellImportwizard.exec() )
|
||||
{
|
||||
@@ -96,11 +88,11 @@ void RicWellPathsImportOsduFeature::onActionTriggered( bool isChecked )
|
||||
wellPath->setWellId( w.wellId );
|
||||
wellPath->setWellboreId( w.wellboreId );
|
||||
wellPath->setWellboreTrajectoryId( w.wellboreTrajectoryId );
|
||||
wellPath->setFileId( w.fileId );
|
||||
|
||||
oilField->wellPathCollection->addWellPath( wellPath );
|
||||
|
||||
auto [wellPathGeometry, errorMessage] = RimWellPathCollection::loadWellPathGeometryFromOsdu( &osduConnector, w.fileId );
|
||||
auto [wellPathGeometry, errorMessage] =
|
||||
RimWellPathCollection::loadWellPathGeometryFromOsdu( osduConnector, w.wellboreTrajectoryId );
|
||||
if ( wellPathGeometry.notNull() )
|
||||
{
|
||||
wellPath->setWellPathGeometry( wellPathGeometry.p() );
|
||||
|
||||
@@ -77,7 +77,7 @@ RiuWellImportWizard::~RiuWellImportWizard()
|
||||
void RiuWellImportWizard::downloadFields()
|
||||
{
|
||||
// TODO: filter by user input
|
||||
m_osduConnector->requestFieldsByName( "AZERI" );
|
||||
m_osduConnector->requestFieldsByName( "CASTBERG" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -436,7 +436,6 @@ WellSummaryPage::WellSummaryPage( RimWellPathImport* wellPathImport, RiaOsduConn
|
||||
setButtonText( QWizard::FinishButton, "Import" );
|
||||
|
||||
connect( m_osduConnector, SIGNAL( wellboreTrajectoryFinished( const QString& ) ), SLOT( wellboreTrajectoryFinished( const QString& ) ) );
|
||||
connect( m_osduConnector, SIGNAL( fileDownloadFinished( const QString& ) ), SLOT( fileDownloadFinished( const QString& ) ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -450,17 +449,6 @@ void WellSummaryPage::initializePage()
|
||||
wiz->downloadWellPaths( wellboreId );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void WellSummaryPage::fileDownloadFinished( const QString& fileId, const QString& filePath )
|
||||
{
|
||||
m_textEdit->setText( "Summary of imported wells\n\n" );
|
||||
|
||||
m_textEdit->append( "FileId:" );
|
||||
m_textEdit->append( fileId );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -482,11 +470,6 @@ void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId )
|
||||
|
||||
for ( auto w : wellboreTrajectories )
|
||||
{
|
||||
// TODO: remove hack. A lot of the data set IDs in OSDU has trailing ":" which should not be
|
||||
// there (i.e. the real id is without it). Chop them off to make more data sets work.
|
||||
QString fileId = w.dataSetId;
|
||||
if ( fileId.endsWith( ":" ) ) fileId.truncate( fileId.lastIndexOf( QChar( ':' ) ) );
|
||||
|
||||
QString wellId = m_osduConnector->wellIdForWellboreId( w.wellboreId );
|
||||
std::optional<const OsduWell> well = findWellForWellId( wells, wellId );
|
||||
|
||||
@@ -496,8 +479,7 @@ void WellSummaryPage::wellboreTrajectoryFinished( const QString& wellboreId )
|
||||
wiz->addWellInfo( { .name = well.value().name,
|
||||
.wellId = well.value().id,
|
||||
.wellboreId = w.wellboreId,
|
||||
.wellboreTrajectoryId = wellboreTrajectoryId,
|
||||
.fileId = fileId } );
|
||||
.wellboreTrajectoryId = wellboreTrajectoryId } );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +293,6 @@ public:
|
||||
|
||||
private slots:
|
||||
void wellboreTrajectoryFinished( const QString& wellId );
|
||||
void fileDownloadFinished( const QString& fileId, const QString& filePath );
|
||||
|
||||
private:
|
||||
RimWellPathImport* m_wellPathImportObject;
|
||||
@@ -315,7 +314,6 @@ public:
|
||||
QString wellId;
|
||||
QString wellboreId;
|
||||
QString wellboreTrajectoryId;
|
||||
QString fileId;
|
||||
};
|
||||
|
||||
RiuWellImportWizard( const QString& downloadFolder,
|
||||
|
||||
@@ -52,17 +52,6 @@ bool RicImportWellLogOsduFeature::isCommandEnabled() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
auto makeOsduConnector = []( auto app )
|
||||
{
|
||||
RiaPreferencesOsdu* osduPreferences = app->preferences()->osduPreferences();
|
||||
const QString server = osduPreferences->server();
|
||||
const QString dataPartitionId = osduPreferences->dataPartitionId();
|
||||
const QString authority = osduPreferences->authority();
|
||||
const QString scopes = osduPreferences->scopes();
|
||||
const QString clientId = osduPreferences->clientId();
|
||||
return std::make_unique<RiaOsduConnector>( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId );
|
||||
};
|
||||
|
||||
if ( auto wellPath = caf::SelectionManager::instance()->selectedItemOfType<RimOsduWellPath>() )
|
||||
{
|
||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||
@@ -72,19 +61,17 @@ void RicImportWellLogOsduFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
if ( !oilField->wellPathCollection ) oilField->wellPathCollection = std::make_unique<RimWellPathCollection>();
|
||||
|
||||
// TODO: get from OSDU...
|
||||
std::vector<QString> wellLogIds = { "npequinor-dev:work-product-component--WellLog:aeb5bd8b1de14138afe9f23cacbc7fe7" };
|
||||
auto osduConnector = app->makeOsduConnector();
|
||||
std::vector<OsduWellLog> wellLogs = osduConnector->requestWellLogsByWellboreIdBlocking( wellPath->wellboreId() );
|
||||
|
||||
for ( QString wellLogId : wellLogIds )
|
||||
for ( OsduWellLog wellLog : wellLogs )
|
||||
{
|
||||
RimOsduWellLog* osduWellLog = new RimOsduWellLog;
|
||||
osduWellLog->setName( wellLogId );
|
||||
osduWellLog->setWellLogId( wellLogId );
|
||||
osduWellLog->setName( wellLog.id );
|
||||
osduWellLog->setWellLogId( wellLog.id );
|
||||
oilField->wellPathCollection->addWellLog( osduWellLog, wellPath );
|
||||
|
||||
auto osduConnector = makeOsduConnector( app );
|
||||
|
||||
auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector.get(), osduWellLog->wellLogId() );
|
||||
auto [wellLogData, errorMessage] = RimWellPathCollection::loadWellLogFromOsdu( osduConnector, osduWellLog->wellLogId() );
|
||||
if ( wellLogData.notNull() )
|
||||
{
|
||||
osduWellLog->setWellLogData( wellLogData.p() );
|
||||
|
||||
Reference in New Issue
Block a user