Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs
===================================================================
diff -u -r8db89aecb3565f4784cedd541e7407e8360b6a6f -r02670d8c9fceeaea5f829937a2eb269f3488c6b1
--- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision 8db89aecb3565f4784cedd541e7407e8360b6a6f)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision 02670d8c9fceeaea5f829937a2eb269f3488c6b1)
@@ -20,27 +20,24 @@
// All rights reserved.
using System;
-using Core.Common.Base.Data;
using Core.Common.Base.Service;
-using log4net;
using Ringtoets.Common.Service.MessageProviders;
using Ringtoets.HydraRing.Calculation.Activities;
-using Ringtoets.HydraRing.Calculation.Data.Output;
using Ringtoets.HydraRing.Data;
namespace Ringtoets.Common.Service
{
///
/// for running a design water level calculation.
///
- public class DesignWaterLevelCalculationActivity : HydraRingActivity
+ public class DesignWaterLevelCalculationActivity : NewHydraRingActivity
{
- private static readonly ILog log = LogManager.GetLogger(typeof(DesignWaterLevelCalculationActivity));
private readonly HydraulicBoundaryLocation hydraulicBoundaryLocation;
private readonly double norm;
private readonly string hydraulicBoundaryDatabaseFilePath;
private readonly string ringId;
private readonly ICalculationMessageProvider messageProvider;
+ private readonly DesignWaterLevelCalculationService calculationService;
///
/// Creates a new instance of .
@@ -69,46 +66,48 @@
this.hydraulicBoundaryLocation = hydraulicBoundaryLocation;
this.messageProvider = messageProvider;
-
this.hydraulicBoundaryDatabaseFilePath = hydraulicBoundaryDatabaseFilePath;
this.ringId = ringId;
this.norm = norm;
+ calculationService = new DesignWaterLevelCalculationService();
+
Name = messageProvider.GetActivityName(hydraulicBoundaryLocation.Name);
}
- protected override void OnRun()
+ protected override bool Validate()
{
+ return calculationService.Validate(
+ hydraulicBoundaryLocation.Name,
+ hydraulicBoundaryDatabaseFilePath,
+ messageProvider);
+ }
+
+ protected override void PerformCalculation()
+ {
if (!double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel))
{
State = ActivityState.Skipped;
- return;
}
+ else
+ {
+ calculationService.Calculate(
+ hydraulicBoundaryLocation,
+ hydraulicBoundaryDatabaseFilePath,
+ ringId,
+ norm,
+ messageProvider);
+ }
+ }
- PerformRun(() => DesignWaterLevelCalculationService.Instance.Validate(messageProvider.GetCalculationName(hydraulicBoundaryLocation.Name),
- hydraulicBoundaryDatabaseFilePath),
- () => RingtoetsCommonDataSynchronizationService.ClearDesignWaterLevel(hydraulicBoundaryLocation),
- () => DesignWaterLevelCalculationService.Instance.Calculate(hydraulicBoundaryLocation,
- hydraulicBoundaryDatabaseFilePath,
- ringId,
- norm,
- messageProvider));
+ protected override void OnCancel()
+ {
+ calculationService.Cancel();
}
protected override void OnFinish()
{
- PerformFinish(() =>
- {
- hydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) Output.Result;
- bool designWaterLevelCalculationConvergence = RingtoetsCommonDataCalculationService.CalculationConverged(Output, norm);
- if (!designWaterLevelCalculationConvergence)
- {
- log.Warn(messageProvider.GetCalculatedNotConvergedMessage(hydraulicBoundaryLocation.Name));
- }
- hydraulicBoundaryLocation.DesignWaterLevelCalculationConvergence = designWaterLevelCalculationConvergence
- ? CalculationConvergence.CalculatedConverged
- : CalculationConvergence.CalculatedNotConverged;
- });
+ // hydraulicBoundaryLocation.NotifyObservers();
}
}
}
\ No newline at end of file