Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -54,6 +54,8 @@ + + @@ -140,18 +142,28 @@ RingtoetsEntities.tt + + RingtoetsEntities.tt + RingtoetsEntities.tt RingtoetsEntities.tt + + RingtoetsEntities.tt + RingtoetsEntities.tt + + RingtoetsEntities.tt + + @@ -204,6 +216,8 @@ + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (.../AssessmentSectionCreateExtensions.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -60,6 +60,8 @@ entity.FailureMechanismEntities.Add(section.PipingFailureMechanism.Create(registry)); entity.FailureMechanismEntities.Add(section.GrassCoverErosionInwards.Create(registry)); entity.FailureMechanismEntities.Add(section.HeightStructures.Create(registry)); + entity.FailureMechanismEntities.Add(section.StrengthStabilityLengthwiseConstruction.Create(registry)); + AddEntitiesForAddStandAloneFailureMechanisms(section, entity, registry); registry.Register(entity, section); @@ -80,7 +82,6 @@ entity.FailureMechanismEntities.Add(section.ClosingStructure.Create(FailureMechanismType.ReliabilityClosingOfStructure, registry)); entity.FailureMechanismEntities.Add(section.PipingStructure.Create(FailureMechanismType.PipingAtStructure, registry)); entity.FailureMechanismEntities.Add(section.StrengthStabilityPointConstruction.Create(FailureMechanismType.StrengthAndStabilityPointConstruction, registry)); - entity.FailureMechanismEntities.Add(section.StrengthStabilityLengthwiseConstruction.Create(FailureMechanismType.StrengthAndStabilityParallelConstruction, registry)); entity.FailureMechanismEntities.Add(section.DuneErosion.Create(FailureMechanismType.DuneErosion, registry)); entity.FailureMechanismEntities.Add(section.TechnicalInnovation.Create(FailureMechanismType.TechnicalInnovations, registry)); } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -35,6 +35,7 @@ using Ringtoets.HeightStructures.Data; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; +using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Piping.Data; using Ringtoets.Piping.Primitives; @@ -55,6 +56,7 @@ private readonly Dictionary pipingFailureMechanismSectionResults = new Dictionary(); private readonly Dictionary grassCoverErosionInwardsFailureMechanismSectionResults = new Dictionary(); private readonly Dictionary heightStructuresFailureMechanismSectionResults = new Dictionary(); + private readonly Dictionary strengthStabilityLengthwiseConstructionFailureMechanismSectionResults = new Dictionary(); private readonly Dictionary hydraulicLocations = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary calculationGroups = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary pipingCalculations = new Dictionary(new ReferenceEqualityComparer()); @@ -137,6 +139,22 @@ /// Registers a create or update operation for and the /// that was constructed with the information. /// + /// The to be registered. + /// The to be registered. + /// Thrown when either: + /// + /// is null + /// is null + /// + public void Register(StrengthStabilityLengthwiseConstructionSectionResultEntity entity, StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult model) + { + Register(strengthStabilityLengthwiseConstructionFailureMechanismSectionResults, entity, model); + } + + /// + /// Registers a create or update operation for and the + /// that was constructed with the information. + /// /// The to be registered. /// The to be registered. /// Thrown when either: @@ -618,6 +636,11 @@ heightStructuresFailureMechanismSectionResults[entity].StorageId = entity.HeightStructuresSectionResultEntityId; } + foreach (var entity in strengthStabilityLengthwiseConstructionFailureMechanismSectionResults.Keys) + { + strengthStabilityLengthwiseConstructionFailureMechanismSectionResults[entity].StorageId = entity.StrengthStabilityLengthwiseConstructionSectionResultEntityId; + } + foreach (var entity in hydraulicLocations.Keys) { hydraulicLocations[entity].StorageId = entity.HydraulicLocationEntityId; @@ -765,6 +788,17 @@ } dbContext.HeightStructuresSectionResultEntities.RemoveRange(orphanedHeightStructuresSectionResultEntities); + var orphanedStrengthStabilityLengthwiseConstructionSectionResultEntities = new List(); + foreach (StrengthStabilityLengthwiseConstructionSectionResultEntity sectionResultEntity in dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities + .Where(e => e.StrengthStabilityLengthwiseConstructionSectionResultEntityId > 0)) + { + if (!strengthStabilityLengthwiseConstructionFailureMechanismSectionResults.ContainsKey(sectionResultEntity)) + { + orphanedStrengthStabilityLengthwiseConstructionSectionResultEntities.Add(sectionResultEntity); + } + } + dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities.RemoveRange(orphanedStrengthStabilityLengthwiseConstructionSectionResultEntities); + var orphanedHydraulicLocationEntities = new List(); foreach (HydraulicLocationEntity hydraulicLocationEntity in dbContext.HydraulicLocationEntities .Where(e => e.HydraulicLocationEntityId > 0)) Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StrengthStabilityLengthwiseConstructionFailureMechanismCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StrengthStabilityLengthwiseConstructionFailureMechanismCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StrengthStabilityLengthwiseConstructionFailureMechanismCreateExtensions.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,71 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.DbContext; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a . + /// + internal static class StrengthStabilityLengthwiseConstructionFailureMechanismCreateExtensions + { + /// + /// Creates a based on the information of the . + /// + /// The failure mechanism to create a database entity for. + /// The object keeping track of create operations. + /// A new . + /// Thrown when is null. + internal static FailureMechanismEntity Create(this StrengthStabilityLengthwiseConstructionFailureMechanism mechanism, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + var entity = new FailureMechanismEntity + { + FailureMechanismType = (short) FailureMechanismType.StrengthAndStabilityParallelConstruction, + IsRelevant = Convert.ToByte(mechanism.IsRelevant), + Comments = mechanism.Comments + }; + + mechanism.AddEntitiesForFailureMechanismSections(registry, entity); + AddEntitiesForSectionResults(mechanism, registry); + + registry.Register(entity, mechanism); + return entity; + } + + private static void AddEntitiesForSectionResults(StrengthStabilityLengthwiseConstructionFailureMechanism mechanism, PersistenceRegistry registry) + { + foreach (var failureMechanismSectionResult in mechanism.SectionResults) + { + var sectionResultEntity = failureMechanismSectionResult.Create(registry); + var section = registry.Get(failureMechanismSectionResult.Section); + section.StrengthStabilityLengthwiseConstructionSectionResultEntities.Add(sectionResultEntity); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultCreateExtensions.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,57 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.DbContext; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a + /// . + /// + internal static class StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultCreateExtensions + { + /// + /// Creates a based on the information of the . + /// + /// The result to create a database entity for. + /// The object keeping track of create operations. + /// A new . + /// Thrown when is null. + internal static StrengthStabilityLengthwiseConstructionSectionResultEntity Create(this StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult result, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + var sectionResultEntity = new StrengthStabilityLengthwiseConstructionSectionResultEntity + { + LayerOne = Convert.ToByte(result.AssessmentLayerOne), + LayerThree = result.AssessmentLayerThree.Value.ToNullableDecimal() + }; + + registry.Register(sectionResultEntity, result); + return sectionResultEntity; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -1,6 +1,6 @@ /* ---------------------------------------------------- */ /* Generated by Enterprise Architect Version 12.0 */ -/* Created On : 15-jun-2016 12:00:53 */ +/* Created On : 15-jun-2016 14:07:57 */ /* DBMS : SQLite */ /* ---------------------------------------------------- */ @@ -39,10 +39,10 @@ DROP TABLE IF EXISTS 'ReferenceLinePointEntity' ; -DROP TABLE IF EXISTS 'SoilLayerEntity' +DROP TABLE IF EXISTS 'SoilProfileEntity' ; -DROP TABLE IF EXISTS 'SoilProfileEntity' +DROP TABLE IF EXISTS 'SoilLayerEntity' ; DROP TABLE IF EXISTS 'StochasticSoilProfileEntity' @@ -78,6 +78,15 @@ DROP TABLE IF EXISTS 'HeightStructuresSectionResultEntity' ; +DROP TABLE IF EXISTS 'StrengthStabilityLengthwiseConstructionSectionResultEntity' +; + +DROP TABLE IF EXISTS 'TechnicalInnovationSectionResultEntity' +; + +DROP TABLE IF EXISTS 'WaterPressureAsphaltCoverSectionResultEntity' +; + /* Create Tables with Primary and Foreign Keys, Check and Unique Constraints */ CREATE TABLE 'VersionEntity' @@ -224,6 +233,14 @@ ) ; +CREATE TABLE 'SoilProfileEntity' +( + 'SoilProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'Bottom' NUMERIC NOT NULL, + 'Name' TEXT +) +; + CREATE TABLE 'SoilLayerEntity' ( 'SoilLayerEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, @@ -237,14 +254,6 @@ ) ; -CREATE TABLE 'SoilProfileEntity' -( - 'SoilProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - 'Bottom' NUMERIC NOT NULL, - 'Name' TEXT -) -; - CREATE TABLE 'StochasticSoilProfileEntity' ( 'StochasticSoilProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, @@ -371,6 +380,36 @@ ) ; +CREATE TABLE 'StrengthStabilityLengthwiseConstructionSectionResultEntity' +( + 'StrengthStabilityLengthwiseConstructionSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER, + 'LayerOne' TINYINT (1) NOT NULL, -- true or false + 'LayerThree' NUMERIC, + CONSTRAINT 'FK_StrengthStabilityLengthwiseConstructionSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'TechnicalInnovationSectionResultEntity' +( + 'TechnicalInnovationSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER, + 'LayerOne' TINYINT (1) NOT NULL, -- true or false + 'LayerThree' NUMERIC, + CONSTRAINT 'FK_TechnicalInnovationSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + +CREATE TABLE 'WaterPressureAsphaltCoverSectionResultEntity' +( + 'WaterPressureAsphaltCoverSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER, + 'LayerOne' TINYINT (1) NOT NULL, -- true or false + 'LayerThree' NUMERIC, + CONSTRAINT 'FK_WaterPressureAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + /* Create Indexes and Triggers */ CREATE INDEX 'IXFK_PipingFailureMechanismMetaEntity_FailureMechanismEntity' @@ -468,3 +507,15 @@ CREATE INDEX 'IXFK_HeightStructuresSectionResultEntity_FailureMechanismSectionEntity' ON 'HeightStructuresSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) ; + +CREATE INDEX 'IXFK_StrengthStabilityLengthwiseConstructionSectionResultEntity_FailureMechanismSectionEntity' + ON 'StrengthStabilityLengthwiseConstructionSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_TechnicalInnovationSectionResultEntity_FailureMechanismSectionEntity' + ON 'TechnicalInnovationSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; + +CREATE INDEX 'IXFK_WaterPressureAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity' + ON 'WaterPressureAsphaltCoverSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/FailureMechanismSectionEntity.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/FailureMechanismSectionEntity.cs (.../FailureMechanismSectionEntity.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/FailureMechanismSectionEntity.cs (.../FailureMechanismSectionEntity.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -42,6 +42,9 @@ this.GrassCoverErosionInwardsSectionResultEntities = new HashSet(); this.HeightStructuresSectionResultEntities = new HashSet(); this.PipingSectionResultEntities = new HashSet(); + this.StrengthStabilityLengthwiseConstructionSectionResultEntities = new HashSet(); + this.TechnicalInnovationSectionResultEntities = new HashSet(); + this.WaterPressureAsphaltCoverSectionResultEntities = new HashSet(); } public long FailureMechanismSectionEntityId { get; set; } @@ -57,5 +60,11 @@ public virtual ICollection HeightStructuresSectionResultEntities { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection PipingSectionResultEntities { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection StrengthStabilityLengthwiseConstructionSectionResultEntities { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection TechnicalInnovationSectionResultEntities { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection WaterPressureAsphaltCoverSectionResultEntities { get; set; } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs (.../IRingtoetsEntities.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs (.../IRingtoetsEntities.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -73,6 +73,12 @@ DbSet HeightStructuresSectionResultEntities { get; } /// + /// Gets a of containing + /// every entity found in the database. + /// + DbSet StrengthStabilityLengthwiseConstructionSectionResultEntities { get; } + + /// /// Gets a of containing /// every entity found in the database. /// Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -73,8 +73,11 @@ public virtual DbSet StochasticSoilModelEntities { get; set; } public virtual DbSet StochasticSoilModelSegmentPointEntities { get; set; } public virtual DbSet StochasticSoilProfileEntities { get; set; } + public virtual DbSet StrengthStabilityLengthwiseConstructionSectionResultEntities { get; set; } public virtual DbSet SurfaceLineEntities { get; set; } public virtual DbSet SurfaceLinePointEntities { get; set; } + public virtual DbSet TechnicalInnovationSectionResultEntities { get; set; } public virtual DbSet VersionEntities { get; set; } + public virtual DbSet WaterPressureAsphaltCoverSectionResultEntities { get; set; } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -239,6 +239,15 @@ + + + + + + + + + @@ -260,6 +269,15 @@ + + + + + + + + + @@ -269,6 +287,15 @@ + + + + + + + + + @@ -557,6 +584,18 @@ + + + + + + + + + + + + @@ -581,6 +620,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -603,9 +666,12 @@ + + + @@ -702,6 +768,10 @@ + + + + @@ -710,6 +780,14 @@ + + + + + + + + @@ -737,9 +815,12 @@ + + + @@ -804,6 +885,18 @@ + + + + + + + + + + + + @@ -914,6 +1007,9 @@ + + + @@ -1126,6 +1222,16 @@ + + + + + + + + + + @@ -1152,6 +1258,16 @@ + + + + + + + + + + @@ -1161,6 +1277,16 @@ + + + + + + + + + + @@ -1353,6 +1479,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1734,6 +1896,16 @@ + + + + + + + + + + @@ -1757,6 +1929,16 @@ + + + + + + + + + + @@ -1767,6 +1949,16 @@ + + + + + + + + + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -5,30 +5,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -45,6 +48,9 @@ + + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/StrengthStabilityLengthwiseConstructionSectionResultEntity.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/StrengthStabilityLengthwiseConstructionSectionResultEntity.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/StrengthStabilityLengthwiseConstructionSectionResultEntity.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,45 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Application.Ringtoets.Storage.DbContext +{ + using System; + using System.Collections.Generic; + + public partial class StrengthStabilityLengthwiseConstructionSectionResultEntity + { + public long StrengthStabilityLengthwiseConstructionSectionResultEntityId { get; set; } + public Nullable FailureMechanismSectionEntityId { get; set; } + public byte LayerOne { get; set; } + public Nullable LayerThree { get; set; } + + public virtual FailureMechanismSectionEntity FailureMechanismSectionEntity { get; set; } + } +} Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/TechnicalInnovationSectionResultEntity.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/TechnicalInnovationSectionResultEntity.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/TechnicalInnovationSectionResultEntity.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,45 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Application.Ringtoets.Storage.DbContext +{ + using System; + using System.Collections.Generic; + + public partial class TechnicalInnovationSectionResultEntity + { + public long TechnicalInnovationSectionResultEntityId { get; set; } + public Nullable FailureMechanismSectionEntityId { get; set; } + public byte LayerOne { get; set; } + public Nullable LayerThree { get; set; } + + public virtual FailureMechanismSectionEntity FailureMechanismSectionEntity { get; set; } + } +} Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/WaterPressureAsphaltCoverSectionResultEntity.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/WaterPressureAsphaltCoverSectionResultEntity.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/WaterPressureAsphaltCoverSectionResultEntity.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,45 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Application.Ringtoets.Storage.DbContext +{ + using System; + using System.Collections.Generic; + + public partial class WaterPressureAsphaltCoverSectionResultEntity + { + public long WaterPressureAsphaltCoverSectionResultEntityId { get; set; } + public Nullable FailureMechanismSectionEntityId { get; set; } + public byte LayerOne { get; set; } + public Nullable LayerThree { get; set; } + + public virtual FailureMechanismSectionEntity FailureMechanismSectionEntity { get; set; } + } +} Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs (.../AssessmentSectionEntityReadExtensions.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntityReadExtensions.cs (.../AssessmentSectionEntityReadExtensions.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -68,6 +68,7 @@ entity.ReadPipingFailureMechanism(assessmentSection, collector); entity.ReadGrassCoverErosionInwardsFailureMechanism(assessmentSection, collector); entity.ReadHeightStructuresFailureMechanism(assessmentSection, collector); + entity.ReadStrengthStabilityLengthwiseConstructionFailureMechanism(assessmentSection, collector); entity.ReadStandAloneFailureMechanisms(assessmentSection, collector); return assessmentSection; @@ -126,6 +127,15 @@ } } + private static void ReadStrengthStabilityLengthwiseConstructionFailureMechanism(this AssessmentSectionEntity entity, AssessmentSection assessmentSection, ReadConversionCollector collector) + { + var strengthStabilityLengthwiseConstructionFailureMechanismEntity = entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int) FailureMechanismType.StrengthAndStabilityParallelConstruction); + if (strengthStabilityLengthwiseConstructionFailureMechanismEntity != null) + { + strengthStabilityLengthwiseConstructionFailureMechanismEntity.ReadAsStrengthStabilityLengthwiseConstructionFailureMechanism(assessmentSection.StrengthStabilityLengthwiseConstruction, collector); + } + } + private static void ReadStandAloneFailureMechanisms(this AssessmentSectionEntity entity, AssessmentSection assessmentSection, ReadConversionCollector collector) { entity.ReadStandAloneFailureMechanism(FailureMechanismType.MacrostabilityInwards, assessmentSection.MacrostabilityInwards, collector); @@ -140,7 +150,6 @@ entity.ReadStandAloneFailureMechanism(FailureMechanismType.ReliabilityClosingOfStructure, assessmentSection.ClosingStructure, collector); entity.ReadStandAloneFailureMechanism(FailureMechanismType.PipingAtStructure, assessmentSection.PipingStructure, collector); entity.ReadStandAloneFailureMechanism(FailureMechanismType.StrengthAndStabilityPointConstruction, assessmentSection.StrengthStabilityPointConstruction, collector); - entity.ReadStandAloneFailureMechanism(FailureMechanismType.StrengthAndStabilityParallelConstruction, assessmentSection.StrengthStabilityLengthwiseConstruction, collector); entity.ReadStandAloneFailureMechanism(FailureMechanismType.DuneErosion, assessmentSection.DuneErosion, collector); entity.ReadStandAloneFailureMechanism(FailureMechanismType.TechnicalInnovations, assessmentSection.TechnicalInnovation, collector); } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -88,10 +88,10 @@ private static void ReadPipingMechanismSectionResults(this FailureMechanismEntity entity, PipingFailureMechanism failureMechanism, ReadConversionCollector collector) { - foreach (var pipingSectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.PipingSectionResultEntities)) + foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.PipingSectionResultEntities)) { - var readSectionResult = pipingSectionResultEntity.Read(collector); - var failureMechanismSection = collector.Get(pipingSectionResultEntity.FailureMechanismSectionEntity); + var readSectionResult = sectionResultEntity.Read(collector); + var failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); result.StorageId = readSectionResult.StorageId; result.AssessmentLayerOne = readSectionResult.AssessmentLayerOne; @@ -117,10 +117,10 @@ private static void ReadGrassCoverErosionInwardsMechanismSectionResults(this FailureMechanismEntity entity, GrassCoverErosionInwardsFailureMechanism failureMechanism, ReadConversionCollector collector) { - foreach (var grassCoverErosionInwardsSectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverErosionInwardsSectionResultEntities)) + foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverErosionInwardsSectionResultEntities)) { - var readSectionResult = grassCoverErosionInwardsSectionResultEntity.Read(collector); - var failureMechanismSection = collector.Get(grassCoverErosionInwardsSectionResultEntity.FailureMechanismSectionEntity); + var readSectionResult = sectionResultEntity.Read(collector); + var failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); result.StorageId = readSectionResult.StorageId; result.AssessmentLayerOne = readSectionResult.AssessmentLayerOne; @@ -146,10 +146,10 @@ private static void ReadHeightStructuresMechanismSectionResults(this FailureMechanismEntity entity, HeightStructuresFailureMechanism failureMechanism, ReadConversionCollector collector) { - foreach (var grassCoverErosionInwardsSectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.HeightStructuresSectionResultEntities)) + foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.HeightStructuresSectionResultEntities)) { - var readSectionResult = grassCoverErosionInwardsSectionResultEntity.Read(collector); - var failureMechanismSection = collector.Get(grassCoverErosionInwardsSectionResultEntity.FailureMechanismSectionEntity); + var readSectionResult = sectionResultEntity.Read(collector); + var failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); result.StorageId = readSectionResult.StorageId; result.AssessmentLayerOne = readSectionResult.AssessmentLayerOne; @@ -158,6 +158,35 @@ } /// + /// Read the and use the information to update a . + /// + /// The to create for. + /// + /// The object keeping track of read operations. + internal static void ReadAsStrengthStabilityLengthwiseConstructionFailureMechanism(this FailureMechanismEntity entity, StrengthStabilityLengthwiseConstructionFailureMechanism failureMechanism, ReadConversionCollector collector) + { + failureMechanism.StorageId = entity.FailureMechanismEntityId; + failureMechanism.IsRelevant = entity.IsRelevant == 1; + failureMechanism.Comments = entity.Comments; + + entity.ReadFailureMechanismSections(failureMechanism, collector); + entity.ReadStrengthStabilityLengthwiseConstructionMechanismSectionResults(failureMechanism, collector); + } + + private static void ReadStrengthStabilityLengthwiseConstructionMechanismSectionResults(this FailureMechanismEntity entity, StrengthStabilityLengthwiseConstructionFailureMechanism failureMechanism, ReadConversionCollector collector) + { + foreach (var sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.StrengthStabilityLengthwiseConstructionSectionResultEntities)) + { + var readSectionResult = sectionResultEntity.Read(collector); + var failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); + var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); + result.StorageId = readSectionResult.StorageId; + result.AssessmentLayerOne = readSectionResult.AssessmentLayerOne; + result.AssessmentLayerThree = readSectionResult.AssessmentLayerThree; + } + } + + /// /// Read the and use the information to update a . /// /// The to read into a . Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensions.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,58 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.DbContext; +using Core.Common.Base.Data; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Read +{ + /// + /// This class defines extension methods for read operations for a based on the + /// . + /// + internal static class StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensions + { + /// + /// Reads the and use the information to construct a + /// . + /// + /// The to create for. + /// The object keeping track of read operations. + /// A new . + /// Thrown when is null. + internal static StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult Read(this StrengthStabilityLengthwiseConstructionSectionResultEntity entity, ReadConversionCollector collector) + { + if (collector == null) + { + throw new ArgumentNullException("collector"); + } + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(collector.Get(entity.FailureMechanismSectionEntity)) + { + StorageId = entity.StrengthStabilityLengthwiseConstructionSectionResultEntityId, + AssessmentLayerOne = Convert.ToBoolean(entity.LayerOne), + AssessmentLayerThree = (RoundedDouble) entity.LayerThree.ToNanableDouble() + }; + return sectionResult; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensions.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,83 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Exceptions; +using Application.Ringtoets.Storage.Properties; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a + /// . + /// + internal static class StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The result to update the database entity for. + /// The object keeping track of update operations. + /// The context to obtain the existing entity from. + /// Thrown when either: + /// + /// is null + /// is null + /// + /// When + /// does not have a corresponding entity in . + internal static void Update(this StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + StrengthStabilityLengthwiseConstructionSectionResultEntity entity = GetCorrespondingStrengthStabilityLengthwiseConstructionSectionResult(result, context); + + entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne); + entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree); + + registry.Register(entity, result); + } + + private static StrengthStabilityLengthwiseConstructionSectionResultEntity GetCorrespondingStrengthStabilityLengthwiseConstructionSectionResult(StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult result, IRingtoetsEntities context) + { + try + { + return context.StrengthStabilityLengthwiseConstructionSectionResultEntities.Single(sle => sle.StrengthStabilityLengthwiseConstructionSectionResultEntityId == result.StorageId); + } + catch (InvalidOperationException exception) + { + throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(StrengthStabilityLengthwiseConstructionSectionResultEntity).Name, result.StorageId), exception); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensions.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,84 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Exceptions; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a . + /// + internal static class StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensions + { + /// + /// Updates a in the database based on the information of the + /// . + /// + /// The mechanism to update the database entity for. + /// The object keeping track of update operations. + /// The context to obtain the existing entity from. + /// Thrown when either: + /// + /// is null + /// is null + /// + /// When + /// does not have a corresponding entity in . + internal static void Update(this StrengthStabilityLengthwiseConstructionFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + FailureMechanismEntity entity = mechanism.GetCorrespondingFailureMechanismEntity(context); + entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant); + + mechanism.UpdateFailureMechanismSections(registry, entity, context); + UpdateSectionResults(mechanism, registry, context); + + registry.Register(entity, mechanism); + } + + private static void UpdateSectionResults(StrengthStabilityLengthwiseConstructionFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context) + { + foreach (var sectionResult in mechanism.SectionResults) + { + if (sectionResult.IsNew()) + { + registry.Get(sectionResult.Section).StrengthStabilityLengthwiseConstructionSectionResultEntities.Add(sectionResult.Create(registry)); + } + else + { + sectionResult.Update(registry, context); + } + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -82,6 +82,8 @@ + + @@ -109,6 +111,7 @@ + @@ -139,6 +142,8 @@ + + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -39,6 +39,7 @@ using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.KernelWrapper.TestUtil; @@ -964,6 +965,34 @@ } [Test] + public void Register_WithNullStrengthStabilityLengthwiseConstructionFailureMechanismSectionResult_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(new StrengthStabilityLengthwiseConstructionSectionResultEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Register_WithNullStrengthStabilityLengthwiseConstructionSectionResultEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(null, new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection())); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] public void Register_WithNullHydraulicLocationEntity_ThrowsArgumentNullException() { // Setup @@ -1474,6 +1503,27 @@ } [Test] + public void TransferIds_WithStrengthStabilityLengthwiseConstructionSectionResultEntityAddedWithStrengthStabilityLengthwiseConstructionFailureMechanismSectionResult_EqualStrengthStabilityLengthwiseConstructionSectionEntityIdAndStrengthStabilityLengthwiseConstructionFailureMechanismSectionResultStorageId() + { + // Setup + var registry = new PersistenceRegistry(); + + long storageId = new Random(21).Next(1,4000); + var entity = new StrengthStabilityLengthwiseConstructionSectionResultEntity() + { + StrengthStabilityLengthwiseConstructionSectionResultEntityId = storageId + }; + var model = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()); + registry.Register(entity, model); + + // Call + registry.TransferIds(); + + // Assert + Assert.AreEqual(storageId, model.StorageId); + } + + [Test] public void TransferIds_WithHydraulicLocationEntityAdded_EqualHydraulicLocationEntityIdAndHydraulicBoundaryLocationStorageId() { // Setup @@ -1971,6 +2021,42 @@ } [Test] + public void RemoveUntouched_StrengthStabilityLengthwiseConstructionSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() + { + // Setup + var mocks = new MockRepository(); + IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var orphanedEntity = new StrengthStabilityLengthwiseConstructionSectionResultEntity + { + StrengthStabilityLengthwiseConstructionSectionResultEntityId = 1 + }; + var persistentEntity = new StrengthStabilityLengthwiseConstructionSectionResultEntity + { + StrengthStabilityLengthwiseConstructionSectionResultEntityId = 2 + }; + dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities.Add(orphanedEntity); + dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities.Add(persistentEntity); + + var section = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = persistentEntity.StrengthStabilityLengthwiseConstructionSectionResultEntityId + }; + + var registry = new PersistenceRegistry(); + registry.Register(persistentEntity, section); + + // Call + registry.RemoveUntouched(dbContext); + + // Assert + Assert.AreEqual(1, dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities.Count()); + CollectionAssert.Contains(dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities, persistentEntity); + mocks.VerifyAll(); + } + + [Test] public void RemoveUntouched_HydraulicLocationEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() { // Setup Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StrengthStabilityLengthwiseConstructionFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StrengthStabilityLengthwiseConstructionFailureMechanismCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StrengthStabilityLengthwiseConstructionFailureMechanismCreateExtensionsTest.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,104 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class StrengthStabilityLengthwiseConstructionFailureMechanismCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Create(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool isRelevant) + { + // Setup + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism + { + IsRelevant = isRelevant, + Comments = "Some text" + }; + var registry = new PersistenceRegistry(); + + // Call + var entity = failureMechanism.Create(registry); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual((short)FailureMechanismType.StructureHeight, entity.FailureMechanismType); + Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant); + Assert.AreEqual(failureMechanism.Comments, entity.Comments); + } + + [Test] + public void Create_WithoutSections_EmptyFailureMechanismSectionEntities() + { + // Setup + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.IsEmpty(entity.FailureMechanismSectionEntities); + } + + [Test] + public void Create_WithSections_FailureMechanismSectionEntitiesCreated() + { + // Setup + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("", new[] + { + new Point2D(0, 0) + })); + + // Call + var entity = failureMechanism.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, entity.FailureMechanismSectionEntities.SelectMany(fms => fms.StrengthStabilityLengthwiseConstructionSectionResultEntities).Count()); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultCreateExtensionsTest.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.Create; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new FailureMechanismSection("", new[] { new Point2D(0, 0) })); + + // Call + TestDelegate test = () => sectionResult.Create(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( + [Values(true, false)] bool assessmentLayerOneResult, + [Values(3.2, 4.5)] double assessmentLayerThreeResult + ) + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new FailureMechanismSection("", new[] { new Point2D(0, 0) })); + sectionResult.AssessmentLayerOne = assessmentLayerOneResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) assessmentLayerThreeResult; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerThreeResult), result.LayerThree); + } + + [Test] + public void Create_WithNaNLevel3Result_ReturnsEntityWithExpectedResults() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new FailureMechanismSection("", new[] { new Point2D(0, 0) })); + sectionResult.AssessmentLayerThree = (RoundedDouble) double.NaN; + + // Call + var result = sectionResult.Create(new PersistenceRegistry()); + + // Assert + Assert.IsNull(result.LayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -42,6 +42,7 @@ using Ringtoets.HeightStructures.Data; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; +using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Piping.Data; using Ringtoets.Piping.Primitives; @@ -262,6 +263,9 @@ AssertFailureMechanismSectionResults( expectedAssessmentSection.HeightStructures.SectionResults, actualAssessmentSection.HeightStructures.SectionResults); + AssertFailureMechanismSectionResults( + expectedAssessmentSection.StrengthStabilityLengthwiseConstruction.SectionResults, + actualAssessmentSection.StrengthStabilityLengthwiseConstruction.SectionResults); } } @@ -318,6 +322,23 @@ } } + private void AssertFailureMechanismSectionResults(IEnumerable expectedSectionResults, IEnumerable actualSectionResults) + { + var expectedSectionResultsArray = expectedSectionResults.ToArray(); + var actualSectionResultsArray = actualSectionResults.ToArray(); + + Assert.AreEqual(expectedSectionResultsArray.Length, actualSectionResultsArray.Length); + + for (var i = 0; i < expectedSectionResultsArray.Length; i++) + { + StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult expectedSection = expectedSectionResultsArray[i]; + StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult actualSection = actualSectionResultsArray[i]; + + Assert.AreEqual(expectedSection.AssessmentLayerOne, actualSection.AssessmentLayerOne); + Assert.AreEqual(expectedSection.AssessmentLayerThree, actualSection.AssessmentLayerThree); + } + } + private void AssertFailureMechanism(IFailureMechanism expectedFailureMechanism, IFailureMechanism actualFailureMechanism) { Assert.AreEqual(expectedFailureMechanism.Name, actualFailureMechanism.Name); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensionsTest.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,101 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Read; +using Application.Ringtoets.Storage.Test.Update; +using NUnit.Framework; + +namespace Application.Ringtoets.Storage.Test.Read +{ + [TestFixture] + public class StrengthStabilityLengthwiseConstructionSectionResultEntityReadExtensionsTest + { + [Test] + public void Read_CollectorIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new StrengthStabilityLengthwiseConstructionSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("collector", paramName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Read_WithDecimalParameterValues_ReturnStrengthStabilityLengthwiseConstructionSoilLayerWithDoubleParameterValues(bool layerOne) + { + // Setup + var random = new Random(21); + var entityId = random.Next(1, 502); + double layerThree = random.NextDouble(); + var collector = new ReadConversionCollector(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new StrengthStabilityLengthwiseConstructionSectionResultEntity + { + StrengthStabilityLengthwiseConstructionSectionResultEntityId = entityId, + LayerThree = Convert.ToDecimal(layerThree), + LayerOne = Convert.ToByte(layerOne), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + + // Call + var result = entity.Read(collector); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual(entityId, result.StorageId); + Assert.AreEqual(layerOne, result.AssessmentLayerOne); + Assert.AreEqual(layerThree, result.AssessmentLayerThree, 1e-6); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Read_WithNullParameterValues_ReturnStrengthStabilityLengthwiseConstructionSoilLayerWithNullParameters(bool layerOne) + { + // Setup + var collector = new ReadConversionCollector(); + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new StrengthStabilityLengthwiseConstructionSectionResultEntity + { + LayerOne = Convert.ToByte(layerOne), + LayerThree = null, + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + + // Call + var layer = entity.Read(collector); + + // Assert + Assert.IsNaN(layer.AssessmentLayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensionsTest.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,159 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Exceptions; +using Application.Ringtoets.Storage.TestUtil; +using Application.Ringtoets.Storage.Update; +using Core.Common.Base.Data; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ArgumentNullException() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ArgumentNullException() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoStrengthStabilityLengthwiseConstructionSoilLayer_EntityNotFoundException() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'StrengthStabilityLengthwiseConstructionSectionResultEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoStrengthStabilityLengthwiseConstructionSoilLayerWithId_EntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = storageId + }; + + ringtoetsEntities.StrengthStabilityLengthwiseConstructionSectionResultEntities.Add(new StrengthStabilityLengthwiseConstructionSectionResultEntity + { + StrengthStabilityLengthwiseConstructionSectionResultEntityId = 2 + }); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'StrengthStabilityLengthwiseConstructionSectionResultEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_WithStrengthStabilityLengthwiseConstructionSoilLayer_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = 1, + AssessmentLayerOne = true, + AssessmentLayerThree = (RoundedDouble) 4.4 + }; + + var sectionResultEntity = new StrengthStabilityLengthwiseConstructionSectionResultEntity + { + StrengthStabilityLengthwiseConstructionSectionResultEntityId = sectionResult.StorageId, + LayerOne = Convert.ToByte(false), + LayerThree = 1.1m, + }; + + ringtoetsEntities.StrengthStabilityLengthwiseConstructionSectionResultEntities.Add(sectionResultEntity); + + // Call + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), sectionResultEntity.LayerOne); + Assert.AreEqual(sectionResult.AssessmentLayerThree.Value.ToNullableDecimal(), sectionResultEntity.LayerThree); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensionsTest.cs (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -0,0 +1,243 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; + +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Exceptions; +using Application.Ringtoets.Storage.TestUtil; +using Application.Ringtoets.Storage.Update; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Data.StandAlone; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("context", paramName); + } + + [Test] + public void Update_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(null, ringtoetsEntities); + } + }; + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + public void Update_ContextWithNoStrengthStabilityLengthwiseConstructionFailureMechanism_ThrowsEntityNotFoundException() + { + // Setup + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoStrengthStabilityLengthwiseConstructionFailureMechanismWithId_ThrowsEntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism + { + StorageId = storageId + }; + + ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity + { + FailureMechanismEntityId = 2 + }); + + // Call + TestDelegate test = () => failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithStrengthStabilityLengthwiseConstructionFailureMechanism_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism + { + StorageId = 1, + IsRelevant = true + }; + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + IsRelevant = Convert.ToByte(false) + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(Convert.ToByte(true), failureMechanismEntity.IsRelevant); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithNewFailureMechanismSections_FailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism + { + StorageId = 1 + }; + failureMechanism.AddSection(new FailureMechanismSection("", new[] + { + new Point2D(0, 0) + })); + + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.StrengthStabilityLengthwiseConstructionSectionResultEntities).Count()); + + mocks.VerifyAll(); + } + + [Test] + public void Update_ContextWithUpdatedFailureMechanismSections_NoNewFailureMechanismSectionsAdded() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism + { + StorageId = 1 + }; + var testName = "testName"; + failureMechanism.AddSection(new FailureMechanismSection(testName, new[] + { + new Point2D(0, 0) + }) + { + StorageId = 1 + }); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity + { + FailureMechanismSectionEntityId = 1, + }; + var failureMechanismEntity = new FailureMechanismEntity + { + FailureMechanismEntityId = 1, + FailureMechanismSectionEntities = + { + failureMechanismSectionEntity + } + }; + + ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); + ringtoetsEntities.FailureMechanismSectionEntities.Add(failureMechanismSectionEntity); + + // Call + failureMechanism.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.StrengthStabilityLengthwiseConstructionSectionResultEntities).Count()); + Assert.AreEqual(testName, failureMechanismEntity.FailureMechanismSectionEntities.ElementAt(0).Name); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs (.../RingtoetsEntitiesHelper.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs (.../RingtoetsEntitiesHelper.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -44,6 +44,7 @@ DbSet pipingSectionResultsSet = CreateEmptyTestDbSet(); DbSet grassCoverErosionInwardsSectionResultsSet = CreateEmptyTestDbSet(); DbSet heightStructuresSectionResultsSet = CreateEmptyTestDbSet(); + DbSet strengthStabilityLengthwiseConstructionSectionResultsSet = CreateEmptyTestDbSet(); DbSet assessmentSectionsSet = CreateEmptyTestDbSet(); DbSet referenceLinesSet = CreateEmptyTestDbSet(); DbSet calculationGroupsSet = CreateEmptyTestDbSet(); @@ -69,6 +70,7 @@ ringtoetsEntities.Stub(r => r.PipingSectionResultEntities).Return(pipingSectionResultsSet); ringtoetsEntities.Stub(r => r.GrassCoverErosionInwardsSectionResultEntities).Return(grassCoverErosionInwardsSectionResultsSet); ringtoetsEntities.Stub(r => r.HeightStructuresSectionResultEntities).Return(heightStructuresSectionResultsSet); + ringtoetsEntities.Stub(r => r.StrengthStabilityLengthwiseConstructionSectionResultEntities).Return(strengthStabilityLengthwiseConstructionSectionResultsSet); ringtoetsEntities.Stub(r => r.AssessmentSectionEntities).Return(assessmentSectionsSet); ringtoetsEntities.Stub(r => r.ReferenceLinePointEntities).Return(referenceLinesSet); ringtoetsEntities.Stub(r => r.CalculationGroupEntities).Return(calculationGroupsSet); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs =================================================================== diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs (.../RingtoetsProjectHelper.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs (.../RingtoetsProjectHelper.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -32,6 +32,7 @@ using Ringtoets.HeightStructures.Data; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; +using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Piping.Data; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; @@ -229,6 +230,7 @@ AddSections(assessmentSection.ClosingStructure); AddSections(assessmentSection.StrengthStabilityPointConstruction); AddSections(assessmentSection.StrengthStabilityLengthwiseConstruction); + SetSectionResults(assessmentSection.StrengthStabilityLengthwiseConstruction.SectionResults); AddSections(assessmentSection.PipingStructure); AddSections(assessmentSection.DuneErosion); AddSections(assessmentSection.TechnicalInnovation); @@ -266,6 +268,15 @@ } } + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerThree = (RoundedDouble)random.NextDouble(); + } + } private static void AddSections(IFailureMechanism failureMechanism) { Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult.cs =================================================================== diff -u -rf72f906a6875250a4378945ce814997ff8aaf1a7 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult.cs) (revision f72f906a6875250a4378945ce814997ff8aaf1a7) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/SectionResults/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31) @@ -21,6 +21,7 @@ using System; using Core.Common.Base.Data; +using Core.Common.Base.Storage; using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Integration.Data.StandAlone.SectionResults @@ -29,7 +30,7 @@ /// This class holds information about the result of a calculation on section level for the /// Strength and Stability of Lengthwise Constructions failure mechanism. /// - public class StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult : FailureMechanismSectionResult + public class StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult : FailureMechanismSectionResult, IStorable { /// /// Creates a new instance of . @@ -48,5 +49,7 @@ /// Gets or sets the value of the tailored assessment of safety. /// public RoundedDouble AssessmentLayerThree { get; set; } + + public long StorageId { get; set; } } }