Skip to content

Commit

Permalink
Add support for well paths from OSDU.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed May 22, 2024
1 parent b89e658 commit bac210d
Show file tree
Hide file tree
Showing 33 changed files with 1,960 additions and 1,227 deletions.
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 @@ -25,6 +25,7 @@
#include "RiaDefines.h"
#include "RiaFontCache.h"

#include "RiaPreferencesOsdu.h"
#include "cafAppEnum.h"
#include "cafPdmChildField.h"
#include "cafPdmField.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;
};
2 changes: 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.h
${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand All @@ -14,14 +16,17 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimWellPathImport.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellsEntry.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.cpp
)

list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})

list(APPEND COMMAND_QT_MOC_HEADERS
list(APPEND COMMAND_QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellImportWizard.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduOAuthHttpServerReplyHandler.h
)

source_group(
Expand Down
Loading

0 comments on commit bac210d

Please sign in to comment.