Janitor issues

* Remove obsolete code
* Fix path modification of a relative folder
Replace start token '.' with file path to the project file to make sure that the path './wells/a-1h.dev' can be imported correctly.
* Add more logging when keywords are missing from import
This commit is contained in:
Magne Sjaastad 2023-02-15 07:56:17 +01:00
parent 9099919bbc
commit 48469f33f6
16 changed files with 29 additions and 117 deletions

View File

@ -199,6 +199,13 @@ bool RifEclipseInputFileTools::openGridFile( const QString& fileName,
return true; return true;
} }
QString txt = "Missing required keywords :";
if ( !specGridKw ) txt += " SPECGRID";
if ( !zCornKw ) txt += " ZCORN";
if ( !coordKw ) txt += " COORD";
RiaLogging::error( txt );
return false; return false;
} }

View File

@ -277,17 +277,7 @@ void RimFractureTemplateCollection::loadAndUpdateData()
{ {
stimPlanFracture->loadDataAndUpdate(); stimPlanFracture->loadDataAndUpdate();
} }
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureTemplateCollection::updateFilePathsFromProjectPath( const QString& newProjectPath,
const QString& oldProjectPath )
{
for ( RimFractureTemplate* f : m_fractureDefinitions() )
{
RimEllipseFractureTemplate* ellipseFracture = dynamic_cast<RimEllipseFractureTemplate*>( f ); RimEllipseFractureTemplate* ellipseFracture = dynamic_cast<RimEllipseFractureTemplate*>( f );
if ( ellipseFracture ) if ( ellipseFracture )
{ {

View File

@ -60,8 +60,6 @@ public:
void createAndAssignTemplateCopyForNonMatchingUnit(); void createAndAssignTemplateCopyForNonMatchingUnit();
void loadAndUpdateData(); void loadAndUpdateData();
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath );
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override; std::vector<caf::PdmObjectHandle*>& referringObjects ) override;

View File

@ -150,15 +150,6 @@ void RimFormationNames::readFormationNamesFile( QString* errorMessage )
m_formationNamesData = RifColorLegendData::readFormationNamesFile( m_formationNamesFileName().path(), errorMessage ); m_formationNamesData = RifColorLegendData::readFormationNamesFile( m_formationNamesFileName().path(), errorMessage );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFormationNames::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{
// m_formationNamesFileName =
// RimTools::relocateFile( m_formationNamesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -44,7 +44,6 @@ public:
void updateConnectedViews(); void updateConnectedViews();
void readFormationNamesFile( QString* errorMessage ); void readFormationNamesFile( QString* errorMessage );
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath );
static QString layerZoneTableFileName(); static QString layerZoneTableFileName();

View File

@ -112,18 +112,6 @@ std::vector<RimFormationNames*> RimFormationNamesCollection::importFiles( const
return m_formationNamesList.children(); return m_formationNamesList.children();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFormationNamesCollection::updateFilePathsFromProjectPath( const QString& newProjectPath,
const QString& oldProjectPath )
{
for ( RimFormationNames* fmNames : m_formationNamesList )
{
fmNames->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath );
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -39,8 +39,6 @@ public:
std::vector<RimFormationNames*> importFiles( const QStringList& fileNames ); std::vector<RimFormationNames*> importFiles( const QStringList& fileNames );
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath );
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override; std::vector<caf::PdmObjectHandle*>& referringObjects ) override;

View File

@ -473,38 +473,18 @@ void RimProject::setProjectFileNameAndUpdateDependencies( const QString& project
bool foundFile = false; bool foundFile = false;
std::vector<QString> searchedPaths; std::vector<QString> searchedPaths;
QString filePathCandidate = filePath->path();
if ( filePathCandidate.startsWith( '.' ) )
{
filePathCandidate = filePathCandidate.right( filePathCandidate.size() - 1 );
filePathCandidate = newProjectPath + filePathCandidate;
}
QString newFilePath = QString newFilePath =
RimTools::relocateFile( filePath->path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); RimTools::relocateFile( filePathCandidate, newProjectPath, oldProjectPath, &foundFile, &searchedPaths );
filePath->setPath( newFilePath ); filePath->setPath( newFilePath );
} }
// Update path to well path file cache
for ( RimOilField* oilField : oilFields )
{
if ( oilField == nullptr ) continue;
if ( oilField->wellPathCollection() != nullptr )
{
oilField->wellPathCollection()->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath );
}
if ( oilField->formationNamesCollection() != nullptr )
{
oilField->formationNamesCollection()->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath );
}
CVF_ASSERT( oilField->fractureDefinitionCollection() );
oilField->fractureDefinitionCollection()->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath );
}
{
std::vector<RimWellLogFile*> rimWellLogFiles;
this->descendantsIncludingThisOfType( rimWellLogFiles );
for ( auto rimWellLogFile : rimWellLogFiles )
{
rimWellLogFile->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath );
}
}
wellPathImport->updateFilePaths(); wellPathImport->updateFilePaths();
} }

