Add Sumo connector and related cloud tools

* Add cloud data icon
* Add Sumo connector and related helper tools
* Reorganize preferences and remove ssihub
* Use timeout defined for Sumo
This commit is contained in:
Magne Sjaastad 2024-07-05 09:31:16 +02:00 committed by GitHub
parent 868e9916bc
commit ffc1687cc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 2077 additions and 36 deletions

View File

@ -302,12 +302,7 @@ set(UNITY_EXCLUDE_FILES
# forever is used as variable name, and this symbol is defined by Qt and
# used in precompiled headers
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
qrc_cafAnimControl.cpp
qrc_ResInsight.cpp
qrc_cafCommandFeatures.cpp
# Exclude files including opm-common
ProjectDataModel/RimVfpTableExtractor.cpp
ProjectDataModel/RimVfpPlot.cpp
qrc_cafAnimControl.cpp qrc_ResInsight.cpp qrc_cafCommandFeatures.cpp
)
if(RESINSIGHT_ENABLE_UNITY_BUILD)

View File

@ -287,6 +287,7 @@
<file>regression-curve.svg</file>
<file>padlock.svg</file>
<file>warning.svg</file>
<file>cloud-and-server.svg</file>
</qresource>
<qresource prefix="/Shader">
<file>fs_CellFace.glsl</file>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M21.254 17.528A4.165 4.165 0 0 0 17.094 14a4.22 4.22 0 0 0-3.685 2.137 1.717 1.717 0 0 0-.534-.092 1.67 1.67 0 0 0-1.556 1.04A2.996 2.996 0 0 0 12 23h8.018A2.918 2.918 0 0 0 23 20.136a2.858 2.858 0 0 0-1.746-2.608zM19.994 22h-7.54l-.46-.003a1.995 1.995 0 0 1-.448-3.938l.506-.118.195-.481a.67.67 0 0 1 .628-.415.734.734 0 0 1 .225.043l.777.252.402-.711A3.231 3.231 0 0 1 17.094 15a3.18 3.18 0 0 1 3.17 2.67l.08.552.51.223A1.863 1.863 0 0 1 22 20.137 1.916 1.916 0 0 1 19.995 22zM11.5 2C6.78 2 2 3.03 2 5v12.58c0 1.64 2.676 2.695 6 3.123v-1.006c-3.16-.426-5-1.381-5-2.118v-6.248C4.643 12.429 8.082 13 11.5 13s6.857-.57 8.5-1.67v2.568a5.22 5.22 0 0 1 1 .856V5c0-1.97-4.78-3-9.5-3zM20 9.848C20 10.726 16.689 12 11.5 12S3 10.726 3 9.848V6.41C4.643 7.457 8.082 8 11.5 8s6.857-.543 8.5-1.589zM11.5 7C6 7 3 5.679 3 5s3-2 8.5-2S20 4.321 20 5s-3 2-8.5 2z"/><path fill="none" d="M0 0h24v24H0z"/></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -11,6 +11,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGrid.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSumo.h
${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.h
${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.h
@ -54,6 +55,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGrid.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSumo.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.cpp

View File

@ -17,7 +17,10 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiaApplication.h"
#include "Cloud/RiaSumoConnector.h"
#include "Cloud/RiaSumoDefines.h"
#include "OsduImportCommands/RiaOsduConnector.h"
#include "RiaArgumentParser.h"
#include "RiaBaseDefs.h"
#include "RiaFilePathTools.h"
@ -26,6 +29,7 @@
#include "RiaImportEclipseCaseTools.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaPreferencesSumo.h"
#include "RiaPreferencesSystem.h"
#include "RiaProjectModifier.h"
#include "RiaSocketServer.h"
@ -1710,3 +1714,25 @@ RiaOsduConnector* RiaApplication::makeOsduConnector()
m_osduConnector = new RiaOsduConnector( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId );
return m_osduConnector;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSumoConnector* RiaApplication::makeSumoConnector()
{
if ( !m_sumoConnector )
{
auto sumoPrefs = preferences()->sumoPreferences();
const QString server = sumoPrefs->server();
const QString authority = sumoPrefs->authority();
const QString scopes = sumoPrefs->scopes();
const QString clientId = sumoPrefs->clientId();
m_sumoConnector = new RiaSumoConnector( RiuMainWindow::instance(), server, authority, scopes, clientId );
m_sumoConnector->setTokenDataFilePath( RiaSumoDefines::tokenPath() );
m_sumoConnector->importTokenFromFile();
}
return m_sumoConnector;
}

View File

@ -69,6 +69,7 @@ class RiuPlotMainWindow;
class RiuRecentFileActionProvider;
class RiaArgumentParser;
class RiaOsduConnector;
class RiaSumoConnector;
namespace caf
{
@ -202,6 +203,7 @@ public:
virtual void showFormattedTextInMessageBoxOrConsole( const QString& errMsg ) = 0;
RiaOsduConnector* makeOsduConnector();
RiaSumoConnector* makeSumoConnector();
protected:
// Protected implementation specific overrides
@ -259,4 +261,5 @@ protected:
private:
static RiaApplication* s_riaApplication;
QPointer<RiaOsduConnector> m_osduConnector;
QPointer<RiaSumoConnector> m_sumoConnector;
};

View File

@ -27,6 +27,7 @@
#include "RiaPreferencesGeoMech.h"
#include "RiaPreferencesGrid.h"
#include "RiaPreferencesSummary.h"
#include "RiaPreferencesSumo.h"
#include "RiaPreferencesSystem.h"
#include "RiaQDateTimeTools.h"
#include "RiaValidRegExpValidator.h"
@ -146,9 +147,6 @@ RiaPreferences::RiaPreferences()
CAF_PDM_InitField( &m_storeBackupOfProjectFile, "storeBackupOfProjectFile", true, "Store Backup of Project Files" );
CAF_PDM_InitField( &ssihubAddress, "ssihubAddress", QString( "http://" ), "SSIHUB Address" );
ssihubAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
CAF_PDM_InitFieldNoDefault( &m_defaultMeshModeType, "defaultMeshModeType", "Show Grid Lines" );
CAF_PDM_InitField( &defaultGridLineColors, "defaultGridLineColors", RiaColorTables::defaultGridLineColor(), "Mesh Color" );
CAF_PDM_InitField( &defaultFaultGridLineColors,
@ -273,6 +271,9 @@ RiaPreferences::RiaPreferences()
CAF_PDM_InitFieldNoDefault( &m_osduPreferences, "osduPreferences", "osduPreferences" );
m_osduPreferences = new RiaPreferencesOsdu;
CAF_PDM_InitFieldNoDefault( &m_sumoPreferences, "sumoPreferences", "sumoPreferences" );
m_sumoPreferences = new RiaPreferencesSumo;
}
//--------------------------------------------------------------------------------------------------
@ -370,8 +371,15 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
viewsGroup->add( &m_showInfoBox );
viewsGroup->add( &m_showGridBox, { .newRow = false, .totalColumnSpan = 1 } );
caf::PdmUiGroup* loggingGroup = uiOrdering.addNewGroup( "Logging and Backup" );
loggingGroup->add( &m_storeBackupOfProjectFile );
loggingGroup->add( &m_loggerFilename );
loggingGroup->add( &m_loggerFlushInterval );
loggingGroup->add( &m_loggerTrapSignalAndFlush );
m_loggerTrapSignalAndFlush.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
m_loggerFlushInterval.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
caf::PdmUiGroup* otherGroup = uiOrdering.addNewGroup( "Other" );
otherGroup->add( &ssihubAddress );
otherGroup->add( &holoLensDisableCertificateVerification );
otherGroup->add( &m_useUndoRedo );
}
@ -466,17 +474,11 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
otherGroup->add( &m_gridCalculationExpressionFolder );
otherGroup->add( &m_summaryCalculationExpressionFolder );
caf::PdmUiGroup* loggingGroup = uiOrdering.addNewGroup( "Logging and Backup" );
loggingGroup->add( &m_storeBackupOfProjectFile );
loggingGroup->add( &m_loggerFilename );
loggingGroup->add( &m_loggerFlushInterval );
loggingGroup->add( &m_loggerTrapSignalAndFlush );
m_loggerTrapSignalAndFlush.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
m_loggerFlushInterval.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
}
else if ( uiConfigName == RiaPreferences::tabNameOsdu() )
{
m_osduPreferences()->uiOrdering( uiConfigName, uiOrdering );
caf::PdmUiGroup* osduGroup = uiOrdering.addNewGroup( "OSDU" );
m_osduPreferences()->uiOrdering( uiConfigName, *osduGroup );
caf::PdmUiGroup* sumoGroup = uiOrdering.addNewGroup( "SUMO" );
m_sumoPreferences()->uiOrdering( uiConfigName, *sumoGroup );
}
else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() )
{
@ -605,14 +607,6 @@ QString RiaPreferences::tabNameSystem()
return "System";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferences::tabNameOsdu()
{
return "Osdu";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -653,7 +647,6 @@ QStringList RiaPreferences::tabNames()
names << tabNameGeomech();
#endif
names << tabNameImportExport();
names << tabNameOsdu();
if ( RiaApplication::enableDevelopmentFeatures() )
{
@ -1028,6 +1021,14 @@ RiaPreferencesOsdu* RiaPreferences::osduPreferences() const
return m_osduPreferences();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesSumo* RiaPreferences::sumoPreferences() const
{
return m_sumoPreferences();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -46,6 +46,7 @@ class RiaPreferencesGeoMech;
class RiaPreferencesSystem;
class RiaPreferencesOsdu;
class RiaPreferencesGrid;
class RiaPreferencesSumo;
//--------------------------------------------------------------------------------------------------
///
@ -129,6 +130,7 @@ public:
RiaPreferencesSummary* summaryPreferences() const;
RiaPreferencesSystem* systemPreferences() const;
RiaPreferencesOsdu* osduPreferences() const;
RiaPreferencesSumo* sumoPreferences() const;
RiaPreferencesGrid* gridPreferences() const;
public:
@ -139,8 +141,6 @@ public:
caf::PdmField<QString> scriptEditorExecutable;
caf::PdmField<bool> showPythonDebugInfo;
caf::PdmField<QString> ssihubAddress;
caf::PdmField<cvf::Color3f> defaultGridLineColors;
caf::PdmField<cvf::Color3f> defaultFaultGridLineColors;
caf::PdmField<cvf::Color3f> defaultViewerBackgroundColor;
@ -171,7 +171,6 @@ private:
static QString tabNamePlotting();
static QString tabNameScripting();
static QString tabNameSystem();
static QString tabNameOsdu();
static QString tabNameImportExport();
static double defaultMarginSize( QPageSize::PageSizeId pageSizeId );
@ -238,6 +237,7 @@ private:
// Osdu settings
caf::PdmChildField<RiaPreferencesOsdu*> m_osduPreferences;
caf::PdmChildField<RiaPreferencesSumo*> m_sumoPreferences;
// 3d view
caf::PdmField<caf::AppEnum<RiaDefines::MeshModeType>> m_defaultMeshModeType;

View File

@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaPreferencesSumo.h"
CAF_PDM_SOURCE_INIT( RiaPreferencesSumo, "RiaPreferencesSumo" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesSumo::RiaPreferencesSumo()
{
CAF_PDM_InitFieldNoDefault( &m_server, "server", "Server" );
CAF_PDM_InitFieldNoDefault( &m_authority, "authority", "Authority" );
CAF_PDM_InitFieldNoDefault( &m_scopes, "scopes", "Scopes" );
CAF_PDM_InitFieldNoDefault( &m_clientId, "clientId", "Client Id" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesSumo* RiaPreferencesSumo::current()
{
return RiaApplication::instance()->preferences()->sumoPreferences();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesSumo::server() const
{
return m_server;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesSumo::authority() const
{
return m_authority;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesSumo::scopes() const
{
return m_scopes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesSumo::clientId() const
{
return m_clientId;
}

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RiaPreferencesSumo : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RiaPreferencesSumo();
static RiaPreferencesSumo* current();
QString server() const;
QString authority() const;
QString scopes() const;
QString clientId() const;
private:
caf::PdmField<QString> m_server;
caf::PdmField<QString> m_authority;
caf::PdmField<QString> m_scopes;
caf::PdmField<QString> m_clientId;
};

View File

@ -0,0 +1,17 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h
${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.cpp
)
list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})

View File

@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaConnectorTools.h"
#include <QFile>
#include <QJsonDocument>
#include <QJsonObject>
#include <QOAuth2AuthorizationCodeFlow>
#include <QTextStream>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaConnectorTools::tokenDataAsJson( QOAuth2AuthorizationCodeFlow* authCodeFlow )
{
QJsonObject obj;
obj.insert( "token", authCodeFlow->token() );
obj.insert( "refreshToken", authCodeFlow->refreshToken() );
QJsonDocument doc( obj );
return doc.toJson( QJsonDocument::Indented );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaConnectorTools::initializeTokenDataFromJson( QOAuth2AuthorizationCodeFlow* authCodeFlow, const QString& tokenDataJson )
{
QJsonDocument doc = QJsonDocument::fromJson( tokenDataJson.toUtf8() );
QJsonObject obj = doc.object();
authCodeFlow->setToken( obj["token"].toString() );
authCodeFlow->setRefreshToken( obj["refreshToken"].toString() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaConnectorTools::writeTokenData( const QString& filePath, const QString& tokenDataJson )
{
QFile file( filePath );
if ( file.open( QIODevice::WriteOnly ) )
{
QTextStream stream( &file );
stream << tokenDataJson;
file.close();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaConnectorTools::readTokenData( const QString& filePath )
{
QFile file( filePath );
if ( file.open( QIODevice::ReadOnly ) )
{
QTextStream stream( &file );
QString result = stream.readAll();
file.close();
return result;
}
return {};
}

View File

@ -0,0 +1,31 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <QString>
class QOAuth2AuthorizationCodeFlow;
namespace RiaConnectorTools
{
QString tokenDataAsJson( QOAuth2AuthorizationCodeFlow* authCodeFlow );
void initializeTokenDataFromJson( QOAuth2AuthorizationCodeFlow* authCodeFlow, const QString& tokenDataJson );
void writeTokenData( const QString& filePath, const QString& tokenDataJson );
QString readTokenData( const QString& filePath );
} // namespace RiaConnectorTools

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,182 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaSumoDefines.h"
#include <QByteArray>
#include <QNetworkAccessManager>
#include <QOAuth2AuthorizationCodeFlow>
#include <map>
using SumoObjectId = QString;
struct SumoAsset
{
SumoAssetId assetId;
QString kind;
QString name;
};
struct SumoCase
{
SumoCaseId caseId;
QString kind;
QString name;
};
struct SumoRedirect
{
SumoObjectId objectId;
QString blobName;
QString url;
QString redirectBaseUri;
QString redirectAuth;
QByteArray contents;
};
struct SumoEnsemble
{
SumoCaseId caseId;
QString name;
};
//==================================================================================================
///
//==================================================================================================
class RiaSumoConnector : public QObject
{
Q_OBJECT
public:
RiaSumoConnector( QObject* parent, const QString& server, const QString& authority, const QString& scopes, const QString& clientId );
~RiaSumoConnector() override;
QString token() const;
void importTokenFromFile();
void setTokenDataFilePath( const QString& filePath );
void requestAssets();
void requestAssetsBlocking();
void requestCasesForField( const QString& fieldName );
void requestCasesForFieldBlocking( const QString& fieldName );
void requestEnsembleByCasesId( const SumoCaseId& caseId );
void requestEnsembleByCasesIdBlocking( const SumoCaseId& caseId );
void requestVectorNamesForEnsemble( const SumoCaseId& caseId, const QString& ensembleName );
void requestVectorNamesForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName );
void requestRealizationIdsForEnsemble( const SumoCaseId& caseId, const QString& ensembleName );
void requestRealizationIdsForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName );
void requestBlobIdForEnsemble( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName );
void requestBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName );
void requestBlobDownload( const QString& blobId );
void requestBlobByRedirectUri( const QString& blobId, const QString& redirectUri );
QByteArray requestParquetDataBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName );
QString server() const;
std::vector<SumoAsset> assets() const;
std::vector<SumoCase> cases() const;
std::vector<QString> ensembleNamesForCase( const SumoCaseId& caseId ) const;
std::vector<QString> vectorNames() const;
std::vector<QString> realizationIds() const;
std::vector<QString> blobUrls() const;
std::vector<SumoRedirect> blobContents() const;
public slots:
void requestToken();
void parseAssets( QNetworkReply* reply );
void parseEnsembleNames( QNetworkReply* reply, const SumoCaseId& caseId );
void parseCases( QNetworkReply* reply );
void parseVectorNames( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName );
void parseRealizationNumbers( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName );
void parseBlobIds( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName );
void saveFile( QNetworkReply* reply, const QString& fileId );
void accessGranted();
void requestFailed( const QAbstractOAuth::Error error );
void parquetDownloadComplete( const QString& blobId, const QByteArray&, const QString& url );
signals:
void fileDownloadFinished( const QString& fileId, const QString& filePath );
void casesFinished();
void wellsFinished();
void wellboresFinished( const QString& wellId );
void wellboreTrajectoryFinished( const QString& wellboreId );
void tokenReady( const QString& token );
void parquetDownloadFinished( const QByteArray& contents, const QString& url );
void ensembleNamesFinished();
void vectorNamesFinished();
void blobIdFinished();
void assetsFinished();
void realizationIdsFinished();
private:
void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& contentType );
QString requestTokenBlocking();
QNetworkReply* makeRequest( const std::map<QString, QString>& parameters, const QString& server, const QString& token );
QNetworkReply* makeDownloadRequest( const QString& url, const QString& token, const QString& contentType );
void requestParquetData( const QString& url, const QString& token );
static QString generateRandomString( int length = 20 );
static QString constructSearchUrl( const QString& server );
static QString constructDownloadUrl( const QString& server, const QString& blobId );
static QString constructAuthUrl( const QString& authority );
static QString constructTokenUrl( const QString& authority );
private:
QOAuth2AuthorizationCodeFlow* m_authCodeFlow;
QNetworkAccessManager* m_networkAccessManager;
const QString m_server;
const QString m_authority;
const QString m_scopes;
const QString m_clientId;
QString m_token;
std::vector<SumoAsset> m_assets;
std::vector<SumoCase> m_cases;
std::vector<QString> m_vectorNames;
std::vector<QString> m_realizationIds;
std::vector<SumoEnsemble> m_ensembleNames;
std::vector<QString> m_blobUrl;
QString m_redirect;
std::vector<SumoRedirect> m_redirectInfo;
QByteArray m_parquetData;
QString m_tokenDataFilePath;
};

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaSumoDefines.h"
#include <QDir>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaSumoDefines::tokenPath()
{
QString homePath = QDir::homePath();
return homePath + "/.resinsight/sumo_token.json";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaSumoDefines::requestTimeoutMillis()
{
return 500;
}

View File

@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "nonstd/type.hpp"
#include <QString>
using SumoAssetId = nonstd::ordered<QString, struct sumo_asset_tag>;
using SumoCaseId = nonstd::ordered<QString, struct sumo_case_tag>;
namespace RiaSumoDefines
{
QString tokenPath();
int requestTimeoutMillis();
}; // namespace RiaSumoDefines

View File

@ -393,3 +393,23 @@ void RiaSummaryTools::reloadSummaryCase( RimSummaryCase* summaryCase )
multiPlot->updatePlotTitles();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryTools::reloadSummaryEnsemble( RimSummaryCaseCollection* ensemble )
{
RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection();
for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() )
{
for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() )
{
summaryPlot->loadDataAndUpdate();
// Consider to make the zoom optional
summaryPlot->zoomAll();
}
multiPlot->updatePlotTitles();
}
}

View File

@ -86,6 +86,7 @@ public:
static void copyCurveAxisData( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve );
static void reloadSummaryCase( RimSummaryCase* summaryCase );
static void reloadSummaryEnsemble( RimSummaryCaseCollection* ensemble );
private:
static void updateRequiredCalculatedCurves( RimSummaryCase* sourceSummaryCase );

View File

@ -93,6 +93,7 @@ list(
Application/CMakeLists_files.cmake
Application/Tools/CMakeLists_files.cmake
Application/Tools/WellPathTools/CMakeLists_files.cmake
Application/Tools/Cloud/CMakeLists_files.cmake
ReservoirDataModel/CMakeLists_files.cmake
ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake
ReservoirDataModel/Completions/CMakeLists_files.cmake
@ -415,6 +416,7 @@ set(UNITY_EXCLUDE_FILES
FileInterface/RifOsduWellPathReader.cpp
FileInterface/RifOsduWellLogReader.cpp
FileInterface/RifByteArrayArrowRandomAccessFile.cpp
FileInterface/RifArrowTools.cpp
)
if(RESINSIGHT_ENABLE_UNITY_BUILD)

View File

@ -20,6 +20,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryReportFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSumoDataFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -44,13 +45,16 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryReportFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSumoDataFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
set(COMMAND_QT_MOC_HEADERS ${COMMAND_QT_MOC_HEADERS})
list(APPEND COMMAND_QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RicSumoDataFeature.h
)
source_group(
"CommandFeature\\Application"

View File

@ -64,7 +64,6 @@ void RicEditPreferencesFeature::onActionTriggered( bool isChecked )
std::unique_ptr<RiaPreferences> oldPreferences = clonePreferences( app->preferences() );
RiuPropertyViewTabWidget propertyDialog( nullptr, app->preferences(), "Preferences", tabNames );
propertyDialog.setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
auto pushButton = propertyDialog.dialogButtonBox()->addButton( "Help", QDialogButtonBox::HelpRole );
connect( pushButton, &QPushButton::clicked, this, &RicEditPreferencesFeature::showHelp );

View File

@ -0,0 +1,288 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicSumoDataFeature.h"
#include "RiaApplication.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaPreferencesSystem.h"
#include "RifArrowTools.h"
#include "RiuMainWindow.h"
#include <QAction>
#include <QSettings>
CAF_CMD_SOURCE_INIT( RicSumoDataFeature, "RicSumoDataFeature" );
SimpleDialog::SimpleDialog( QWidget* parent )
: QDialog( parent )
{
setWindowTitle( "Simple Dialog" );
QVBoxLayout* layout = new QVBoxLayout( this );
label = new QLabel( "This is a simple dialog.", this );
layout->addWidget( label );
authButton = new QPushButton( "Authenticate", this );
connect( authButton, &QPushButton::clicked, this, &SimpleDialog::onAuthClicked );
layout->addWidget( authButton );
assetsButton = new QPushButton( "Asset Names", this );
connect( assetsButton, &QPushButton::clicked, this, &SimpleDialog::onAssetsClicked );
layout->addWidget( assetsButton );
casesButton = new QPushButton( "Cases", this );
connect( casesButton, &QPushButton::clicked, this, &SimpleDialog::onCasesClicked );
layout->addWidget( casesButton );
vectorNamesButton = new QPushButton( "Vector Names", this );
connect( vectorNamesButton, &QPushButton::clicked, this, &SimpleDialog::onVectorNamesClicked );
layout->addWidget( vectorNamesButton );
blobIdButton = new QPushButton( "Blob Id", this );
connect( blobIdButton, &QPushButton::clicked, this, &SimpleDialog::onFindBlobIdClicked );
layout->addWidget( blobIdButton );
parquetDownloadButton = new QPushButton( "Parquet", this );
connect( parquetDownloadButton, &QPushButton::clicked, this, &SimpleDialog::onParquetClicked );
layout->addWidget( parquetDownloadButton );
showContentParquetButton = new QPushButton( "Show Content Parquet", this );
connect( showContentParquetButton, &QPushButton::clicked, this, &SimpleDialog::onShowContentParquetClicked );
layout->addWidget( showContentParquetButton );
realizationIdsButton = new QPushButton( "Realizations", this );
connect( realizationIdsButton, &QPushButton::clicked, this, &SimpleDialog::onRealizationsClicked );
layout->addWidget( realizationIdsButton );
okButton = new QPushButton( "OK", this );
connect( okButton, &QPushButton::clicked, this, &SimpleDialog::onOkClicked );
layout->addWidget( okButton );
cancelButton = new QPushButton( "Cancel", this );
connect( cancelButton, &QPushButton::clicked, this, &SimpleDialog::onCancelClicked );
layout->addWidget( cancelButton );
setLayout( layout );
m_sumoConnector = RiaApplication::instance()->makeSumoConnector();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
SimpleDialog::~SimpleDialog()
{
if ( m_sumoConnector )
{
m_sumoConnector->deleteLater();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::createConnection()
{
m_sumoConnector = RiaApplication::instance()->makeSumoConnector();
connect( m_sumoConnector, &RiaSumoConnector::tokenReady, this, &SimpleDialog::onTokenReady );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::onAuthClicked()
{
createConnection();
m_sumoConnector->requestToken();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::onAssetsClicked()
{
if ( !isTokenValid() ) return;
m_sumoConnector->requestAssets();
m_sumoConnector->assets();
label->setText( "Requesting fields (see log for response" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::onCasesClicked()
{
if ( !isTokenValid() ) return;
QString fieldName = "Drogon";
m_sumoConnector->requestCasesForField( fieldName );
label->setText( "Requesting cases (see log for response" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::onVectorNamesClicked()
{
if ( !isTokenValid() ) return;
SumoCaseId caseId( "5b783aab-ce10-4b78-b129-baf8d8ce4baa" );
QString iteration = "iter-0";
m_sumoConnector->requestVectorNamesForEnsemble( caseId, iteration );
label->setText( "Requesting vector names (see log for response" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::onFindBlobIdClicked()
{
if ( !isTokenValid() ) return;
SumoCaseId caseId( "5b783aab-ce10-4b78-b129-baf8d8ce4baa" );
QString iteration = "iter-0";
QString vectorName = "FOPT";
m_sumoConnector->requestBlobIdForEnsemble( caseId, iteration, vectorName );
label->setText( "Requesting blob ID for vector name (see log for response" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::onParquetClicked()
{
if ( !isTokenValid() ) return;
if ( m_sumoConnector->blobUrls().empty() )
{
onFindBlobIdClicked();
}
if ( !m_sumoConnector->blobUrls().empty() )
{
m_sumoConnector->requestBlobDownload( m_sumoConnector->blobUrls().back() );
label->setText( "Requesting blob ID for vector name (see log for response" );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::onShowContentParquetClicked()
{
if ( m_sumoConnector->blobContents().empty() ) return;
auto blob = m_sumoConnector->blobContents().back();
auto content = blob.contents;
// TODO: show content using parquet reader
auto tableText = RifArrowTools::readFirstRowsOfTable( content );
RiaLogging::info( tableText );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::onRealizationsClicked()
{
if ( !isTokenValid() ) return;
SumoCaseId caseId( "485041ce-ad72-48a3-ac8c-484c0ed95cf8" );
QString iteration = "iter-0";
m_sumoConnector->requestRealizationIdsForEnsembleBlocking( caseId, iteration );
auto ids = m_sumoConnector->realizationIds();
for ( const auto& id : ids )
{
RiaLogging::info( id );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool SimpleDialog::isTokenValid()
{
if ( !m_sumoConnector )
{
createConnection();
}
if ( m_sumoConnector->token().isEmpty() )
{
m_sumoConnector->requestToken();
}
return !m_sumoConnector->token().isEmpty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SimpleDialog::onTokenReady( const QString& token )
{
RiaLogging::info( "Token ready: " + token );
}
void SimpleDialog::onOkClicked()
{
qDebug( "OK button clicked" );
accept();
}
void SimpleDialog::onCancelClicked()
{
qDebug( "Cancel button clicked" );
reject();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSumoDataFeature::onActionTriggered( bool isChecked )
{
if ( !m_dialog )
{
m_dialog = new SimpleDialog( RiaGuiApplication::instance()->mainWindow() );
}
m_dialog->show();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSumoDataFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "SUMO" );
}

View File

@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
#include "Cloud/RiaSumoConnector.h"
#include <QDialog>
#include <QLabel>
#include <QPointer>
#include <QPushButton>
#include <QVBoxLayout>
class SimpleDialog : public QDialog
{
Q_OBJECT
public:
SimpleDialog( QWidget* parent = nullptr );
~SimpleDialog();
void createConnection();
private:
void onOkClicked();
void onCancelClicked();
void onTokenReady( const QString& token );
void onAuthClicked();
void onAssetsClicked();
void onCasesClicked();
void onVectorNamesClicked();
void onFindBlobIdClicked();
void onParquetClicked();
void onShowContentParquetClicked();
void onRealizationsClicked();
bool isTokenValid();
private:
QLabel* label;
QPushButton* okButton;
QPushButton* cancelButton;
QPushButton* authButton;
QPushButton* assetsButton;
QPushButton* casesButton;
QPushButton* vectorNamesButton;
QPushButton* blobIdButton;
QPushButton* parquetDownloadButton;
QPushButton* showContentParquetButton;
QPushButton* realizationIdsButton;
QPointer<RiaSumoConnector> m_sumoConnector;
};
//==================================================================================================
///
//==================================================================================================
class RicSumoDataFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
SimpleDialog* m_dialog = nullptr;
};

View File

@ -684,6 +684,7 @@ void RiuMainWindow::createToolBars()
{
QToolBar* toolbar = addToolBar( tr( "Test" ) );
toolbar->setObjectName( toolbar->windowTitle() );
toolbar->addAction( cmdFeatureMgr->action( "RicSumoDataFeature" ) );
toolbar->addAction( cmdFeatureMgr->action( "RicLaunchRegressionTestsFeature" ) );
toolbar->addAction( cmdFeatureMgr->action( "RicLaunchRegressionTestDialogFeature" ) );
toolbar->addAction( cmdFeatureMgr->action( "RicShowClassNamesFeature" ) );

View File

@ -114,7 +114,7 @@ QSize RiuPropertyViewTabWidget::sizeHint() const
// qDebug() << "tab size hint" << w->sizeHint();
QSize pageSize = w->sizeHint();
pageSize += QSize( 0, 100 );
pageSize += QSize( 60, 100 );
maxSizeHint = maxSizeHint.expandedTo( pageSize );
}