Skip to content

Commit

Permalink
WIP: integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Apr 29, 2024
1 parent 4c8ffad commit b9b202a
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 364 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ RiaOsduConnector::RiaOsduConnector( QObject* parent,
void RiaOsduConnector::accessGranted()
{
qDebug() << "ACCESS GRANTED!!" << QThread::currentThread();
QString token = m_osdu->token();
emit tokenReady( token );
m_token = m_osdu->token();
emit tokenReady( m_token );
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -108,6 +108,14 @@ void RiaOsduConnector::requestFieldsByName( const QString& token, const QString&
requestFieldsByName( m_server, m_dataPartitionId, token, fieldName );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestFieldsByName( const QString& fieldName )
{
requestFieldsByName( m_token, fieldName );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -265,9 +273,9 @@ void RiaOsduConnector::parseWells( QNetworkReply* reply )
QString kind = resultObj["kind"].toString();

qDebug() << "Id:" << id << " kind: " << kind;

printf( "%s\n", id.toStdString().c_str() );
qDebug() << resultObj;
}

emit finished();
}

Expand Down Expand Up @@ -392,3 +400,19 @@ QString RiaOsduConnector::generateRandomString( int randomStringLength )
}
return randomString;
}

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

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaOsduConnector::dataPartition() const
{
return m_dataPartitionId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class RiaOsduConnector : public QObject
~RiaOsduConnector() override;

void requestFieldsByName( const QString& token, const QString& fieldName );
void requestFieldsByName( const QString& fieldName );

QString server() const;
QString dataPartition() const;

public slots:
void requestToken();
Expand Down Expand Up @@ -66,4 +70,6 @@ public slots:
const QString m_authority;
const QString m_scopes;
const QString m_clientId;

QString m_token;
};
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered( bool isChecked )

auto m_osduConnector = new RiaOsduConnector( RiuMainWindow::instance(), server, dataParitionId, authority, scopes, clientId );

RiuWellImportWizard wellImportwizard( app->preferences()->ssihubAddress,
wellPathsFolderPath,
m_osduConnector,
app->project()->wellPathImport(),
RiuMainWindow::instance() );
RiuWellImportWizard wellImportwizard( wellPathsFolderPath, m_osduConnector, app->project()->wellPathImport(), RiuMainWindow::instance() );

