/// <summary>
        /// Creates a <see cref="HydraulicLocationCalculationForTargetProbabilityCollectionEntity"/> based on the information
        /// of the <paramref name="calculations"/>.
        /// </summary>
        /// <param name="calculations">
        /// The collection of <see cref="HydraulicBoundaryLocationCalculationsForTargetProbability"/>
        /// to create a database entity for.
        /// </param>
        /// <param name="calculationType">The type of calculation the entity should be created for.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="HydraulicLocationCalculationForTargetProbabilityCollectionEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculations"/> or <paramref name="registry"/> is <c>null</c>.</exception>
        internal static HydraulicLocationCalculationForTargetProbabilityCollectionEntity Create(this HydraulicBoundaryLocationCalculationsForTargetProbability calculations,
                                                                                                HydraulicBoundaryLocationCalculationType calculationType,
                                                                                                int order,
                                                                                                PersistenceRegistry registry)
        {
            if (calculations == null)
            {
                throw new ArgumentNullException(nameof(calculations));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(calculations))
            {
                return(registry.Get(calculations));
            }

            var collectionEntity = new HydraulicLocationCalculationForTargetProbabilityCollectionEntity
            {
                HydraulicBoundaryLocationCalculationType = Convert.ToByte(calculationType),
                TargetProbability = calculations.TargetProbability,
                Order             = order
            };

            foreach (HydraulicBoundaryLocationCalculation calculation in calculations.HydraulicBoundaryLocationCalculations)
            {
                collectionEntity.HydraulicLocationCalculationEntities.Add(calculation.Create(registry));
            }

            registry.Register(collectionEntity, calculations);
            return(collectionEntity);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a <see cref="HydraulicLocationEntity"/> based on the information of the <see cref="HydraulicBoundaryLocation"/>.
        /// </summary>
        /// <param name="location">The location to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="HydraulicLocationEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> or <param name="location"></param>
        /// is <c>null</c>.</exception>
        internal static HydraulicLocationEntity Create(this HydraulicBoundaryLocation location, PersistenceRegistry registry, int order)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(location))
            {
                return(registry.Get(location));
            }

            var entity = new HydraulicLocationEntity
            {
                LocationId = location.Id,
                Name       = location.Name.DeepClone(),
                LocationX  = location.Location.X.ToNaNAsNull(),
                LocationY  = location.Location.Y.ToNaNAsNull(),
                Order      = order
            };

            registry.Register(entity, location);
            return(entity);
        }
        /// <summary>
        /// Creates a <see cref="ForeshoreProfileEntity"/> based on the information of the <see cref="ForeshoreProfile"/>.
        /// </summary>
        /// <param name="foreshoreProfile">The foreshore profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">The index at which <paramref name="foreshoreProfile"/> resides within its parent.</param>
        /// <returns>A new <see cref="ForeshoreProfileEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static ForeshoreProfileEntity Create(this ForeshoreProfile foreshoreProfile, PersistenceRegistry registry, int order)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(foreshoreProfile))
            {
                return(registry.Get(foreshoreProfile));
            }

            var foreshoreProfileEntity = new ForeshoreProfileEntity
            {
                Id          = foreshoreProfile.Id.DeepClone(),
                Name        = foreshoreProfile.Name.DeepClone(),
                GeometryXml = new Point2DCollectionXmlSerializer().ToXml(foreshoreProfile.Geometry),
                X           = foreshoreProfile.WorldReferencePoint.X,
                Y           = foreshoreProfile.WorldReferencePoint.Y,
                X0          = foreshoreProfile.X0,
                Orientation = foreshoreProfile.Orientation,
                Order       = order
            };

            if (foreshoreProfile.HasBreakWater)
            {
                foreshoreProfileEntity.BreakWaterHeight = foreshoreProfile.BreakWater.Height;
                foreshoreProfileEntity.BreakWaterType   = Convert.ToByte(foreshoreProfile.BreakWater.Type);
            }

            registry.Register(foreshoreProfileEntity, foreshoreProfile);

            return(foreshoreProfileEntity);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a <see cref="SpecificFailureMechanismEntity"/> based on the information of the <see cref="SpecificFailureMechanism"/>.
        /// </summary>
        /// <param name="specificFailureMechanism">The structure to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">The index at which <paramref name="specificFailureMechanism"/> resides within its parent.</param>
        /// <returns>A new <see cref="SpecificFailureMechanismEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static SpecificFailureMechanismEntity Create(this SpecificFailureMechanism specificFailureMechanism, PersistenceRegistry registry, int order)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            var entity = Create <SpecificFailureMechanismEntity>(specificFailureMechanism, registry);

            AddEntitiesForSectionResults(specificFailureMechanism.SectionResults, registry);
            entity.Name  = specificFailureMechanism.Name.DeepClone();
            entity.Code  = specificFailureMechanism.Code.DeepClone();
            entity.Order = order;
            entity.N     = specificFailureMechanism.GeneralInput.N;
            entity.ApplyLengthEffectInSection = Convert.ToByte(specificFailureMechanism.GeneralInput.ApplyLengthEffectInSection);

            return(entity);
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="ICalculatableFailureMechanism"/>.
        /// </summary>
        /// <param name="mechanism">The failure mechanism to create a database entity for.</param>
        /// <param name="type">The type of the failure mechanism that is being created.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static FailureMechanismEntity Create(this ICalculatableFailureMechanism mechanism, FailureMechanismType type, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            var entity = Create <FailureMechanismEntity>(mechanism, registry);

            entity.FailureMechanismType      = (short)type;
            entity.CalculationsInputComments = mechanism.CalculationsInputComments.Body.DeepClone();

            return(entity);
        }
