Index: Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs
===================================================================
diff -u -r8bb6e849266ec28412ebfe23beccd7235c4db9bf -r959924f8d1ddff924bb3306444d1f13fef85e545
--- Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision 8bb6e849266ec28412ebfe23beccd7235c4db9bf)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision 959924f8d1ddff924bb3306444d1f13fef85e545)
@@ -74,11 +74,11 @@
///
/// Performs a calculation for wave height.
///
- /// The hydraulic boundary location used in the calculation.
+ /// The wave height calculation to use.
/// The path which points to the hydraulic boundary database file.
/// The norm of the assessment section.
/// The object which is used to build log messages.
- /// Thrown when is null.
+ /// Thrown when is null.
/// Thrown when
///
/// - contains invalid characters.
@@ -92,18 +92,18 @@
/// - Unable to read required data from database file.
///
/// Thrown when an error occurs while performing the calculation.
- public void Calculate(HydraulicBoundaryLocation hydraulicBoundaryLocation,
+ public void Calculate(IWaveHeightCalculation waveHeightCalculation,
string hydraulicBoundaryDatabaseFilePath,
double norm,
ICalculationMessageProvider messageProvider)
{
- if (hydraulicBoundaryLocation == null)
+ if (waveHeightCalculation == null)
{
- throw new ArgumentNullException(nameof(hydraulicBoundaryLocation));
+ throw new ArgumentNullException(nameof(waveHeightCalculation));
}
string hlcdDirectory = Path.GetDirectoryName(hydraulicBoundaryDatabaseFilePath);
- string calculationName = messageProvider.GetCalculationName(hydraulicBoundaryLocation.Name);
+ string calculationName = messageProvider.GetCalculationName(waveHeightCalculation.GetName());
CalculationServiceHelper.LogCalculationBegin(calculationName);
@@ -113,13 +113,14 @@
try
{
- WaveHeightCalculationInput calculationInput = CreateInput(hydraulicBoundaryLocation, norm, hydraulicBoundaryDatabaseFilePath);
+ WaveHeightCalculationInput calculationInput = CreateInput(waveHeightCalculation, norm, hydraulicBoundaryDatabaseFilePath);
calculator.Calculate(calculationInput);
- if (string.IsNullOrEmpty(calculator.LastErrorFileContent))
+ if (!canceled && string.IsNullOrEmpty(calculator.LastErrorFileContent))
{
- hydraulicBoundaryLocation.WaveHeightCalculation.Output = CreateHydraulicBoundaryLocationOutput(
- messageProvider, hydraulicBoundaryLocation.Name, calculationInput.Beta, norm, calculator.Converged);
+ waveHeightCalculation.SetOutput(
+ CreateHydraulicBoundaryLocationOutput(
+ messageProvider, waveHeightCalculation.GetName(), calculationInput.Beta, norm, calculator.Converged));
}
}
catch (HydraRingCalculationException)
@@ -128,8 +129,8 @@
{
string lastErrorContent = calculator.LastErrorFileContent;
log.Error(string.IsNullOrEmpty(lastErrorContent)
- ? messageProvider.GetCalculationFailedUnexplainedMessage(hydraulicBoundaryLocation.Name)
- : messageProvider.GetCalculationFailedMessage(hydraulicBoundaryLocation.Name, lastErrorContent));
+ ? messageProvider.GetCalculationFailedUnexplainedMessage(waveHeightCalculation.GetName())
+ : messageProvider.GetCalculationFailedMessage(waveHeightCalculation.GetName(), lastErrorContent));
exceptionThrown = true;
throw;
@@ -141,7 +142,7 @@
bool errorOccurred = CalculationServiceHelper.HasErrorOccurred(canceled, exceptionThrown, lastErrorFileContent);
if (errorOccurred)
{
- log.Error(messageProvider.GetCalculationFailedMessage(hydraulicBoundaryLocation.Name, lastErrorFileContent));
+ log.Error(messageProvider.GetCalculationFailedMessage(waveHeightCalculation.GetName(), lastErrorFileContent));
}
log.InfoFormat(Resources.WaveHeightCalculationService_Calculate_Calculation_temporary_directory_can_be_found_on_location_0, calculator.OutputDirectory);
@@ -200,7 +201,7 @@
///
/// Creates the input for an wave height calculation.
///
- /// The
+ /// The
/// to create the input from.
/// The norm to use during the calculation.
/// The file path to the hydraulic
@@ -216,11 +217,11 @@
/// - Unable to read required data from database file.
///
///
- private static WaveHeightCalculationInput CreateInput(HydraulicBoundaryLocation hydraulicBoundaryLocation,
+ private static WaveHeightCalculationInput CreateInput(IWaveHeightCalculation waveHeightCalculation,
double norm,
string hydraulicBoundaryDatabaseFilePath)
{
- var waveHeightCalculationInput = new WaveHeightCalculationInput(1, hydraulicBoundaryLocation.Id, norm);
+ var waveHeightCalculationInput = new WaveHeightCalculationInput(1, waveHeightCalculation.GetId(), norm);
HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(waveHeightCalculationInput, hydraulicBoundaryDatabaseFilePath);