mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-29 16:40:20 -05:00
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:
1 parent
868e9916bc
commit
ffc1687cc7
26 files changed
+2077
-36
No files matched your search
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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})
|
||||
@@ -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 {};
|
||||
}
|
||||
@@ -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
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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 );
|
||||
|
||||
Reference in new issue
Block a user