if ( QDialog::Accepted == wellImportwizard.exec() )
{
Expand All @@ -128,6 +124,6 @@ void RicWellPathsImportSsihubFeature::onActionTriggered( bool isChecked )
//--------------------------------------------------------------------------------------------------
void RicWellPathsImportSsihubFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Import Well Paths from &SSI-hub" );
actionToSetup->setText( "Import Well Paths from &OSDU" );
actionToSetup->setIcon( QIcon( ":/WellCollection.png" ) );
}
190 changes: 95 additions & 95 deletions ApplicationLibCode/Commands/OsduImportCommands/RimWellPathImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,83 +71,83 @@ void RimWellPathImport::updateRegions( const QStringList& regionStrings, const Q
{
assert( regionStrings.size() == fieldStrings.size() && regionStrings.size() == edmIds.size() );

std::vector<RimOilRegionEntry*> regionsToRemove;

// Remove regions and fields not present in last request
for ( size_t regionIdx = 0; regionIdx < regions.size(); regionIdx++ )
{
if ( !regionStrings.contains( regions[regionIdx]->name ) )
{
regionsToRemove.push_back( regions[regionIdx] );
}
else
{
std::vector<RimOilFieldEntry*> fieldsToRemove;

for ( size_t fIdx = 0; fIdx < regions[regionIdx]->fields.size(); fIdx++ )
{
if ( !fieldStrings.contains( regions[regionIdx]->fields[fIdx]->name ) )
{
fieldsToRemove.push_back( regions[regionIdx]->fields[fIdx] );
}
}

for ( size_t i = 0; i < fieldsToRemove.size(); i++ )
{
regions[regionIdx]->fields.removeChild( fieldsToRemove[i] );

delete fieldsToRemove[i];
}
}
}

for ( size_t i = 0; i < regionsToRemove.size(); i++ )
{
regions.removeChild( regionsToRemove[i] );

delete regionsToRemove[i];
}

for ( int i = 0; i < regionStrings.size(); i++ )
{
RimOilRegionEntry* oilRegionEntry = nullptr;
RimOilFieldEntry* oilFieldEntry = nullptr;

for ( size_t regionIdx = 0; regionIdx < regions.size(); regionIdx++ )
{
if ( regions[regionIdx]->name == regionStrings[i] )
{
oilRegionEntry = regions[regionIdx];

for ( size_t fIdx = 0; fIdx < regions[regionIdx]->fields.size(); fIdx++ )
{
if ( regions[regionIdx]->fields[fIdx]->edmId == edmIds[i] )
{
oilFieldEntry = regions[regionIdx]->fields[fIdx];
}
}
}
}

if ( !oilRegionEntry )
{
oilRegionEntry = new RimOilRegionEntry;
oilRegionEntry->name = regionStrings[i];

regions.push_back( oilRegionEntry );
}

assert( oilRegionEntry );

if ( !oilFieldEntry )
{
oilFieldEntry = new RimOilFieldEntry;
oilFieldEntry->name = fieldStrings[i];
oilFieldEntry->edmId = edmIds[i];

oilRegionEntry->fields.push_back( oilFieldEntry );
}
}
// std::vector<RimOilRegionEntry*> regionsToRemove;

// // Remove regions and fields not present in last request
// for ( size_t regionIdx = 0; regionIdx < regions.size(); regionIdx++ )
// {
// if ( !regionStrings.contains( regions[regionIdx]->name ) )
// {
// regionsToRemove.push_back( regions[regionIdx] );
// }
// else
// {
// std::vector<RimOilFieldEntry*> fieldsToRemove;

// for ( size_t fIdx = 0; fIdx < regions[regionIdx]->fields.size(); fIdx++ )
// {
// if ( !fieldStrings.contains( regions[regionIdx]->fields[fIdx]->name ) )
// {
// fieldsToRemove.push_back( regions[regionIdx]->fields[fIdx] );
// }
// }

// for ( size_t i = 0; i < fieldsToRemove.size(); i++ )
// {
// regions[regionIdx]->fields.removeChild( fieldsToRemove[i] );

// delete fieldsToRemove[i];
// }
// }
// }

// for ( size_t i = 0; i < regionsToRemove.size(); i++ )
// {
// regions.removeChild( regionsToRemove[i] );

// delete regionsToRemove[i];
// }

// for ( int i = 0; i < regionStrings.size(); i++ )
// {
// RimOilRegionEntry* oilRegionEntry = nullptr;
// RimOilFieldEntry* oilFieldEntry = nullptr;

// for ( size_t regionIdx = 0; regionIdx < regions.size(); regionIdx++ )
// {
// if ( regions[regionIdx]->name == regionStrings[i] )
// {
// oilRegionEntry = regions[regionIdx];

// for ( size_t fIdx = 0; fIdx < regions[regionIdx]->fields.size(); fIdx++ )
// {
// if ( regions[regionIdx]->fields[fIdx]->edmId == edmIds[i] )
// {
// oilFieldEntry = regions[regionIdx]->fields[fIdx];
// }
// }
// }
// }

// if ( !oilRegionEntry )
// {
// oilRegionEntry = new RimOilRegionEntry;
// oilRegionEntry->name = regionStrings[i];

// regions.push_back( oilRegionEntry );
// }

// assert( oilRegionEntry );

// if ( !oilFieldEntry )
// {
// oilFieldEntry = new RimOilFieldEntry;
// oilFieldEntry->name = fieldStrings[i];
// oilFieldEntry->edmId = edmIds[i];

// oilRegionEntry->fields.push_back( oilFieldEntry );
// }
// }

updateFieldVisibility();
}
Expand Down Expand Up @@ -219,28 +219,28 @@ RimWellPathImport::~RimWellPathImport()
//--------------------------------------------------------------------------------------------------
void RimWellPathImport::updateFilePaths()
{
QString wellPathsFolderPath = RimFileWellPath::getCacheDirectoryPath();
// QString wellPathsFolderPath = RimFileWellPath::getCacheDirectoryPath();

for ( size_t regionIdx = 0; regionIdx < regions.size(); regionIdx++ )
{
for ( size_t fIdx = 0; fIdx < regions[regionIdx]->fields.size(); fIdx++ )
{
RimOilFieldEntry* oilField = regions[regionIdx]->fields[fIdx];
// for ( size_t regionIdx = 0; regionIdx < regions.size(); regionIdx++ )
// {
// for ( size_t fIdx = 0; fIdx < regions[regionIdx]->fields.size(); fIdx++ )
// {
// RimOilFieldEntry* oilField = regions[regionIdx]->fields[fIdx];

QFileInfo fi( oilField->wellsFilePath );
// QFileInfo fi( oilField->wellsFilePath );

QString newWellsFilePath = wellPathsFolderPath + "/" + fi.fileName();
oilField->wellsFilePath = newWellsFilePath;
// QString newWellsFilePath = wellPathsFolderPath + "/" + fi.fileName();
// oilField->wellsFilePath = newWellsFilePath;

for ( size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++ )
{
RimWellPathEntry* rimWellPathEntry = oilField->wells[wIdx];
// for ( size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++ )
// {
// RimWellPathEntry* rimWellPathEntry = oilField->wells[wIdx];

QFileInfo fiWell( rimWellPathEntry->wellPathFilePath );
// QFileInfo fiWell( rimWellPathEntry->wellPathFilePath );

QString newFilePath = wellPathsFolderPath + "/" + fiWell.fileName();
rimWellPathEntry->wellPathFilePath = newFilePath;
}
}
}
// QString newFilePath = wellPathsFolderPath + "/" + fiWell.fileName();
// rimWellPathEntry->wellPathFilePath = newFilePath;
// }
// }
// }
}
Loading

0 comments on commit b9b202a

Please sign in to comment.