Osdu: extract constants to separate namespace.

This commit is contained in:
Kristian Bendiksen
2024-06-14 15:16:05 +02:00
parent a85fd12989
commit 44ca21636a
5 changed files with 117 additions and 16 deletions

View File

@@ -34,6 +34,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h
@@ -75,6 +76,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.cpp

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 "RiaOsduDefines.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::osduFieldKind()
{
return "osdu:wks:master-data--Field:1.0.0";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::osduWellKind()
{
return "osdu:wks:master-data--Well:1.*.*";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::osduWellboreKind()
{
return "osdu:wks:master-data--Wellbore:1.*.*";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::osduWellboreTrajectoryKind()
{
return "osdu:wks:work-product-component--WellboreTrajectory:1.*.*";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::osduWellLogKind()
{
return "osdu:wks:work-product-component--WellLog:1.*.*";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::contentTypeJson()
{
return "application/json";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::contentTypeParquet()
{
return "application/x-parquet";
}

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 <QString>
namespace RiaDefines
{
QString osduFieldKind();
QString osduWellKind();
QString osduWellboreKind();
QString osduWellboreTrajectoryKind();
QString osduWellLogKind();
QString contentTypeJson();
QString contentTypeParquet();
}; // namespace RiaDefines

View File

@@ -1,6 +1,7 @@
#include "RiaOsduConnector.h"
#include "RiaFileDownloader.h"
#include "RiaLogging.h"
#include "RiaOsduDefines.h"
#include "RiaOsduOAuthHttpServerReplyHandler.h"
#include <QAbstractOAuth>
@@ -124,7 +125,7 @@ void RiaOsduConnector::requestFieldsByName( const QString& fieldName )
void RiaOsduConnector::requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName )
{
std::map<QString, QString> params;
params["kind"] = FIELD_KIND;
params["kind"] = RiaDefines::osduFieldKind();
params["limit"] = "10000";
params["query"] = "data.FieldName:" + fieldName;
@@ -154,7 +155,7 @@ void RiaOsduConnector::requestWellsByFieldId( const QString& fieldId )
void RiaOsduConnector::requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId )
{
std::map<QString, QString> params;
params["kind"] = WELL_KIND;
params["kind"] = RiaDefines::osduWellKind();
params["limit"] = "10000";
params["query"] = QString( "nested(data.GeoContexts, (FieldID:\"%1\"))" ).arg( fieldId );
@@ -184,7 +185,7 @@ void RiaOsduConnector::requestWellboresByWellId( const QString& wellId )
void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellId )
{
std::map<QString, QString> params;
params["kind"] = WELLBORE_KIND;
params["kind"] = RiaDefines::osduWellboreKind();
params["limit"] = "10000";
params["query"] = "data.WellID: \"" + wellId + "\"";
@@ -232,7 +233,7 @@ void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server,
const QString& wellboreId )
{
std::map<QString, QString> params;
params["kind"] = WELL_LOG_KIND;
params["kind"] = RiaDefines::osduWellLogKind();
params["limit"] = "10000";
params["query"] = "data.WellboreID: \"" + wellboreId + "\"";
@@ -265,7 +266,7 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser
const QString& wellboreId )
{
std::map<QString, QString> params;
params["kind"] = WELLBORE_TRAJECTORY_KIND;
params["kind"] = RiaDefines::osduWellboreTrajectoryKind();
params["limit"] = "10000";
params["query"] = "data.WellboreID: \"" + wellboreId + "\"";
@@ -340,7 +341,7 @@ QNetworkReply* RiaOsduConnector::makeSearchRequest( const std::map<QString, QStr
QNetworkRequest m_networkRequest;
m_networkRequest.setUrl( QUrl( constructSearchUrl( server ) ) );
addStandardHeader( m_networkRequest, token, dataPartitionId, CONTENT_TYPE_JSON );
addStandardHeader( m_networkRequest, token, dataPartitionId, RiaDefines::contentTypeJson() );
QJsonObject obj;
for ( auto [key, value] : parameters )
@@ -675,7 +676,7 @@ void RiaOsduConnector::requestParquetData( const QString& url, const QString& da
{
RiaLogging::info( "Requesting download of parquet from: " + url );
auto reply = makeDownloadRequest( url, dataPartitionId, token, CONTENT_TYPE_PARQUET );
auto reply = makeDownloadRequest( url, dataPartitionId, token, RiaDefines::contentTypeParquet() );
connect( reply,
&QNetworkReply::finished,
[this, reply, url]()

View File

@@ -149,13 +149,4 @@ private:
std::map<QString, std::vector<OsduWellboreTrajectory>> m_wellboreTrajectories;
std::map<QString, std::vector<OsduWellLog>> m_wellLogs;
QByteArray m_parquetData;
static inline const QString FIELD_KIND = "osdu:wks:master-data--Field:1.0.0";
static inline const QString WELL_KIND = "osdu:wks:master-data--Well:1.*.*";
static inline const QString WELLBORE_KIND = "osdu:wks:master-data--Wellbore:1.*.*";
static inline const QString WELLBORE_TRAJECTORY_KIND = "osdu:wks:work-product-component--WellboreTrajectory:1.*.*";
static inline const QString WELL_LOG_KIND = "osdu:wks:work-product-component--WellLog:1.*.*";
static inline const QString CONTENT_TYPE_JSON = "application/json";
static inline const QString CONTENT_TYPE_PARQUET = "application/x-parquet";
};