Esempio n. 6
0
        /// <summary>
        /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="IFailureMechanism"/>.
        /// </summary>
        /// <param name="mechanism">The failure mechanism to create a database entity for.</param>
        /// <param name="type">The type of the failure mechanism that is being created.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static FailureMechanismEntity Create(this IFailureMechanism mechanism, FailureMechanismType type, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            var entity = Create <FailureMechanismEntity>(mechanism, registry);

            entity.FailureMechanismType = (short)type;
            return(entity);
        }
Esempio n. 7
0
        private static void SetStabilityPointStructuresInputValues(StabilityPointStructuresCalculationEntity entity,
                                                                   StabilityPointStructuresInput input, PersistenceRegistry registry)
        {
            input.Create(entity, registry);

            if (input.Structure != null)
            {
                entity.StabilityPointStructureEntity = registry.Get(input.Structure);
            }

            entity.InsideWaterLevelMean = input.InsideWaterLevel.Mean.ToNaNAsNull();
            entity.InsideWaterLevelStandardDeviation = input.InsideWaterLevel.StandardDeviation.ToNaNAsNull();

            entity.ThresholdHeightOpenWeirMean = input.ThresholdHeightOpenWeir.Mean.ToNaNAsNull();
            entity.ThresholdHeightOpenWeirStandardDeviation = input.ThresholdHeightOpenWeir.StandardDeviation.ToNaNAsNull();

            entity.ConstructiveStrengthLinearLoadModelMean = input.ConstructiveStrengthLinearLoadModel.Mean.ToNaNAsNull();
            entity.ConstructiveStrengthLinearLoadModelCoefficientOfVariation = input.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation.ToNaNAsNull();

            entity.ConstructiveStrengthQuadraticLoadModelMean = input.ConstructiveStrengthQuadraticLoadModel.Mean.ToNaNAsNull();
            entity.ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation = input.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation.ToNaNAsNull();

            entity.BankWidthMean = input.BankWidth.Mean.ToNaNAsNull();
            entity.BankWidthStandardDeviation = input.BankWidth.StandardDeviation.ToNaNAsNull();

            entity.InsideWaterLevelFailureConstructionMean = input.InsideWaterLevelFailureConstruction.Mean.ToNaNAsNull();
            entity.InsideWaterLevelFailureConstructionStandardDeviation = input.InsideWaterLevelFailureConstruction.StandardDeviation.ToNaNAsNull();

            entity.EvaluationLevel = input.EvaluationLevel.ToNaNAsNull();

            entity.LevelCrestStructureMean = input.LevelCrestStructure.Mean.ToNaNAsNull();
            entity.LevelCrestStructureStandardDeviation = input.LevelCrestStructure.StandardDeviation.ToNaNAsNull();

            entity.VerticalDistance = input.VerticalDistance.ToNaNAsNull();

            entity.FailureProbabilityRepairClosure = input.FailureProbabilityRepairClosure;

            entity.FailureCollisionEnergyMean = input.FailureCollisionEnergy.Mean.ToNaNAsNull();
            entity.FailureCollisionEnergyCoefficientOfVariation = input.FailureCollisionEnergy.CoefficientOfVariation.ToNaNAsNull();

            entity.ShipMassMean = input.ShipMass.Mean.ToNaNAsNull();
            entity.ShipMassCoefficientOfVariation = input.ShipMass.CoefficientOfVariation.ToNaNAsNull();

            entity.ShipVelocityMean = input.ShipVelocity.Mean.ToNaNAsNull();
            entity.ShipVelocityCoefficientOfVariation = input.ShipVelocity.CoefficientOfVariation.ToNaNAsNull();

            entity.LevellingCount = input.LevellingCount;

            entity.ProbabilityCollisionSecondaryStructure = input.ProbabilityCollisionSecondaryStructure;

            entity.FlowVelocityStructureClosableMean = input.FlowVelocityStructureClosable.Mean.ToNaNAsNull();

            entity.StabilityLinearLoadModelMean = input.StabilityLinearLoadModel.Mean.ToNaNAsNull();
            entity.StabilityLinearLoadModelCoefficientOfVariation = input.StabilityLinearLoadModel.CoefficientOfVariation.ToNaNAsNull();

            entity.StabilityQuadraticLoadModelMean = input.StabilityQuadraticLoadModel.Mean.ToNaNAsNull();
            entity.StabilityQuadraticLoadModelCoefficientOfVariation = input.StabilityQuadraticLoadModel.CoefficientOfVariation.ToNaNAsNull();

            entity.AreaFlowAperturesMean = input.AreaFlowApertures.Mean.ToNaNAsNull();
            entity.AreaFlowAperturesStandardDeviation = input.AreaFlowApertures.StandardDeviation.ToNaNAsNull();

            entity.InflowModelType                   = Convert.ToByte(input.InflowModelType);
            entity.LoadSchematizationType            = Convert.ToByte(input.LoadSchematizationType);
            entity.VolumicWeightWater                = input.VolumicWeightWater.ToNaNAsNull();
            entity.FactorStormDurationOpenStructure  = input.FactorStormDurationOpenStructure.ToNaNAsNull();
            entity.DrainCoefficientMean              = input.DrainCoefficient.Mean.ToNaNAsNull();
            entity.DrainCoefficientStandardDeviation = input.DrainCoefficient.StandardDeviation.ToNaNAsNull();
        }
Esempio n. 8
0
        /// <summary>
        /// Creates a <see cref="StabilityPointStructuresCalculationEntity"/> based
        /// on the information of the <see cref="StructuresCalculationScenario{T}"/>.
        /// </summary>
        /// <param name="calculation">The calculation to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">The index at where <paramref name="calculation"/> resides
        /// in its parent container.</param>
        /// <returns>A new <see cref="StabilityPointStructuresCalculationEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static StabilityPointStructuresCalculationEntity CreateForStabilityPointStructures(this StructuresCalculationScenario <StabilityPointStructuresInput> calculation,
                                                                                                    PersistenceRegistry registry, int order)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            var entity = new StabilityPointStructuresCalculationEntity
            {
                Name = calculation.Name.DeepClone(),
                RelevantForScenario  = Convert.ToByte(calculation.IsRelevant),
                ScenarioContribution = calculation.Contribution,
                Comments             = calculation.Comments.Body.DeepClone(),
                Order = order
            };

            SetStabilityPointStructuresInputValues(entity, calculation.InputParameters, registry);
            SetStabilityPointStructuresOutputEntity(calculation, entity);

            return(entity);
        }