#6791 Ensemble import: Show name of case with non-matching parameters

This commit is contained in:
Magne Sjaastad
2020-10-16 10:30:45 +02:00
parent b406649e17
commit 7be1763941

View File

@@ -859,16 +859,14 @@ void RimSummaryCaseCollection::loadDataAndUpdate()
bool RimSummaryCaseCollection::validateEnsembleCases( const std::vector<RimSummaryCase*> cases )
{
// Validate ensemble parameters
try
{
QString errors;
std::hash<std::string> paramsHasher;
size_t paramsHash = 0;
RimSummaryCase* parameterBaseCase = nullptr;
for ( RimSummaryCase* rimCase : cases )
{
if ( rimCase->caseRealizationParameters() == nullptr ||
rimCase->caseRealizationParameters()->parameters().empty() )
if ( rimCase->caseRealizationParameters() == nullptr || rimCase->caseRealizationParameters()->parameters().empty() )
{
errors.append( QString( "The case %1 has no ensemble parameters\n" )
.arg( QFileInfo( rimCase->summaryHeaderFilename() ).fileName() ) );
@@ -886,35 +884,28 @@ bool RimSummaryCaseCollection::validateEnsembleCases( const std::vector<RimSumma
if ( paramsHash == 0 )
{
paramsHash = currHash;
parameterBaseCase = rimCase;
}
else if ( paramsHash != currHash )
{
throw QString( "Ensemble parameters differ between cases" );
errors.append( QString( "The parameters in case %1 is not matching base parameters in %2\n" )
.arg( QFileInfo( rimCase->summaryHeaderFilename() ).fileName() )
.arg( QFileInfo( parameterBaseCase->summaryHeaderFilename() ).fileName() ) );
}
}
}
if ( !errors.isEmpty() )
{
QString textToDisplay = errors.left( 500 );
const int maxNumberOfCharactersToDisplaye = 1000;
QString textToDisplay = errors.left( maxNumberOfCharactersToDisplaye );
textToDisplay.prepend( "Missing ensemble parameters\n\n" );
textToDisplay.append( "\n" );
textToDisplay.append( "No parameters file (parameters.txt or runspecification.xml) was found in \n" );
textToDisplay.append( "the searched folders. ResInsight searches the home folder of the summary \n" );
textToDisplay.append( "case file and the three folder levels above that.\n" );
throw textToDisplay;
}
return true;
}
catch ( QString errorMessage )
{
RiaLogging::errorInMessageBox( nullptr, "", errorMessage );
RiaLogging::errorInMessageBox( nullptr, "", textToDisplay );
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------