Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StructuresCalculationCreateExtensions.cs
===================================================================
diff -u -r183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3 -rbce62ec6102f15b0dbb1328fd9d14063fd21c978
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StructuresCalculationCreateExtensions.cs (.../StructuresCalculationCreateExtensions.cs) (revision 183d1e7ed095ea4e8024068bc4ddfcf3ac6997d3)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StructuresCalculationCreateExtensions.cs (.../StructuresCalculationCreateExtensions.cs) (revision bce62ec6102f15b0dbb1328fd9d14063fd21c978)
@@ -22,6 +22,8 @@
using System;
using Application.Ringtoets.Storage.DbContext;
using Core.Common.Utils.Extensions;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.Common.Data;
using Ringtoets.Common.Data.Structures;
using Ringtoets.HeightStructures.Data;
@@ -43,7 +45,7 @@
/// in its parent container.
/// A new .
/// Thrown when is null.
- internal static HeightStructuresCalculationEntity Create(this StructuresCalculation calculation, PersistenceRegistry registry, int order)
+ internal static HeightStructuresCalculationEntity CreateForHeightStructures(this StructuresCalculation calculation, PersistenceRegistry registry, int order)
{
if (registry == null)
{
@@ -68,52 +70,134 @@
return entity;
}
- private static void SetInputValues(HeightStructuresCalculationEntity entity, HeightStructuresInput input, PersistenceRegistry registry)
+ ///
+ /// Creates a based
+ /// on the information of the .
+ ///
+ /// The calculation to create a database entity for.
+ /// The object keeping track of create operations.
+ /// The index at where resides
+ /// in its parent container.
+ /// A new .
+ /// Thrown when is null.
+ internal static ClosingStructuresCalculationEntity CreateForClosingStructures(this StructuresCalculation calculation, PersistenceRegistry registry, int order)
{
- if (input.HydraulicBoundaryLocation != null)
+ if (registry == null)
{
- entity.HydraulicLocationEntity = registry.Get(input.HydraulicBoundaryLocation);
+ throw new ArgumentNullException("registry");
}
+
+ var entity = new ClosingStructuresCalculationEntity
+ {
+ Name = calculation.Name.DeepClone(),
+ Comments = calculation.Comments.DeepClone(),
+ Order = order
+ };
+ SetInputValues(entity, calculation.InputParameters, registry);
+
+ return entity;
+ }
+
+ private static void SetInputValues(HeightStructuresCalculationEntity entity, HeightStructuresInput input, PersistenceRegistry registry)
+ {
+ input.Create(entity, registry);
+
if (input.Structure != null)
{
entity.HeightStructureEntity = registry.Get(input.Structure);
}
- if (input.ForeshoreProfile != null)
+
+ entity.LevelCrestStructureMean = input.LevelCrestStructure.Mean.Value.ToNaNAsNull();
+ entity.LevelCrestStructureStandardDeviation = input.LevelCrestStructure.StandardDeviation.Value.ToNaNAsNull();
+
+ entity.DeviationWaveDirection = input.DeviationWaveDirection.Value.ToNaNAsNull();
+ }
+
+ private static void SetInputValues(ClosingStructuresCalculationEntity entity, ClosingStructuresInput input, PersistenceRegistry registry)
+ {
+ input.Create(entity, registry);
+
+ if (input.Structure != null)
{
- entity.ForeshoreProfileEntity = registry.Get(input.ForeshoreProfile);
+ entity.ClosingStructureEntity = registry.Get(input.Structure);
}
- entity.StructureNormalOrientation = input.StructureNormalOrientation.Value.ToNaNAsNull();
- entity.ModelFactorSuperCriticalFlowMean = input.ModelFactorSuperCriticalFlow.Mean.Value.ToNaNAsNull();
+ entity.InflowModelType = Convert.ToByte(input.InflowModelType);
- entity.AllowedLevelIncreaseStorageMean = input.AllowedLevelIncreaseStorage.Mean.Value.ToNaNAsNull();
- entity.AllowedLevelIncreaseStorageStandardDeviation = input.AllowedLevelIncreaseStorage.StandardDeviation.Value.ToNaNAsNull();
+ entity.InsideWaterLevelMean = input.InsideWaterLevel.Mean.Value.ToNaNAsNull();
+ entity.InsideWaterLevelStandardDeviation = input.InsideWaterLevel.StandardDeviation.Value.ToNaNAsNull();
- entity.StorageStructureAreaMean = input.StorageStructureArea.Mean.Value.ToNaNAsNull();
- entity.StorageStructureAreaCoefficientOfVariation = input.StorageStructureArea.CoefficientOfVariation.Value.ToNaNAsNull();
+ entity.DeviationWaveDirection = input.DeviationWaveDirection.Value.ToNaNAsNull();
- entity.FlowWidthAtBottomProtectionMean = input.FlowWidthAtBottomProtection.Mean.Value.ToNaNAsNull();
- entity.FlowWidthAtBottomProtectionStandardDeviation = input.FlowWidthAtBottomProtection.StandardDeviation.Value.ToNaNAsNull();
+ entity.DrainCoefficientMean = input.DrainCoefficient.Mean.Value.ToNaNAsNull();
- entity.CriticalOvertoppingDischargeMean = input.CriticalOvertoppingDischarge.Mean.Value.ToNaNAsNull();
- entity.CriticalOvertoppingDischargeCoefficientOfVariation = input.CriticalOvertoppingDischarge.CoefficientOfVariation.Value.ToNaNAsNull();
+ entity.FactorStormDurationOpenStructure = input.FactorStormDurationOpenStructure.Value.ToNaNAsNull();
- entity.FailureProbabilityStructureWithErosion = input.FailureProbabilityStructureWithErosion;
+ entity.ThresholdHeightOpenWeirMean = input.ThresholdHeightOpenWeir.Mean.Value.ToNaNAsNull();
+ entity.ThresholdHeightOpenWeirStandardDeviation = input.ThresholdHeightOpenWeir.StandardDeviation.Value.ToNaNAsNull();
- entity.WidthFlowAperturesMean = input.WidthFlowApertures.Mean.Value.ToNaNAsNull();
- entity.WidthFlowAperturesCoefficientOfVariation = input.WidthFlowApertures.CoefficientOfVariation.Value.ToNaNAsNull();
+ entity.AreaFlowAperturesMean = input.AreaFlowApertures.Mean.Value.ToNaNAsNull();
+ entity.AreaFlowAperturesStandardDeviation = input.AreaFlowApertures.StandardDeviation.Value.ToNaNAsNull();
- entity.StormDurationMean = input.StormDuration.Mean.Value.ToNaNAsNull();
+ entity.FailureProbabilityOpenStructure = input.FailureProbabilityOpenStructure;
- entity.LevelCrestStructureMean = input.LevelCrestStructure.Mean.Value.ToNaNAsNull();
- entity.LevelCrestStructureStandardDeviation = input.LevelCrestStructure.StandardDeviation.Value.ToNaNAsNull();
+ entity.FailureProbablityReparation = input.FailureProbabilityReparation;
- entity.DeviationWaveDirection = input.DeviationWaveDirection.Value.ToNaNAsNull();
+ entity.IdenticalApertures = input.IdenticalApertures;
- entity.BreakWaterHeight = input.BreakWater.Height.Value.ToNaNAsNull();
- entity.BreakWaterType = Convert.ToInt16(input.BreakWater.Type);
- entity.UseBreakWater = Convert.ToByte(input.UseBreakWater);
- entity.UseForeshore = Convert.ToByte(input.UseForeshore);
+ entity.LevelCrestStructureNotClosingMean = input.LevelCrestStructureNotClosing.Mean.Value.ToNaNAsNull();
+ entity.LevelCrestStructureNotClosingStandardDeviation = input.LevelCrestStructureNotClosing.StandardDeviation.Value.ToNaNAsNull();
+
+ entity.ProbabilityOpenStructureBeforeFlooding = input.ProbabilityOpenStructureBeforeFlooding;
}
+
+ private static void Create(this StructuresInputBase input, IStructuresCalculationEntity entityToUpdate, PersistenceRegistry registry)
+ where T : StructureBase
+ {
+ if (entityToUpdate == null)
+ {
+ throw new ArgumentNullException("entityToUpdate");
+ }
+ if (registry == null)
+ {
+ throw new ArgumentNullException("registry");
+ }
+
+ entityToUpdate.StormDurationMean = input.StormDuration.Mean.Value.ToNaNAsNull();
+ entityToUpdate.StructureNormalOrientation = input.StructureNormalOrientation.Value.ToNaNAsNull();
+ entityToUpdate.FailureProbabilityStructureWithErosion = input.FailureProbabilityStructureWithErosion;
+
+ if (input.HydraulicBoundaryLocation != null)
+ {
+ entityToUpdate.HydraulicLocationEntity = registry.Get(input.HydraulicBoundaryLocation);
+ }
+
+ if (input.ForeshoreProfile != null)
+ {
+ entityToUpdate.ForeshoreProfileEntity = registry.Get(input.ForeshoreProfile);
+ }
+ entityToUpdate.UseForeshore = Convert.ToByte(input.UseForeshore);
+
+ entityToUpdate.UseBreakWater = Convert.ToByte(input.UseBreakWater);
+ entityToUpdate.BreakWaterType = Convert.ToInt16(input.BreakWater.Type);
+ entityToUpdate.BreakWaterHeight = input.BreakWater.Height.Value.ToNaNAsNull();
+
+ entityToUpdate.AllowedLevelIncreaseStorageMean = input.AllowedLevelIncreaseStorage.Mean.Value.ToNaNAsNull();
+ entityToUpdate.AllowedLevelIncreaseStorageStandardDeviation = input.AllowedLevelIncreaseStorage.StandardDeviation.Value.ToNaNAsNull();
+
+ entityToUpdate.StorageStructureAreaMean = input.StorageStructureArea.Mean.Value.ToNaNAsNull();
+ entityToUpdate.StorageStructureAreaCoefficientOfVariation = input.StorageStructureArea.CoefficientOfVariation.Value.ToNaNAsNull();
+
+ entityToUpdate.FlowWidthAtBottomProtectionMean = input.FlowWidthAtBottomProtection.Mean.Value.ToNaNAsNull();
+ entityToUpdate.FlowWidthAtBottomProtectionStandardDeviation = input.FlowWidthAtBottomProtection.StandardDeviation.Value.ToNaNAsNull();
+
+ entityToUpdate.CriticalOvertoppingDischargeMean = input.CriticalOvertoppingDischarge.Mean.Value.ToNaNAsNull();
+ entityToUpdate.CriticalOvertoppingDischargeCoefficientOfVariation = input.CriticalOvertoppingDischarge.CoefficientOfVariation.Value.ToNaNAsNull();
+
+ entityToUpdate.ModelFactorSuperCriticalFlowMean = input.ModelFactorSuperCriticalFlow.Mean.Value.ToNaNAsNull();
+
+ entityToUpdate.WidthFlowAperturesMean = input.WidthFlowApertures.Mean.Value.ToNaNAsNull();
+ entityToUpdate.WidthFlowAperturesCoefficientOfVariation = input.WidthFlowApertures.CoefficientOfVariation.Value.ToNaNAsNull();
+ }
}
}
\ No newline at end of file