Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -57,6 +57,7 @@ + @@ -103,6 +104,9 @@ RingtoetsEntities.tt + + RingtoetsEntities.tt + RingtoetsEntities.tt @@ -191,6 +195,7 @@ + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs =================================================================== diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -50,6 +50,7 @@ private readonly Dictionary assessmentSections = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary failureMechanisms = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary failureMechanismSections = new Dictionary(); + private readonly Dictionary pipingFailureMechanismSectionResults = 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()); @@ -84,6 +85,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(PipingSectionResultEntity entity, PipingFailureMechanismSectionResult model) + { + Register(pipingFailureMechanismSectionResults, 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: @@ -333,6 +350,18 @@ } /// + /// Checks whether a create or update operations has been registered for the given + /// . + /// + /// The to check for. + /// true if the was registered before, false otherwise. + /// Thrown when is null. + internal bool Contains(FailureMechanismSection model) + { + return ContainsValue(failureMechanismSections, model); + } + + /// /// Obtains the which was registered for /// the given . /// @@ -410,14 +439,31 @@ /// Thrown when is null. /// Thrown when no create/update operation /// has been registered for . - /// Use to find out + /// Use to find out /// whether a create/update operation has been registered for . internal HydraulicLocationEntity Get(HydraulicBoundaryLocation model) { return Get(hydraulicLocations, model); } /// + /// Obtains the which was registered for the + /// given . + /// + /// The for which a + /// read/update operation has been registered. + /// The constructed . + /// Thrown when is null. + /// Thrown when no create/update operation + /// has been registered for . + /// Use to find out + /// whether a create/update operation has been registered for . + internal FailureMechanismSectionEntity Get(FailureMechanismSection model) + { + return Get(failureMechanismSections, model); + } + + /// /// Registers a create or update operation for and the /// that was constructed with the information. /// @@ -521,6 +567,11 @@ assessmentSections[entity].StorageId = entity.AssessmentSectionEntityId; } + foreach (var entity in pipingFailureMechanismSectionResults.Keys) + { + pipingFailureMechanismSectionResults[entity].StorageId = entity.PipingSectionResultEntityId; + } + foreach (var entity in hydraulicLocations.Keys) { hydraulicLocations[entity].StorageId = entity.HydraulicLocationEntityId; @@ -635,6 +686,17 @@ } dbContext.FailureMechanismSectionEntities.RemoveRange(orphanedFailureMechanismSectionEntities); + var orphanedPipingSectionResultEntities = new List(); + foreach (PipingSectionResultEntity pipingSectionResultEntity in dbContext.PipingSectionResultEntities + .Where(e => e.PipingSectionResultEntityId > 0)) + { + if (!pipingFailureMechanismSectionResults.ContainsKey(pipingSectionResultEntity)) + { + orphanedPipingSectionResultEntities.Add(pipingSectionResultEntity); + } + } + dbContext.PipingSectionResultEntities.RemoveRange(orphanedPipingSectionResultEntities); + var orphanedHydraulicLocationEntities = new List(); foreach (HydraulicLocationEntity hydraulicLocationEntity in dbContext.HydraulicLocationEntities .Where(e => e.HydraulicLocationEntityId > 0)) Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingFailureMechanismCreateExtensions.cs =================================================================== diff -u -rd21cd84fd8eaf1281fd1469932414e42a50c635d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingFailureMechanismCreateExtensions.cs (.../PipingFailureMechanismCreateExtensions.cs) (revision d21cd84fd8eaf1281fd1469932414e42a50c635d) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingFailureMechanismCreateExtensions.cs (.../PipingFailureMechanismCreateExtensions.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -56,13 +56,24 @@ AddEntitiesForStochasticSoilModels(mechanism, registry, entity); AddEntitiesForSurfaceLines(mechanism, registry, entity); mechanism.AddEntitiesForFailureMechanismSections(registry, entity); + AddEntitiesForSectionResults(mechanism, registry, entity); entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0); registry.Register(entity, mechanism); return entity; } + private static void AddEntitiesForSectionResults(PipingFailureMechanism mechanism, PersistenceRegistry registry, FailureMechanismEntity entity) + { + foreach (var pipingFailureMechanismSectionResult in mechanism.SectionResults) + { + var pipingSectionResultEntity = pipingFailureMechanismSectionResult.Create(registry); + var section = registry.Get(pipingFailureMechanismSectionResult.Section); + section.PipingSectionResultEntities.Add(pipingSectionResultEntity); + } + } + private static void AddEntitiesForFailureMechanismMeta(PipingFailureMechanism mechanism, PersistenceRegistry registry, FailureMechanismEntity entity) { entity.PipingFailureMechanismMetaEntities.Add(mechanism.PipingProbabilityAssessmentInput.Create(registry)); Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingFailureMechanismSectionResultCreateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingFailureMechanismSectionResultCreateExtensions.cs (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -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.Piping.Data; + +namespace Application.Ringtoets.Storage.Create +{ + /// + /// Extension methods for related to creating a + /// . + /// + internal static class PipingFailureMechanismSectionResultCreateExtensions + { + /// + /// 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 PipingSectionResultEntity Create(this PipingFailureMechanismSectionResult result, PersistenceRegistry registry) + { + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + var pipingSectionResultEntity = new PipingSectionResultEntity + { + LayerOne = Convert.ToByte(result.AssessmentLayerOne), + LayerThree = result.AssessmentLayerThree.Value.ToNullableDecimal() + }; + + registry.Register(pipingSectionResultEntity, result); + return pipingSectionResultEntity; + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql =================================================================== diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -1,15 +1,15 @@ /* ---------------------------------------------------- */ /* Generated by Enterprise Architect Version 12.0 */ -/* Created On : 09-jun-2016 16:44:00 */ +/* Created On : 14-jun-2016 13:34:24 */ /* DBMS : SQLite */ /* ---------------------------------------------------- */ /* Drop Tables */ -DROP TABLE IF EXISTS 'PipingFailureMechanismMetaEntity' +DROP TABLE IF EXISTS 'VersionEntity' ; -DROP TABLE IF EXISTS 'VersionEntity' +DROP TABLE IF EXISTS 'PipingFailureMechanismMetaEntity' ; DROP TABLE IF EXISTS 'ProjectEntity' @@ -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' @@ -69,17 +69,11 @@ DROP TABLE IF EXISTS 'PipingSemiProbabilisticOutputEntity' ; -/* Create Tables with Primary and Foreign Keys, Check and Unique Constraints */ - -CREATE TABLE 'PipingFailureMechanismMetaEntity' -( - 'PipingFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - 'FailureMechanismEntityId' INTEGER, - 'A' NUMERIC NOT NULL, - CONSTRAINT 'FK_PipingFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade -) +DROP TABLE IF EXISTS 'PipingSectionResultEntity' ; +/* Create Tables with Primary and Foreign Keys, Check and Unique Constraints */ + CREATE TABLE 'VersionEntity' ( 'VersionId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, @@ -89,6 +83,15 @@ ) ; +CREATE TABLE 'PipingFailureMechanismMetaEntity' +( + 'PipingFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismEntityId' INTEGER, + 'A' NUMERIC NOT NULL, + CONSTRAINT 'FK_PipingFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade +) +; + CREATE TABLE 'ProjectEntity' ( 'ProjectEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, @@ -215,6 +218,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, @@ -228,14 +239,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, @@ -332,6 +335,16 @@ ) ; +CREATE TABLE 'PipingSectionResultEntity' +( + 'PipingSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + 'FailureMechanismSectionEntityId' INTEGER, + 'LayerOne' NUMERIC, + 'LayerThree' NUMERIC, + CONSTRAINT 'FK_PipingSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE No Action ON UPDATE No Action +) +; + /* Create Indexes and Triggers */ CREATE INDEX 'IXFK_PipingFailureMechanismMetaEntity_FailureMechanismEntity' @@ -417,3 +430,7 @@ CREATE INDEX 'IXFK_CharacteristicPointEntity_SurfaceLinePointEntity' ON 'CharacteristicPointEntity' ('SurfaceLinePointEntityId' ASC) ; + +CREATE INDEX 'IXFK_PipingSectionResultEntity_FailureMechanismSectionEntity' + ON 'PipingSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) +; Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/FailureMechanismSectionEntity.cs =================================================================== diff -u -rb809769cd89b011d6746bf0b9b99eff1abd49f60 -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/FailureMechanismSectionEntity.cs (.../FailureMechanismSectionEntity.cs) (revision b809769cd89b011d6746bf0b9b99eff1abd49f60) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/FailureMechanismSectionEntity.cs (.../FailureMechanismSectionEntity.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -39,6 +39,7 @@ public FailureMechanismSectionEntity() { this.FailureMechanismSectionPointEntities = new HashSet(); + this.PipingSectionResultEntities = new HashSet(); } public long FailureMechanismSectionEntityId { get; set; } @@ -48,5 +49,7 @@ public virtual FailureMechanismEntity FailureMechanismEntity { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection FailureMechanismSectionPointEntities { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection PipingSectionResultEntities { get; set; } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs =================================================================== diff -u -re69abddf5b9c6634b764df231d4e1b290c9e0fb5 -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs (.../IRingtoetsEntities.cs) (revision e69abddf5b9c6634b764df231d4e1b290c9e0fb5) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/IRingtoetsEntities.cs (.../IRingtoetsEntities.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -55,6 +55,12 @@ DbSet FailureMechanismSectionEntities { get; } /// + /// Gets a of containing + /// every entity found in the database. + /// + DbSet PipingSectionResultEntities { get; } + + /// /// Gets a of containing /// every entity found in the database. /// Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/PipingSectionResultEntity.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/PipingSectionResultEntity.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/PipingSectionResultEntity.cs (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -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 PipingSectionResultEntity + { + public long PipingSectionResultEntityId { get; set; } + public Nullable FailureMechanismSectionEntityId { get; set; } + public Nullable LayerOne { get; set; } + public Nullable LayerThree { get; set; } + + public virtual FailureMechanismSectionEntity FailureMechanismSectionEntity { get; set; } + } +} Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs =================================================================== diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -62,6 +62,7 @@ public virtual DbSet PipingCalculationEntities { get; set; } public virtual DbSet PipingCalculationOutputEntities { get; set; } public virtual DbSet PipingFailureMechanismMetaEntities { get; set; } + public virtual DbSet PipingSectionResultEntities { get; set; } public virtual DbSet PipingSemiProbabilisticOutputEntities { get; set; } public virtual DbSet ProjectEntities { get; set; } public virtual DbSet ReferenceLinePointEntities { get; set; } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs =================================================================== diff -u -r696df91ebc373335894ac95c90ad88d32683870e -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs (.../RingtoetsEntities.Designer.cs) (revision 696df91ebc373335894ac95c90ad88d32683870e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs (.../RingtoetsEntities.Designer.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -1,4 +1,4 @@ -// T4 code generation is enabled for model 'D:\Clean_WTI2017\Application\Ringtoets\src\Application.Ringtoets.Storage\DbContext\RingtoetsEntities.edmx'. +// T4 code generation is enabled for model 'D:\repos\WettelijkToetsInstrumentarium\Application\Ringtoets\src\Application.Ringtoets.Storage\DbContext\RingtoetsEntities.edmx'. // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model // is open in the designer. Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx =================================================================== diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -4,7 +4,7 @@ - + @@ -127,6 +127,15 @@ + + + + + + + + + @@ -422,6 +431,18 @@ + + + + + + + + + + + + @@ -529,6 +550,7 @@ + @@ -600,6 +622,10 @@ + + + + @@ -648,6 +674,7 @@ + @@ -711,6 +738,10 @@ + + + + @@ -818,6 +849,7 @@ + @@ -902,6 +934,16 @@ + + + + + + + + + + @@ -1191,6 +1233,18 @@ + + + + + + + + + + + + @@ -1449,6 +1503,16 @@ + + + + + + + + + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram =================================================================== diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -5,26 +5,27 @@ - - - + + + - - - + + + - - + + + - - + + - - + + @@ -39,6 +40,7 @@ + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismSectionResultUpdateExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismSectionResultUpdateExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismSectionResultUpdateExtensions.cs (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -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.Piping.Data; + +namespace Application.Ringtoets.Storage.Update +{ + /// + /// Extension methods for related to updating a + /// . + /// + internal static class PipingFailureMechanismSectionResultUpdateExtensions + { + /// + /// 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 PipingFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context) + { + if (context == null) + { + throw new ArgumentNullException("context"); + } + if (registry == null) + { + throw new ArgumentNullException("registry"); + } + + PipingSectionResultEntity entity = GetCorrespondingPipingSectionResult(result, context); + + entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne); + entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree); + + registry.Register(entity, result); + } + + private static PipingSectionResultEntity GetCorrespondingPipingSectionResult(PipingFailureMechanismSectionResult result, IRingtoetsEntities context) + { + try + { + return context.PipingSectionResultEntities.Single(sle => sle.PipingSectionResultEntityId == result.StorageId); + } + catch (InvalidOperationException exception) + { + throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(PipingSectionResultEntity).Name, result.StorageId), exception); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismUpdateExtensions.cs =================================================================== diff -u -r9d77e28eef1dda363f4854ba2011a0107588d82c -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismUpdateExtensions.cs (.../PipingFailureMechanismUpdateExtensions.cs) (revision 9d77e28eef1dda363f4854ba2011a0107588d82c) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismUpdateExtensions.cs (.../PipingFailureMechanismUpdateExtensions.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -67,11 +67,27 @@ UpdateSoilModels(mechanism, registry, context, entity); UpdateSurfaceLines(mechanism, registry, context, entity); mechanism.UpdateFailureMechanismSections(registry, entity, context); + UpdateSectionResults(mechanism, registry, context, entity); mechanism.CalculationsGroup.Update(registry, context); registry.Register(entity, mechanism); } + private static void UpdateSectionResults(PipingFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context, FailureMechanismEntity entity) + { + foreach (var sectionResult in mechanism.SectionResults) + { + if (sectionResult.IsNew()) + { + registry.Get(sectionResult.Section).PipingSectionResultEntities.Add(sectionResult.Create(registry)); + } + else + { + sectionResult.Update(registry, context); + } + } + } + private static void UpdateSoilModels(PipingFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context, FailureMechanismEntity entity) { foreach (var stochasticSoilModel in mechanism.StochasticSoilModels) Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -86,6 +86,7 @@ + @@ -138,6 +139,7 @@ + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs =================================================================== diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -24,6 +24,7 @@ using Application.Ringtoets.Storage.Create; using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Test.Update; using Application.Ringtoets.Storage.TestUtil; using Core.Common.Base.Data; @@ -338,12 +339,56 @@ Assert.IsFalse(result); } + [Test] + public void Contains_FailureMechanismSectionAdded_True() + { + // Setup + var registry = new PersistenceRegistry(); + var failureMechanismSection = new TestFailureMechanismSection(); + registry.Register(new FailureMechanismSectionEntity(), failureMechanismSection); + + // Call + bool result = registry.Contains(failureMechanismSection); + + // Assert + Assert.IsTrue(result); + } + + [Test] + public void Contains_NoFailureMechanismSectionAdded_False() + { + // Setup + var registry = new PersistenceRegistry(); + var failureMechanismSection = new TestFailureMechanismSection(); + + // Call + bool result = registry.Contains(failureMechanismSection); + + // Assert + Assert.IsFalse(result); + } + + [Test] + public void Contains_OtherSFailureMechanismSectionAdded_False() + { + // Setup + var registry = new PersistenceRegistry(); + var failureMechanismSection = new TestFailureMechanismSection(); + registry.Register(new FailureMechanismSectionEntity(), new TestFailureMechanismSection()); + + // Call + bool result = registry.Contains(failureMechanismSection); + + // Assert + Assert.IsFalse(result); + } + #endregion #region Get methods [Test] - public void Get_WithoutModel_ArgumentNullException() + public void Get_WithoutPipingSoilProfile_ArgumentNullException() { // Setup var registry = new PersistenceRegistry(); @@ -520,7 +565,7 @@ } [Test] - public void Get_WithoutStochasticSoilModelEntity_ArgumentNullException() + public void Get_WithoutStochasticSoilModel_ArgumentNullException() { // Setup var registry = new PersistenceRegistry(); @@ -637,9 +682,66 @@ Assert.Throws(test); } - #endregion + [Test] + public void Get_WithoutFailureMechanismSection_ArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + // Call + TestDelegate test = () => registry.Get((FailureMechanismSection)null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + [Test] + public void Get_FailureMechanismSectionAdded_ReturnsEntity() + { + // Setup + var registry = new PersistenceRegistry(); + var section = new TestFailureMechanismSection(); + var entity = new FailureMechanismSectionEntity(); + registry.Register(entity, section); + + // Call + FailureMechanismSectionEntity result = registry.Get(section); + + // Assert + Assert.AreSame(entity, result); + } + + [Test] + public void Get_NoFailureMechanismSectionAdded_ThrowsInvalidOperationException() + { + // Setup + var registry = new PersistenceRegistry(); + var section = new TestFailureMechanismSection(); + + // Call + TestDelegate test = () => registry.Get(section); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Get_OtherFailureMechanismSectionAdded_ThrowsInvalidOperationException() + { + // Setup + var registry = new PersistenceRegistry(); + var section = new TestFailureMechanismSection(); + registry.Register(new FailureMechanismSectionEntity(), new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => registry.Get(section); + + // Assert + Assert.Throws(test); + } + + [Test] public void GetSurfaceLinePoint_SurfaceLinePointAdded_ReturnsEntity() { // Setup @@ -657,6 +759,8 @@ } + #endregion + #region Register methods [Test] @@ -760,6 +864,48 @@ } [Test] + public void Register_WithNullFailureMechanismSectionEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(null, new TestFailureMechanismSection()); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Register_WithNullPipingFailureMechanismSectionResult_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(new PipingSectionResultEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Register_WithNullPipingSectionResultEntity_ThrowsArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => registry.Register(null, new PipingFailureMechanismSectionResult(new TestFailureMechanismSection())); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] public void Register_WithNullHydraulicLocationEntity_ThrowsArgumentNullException() { // Setup @@ -1207,6 +1353,27 @@ } [Test] + public void TransferIds_WithPipingSectionResultEntityAddedWithPipingFailureMechanismSectionResult_EqualPipingSectionEntityIdAndPipingFailureMechanismSectionResultStorageId() + { + // Setup + var registry = new PersistenceRegistry(); + + long storageId = new Random(21).Next(1,4000); + var entity = new PipingSectionResultEntity() + { + PipingSectionResultEntityId = storageId + }; + var model = new PipingFailureMechanismSectionResult(new TestFailureMechanismSection()); + registry.Register(entity, model); + + // Call + registry.TransferIds(); + + // Assert + Assert.AreEqual(storageId, model.StorageId); + } + + [Test] public void TransferIds_WithHydraulicLocationEntityAdded_EqualHydraulicLocationEntityIdAndHydraulicBoundaryLocationStorageId() { // Setup @@ -1596,6 +1763,42 @@ } [Test] + public void RemoveUntouched_PipingSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() + { + // Setup + var mocks = new MockRepository(); + IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var orphanedEntity = new PipingSectionResultEntity + { + PipingSectionResultEntityId = 1 + }; + var persistentEntity = new PipingSectionResultEntity + { + PipingSectionResultEntityId = 2 + }; + dbContext.PipingSectionResultEntities.Add(orphanedEntity); + dbContext.PipingSectionResultEntities.Add(persistentEntity); + + var section = new PipingFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = persistentEntity.PipingSectionResultEntityId + }; + + var registry = new PersistenceRegistry(); + registry.Register(persistentEntity, section); + + // Call + registry.RemoveUntouched(dbContext); + + // Assert + Assert.AreEqual(1, dbContext.PipingSectionResultEntities.Count()); + CollectionAssert.Contains(dbContext.PipingSectionResultEntities, persistentEntity); + mocks.VerifyAll(); + } + + [Test] public void RemoveUntouched_HydraulicLocationEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() { // Setup Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u -rd21cd84fd8eaf1281fd1469932414e42a50c635d -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingFailureMechanismCreateExtensionsTest.cs (.../PipingFailureMechanismCreateExtensionsTest.cs) (revision d21cd84fd8eaf1281fd1469932414e42a50c635d) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingFailureMechanismCreateExtensionsTest.cs (.../PipingFailureMechanismCreateExtensionsTest.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -102,7 +102,7 @@ [Test] [TestCase(true)] [TestCase(false)] - public void Create_WithSections_ReturnsFailureMechanismEntityWithFailureMechanismSectionEntities(bool isRelevant) + public void Create_WithSections_ReturnsWithFailureMechanismSectionEntitiesAndPipingResultEntities(bool isRelevant) { // Setup var failureMechanism = new PipingFailureMechanism(); @@ -122,6 +122,7 @@ // Assert Assert.IsNotNull(entity); Assert.AreEqual(2, entity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(2, entity.FailureMechanismSectionEntities.SelectMany(fms => fms.PipingSectionResultEntities).Count()); } [Test] Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingFailureMechanismSectionResultCreateExtensionsTest.cs (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -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.Piping.Data; + +namespace Application.Ringtoets.Storage.Test.Create +{ + [TestFixture] + public class PipingFailureMechanismSectionResultCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var sectionResult = new PipingFailureMechanismSectionResult(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 PipingFailureMechanismSectionResult(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 PipingFailureMechanismSectionResult(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/Update/PipingFailureMechanismSectionResultUpdateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingFailureMechanismSectionResultUpdateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingFailureMechanismSectionResultUpdateExtensionsTest.cs (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -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.Piping.Data; + +namespace Application.Ringtoets.Storage.Test.Update +{ + [TestFixture] + public class PipingFailureMechanismSectionResultUpdateExtensionsTest + { + [Test] + public void Update_WithoutContext_ArgumentNullException() + { + // Setup + var sectionResult = new PipingFailureMechanismSectionResult(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 PipingFailureMechanismSectionResult(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_ContextWithNoPipingSoilLayer_EntityNotFoundException() + { + // Setup + var sectionResult = new PipingFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => + { + using (var ringtoetsEntities = new RingtoetsEntities()) + { + sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + } + }; + + // Assert + var expectedMessage = String.Format("Het object 'PipingSectionResultEntity' met id '{0}' is niet gevonden.", 0); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Update_ContextWithNoPipingSoilLayerWithId_EntityNotFoundException() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var storageId = 1; + var sectionResult = new PipingFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = storageId + }; + + ringtoetsEntities.PipingSectionResultEntities.Add(new PipingSectionResultEntity + { + PipingSectionResultEntityId = 2 + }); + + // Call + TestDelegate test = () => sectionResult.Update(new PersistenceRegistry(), ringtoetsEntities); + + // Assert + var expectedMessage = String.Format("Het object 'PipingSectionResultEntity' met id '{0}' is niet gevonden.", storageId); + EntityNotFoundException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + + mocks.VerifyAll(); + } + + [Test] + public void Update_WithPipingSoilLayer_PropertiesUpdated() + { + // Setup + MockRepository mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + + mocks.ReplayAll(); + + var sectionResult = new PipingFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = 1, + AssessmentLayerOne = true, + AssessmentLayerThree = (RoundedDouble) 4.4 + }; + + var sectionResultEntity = new PipingSectionResultEntity + { + PipingSectionResultEntityId = sectionResult.StorageId, + LayerOne = Convert.ToByte(false), + LayerThree = 1.1m, + }; + + ringtoetsEntities.PipingSectionResultEntities.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/PipingFailureMechanismUpdateExtensionsTest.cs =================================================================== diff -u -r9d77e28eef1dda363f4854ba2011a0107588d82c -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingFailureMechanismUpdateExtensionsTest.cs (.../PipingFailureMechanismUpdateExtensionsTest.cs) (revision 9d77e28eef1dda363f4854ba2011a0107588d82c) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingFailureMechanismUpdateExtensionsTest.cs (.../PipingFailureMechanismUpdateExtensionsTest.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -437,6 +437,7 @@ // Assert Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.PipingSectionResultEntities).Count()); mocks.VerifyAll(); } @@ -464,10 +465,19 @@ StorageId = 1 }; failureMechanism.AddSection(failureMechanismSection); + failureMechanism.SectionResults.First().StorageId = 1; + var pipingSectionResultEntity = new PipingSectionResultEntity + { + PipingSectionResultEntityId = failureMechanism.SectionResults.First().StorageId + }; var failureMechanismSectionEntity = new FailureMechanismSectionEntity { FailureMechanismSectionEntityId = failureMechanismSection.StorageId, + PipingSectionResultEntities = + { + pipingSectionResultEntity + } }; var rootCalculationGroupEntity = new CalculationGroupEntity { @@ -486,6 +496,7 @@ ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity); ringtoetsEntities.CalculationGroupEntities.Add(rootCalculationGroupEntity); ringtoetsEntities.FailureMechanismSectionEntities.Add(failureMechanismSectionEntity); + ringtoetsEntities.PipingSectionResultEntities.Add(pipingSectionResultEntity); ringtoetsEntities.PipingFailureMechanismMetaEntities.Add(new PipingFailureMechanismMetaEntity { PipingFailureMechanismMetaEntityId = failureMechanism.PipingProbabilityAssessmentInput.StorageId, @@ -497,6 +508,7 @@ // Assert Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count); + Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.SelectMany(fms => fms.PipingSectionResultEntities).Count()); Assert.AreEqual(testName, failureMechanismEntity.FailureMechanismSectionEntities.ElementAt(0).Name); mocks.VerifyAll(); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs =================================================================== diff -u -re69abddf5b9c6634b764df231d4e1b290c9e0fb5 -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs (.../RingtoetsEntitiesHelper.cs) (revision e69abddf5b9c6634b764df231d4e1b290c9e0fb5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs (.../RingtoetsEntitiesHelper.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -24,6 +24,7 @@ using Application.Ringtoets.Storage.DbContext; using Rhino.Mocks; +using Ringtoets.Piping.Data; namespace Application.Ringtoets.Storage.TestUtil { @@ -41,6 +42,7 @@ DbSet failureMechanismsSet = CreateEmptyTestDbSet(); DbSet failureMechanismSectionsSet = CreateEmptyTestDbSet(); DbSet failureMechanismSectionPointsSet = CreateEmptyTestDbSet(); + DbSet pipingSectionResultssSet = CreateEmptyTestDbSet(); DbSet assessmentSectionsSet = CreateEmptyTestDbSet(); DbSet referenceLinesSet = CreateEmptyTestDbSet(); DbSet calculationGroupsSet = CreateEmptyTestDbSet(); @@ -63,6 +65,7 @@ ringtoetsEntities.Stub(r => r.FailureMechanismEntities).Return(failureMechanismsSet); ringtoetsEntities.Stub(r => r.FailureMechanismSectionEntities).Return(failureMechanismSectionsSet); ringtoetsEntities.Stub(r => r.FailureMechanismSectionPointEntities).Return(failureMechanismSectionPointsSet); + ringtoetsEntities.Stub(r => r.PipingSectionResultEntities).Return(pipingSectionResultssSet); ringtoetsEntities.Stub(r => r.AssessmentSectionEntities).Return(assessmentSectionsSet); ringtoetsEntities.Stub(r => r.ReferenceLinePointEntities).Return(referenceLinesSet); ringtoetsEntities.Stub(r => r.CalculationGroupEntities).Return(calculationGroupsSet); Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSection2aAssessmentResultExtensions.cs =================================================================== diff -u -r80404901c704ca22397f36ebe46f81e73059e30a -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSection2aAssessmentResultExtensions.cs (.../PipingFailureMechanismSection2aAssessmentResultExtensions.cs) (revision 80404901c704ca22397f36ebe46f81e73059e30a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSection2aAssessmentResultExtensions.cs (.../PipingFailureMechanismSection2aAssessmentResultExtensions.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -1,4 +1,25 @@ -using System; +// 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.Collections.Generic; using System.Linq; using Core.Common.Base.Data; Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSectionResult.cs =================================================================== diff -u -r80404901c704ca22397f36ebe46f81e73059e30a -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSectionResult.cs (.../PipingFailureMechanismSectionResult.cs) (revision 80404901c704ca22397f36ebe46f81e73059e30a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSectionResult.cs (.../PipingFailureMechanismSectionResult.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -21,6 +21,7 @@ using System; using Core.Common.Base.Data; +using Core.Common.Base.Storage; using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Piping.Data @@ -29,7 +30,7 @@ /// This class holds the information of the result of the /// for a piping assessment. /// - public class PipingFailureMechanismSectionResult : FailureMechanismSectionResult + public class PipingFailureMechanismSectionResult : FailureMechanismSectionResult, IStorable { /// /// Creates a new instance of . @@ -48,5 +49,7 @@ /// Gets or sets the state of the assessment layer one. /// public bool AssessmentLayerOne { get; set; } + + public long StorageId { get; set; } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSection2aAssessmentResultExtensionsTest.cs =================================================================== diff -u -r80404901c704ca22397f36ebe46f81e73059e30a -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSection2aAssessmentResultExtensionsTest.cs (.../PipingFailureMechanismSection2aAssessmentResultExtensionsTest.cs) (revision 80404901c704ca22397f36ebe46f81e73059e30a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSection2aAssessmentResultExtensionsTest.cs (.../PipingFailureMechanismSection2aAssessmentResultExtensionsTest.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218) @@ -1,4 +1,25 @@ -using System.Linq; +// 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.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using NUnit.Framework;