Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSDU wellpath import #11228

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ResInsightWithCache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ jobs:
version: 5.12.12
dir: "${{ github.workspace }}/Qt/"
cache: true
modules: "qtnetworkauth"

- name: Restore from cache and install vcpkg
uses: lukka/run-vcpkg@v7
Expand Down
5 changes: 5 additions & 0 deletions ApplicationLibCode/Application/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.h
${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.h
${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.h
Expand All @@ -35,6 +36,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand All @@ -48,6 +50,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.cpp
Expand All @@ -74,6 +77,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.cpp
)

list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
Expand All @@ -87,6 +91,7 @@ set(QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaPlotWindowRedrawScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h
)

source_group(
Expand Down
54 changes: 54 additions & 0 deletions ApplicationLibCode/Application/RiaFileDownloader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "RiaFileDownloader.h"

#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>

#include "RiaLogging.h"

RiaFileDownloader::RiaFileDownloader( QObject* parent )
: QObject( parent )
{
}

void RiaFileDownloader::downloadFile( const QUrl& url, const QString& filePath )
{
QNetworkAccessManager* manager = new QNetworkAccessManager( this );
QNetworkRequest request( url );

RiaLogging::debug( "Downloading from: " + url.toString() );

QNetworkReply* reply = manager->get( request );

connect( reply,
&QNetworkReply::finished,
[=]()
{
if ( reply->error() )
{
RiaLogging::error( "Download failed:" + reply->errorString() );
emit done();
}
else
{
QFile file( filePath );
if ( file.open( QIODevice::WriteOnly ) )
{
file.write( reply->readAll() );
file.close();
RiaLogging::info( "Download succeeded. File saved to " + filePath );
emit done();
}
else
{
RiaLogging::info( "Failed to save file to " + filePath );
emit done();
}
}
reply->deleteLater();
manager->deleteLater();
} );
}
16 changes: 16 additions & 0 deletions ApplicationLibCode/Application/RiaFileDownloader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <QObject>
#include <QString>
#include <QUrl>

class RiaFileDownloader : public QObject
{
Q_OBJECT
public:
explicit RiaFileDownloader( QObject* parent = nullptr );

void downloadFile( const QUrl& url, const QString& filePath );
signals:
void done();
};
24 changes: 24 additions & 0 deletions ApplicationLibCode/Application/RiaPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ RiaPreferences::RiaPreferences()

CAF_PDM_InitFieldNoDefault( &m_systemPreferences, "systemPreferences", "systemPreferences" );
m_systemPreferences = new RiaPreferencesSystem;

CAF_PDM_InitFieldNoDefault( &m_osduPreferences, "osduPreferences", "osduPreferences" );
m_osduPreferences = new RiaPreferencesOsdu;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -487,6 +490,10 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
m_loggerTrapSignalAndFlush.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
m_loggerFlushInterval.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
}
else if ( uiConfigName == RiaPreferences::tabNameOsdu() )
{
m_osduPreferences()->uiOrdering( uiConfigName, uiOrdering );
}
else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() )
{
m_systemPreferences()->uiOrdering( uiConfigName, uiOrdering );
Expand Down Expand Up @@ -614,6 +621,14 @@ QString RiaPreferences::tabNameSystem()
return "System";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferences::tabNameOsdu()
{
return "Osdu";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -654,6 +669,7 @@ QStringList RiaPreferences::tabNames()
names << tabNameGeomech();
#endif
names << tabNameImportExport();
names << tabNameOsdu();

if ( RiaApplication::enableDevelopmentFeatures() )
{
Expand Down Expand Up @@ -1018,6 +1034,14 @@ RiaPreferencesGeoMech* RiaPreferences::geoMechPreferences() const
return m_geoMechPreferences();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesOsdu* RiaPreferences::osduPreferences() const
{
return m_osduPreferences();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions ApplicationLibCode/Application/RiaPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "RiaDateTimeDefines.h"
#include "RiaDefines.h"
#include "RiaFontCache.h"
#include "RiaPreferencesOsdu.h"
kriben marked this conversation as resolved.
Show resolved Hide resolved

#include "cafAppEnum.h"
#include "cafPdmChildField.h"
Expand All @@ -43,6 +44,7 @@ class RifReaderSettings;
class RiaPreferencesSummary;
class RiaPreferencesGeoMech;
class RiaPreferencesSystem;
class RiaPreferencesOsdu;

//--------------------------------------------------------------------------------------------------
///
Expand Down Expand Up @@ -125,6 +127,7 @@ class RiaPreferences : public caf::PdmObject
RiaPreferencesGeoMech* geoMechPreferences() const;
RiaPreferencesSummary* summaryPreferences() const;
RiaPreferencesSystem* systemPreferences() const;
RiaPreferencesOsdu* osduPreferences() const;

public:
caf::PdmField<bool> enableGrpcServer;
Expand Down Expand Up @@ -170,6 +173,7 @@ class RiaPreferences : public caf::PdmObject
static QString tabNamePlotting();
static QString tabNameScripting();
static QString tabNameSystem();
static QString tabNameOsdu();
static QString tabNameImportExport();

static double defaultMarginSize( QPageSize::PageSizeId pageSizeId );
Expand Down Expand Up @@ -230,6 +234,9 @@ class RiaPreferences : public caf::PdmObject
// System settings
caf::PdmChildField<RiaPreferencesSystem*> m_systemPreferences;

// Osdu settings
caf::PdmChildField<RiaPreferencesOsdu*> m_osduPreferences;

// 3d view
caf::PdmField<caf::AppEnum<RiaDefines::MeshModeType>> m_defaultMeshModeType;
caf::PdmField<caf::AppEnum<RiaDefines::RINavigationPolicy>> m_navigationPolicy;
Expand Down
84 changes: 84 additions & 0 deletions ApplicationLibCode/Application/RiaPreferencesOsdu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#include "RiaApplication.h"

#include "RiaPreferences.h"
#include "RiaPreferencesOsdu.h"

CAF_PDM_SOURCE_INIT( RiaPreferencesOsdu, "RiaPreferencesOsdu" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesOsdu::RiaPreferencesOsdu()
{
CAF_PDM_InitFieldNoDefault( &m_server, "server", "Server" );
CAF_PDM_InitFieldNoDefault( &m_dataPartitionId, "dataPartitionId", "Data Partition Id" );
CAF_PDM_InitFieldNoDefault( &m_authority, "authority", "Authority" );
CAF_PDM_InitFieldNoDefault( &m_scopes, "scopes", "Scopes" );
CAF_PDM_InitFieldNoDefault( &m_clientId, "clientId", "Client Id" );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesOsdu* RiaPreferencesOsdu::current()
{
return RiaApplication::instance()->preferences()->osduPreferences();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::server() const
{
return m_server;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::dataPartitionId() const
{
return m_dataPartitionId;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::authority() const
{
return m_authority;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::scopes() const
{
return m_scopes;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::clientId() const
{
return m_clientId;
}
48 changes: 48 additions & 0 deletions ApplicationLibCode/Application/RiaPreferencesOsdu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "cafPdmField.h"
#include "cafPdmObject.h"

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RiaPreferencesOsdu : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;

public:
RiaPreferencesOsdu();

static RiaPreferencesOsdu* current();

QString server() const;
QString dataPartitionId() const;
QString authority() const;
QString scopes() const;
QString clientId() const;

private:
caf::PdmField<QString> m_server;
caf::PdmField<QString> m_dataPartitionId;
caf::PdmField<QString> m_authority;
caf::PdmField<QString> m_scopes;
caf::PdmField<QString> m_clientId;
};
3 changes: 3 additions & 0 deletions ApplicationLibCode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if(Qt5Core_FOUND)
Gui
OpenGL
Network
NetworkAuth
Widgets
Xml
Concurrent
Expand All @@ -44,6 +45,7 @@ if(Qt5Core_FOUND)
Qt5::Core
Qt5::Gui
Qt5::Network
Qt5::NetworkAuth
Qt5::OpenGL
Qt5::Widgets
Qt5::Xml
Expand Down Expand Up @@ -416,6 +418,7 @@ set(UNITY_EXCLUDE_FILES
# Exclude files including opm-common
ProjectDataModel/RimVfpTableExtractor.cpp
ProjectDataModel/RimVfpPlot.cpp
ProjectDataModel/RiaOpmParserTools.cpp
)

if(RESINSIGHT_ENABLE_UNITY_BUILD)
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/Commands/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(COMMAND_REFERENCED_CMAKE_FILES
OctaveScriptCommands/CMakeLists_files.cmake
OperationsUsingObjReferences/CMakeLists_files.cmake
SummaryPlotCommands/CMakeLists_files.cmake
SsiHubImportCommands/CMakeLists_files.cmake
OsduImportCommands/CMakeLists_files.cmake
StreamlineCommands/CMakeLists_files.cmake
SurfaceCommands/CMakeLists_files.cmake
SeismicCommands/CMakeLists_files.cmake
Expand Down
Loading