Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StructuresCalculationCreateExtensions.cs =================================================================== diff -u -r43f72f0cd1f19b6bef02964ac191973d6077c74c -r31d2ac70c3ea6bb9f0461a296408af2a316ee5e0 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StructuresCalculationCreateExtensions.cs (.../StructuresCalculationCreateExtensions.cs) (revision 43f72f0cd1f19b6bef02964ac191973d6077c74c) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StructuresCalculationCreateExtensions.cs (.../StructuresCalculationCreateExtensions.cs) (revision 31d2ac70c3ea6bb9f0461a296408af2a316ee5e0) @@ -36,37 +36,58 @@ /// internal static class StructuresCalculationCreateExtensions { - /// - /// 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 HeightStructuresCalculationEntity CreateForHeightStructures(this StructuresCalculation calculation, PersistenceRegistry registry, int order) + 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"); } - var entity = new HeightStructuresCalculationEntity + entityToUpdate.StormDurationMean = input.StormDuration.Mean.Value.ToNaNAsNull(); + entityToUpdate.StructureNormalOrientation = input.StructureNormalOrientation.Value.ToNaNAsNull(); + entityToUpdate.FailureProbabilityStructureWithErosion = input.FailureProbabilityStructureWithErosion; + + if (input.HydraulicBoundaryLocation != null) { - Name = calculation.Name.DeepClone(), - Comments = calculation.Comments.DeepClone(), - Order = order - }; - SetInputValues(entity, calculation.InputParameters, registry); - SetOutputEntity(entity, calculation, registry); + entityToUpdate.HydraulicLocationEntity = registry.Get(input.HydraulicBoundaryLocation); + } - registry.Register(entity, calculation); + if (input.ForeshoreProfile != null) + { + entityToUpdate.ForeshoreProfileEntity = registry.Get(input.ForeshoreProfile); + } + entityToUpdate.UseForeshore = Convert.ToByte(input.UseForeshore); - return entity; + 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(); } + #region ClosingStructures + /// /// Creates a based /// on the information of the . @@ -77,7 +98,8 @@ /// in its parent container. /// A new . /// Thrown when is null. - internal static ClosingStructuresCalculationEntity CreateForClosingStructures(this StructuresCalculation calculation, PersistenceRegistry registry, int order) + internal static ClosingStructuresCalculationEntity CreateForClosingStructures(this StructuresCalculation calculation, + PersistenceRegistry registry, int order) { if (registry == null) { @@ -91,46 +113,99 @@ Order = order }; SetInputValues(entity, calculation.InputParameters, registry); + SetOutputEntity(calculation, entity, registry); + registry.Register(entity, calculation); + + return entity; + } + + private static void SetInputValues(ClosingStructuresCalculationEntity entity, ClosingStructuresInput input, + PersistenceRegistry registry) + { + input.Create(entity, registry); + + if (input.Structure != null) + { + entity.ClosingStructureEntity = registry.Get(input.Structure); + } + + entity.InflowModelType = Convert.ToByte(input.InflowModelType); + + entity.InsideWaterLevelMean = input.InsideWaterLevel.Mean.Value.ToNaNAsNull(); + entity.InsideWaterLevelStandardDeviation = input.InsideWaterLevel.StandardDeviation.Value.ToNaNAsNull(); + + entity.DeviationWaveDirection = input.DeviationWaveDirection.Value.ToNaNAsNull(); + + entity.DrainCoefficientMean = input.DrainCoefficient.Mean.Value.ToNaNAsNull(); + + entity.FactorStormDurationOpenStructure = input.FactorStormDurationOpenStructure.Value.ToNaNAsNull(); + + entity.ThresholdHeightOpenWeirMean = input.ThresholdHeightOpenWeir.Mean.Value.ToNaNAsNull(); + entity.ThresholdHeightOpenWeirStandardDeviation = input.ThresholdHeightOpenWeir.StandardDeviation.Value.ToNaNAsNull(); + + entity.AreaFlowAperturesMean = input.AreaFlowApertures.Mean.Value.ToNaNAsNull(); + entity.AreaFlowAperturesStandardDeviation = input.AreaFlowApertures.StandardDeviation.Value.ToNaNAsNull(); + + entity.FailureProbabilityOpenStructure = input.FailureProbabilityOpenStructure; + + entity.FailureProbabilityReparation = input.FailureProbabilityReparation; + + entity.IdenticalApertures = input.IdenticalApertures; + + entity.LevelCrestStructureNotClosingMean = input.LevelCrestStructureNotClosing.Mean.Value.ToNaNAsNull(); + entity.LevelCrestStructureNotClosingStandardDeviation = input.LevelCrestStructureNotClosing.StandardDeviation.Value.ToNaNAsNull(); + + entity.ProbabilityOpenStructureBeforeFlooding = input.ProbabilityOpenStructureBeforeFlooding; + } + + private static void SetOutputEntity(StructuresCalculation calculation, + ClosingStructuresCalculationEntity entity, PersistenceRegistry registry) + { if (calculation.HasOutput) { entity.ClosingStructuresOutputEntities.Add(calculation.Output.Create(registry)); } + } - registry.Register(entity, calculation); + #endregion - return entity; - } + #region HeightStructures /// - /// Creates a based + /// 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 . + /// A new . /// Thrown when is null. - internal static StabilityPointStructuresCalculationEntity CreateForStabilityPointStructures(this StructuresCalculation calculation, PersistenceRegistry registry, int order) + internal static HeightStructuresCalculationEntity CreateForHeightStructures(this StructuresCalculation calculation, + PersistenceRegistry registry, int order) { if (registry == null) { throw new ArgumentNullException("registry"); } - var entity = new StabilityPointStructuresCalculationEntity + var entity = new HeightStructuresCalculationEntity { Name = calculation.Name.DeepClone(), Comments = calculation.Comments.DeepClone(), Order = order }; SetInputValues(entity, calculation.InputParameters, registry); + SetOutputEntity(calculation, entity, registry); + registry.Register(entity, calculation); + return entity; } - private static void SetInputValues(HeightStructuresCalculationEntity entity, HeightStructuresInput input, PersistenceRegistry registry) + private static void SetInputValues(HeightStructuresCalculationEntity entity, HeightStructuresInput input, + PersistenceRegistry registry) { input.Create(entity, registry); @@ -145,53 +220,51 @@ entity.DeviationWaveDirection = input.DeviationWaveDirection.Value.ToNaNAsNull(); } - private static void SetOutputEntity(HeightStructuresCalculationEntity entity, StructuresCalculation calculation, PersistenceRegistry registry) + private static void SetOutputEntity(StructuresCalculation calculation, + HeightStructuresCalculationEntity entity, PersistenceRegistry registry) { if (calculation.HasOutput) { entity.HeightStructuresOutputEntities.Add(calculation.Output.Create(registry)); } } - private static void SetInputValues(ClosingStructuresCalculationEntity entity, ClosingStructuresInput input, PersistenceRegistry registry) - { - input.Create(entity, registry); + #endregion - if (input.Structure != null) + #region StabilityPointStructures + + /// + /// 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 StabilityPointStructuresCalculationEntity CreateForStabilityPointStructures(this StructuresCalculation calculation, + PersistenceRegistry registry, int order) + { + if (registry == null) { - entity.ClosingStructureEntity = registry.Get(input.Structure); + throw new ArgumentNullException("registry"); } - entity.InflowModelType = Convert.ToByte(input.InflowModelType); + var entity = new StabilityPointStructuresCalculationEntity + { + Name = calculation.Name.DeepClone(), + Comments = calculation.Comments.DeepClone(), + Order = order + }; + SetInputValues(entity, calculation.InputParameters, registry); + SetOutputEntity(calculation, entity, registry); - entity.InsideWaterLevelMean = input.InsideWaterLevel.Mean.Value.ToNaNAsNull(); - entity.InsideWaterLevelStandardDeviation = input.InsideWaterLevel.StandardDeviation.Value.ToNaNAsNull(); - - entity.DeviationWaveDirection = input.DeviationWaveDirection.Value.ToNaNAsNull(); - - entity.DrainCoefficientMean = input.DrainCoefficient.Mean.Value.ToNaNAsNull(); - - entity.FactorStormDurationOpenStructure = input.FactorStormDurationOpenStructure.Value.ToNaNAsNull(); - - entity.ThresholdHeightOpenWeirMean = input.ThresholdHeightOpenWeir.Mean.Value.ToNaNAsNull(); - entity.ThresholdHeightOpenWeirStandardDeviation = input.ThresholdHeightOpenWeir.StandardDeviation.Value.ToNaNAsNull(); - - entity.AreaFlowAperturesMean = input.AreaFlowApertures.Mean.Value.ToNaNAsNull(); - entity.AreaFlowAperturesStandardDeviation = input.AreaFlowApertures.StandardDeviation.Value.ToNaNAsNull(); - - entity.FailureProbabilityOpenStructure = input.FailureProbabilityOpenStructure; - - entity.FailureProbabilityReparation = input.FailureProbabilityReparation; - - entity.IdenticalApertures = input.IdenticalApertures; - - entity.LevelCrestStructureNotClosingMean = input.LevelCrestStructureNotClosing.Mean.Value.ToNaNAsNull(); - entity.LevelCrestStructureNotClosingStandardDeviation = input.LevelCrestStructureNotClosing.StandardDeviation.Value.ToNaNAsNull(); - - entity.ProbabilityOpenStructureBeforeFlooding = input.ProbabilityOpenStructureBeforeFlooding; + return entity; } - private static void SetInputValues(StabilityPointStructuresCalculationEntity entity, StabilityPointStructuresInput input, PersistenceRegistry registry) + private static void SetInputValues(StabilityPointStructuresCalculationEntity entity, + StabilityPointStructuresInput input, PersistenceRegistry registry) { input.Create(entity, registry); @@ -202,91 +275,72 @@ entity.InsideWaterLevelMean = input.InsideWaterLevel.Mean.Value.ToNaNAsNull(); entity.InsideWaterLevelStandardDeviation = input.InsideWaterLevel.StandardDeviation.Value.ToNaNAsNull(); + entity.ThresholdHeightOpenWeirMean = input.ThresholdHeightOpenWeir.Mean.Value.ToNaNAsNull(); entity.ThresholdHeightOpenWeirStandardDeviation = input.ThresholdHeightOpenWeir.StandardDeviation.Value.ToNaNAsNull(); + entity.ConstructiveStrengthLinearLoadModelMean = input.ConstructiveStrengthLinearLoadModel.Mean.Value.ToNaNAsNull(); entity.ConstructiveStrengthLinearLoadModelCoefficientOfVariation = input.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation.Value.ToNaNAsNull(); + entity.ConstructiveStrengthQuadraticLoadModelMean = input.ConstructiveStrengthQuadraticLoadModel.Mean.Value.ToNaNAsNull(); entity.ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation = input.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation.Value.ToNaNAsNull(); + entity.BankWidthMean = input.BankWidth.Mean.Value.ToNaNAsNull(); entity.BankWidthStandardDeviation = input.BankWidth.StandardDeviation.Value.ToNaNAsNull(); + entity.InsideWaterLevelFailureConstructionMean = input.InsideWaterLevelFailureConstruction.Mean.Value.ToNaNAsNull(); entity.InsideWaterLevelFailureConstructionStandardDeviation = input.InsideWaterLevelFailureConstruction.StandardDeviation.Value.ToNaNAsNull(); + entity.EvaluationLevel = input.EvaluationLevel.Value.ToNaNAsNull(); + entity.LevelCrestStructureMean = input.LevelCrestStructure.Mean.Value.ToNaNAsNull(); entity.LevelCrestStructureStandardDeviation = input.LevelCrestStructure.StandardDeviation.Value.ToNaNAsNull(); + entity.VerticalDistance = input.VerticalDistance.Value.ToNaNAsNull(); + entity.FailureProbabilityRepairClosure = input.FailureProbabilityRepairClosure; + entity.FailureCollisionEnergyMean = input.FailureCollisionEnergy.Mean.Value.ToNaNAsNull(); entity.FailureCollisionEnergyCoefficientOfVariation = input.FailureCollisionEnergy.CoefficientOfVariation.Value.ToNaNAsNull(); + entity.ShipMassMean = input.ShipMass.Mean.Value.ToNaNAsNull(); entity.ShipMassCoefficientOfVariation = input.ShipMass.CoefficientOfVariation.Value.ToNaNAsNull(); + entity.ShipVelocityMean = input.ShipVelocity.Mean.Value.ToNaNAsNull(); entity.ShipVelocityCoefficientOfVariation = input.ShipVelocity.CoefficientOfVariation.Value.ToNaNAsNull(); + entity.LevellingCount = input.LevellingCount; + entity.ProbabilityCollisionSecondaryStructure = input.ProbabilityCollisionSecondaryStructure; + entity.FlowVelocityStructureClosableMean = input.FlowVelocityStructureClosable.Mean.Value.ToNaNAsNull(); entity.FlowVelocityStructureClosableStandardDeviation = input.FlowVelocityStructureClosable.StandardDeviation.Value.ToNaNAsNull(); + entity.StabilityLinearLoadModelMean = input.StabilityLinearLoadModel.Mean.Value.ToNaNAsNull(); entity.StabilityLinearLoadModelCoefficientOfVariation = input.StabilityLinearLoadModel.CoefficientOfVariation.Value.ToNaNAsNull(); + entity.StabilityQuadraticLoadModelMean = input.StabilityQuadraticLoadModel.Mean.Value.ToNaNAsNull(); entity.StabilityQuadraticLoadModelCoefficientOfVariation = input.StabilityQuadraticLoadModel.CoefficientOfVariation.Value.ToNaNAsNull(); + entity.AreaFlowAperturesMean = input.AreaFlowApertures.Mean.Value.ToNaNAsNull(); entity.AreaFlowAperturesStandardDeviation = input.AreaFlowApertures.StandardDeviation.Value.ToNaNAsNull(); + entity.InflowModelType = Convert.ToByte(input.InflowModelType); entity.LoadSchematizationType = Convert.ToByte(input.LoadSchematizationType); entity.VolumicWeightWater = input.VolumicWeightWater.Value.ToNaNAsNull(); entity.FactorStormDurationOpenStructure = input.FactorStormDurationOpenStructure.Value.ToNaNAsNull(); entity.DrainCoefficientMean = input.DrainCoefficient.Mean.Value.ToNaNAsNull(); } - private static void Create(this StructuresInputBase input, IStructuresCalculationEntity entityToUpdate, PersistenceRegistry registry) - where T : StructureBase + private static void SetOutputEntity(StructuresCalculation calculation, + StabilityPointStructuresCalculationEntity entity, PersistenceRegistry registry) { - if (entityToUpdate == null) + if (calculation.HasOutput) { - throw new ArgumentNullException("entityToUpdate"); + entity.StabilityPointStructuresOutputEntities.Add(calculation.Output.Create(registry)); } - 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(); } + + #endregion } } \ No newline at end of file