View File

@ -232,22 +232,6 @@ bool RimWellLogFile::hasFlowData() const
return RimWellPlotTools::hasFlowData( this ); return RimWellPlotTools::hasFlowData( this );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogFile::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{
// bool foundFile = false;
// std::vector<QString> searchedPaths;
//
// QString fileNameCandidate =
// RimTools::relocateFile( m_fileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths );
// if ( foundFile )
// {
// m_fileName = fileNameCandidate;
// }
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -70,8 +70,6 @@ public:
RimWellLogFile::WellFlowCondition wellFlowRateCondition() const { return m_wellFlowCondition(); } RimWellLogFile::WellFlowCondition wellFlowRateCondition() const { return m_wellFlowCondition(); }
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath );
static std::vector<std::pair<double, double>> findMdAndChannelValuesForWellPath( const RimWellPath* wellPath, static std::vector<std::pair<double, double>> findMdAndChannelValuesForWellPath( const RimWellPath* wellPath,
const QString& channelName, const QString& channelName,
QString* unitString = nullptr ); QString* unitString = nullptr );

View File

@ -279,19 +279,6 @@ bool RimFileWellPath::isStoredInCache() const
return !id().isEmpty(); return !id().isEmpty();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{
QString newCacheFileName = getCacheFileName();
if ( caf::Utils::fileExists( newCacheFileName ) )
{
m_filePathInCache = newCacheFileName;
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -349,3 +336,16 @@ void RimFileWellPath::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
} }
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFileWellPath::initAfterRead()
{
QString newCacheFileName = getCacheFileName();
if ( caf::Utils::fileExists( newCacheFileName ) )
{
m_filePathInCache = newCacheFileName;
}
}

View File

@ -31,7 +31,6 @@ public:
bool readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter, bool setWellNameForExport ); bool readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter, bool setWellNameForExport );
int wellPathIndexInFile() const; // -1 means none. int wellPathIndexInFile() const; // -1 means none.
void setWellPathIndexInFile( int index ); void setWellPathIndexInFile( int index );
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override;
static QString getCacheDirectoryPath(); static QString getCacheDirectoryPath();
protected: protected:
@ -43,6 +42,7 @@ private:
bool isStoredInCache() const; bool isStoredInCache() const;
QString getCacheFileName(); QString getCacheFileName();
void initAfterRead() override;
void setupBeforeSave() override; void setupBeforeSave() override;
void ensureWellPathStartAtSeaLevel( RigWellPath* wellPath ); void ensureWellPathStartAtSeaLevel( RigWellPath* wellPath );

View File

@ -813,13 +813,6 @@ size_t RimWellPath::simulationWellBranchCount( const QString& simWellName )
return branches.size(); return branches.size();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -87,8 +87,6 @@ public:
bool tryAssociateWithSimulationWell(); bool tryAssociateWithSimulationWell();
bool isAssociatedWithSimulationWell() const; bool isAssociatedWithSimulationWell() const;
virtual void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath );
void setUnitSystem( RiaDefines::EclipseUnitSystem unitSystem ); void setUnitSystem( RiaDefines::EclipseUnitSystem unitSystem );
RiaDefines::EclipseUnitSystem unitSystem() const; RiaDefines::EclipseUnitSystem unitSystem() const;

View File

@ -504,17 +504,6 @@ void RimWellPathCollection::scheduleRedrawAffectedViews()
if ( proj ) proj->reloadCompletionTypeResultsInAllViews(); if ( proj ) proj->reloadCompletionTypeResultsInAllViews();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{
for ( auto wellPath : m_wellPaths )
{
wellPath->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath );
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -120,7 +120,6 @@ public:
void scheduleRedrawAffectedViews(); void scheduleRedrawAffectedViews();
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath );
bool anyWellsContainingPerforationIntervals() const; bool anyWellsContainingPerforationIntervals() const;
size_t modelledWellPathCount() const; size_t modelledWellPathCount() const;