Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r1cd3618f5f8916ef15992d69ec3b447b311c2f72 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 1cd3618f5f8916ef15992d69ec3b447b311c2f72)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -189,6 +189,7 @@
+
@@ -265,7 +266,6 @@
-
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/IStorableExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/IStorableExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/IStorableExtensions.cs (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -0,0 +1,77 @@
+// 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.Data.Entity;
+using System.Linq;
+using System.Linq.Expressions;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Core.Common.Base.Storage;
+
+namespace Application.Ringtoets.Storage
+{
+ ///
+ /// This class contains methods which can be performed on the IStorable interface.
+ ///
+ internal static class IStorableExtensions
+ {
+ ///
+ /// Checks whether the is considered new from the database's perspective.
+ ///
+ /// The to check for.
+ /// true if the is considered new, false otherwise.
+ internal static bool IsNew(this IStorable storable)
+ {
+ return storable.StorageId <= 0;
+ }
+
+ ///
+ /// Gets the corresponding Entity from the database based on the .
+ ///
+ /// The corresponding with the Entity.
+ /// The Entity set to obtain the existing entity from.
+ /// The function to obtain the id field of the Entity.
+ /// The stored as an Entity of type .
+ /// Thrown when either:
+ ///
+ /// - the Entity of type couldn't be found in the
+ /// - more than one Entity of type was found in the
+ /// - has not yet been saved in the database
+ ///
+ public static T GetCorrespondingEntity(this IStorable storable, DbSet entitySet, Func getId) where T : class
+ {
+ if (storable.IsNew())
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(T).Name, storable.StorageId));
+ }
+ try
+ {
+ Func expression = sle => getId(sle) == storable.StorageId;
+ return entitySet.Single(expression);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(T).Name, storable.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/AssessmentSectionUpdateExtensions.cs
===================================================================
diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/AssessmentSectionUpdateExtensions.cs (.../AssessmentSectionUpdateExtensions.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/AssessmentSectionUpdateExtensions.cs (.../AssessmentSectionUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -50,7 +50,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this AssessmentSection section, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -62,7 +62,7 @@
throw new ArgumentNullException("registry");
}
- AssessmentSectionEntity entity = GetCorrespondingAssessmentSectionEntity(section, context);
+ AssessmentSectionEntity entity = section.GetCorrespondingEntity(context.AssessmentSectionEntities, o => o.AssessmentSectionEntityId);
entity.Name = section.Name;
entity.Composition = (short) section.Composition;
entity.Comments = section.Comments;
@@ -97,18 +97,6 @@
section.TechnicalInnovation.Update(registry, context);
}
- private static AssessmentSectionEntity GetCorrespondingAssessmentSectionEntity(AssessmentSection section, IRingtoetsEntities context)
- {
- try
- {
- return context.AssessmentSectionEntities.Single(ase => ase.AssessmentSectionEntityId == section.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(AssessmentSectionEntity).Name, section.StorageId), exception);
- }
- }
-
private static void UpdateReferenceLine(AssessmentSection section, AssessmentSectionEntity entity, IRingtoetsEntities context)
{
if (HasChanges(entity.ReferenceLinePointEntities, section.ReferenceLine))
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/CalculationGroupUpdateExtensions.cs
===================================================================
diff -u -rbba617101367a21a38bf41ad520662058b9012af -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/CalculationGroupUpdateExtensions.cs (.../CalculationGroupUpdateExtensions.cs) (revision bba617101367a21a38bf41ad520662058b9012af)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/CalculationGroupUpdateExtensions.cs (.../CalculationGroupUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -25,8 +25,6 @@
using Application.Ringtoets.Storage.Create;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.Exceptions;
-using Application.Ringtoets.Storage.Properties;
-
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Piping.Data;
@@ -50,7 +48,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this CalculationGroup calculationGroup, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (registry == null)
@@ -62,7 +60,7 @@
throw new ArgumentNullException("context");
}
- CalculationGroupEntity entity = GetCorrespondingCalculationGroupEntity(calculationGroup, context);
+ CalculationGroupEntity entity = calculationGroup.GetCorrespondingEntity(context.CalculationGroupEntities, o => o.CalculationGroupEntityId);
entity.Name = calculationGroup.Name;
UpdateChildren(entity, calculationGroup, registry, context);
@@ -116,20 +114,5 @@
}
}
}
-
- private static CalculationGroupEntity GetCorrespondingCalculationGroupEntity(CalculationGroup calculationGroup, IRingtoetsEntities context)
- {
- try
- {
- return context.CalculationGroupEntities.Single(cge => cge.CalculationGroupEntityId == calculationGroup.StorageId);
- }
- catch (InvalidOperationException e)
- {
- string message = string.Format(Resources.Error_Entity_Not_Found_0_1,
- typeof(CalculationGroupEntity).Name,
- calculationGroup.StorageId);
- throw new EntityNotFoundException(message, e);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ClosingStructureFailureMechanismSectionResultUpdateExtensions.cs
===================================================================
diff -u -r1cd3618f5f8916ef15992d69ec3b447b311c2f72 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ClosingStructureFailureMechanismSectionResultUpdateExtensions.cs (.../ClosingStructureFailureMechanismSectionResultUpdateExtensions.cs) (revision 1cd3618f5f8916ef15992d69ec3b447b311c2f72)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ClosingStructureFailureMechanismSectionResultUpdateExtensions.cs (.../ClosingStructureFailureMechanismSectionResultUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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
@@ -48,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this ClosingStructureFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,25 +58,15 @@
throw new ArgumentNullException("registry");
}
- ClosingStructureSectionResultEntity entity = GetCorrespondingClosingStructureSectionResult(result, context);
+ ClosingStructureSectionResultEntity entity = result.GetCorrespondingEntity(
+ context.ClosingStructureSectionResultEntities,
+ s => s.ClosingStructureSectionResultEntityId);
entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne);
entity.LayerTwoA = Convert.ToDecimal(result.AssessmentLayerTwoA);
entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree);
registry.Register(entity, result);
}
-
- private static ClosingStructureSectionResultEntity GetCorrespondingClosingStructureSectionResult(ClosingStructureFailureMechanismSectionResult result, IRingtoetsEntities context)
- {
- try
- {
- return context.ClosingStructureSectionResultEntities.Single(sle => sle.ClosingStructureSectionResultEntityId == result.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(ClosingStructureSectionResultEntity).Name, result.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ClosingStructureFailureMechanismUpdateExtensions.cs
===================================================================
diff -u -r1cd3618f5f8916ef15992d69ec3b447b311c2f72 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ClosingStructureFailureMechanismUpdateExtensions.cs (.../ClosingStructureFailureMechanismUpdateExtensions.cs) (revision 1cd3618f5f8916ef15992d69ec3b447b311c2f72)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ClosingStructureFailureMechanismUpdateExtensions.cs (.../ClosingStructureFailureMechanismUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -45,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this ClosingStructureFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -57,7 +57,10 @@
throw new ArgumentNullException("registry");
}
- FailureMechanismEntity entity = mechanism.GetCorrespondingFailureMechanismEntity(context);
+ FailureMechanismEntity entity = mechanism.GetCorrespondingEntity(
+ context.FailureMechanismEntities,
+ o => o.FailureMechanismEntityId);
+
entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
mechanism.UpdateFailureMechanismSections(registry, entity, context);
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismSectionUpdateExtensions.cs
===================================================================
diff -u -rd86b1c6e4ebde1570bec162a9043bbb437de5d9c -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismSectionUpdateExtensions.cs (.../FailureMechanismSectionUpdateExtensions.cs) (revision d86b1c6e4ebde1570bec162a9043bbb437de5d9c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismSectionUpdateExtensions.cs (.../FailureMechanismSectionUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -25,7 +25,6 @@
using Application.Ringtoets.Storage.Create;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.Exceptions;
-using Application.Ringtoets.Storage.Properties;
using Core.Common.Base.Geometry;
using Ringtoets.Common.Data.FailureMechanism;
@@ -46,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this FailureMechanismSection section, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -58,26 +57,16 @@
throw new ArgumentNullException("registry");
}
- FailureMechanismSectionEntity entity = GetCorrespondingFailureMechanismSectionEntity(section, context);
+ FailureMechanismSectionEntity entity = section.GetCorrespondingEntity(
+ context.FailureMechanismSectionEntities,
+ o => o.FailureMechanismSectionEntityId);
entity.Name = section.Name;
UpdateGeometry(section, entity, context);
registry.Register(entity, section);
}
- private static FailureMechanismSectionEntity GetCorrespondingFailureMechanismSectionEntity(FailureMechanismSection section, IRingtoetsEntities context)
- {
- try
- {
- return context.FailureMechanismSectionEntities.Single(ase => ase.FailureMechanismSectionEntityId == section.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(FailureMechanismSectionEntity).Name, section.StorageId), exception);
- }
- }
-
private static void UpdateGeometry(FailureMechanismSection section, FailureMechanismSectionEntity entity, IRingtoetsEntities context)
{
if (HasChanges(entity.FailureMechanismSectionPointEntities, section.Points))
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs
===================================================================
diff -u -rbb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs) (revision bb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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.GrassCoverErosionInwards.Data;
namespace Application.Ringtoets.Storage.Update
@@ -48,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this GrassCoverErosionInwardsFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,24 +58,14 @@
throw new ArgumentNullException("registry");
}
- GrassCoverErosionInwardsSectionResultEntity entity = GetCorrespondingGrassCoverErosionInwardsSectionResult(result, context);
+ GrassCoverErosionInwardsSectionResultEntity entity = result.GetCorrespondingEntity(
+ context.GrassCoverErosionInwardsSectionResultEntities,
+ o => o.GrassCoverErosionInwardsSectionResultEntityId);
entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne);
entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree);
registry.Register(entity, result);
}
-
- private static GrassCoverErosionInwardsSectionResultEntity GetCorrespondingGrassCoverErosionInwardsSectionResult(GrassCoverErosionInwardsFailureMechanismSectionResult result, IRingtoetsEntities context)
- {
- try
- {
- return context.GrassCoverErosionInwardsSectionResultEntities.Single(sle => sle.GrassCoverErosionInwardsSectionResultEntityId == result.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(GrassCoverErosionInwardsSectionResultEntity).Name, result.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs
===================================================================
diff -u -rbb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs) (revision bb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -46,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this GrassCoverErosionInwardsFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -58,7 +58,10 @@
throw new ArgumentNullException("registry");
}
- FailureMechanismEntity entity = mechanism.GetCorrespondingFailureMechanismEntity(context);
+ FailureMechanismEntity entity = mechanism.GetCorrespondingEntity(
+ context.FailureMechanismEntities,
+ o => o.FailureMechanismEntityId);
+
entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
mechanism.UpdateFailureMechanismSections(registry, entity, context);
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HeightStructuresFailureMechanismSectionResultUpdateExtensions.cs
===================================================================
diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HeightStructuresFailureMechanismSectionResultUpdateExtensions.cs (.../HeightStructuresFailureMechanismSectionResultUpdateExtensions.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HeightStructuresFailureMechanismSectionResultUpdateExtensions.cs (.../HeightStructuresFailureMechanismSectionResultUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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.HeightStructures.Data;
namespace Application.Ringtoets.Storage.Update
@@ -48,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this HeightStructuresFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,24 +58,14 @@
throw new ArgumentNullException("registry");
}
- HeightStructuresSectionResultEntity entity = GetCorrespondingHeightStructuresSectionResult(result, context);
+ HeightStructuresSectionResultEntity entity = result.GetCorrespondingEntity(
+ context.HeightStructuresSectionResultEntities,
+ o => o.HeightStructuresSectionResultEntityId);
entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne);
entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree);
registry.Register(entity, result);
}
-
- private static HeightStructuresSectionResultEntity GetCorrespondingHeightStructuresSectionResult(HeightStructuresFailureMechanismSectionResult result, IRingtoetsEntities context)
- {
- try
- {
- return context.HeightStructuresSectionResultEntities.Single(sle => sle.HeightStructuresSectionResultEntityId == result.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(HeightStructuresSectionResultEntity).Name, result.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HeightStructuresFailureMechanismUpdateExtensions.cs
===================================================================
diff -u -r0868d78756c7992a83a096f3d3759046c2dbb217 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HeightStructuresFailureMechanismUpdateExtensions.cs (.../HeightStructuresFailureMechanismUpdateExtensions.cs) (revision 0868d78756c7992a83a096f3d3759046c2dbb217)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HeightStructuresFailureMechanismUpdateExtensions.cs (.../HeightStructuresFailureMechanismUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -46,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this HeightStructuresFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -58,7 +58,10 @@
throw new ArgumentNullException("registry");
}
- FailureMechanismEntity entity = mechanism.GetCorrespondingFailureMechanismEntity(context);
+ FailureMechanismEntity entity = mechanism.GetCorrespondingEntity(
+ context.FailureMechanismEntities,
+ o => o.FailureMechanismEntityId);
+
entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
mechanism.UpdateFailureMechanismSections(registry, entity, context);
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HydraulicBoundaryLocationUpdateExtensions.cs
===================================================================
diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HydraulicBoundaryLocationUpdateExtensions.cs (.../HydraulicBoundaryLocationUpdateExtensions.cs) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HydraulicBoundaryLocationUpdateExtensions.cs (.../HydraulicBoundaryLocationUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,12 +20,9 @@
// 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.HydraRing.Data;
namespace Application.Ringtoets.Storage.Update
@@ -48,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this HydraulicBoundaryLocation location, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,25 +57,16 @@
throw new ArgumentNullException("registry");
}
- HydraulicLocationEntity entity = GetCorrespondingHydraulicBoundaryLocationEntity(location, context);
+ HydraulicLocationEntity entity = location.GetCorrespondingEntity(
+ context.HydraulicLocationEntities,
+ o => o.HydraulicLocationEntityId);
+
entity.Name = location.Name;
entity.LocationX = Convert.ToDecimal(location.Location.X);
entity.LocationY = Convert.ToDecimal(location.Location.Y);
entity.DesignWaterLevel = double.IsNaN(location.DesignWaterLevel) ? (double?) null : location.DesignWaterLevel;
registry.Register(entity, location);
}
-
- private static HydraulicLocationEntity GetCorrespondingHydraulicBoundaryLocationEntity(HydraulicBoundaryLocation location, IRingtoetsEntities context)
- {
- try
- {
- return context.HydraulicLocationEntities.Single(hle => hle.HydraulicLocationEntityId == location.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(HydraulicLocationEntity).Name, location.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/IFailureMechanismUpdateExtensions.cs
===================================================================
diff -u -rd21cd84fd8eaf1281fd1469932414e42a50c635d -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/IFailureMechanismUpdateExtensions.cs (.../IFailureMechanismUpdateExtensions.cs) (revision d21cd84fd8eaf1281fd1469932414e42a50c635d)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/IFailureMechanismUpdateExtensions.cs (.../IFailureMechanismUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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.Common.Data.FailureMechanism;
namespace Application.Ringtoets.Storage.Update
@@ -47,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this IFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -59,7 +57,10 @@
throw new ArgumentNullException("registry");
}
- FailureMechanismEntity entity = mechanism.GetCorrespondingFailureMechanismEntity(context);
+ FailureMechanismEntity entity = mechanism.GetCorrespondingEntity(
+ context.FailureMechanismEntities,
+ o => o.FailureMechanismEntityId);
+
entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
entity.Comments = mechanism.Comments;
@@ -110,28 +111,5 @@
}
}
}
-
- ///
- /// Gets the based on the .
- ///
- /// The failure mechanism corresponding with the failure mechanism entity.
- /// The context to obtain the existing entity from.
- /// The stored .
- /// Thrown when either:
- ///
- /// - the couldn't be found in the
- /// - more than one was found in the
- ///
- internal static FailureMechanismEntity GetCorrespondingFailureMechanismEntity(this IFailureMechanism mechanism, IRingtoetsEntities context)
- {
- try
- {
- return context.FailureMechanismEntities.Single(fme => fme.FailureMechanismEntityId == mechanism.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(FailureMechanismEntity).Name, mechanism.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Fisheye: Tag 5b3736b5350315a520f72c90222af261ea651019 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Update/IStorableExtensions.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingCalculationScenarioUpdateExtensions.cs
===================================================================
diff -u -ra2bfc1b408fe5187e5968cc2ff6ac7449211b537 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingCalculationScenarioUpdateExtensions.cs (.../PipingCalculationScenarioUpdateExtensions.cs) (revision a2bfc1b408fe5187e5968cc2ff6ac7449211b537)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingCalculationScenarioUpdateExtensions.cs (.../PipingCalculationScenarioUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,12 +20,9 @@
// 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
@@ -49,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this PipingCalculationScenario calculation, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (registry == null)
@@ -61,7 +58,9 @@
throw new ArgumentNullException("context");
}
- PipingCalculationEntity entity = GetCorrespondingPipingCalculationEntity(calculation, context);
+ PipingCalculationEntity entity = calculation.GetCorrespondingEntity(
+ context.PipingCalculationEntities,
+ o => o.PipingCalculationEntityId);
entity.RelevantForScenario = Convert.ToByte(calculation.IsRelevant);
entity.ScenarioContribution = Convert.ToDecimal(calculation.Contribution);
entity.Name = calculation.Name;
@@ -100,29 +99,6 @@
entity.DarcyPermeabilityStandardDeviation = Convert.ToDecimal(inputParameters.DarcyPermeability.StandardDeviation);
}
- ///
- /// Gets the based on the .
- ///
- /// The piping calculation corresponding with the failure mechanism entity.
- /// The context to obtain the existing entity from.
- /// The stored .
- /// Thrown when either:
- ///
- /// - the couldn't be found in the
- /// - more than one was found in the
- ///
- private static PipingCalculationEntity GetCorrespondingPipingCalculationEntity(this PipingCalculationScenario calculation, IRingtoetsEntities context)
- {
- try
- {
- return context.PipingCalculationEntities.Single(pc => pc.PipingCalculationEntityId == calculation.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(FailureMechanismEntity).Name, calculation.StorageId), exception);
- }
- }
-
private static void UpdatePipingCalculationOutputs(PipingCalculationEntity entity, PipingCalculationScenario calculation, PersistenceRegistry registry)
{
if (calculation.Output != null)
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismSectionResultUpdateExtensions.cs
===================================================================
diff -u -ra8e1897a44aceb5ed4c884797fbb80c9cb92d218 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismSectionResultUpdateExtensions.cs (.../PipingFailureMechanismSectionResultUpdateExtensions.cs) (revision a8e1897a44aceb5ed4c884797fbb80c9cb92d218)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismSectionResultUpdateExtensions.cs (.../PipingFailureMechanismSectionResultUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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
@@ -48,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this PipingFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,24 +58,14 @@
throw new ArgumentNullException("registry");
}
- PipingSectionResultEntity entity = GetCorrespondingPipingSectionResult(result, context);
+ PipingSectionResultEntity entity = result.GetCorrespondingEntity(
+ context.PipingSectionResultEntities,
+ o => o.PipingSectionResultEntityId);
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 -rbb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismUpdateExtensions.cs (.../PipingFailureMechanismUpdateExtensions.cs) (revision bb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismUpdateExtensions.cs (.../PipingFailureMechanismUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -47,7 +47,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this PipingFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -59,7 +59,10 @@
throw new ArgumentNullException("registry");
}
- FailureMechanismEntity entity = mechanism.GetCorrespondingFailureMechanismEntity(context);
+ FailureMechanismEntity entity = mechanism.GetCorrespondingEntity(
+ context.FailureMechanismEntities,
+ o => o.FailureMechanismEntityId);
+
entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
mechanism.PipingProbabilityAssessmentInput.Update(registry, context);
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingProbabilityAssessmentInputUpdateExtensions.cs
===================================================================
diff -u -r9d77e28eef1dda363f4854ba2011a0107588d82c -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingProbabilityAssessmentInputUpdateExtensions.cs (.../PipingProbabilityAssessmentInputUpdateExtensions.cs) (revision 9d77e28eef1dda363f4854ba2011a0107588d82c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingProbabilityAssessmentInputUpdateExtensions.cs (.../PipingProbabilityAssessmentInputUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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
@@ -47,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this PipingProbabilityAssessmentInput probabilityAssessmentInput, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -59,22 +57,13 @@
throw new ArgumentNullException("registry");
}
- PipingFailureMechanismMetaEntity entity = probabilityAssessmentInput.GetCorrespondingPipingFailureMechanismMetaEntity(context);
+ PipingFailureMechanismMetaEntity entity = probabilityAssessmentInput.GetCorrespondingEntity(
+ context.PipingFailureMechanismMetaEntities,
+ o => o.PipingFailureMechanismMetaEntityId);
+
entity.A = Convert.ToDecimal(probabilityAssessmentInput.A);
registry.Register(entity, probabilityAssessmentInput);
}
-
- private static PipingFailureMechanismMetaEntity GetCorrespondingPipingFailureMechanismMetaEntity(this PipingProbabilityAssessmentInput model, IRingtoetsEntities context)
- {
- try
- {
- return context.PipingFailureMechanismMetaEntities.Single(pfmme => pfmme.PipingFailureMechanismMetaEntityId == model.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(PipingFailureMechanismMetaEntity).Name, model.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilLayerUpdateExtensions.cs
===================================================================
diff -u -r02937f67556a7b1d52477b196c62ed50df1cae6d -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilLayerUpdateExtensions.cs (.../PipingSoilLayerUpdateExtensions.cs) (revision 02937f67556a7b1d52477b196c62ed50df1cae6d)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilLayerUpdateExtensions.cs (.../PipingSoilLayerUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,12 +20,9 @@
// 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.Primitives;
namespace Application.Ringtoets.Storage.Update
@@ -48,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this PipingSoilLayer layer, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,7 +57,9 @@
throw new ArgumentNullException("registry");
}
- SoilLayerEntity entity = GetCorrespondingSoilLayerEntity(layer, context);
+ SoilLayerEntity entity = layer.GetCorrespondingEntity(
+ context.SoilLayerEntities,
+ o => o.SoilLayerEntityId);
entity.IsAquifer = Convert.ToByte(layer.IsAquifer);
entity.Top = Convert.ToDecimal(layer.Top);
@@ -70,17 +69,5 @@
registry.Register(entity, layer);
}
-
- private static SoilLayerEntity GetCorrespondingSoilLayerEntity(PipingSoilLayer layer, IRingtoetsEntities context)
- {
- try
- {
- return context.SoilLayerEntities.Single(sle => sle.SoilLayerEntityId == layer.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(SoilLayerEntity).Name, layer.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilProfileUpdateExtensions.cs
===================================================================
diff -u -rd86b1c6e4ebde1570bec162a9043bbb437de5d9c -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilProfileUpdateExtensions.cs (.../PipingSoilProfileUpdateExtensions.cs) (revision d86b1c6e4ebde1570bec162a9043bbb437de5d9c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilProfileUpdateExtensions.cs (.../PipingSoilProfileUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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.Primitives;
namespace Application.Ringtoets.Storage.Update
@@ -47,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this PipingSoilProfile profile, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -59,7 +57,10 @@
throw new ArgumentNullException("registry");
}
- SoilProfileEntity entity = GetCorrespondingPipingSoilProfileEntity(profile, context);
+ SoilProfileEntity entity = profile.GetCorrespondingEntity(
+ context.SoilProfileEntities,
+ o => o.SoilProfileEntityId);
+
entity.Name = profile.Name;
entity.Bottom = Convert.ToDecimal(profile.Bottom);
@@ -77,17 +78,5 @@
registry.Register(entity, profile);
}
-
- private static SoilProfileEntity GetCorrespondingPipingSoilProfileEntity(PipingSoilProfile profile, IRingtoetsEntities context)
- {
- try
- {
- return context.SoilProfileEntities.Single(spe => spe.SoilProfileEntityId == profile.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(SoilProfileEntity).Name, profile.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProjectUpdateExtensions.cs
===================================================================
diff -u -rd86b1c6e4ebde1570bec162a9043bbb437de5d9c -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProjectUpdateExtensions.cs (.../ProjectUpdateExtensions.cs) (revision d86b1c6e4ebde1570bec162a9043bbb437de5d9c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProjectUpdateExtensions.cs (.../ProjectUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -24,7 +24,6 @@
using Application.Ringtoets.Storage.Create;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.Exceptions;
-using Application.Ringtoets.Storage.Properties;
using Core.Common.Base.Data;
using Ringtoets.Integration.Data;
@@ -48,7 +47,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this Project project, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,7 +59,10 @@
throw new ArgumentNullException("registry");
}
- ProjectEntity entity = GetCorrespondingProjectEntity(project, context);
+ ProjectEntity entity = project.GetCorrespondingEntity(
+ context.ProjectEntities,
+ o => o.ProjectEntityId);
+
entity.Description = project.Description;
foreach (var result in project.Items.OfType())
@@ -77,17 +79,5 @@
registry.Register(entity, project);
}
-
- private static ProjectEntity GetCorrespondingProjectEntity(Project project, IRingtoetsEntities context)
- {
- try
- {
- return context.ProjectEntities.Single(pe => pe.ProjectEntityId == project.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(ProjectEntity).Name, project.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/RingtoetsPipingSurfaceLineUpdateExtensions.cs
===================================================================
diff -u -rc7ac7512bbc38609f60d8d8e383f3186cc79a156 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/RingtoetsPipingSurfaceLineUpdateExtensions.cs (.../RingtoetsPipingSurfaceLineUpdateExtensions.cs) (revision c7ac7512bbc38609f60d8d8e383f3186cc79a156)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/RingtoetsPipingSurfaceLineUpdateExtensions.cs (.../RingtoetsPipingSurfaceLineUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -24,9 +24,6 @@
using Application.Ringtoets.Storage.Create;
using Application.Ringtoets.Storage.DbContext;
-using Application.Ringtoets.Storage.Exceptions;
-using Application.Ringtoets.Storage.Properties;
-
using Core.Common.Base.Geometry;
using Ringtoets.Piping.Primitives;
@@ -64,7 +61,9 @@
throw new ArgumentNullException("context");
}
- SurfaceLineEntity entity = GetCorrespondingSurfaceLineEntity(surfaceLine, context);
+ SurfaceLineEntity entity = surfaceLine.GetCorrespondingEntity(
+ context.SurfaceLineEntities,
+ o => o.SurfaceLineEntityId);
entity.Name = surfaceLine.Name;
entity.ReferenceLineIntersectionX = Convert.ToDecimal(surfaceLine.ReferenceLineIntersectionWorldPoint.X);
@@ -173,29 +172,5 @@
registry.Register(characteristicPointEntity, currentCharacteristicPoint);
}
}
-
- ///
- /// Gets the from a
- /// corresponding to an already saved instance.
- ///
- /// The surface line.
- /// The context.
- /// The .
- /// When no
- /// can be found in that matches .
- private static SurfaceLineEntity GetCorrespondingSurfaceLineEntity(RingtoetsPipingSurfaceLine surfaceLine, IRingtoetsEntities context)
- {
- try
- {
- return context.SurfaceLineEntities.Single(sle => sle.SurfaceLineEntityId == surfaceLine.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- string message = string.Format(Resources.Error_Entity_Not_Found_0_1,
- typeof(SurfaceLineEntity).Name,
- surfaceLine.StorageId);
- throw new EntityNotFoundException(message, exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilModelUpdateExtensions.cs
===================================================================
diff -u -rd86b1c6e4ebde1570bec162a9043bbb437de5d9c -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilModelUpdateExtensions.cs (.../StochasticSoilModelUpdateExtensions.cs) (revision d86b1c6e4ebde1570bec162a9043bbb437de5d9c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilModelUpdateExtensions.cs (.../StochasticSoilModelUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -25,8 +25,6 @@
using Application.Ringtoets.Storage.Create;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.Exceptions;
-using Application.Ringtoets.Storage.Properties;
-
using Core.Common.Base.Geometry;
using Ringtoets.Piping.Data;
@@ -51,7 +49,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this StochasticSoilModel model, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -63,7 +61,10 @@
throw new ArgumentNullException("registry");
}
- StochasticSoilModelEntity entity = GetCorrespondingStochasticSoilModelEntity(model, context);
+ StochasticSoilModelEntity entity = model.GetCorrespondingEntity(
+ context.StochasticSoilModelEntities,
+ o => o.StochasticSoilModelEntityId);
+
entity.Name = model.Name;
entity.SegmentName = model.SegmentName;
@@ -125,17 +126,5 @@
entity.StochasticSoilModelSegmentPointEntities.Add(pointEntity);
}
}
-
- private static StochasticSoilModelEntity GetCorrespondingStochasticSoilModelEntity(StochasticSoilModel model, IRingtoetsEntities context)
- {
- try
- {
- return context.StochasticSoilModelEntities.Single(ssme => ssme.StochasticSoilModelEntityId == model.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(StochasticSoilModelEntity).Name, model.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilProfileUpdateExtensions.cs
===================================================================
diff -u -rd86b1c6e4ebde1570bec162a9043bbb437de5d9c -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilProfileUpdateExtensions.cs (.../StochasticSoilProfileUpdateExtensions.cs) (revision d86b1c6e4ebde1570bec162a9043bbb437de5d9c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilProfileUpdateExtensions.cs (.../StochasticSoilProfileUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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
@@ -47,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this StochasticSoilProfile profile, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -59,7 +57,10 @@
throw new ArgumentNullException("registry");
}
- StochasticSoilProfileEntity entity = GetCorrespondingStochasticSoilProfileEntity(profile, context);
+ StochasticSoilProfileEntity entity = profile.GetCorrespondingEntity(
+ context.StochasticSoilProfileEntities,
+ o => o.StochasticSoilProfileEntityId);
+
entity.Probability = Convert.ToDecimal(profile.Probability);
if (profile.SoilProfile.IsNew())
@@ -73,17 +74,5 @@
registry.Register(entity, profile);
}
-
- private static StochasticSoilProfileEntity GetCorrespondingStochasticSoilProfileEntity(StochasticSoilProfile profile, IRingtoetsEntities context)
- {
- try
- {
- return context.StochasticSoilProfileEntities.Single(sspe => sspe.StochasticSoilProfileEntityId == profile.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(StochasticSoilProfileEntity).Name, profile.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensions.cs
===================================================================
diff -u -rebad637e9483d348a5efe2fe902d56aa91bf6a31 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensions.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensions.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensions.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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
@@ -48,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,24 +58,14 @@
throw new ArgumentNullException("registry");
}
- StrengthStabilityLengthwiseConstructionSectionResultEntity entity = GetCorrespondingStrengthStabilityLengthwiseConstructionSectionResult(result, context);
+ StrengthStabilityLengthwiseConstructionSectionResultEntity entity = result.GetCorrespondingEntity(
+ context.StrengthStabilityLengthwiseConstructionSectionResultEntities,
+ o => o.StrengthStabilityLengthwiseConstructionSectionResultEntityId);
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 -rebad637e9483d348a5efe2fe902d56aa91bf6a31 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensions.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensions.cs) (revision ebad637e9483d348a5efe2fe902d56aa91bf6a31)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensions.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -45,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this StrengthStabilityLengthwiseConstructionFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -57,7 +57,10 @@
throw new ArgumentNullException("registry");
}
- FailureMechanismEntity entity = mechanism.GetCorrespondingFailureMechanismEntity(context);
+ FailureMechanismEntity entity = mechanism.GetCorrespondingEntity(
+ context.FailureMechanismEntities,
+ o => o.FailureMechanismEntityId);
+
entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
mechanism.UpdateFailureMechanismSections(registry, entity, context);
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/TechnicalInnovationFailureMechanismSectionResultUpdateExtensions.cs
===================================================================
diff -u -r2fe46c62134fde70ada240fa952971444177be90 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/TechnicalInnovationFailureMechanismSectionResultUpdateExtensions.cs (.../TechnicalInnovationFailureMechanismSectionResultUpdateExtensions.cs) (revision 2fe46c62134fde70ada240fa952971444177be90)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/TechnicalInnovationFailureMechanismSectionResultUpdateExtensions.cs (.../TechnicalInnovationFailureMechanismSectionResultUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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
@@ -48,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this TechnicalInnovationFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,24 +58,14 @@
throw new ArgumentNullException("registry");
}
- TechnicalInnovationSectionResultEntity entity = GetCorrespondingTechnicalInnovationSectionResult(result, context);
+ TechnicalInnovationSectionResultEntity entity = result.GetCorrespondingEntity(
+ context.TechnicalInnovationSectionResultEntities,
+ o => o.TechnicalInnovationSectionResultEntityId);
entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne);
entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree);
registry.Register(entity, result);
}
-
- private static TechnicalInnovationSectionResultEntity GetCorrespondingTechnicalInnovationSectionResult(TechnicalInnovationFailureMechanismSectionResult result, IRingtoetsEntities context)
- {
- try
- {
- return context.TechnicalInnovationSectionResultEntities.Single(sle => sle.TechnicalInnovationSectionResultEntityId == result.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(TechnicalInnovationSectionResultEntity).Name, result.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/TechnicalInnovationFailureMechanismUpdateExtensions.cs
===================================================================
diff -u -r2fe46c62134fde70ada240fa952971444177be90 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/TechnicalInnovationFailureMechanismUpdateExtensions.cs (.../TechnicalInnovationFailureMechanismUpdateExtensions.cs) (revision 2fe46c62134fde70ada240fa952971444177be90)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/TechnicalInnovationFailureMechanismUpdateExtensions.cs (.../TechnicalInnovationFailureMechanismUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -45,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this TechnicalInnovationFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -57,7 +57,10 @@
throw new ArgumentNullException("registry");
}
- FailureMechanismEntity entity = mechanism.GetCorrespondingFailureMechanismEntity(context);
+ FailureMechanismEntity entity = mechanism.GetCorrespondingEntity(
+ context.FailureMechanismEntities,
+ o => o.FailureMechanismEntityId);
+
entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
mechanism.UpdateFailureMechanismSections(registry, entity, context);
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/WaterPressureAsphaltCoverFailureMechanismSectionResultUpdateExtensions.cs
===================================================================
diff -u -r2fe46c62134fde70ada240fa952971444177be90 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/WaterPressureAsphaltCoverFailureMechanismSectionResultUpdateExtensions.cs (.../WaterPressureAsphaltCoverFailureMechanismSectionResultUpdateExtensions.cs) (revision 2fe46c62134fde70ada240fa952971444177be90)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/WaterPressureAsphaltCoverFailureMechanismSectionResultUpdateExtensions.cs (.../WaterPressureAsphaltCoverFailureMechanismSectionResultUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -20,11 +20,9 @@
// 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
@@ -48,7 +46,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this WaterPressureAsphaltCoverFailureMechanismSectionResult result, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -60,24 +58,14 @@
throw new ArgumentNullException("registry");
}
- WaterPressureAsphaltCoverSectionResultEntity entity = GetCorrespondingWaterPressureAsphaltCoverSectionResult(result, context);
+ WaterPressureAsphaltCoverSectionResultEntity entity = result.GetCorrespondingEntity(
+ context.WaterPressureAsphaltCoverSectionResultEntities,
+ o => o.WaterPressureAsphaltCoverSectionResultEntityId);
entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne);
entity.LayerThree = Convert.ToDecimal(result.AssessmentLayerThree);
registry.Register(entity, result);
}
-
- private static WaterPressureAsphaltCoverSectionResultEntity GetCorrespondingWaterPressureAsphaltCoverSectionResult(WaterPressureAsphaltCoverFailureMechanismSectionResult result, IRingtoetsEntities context)
- {
- try
- {
- return context.WaterPressureAsphaltCoverSectionResultEntities.Single(sle => sle.WaterPressureAsphaltCoverSectionResultEntityId == result.StorageId);
- }
- catch (InvalidOperationException exception)
- {
- throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(WaterPressureAsphaltCoverSectionResultEntity).Name, result.StorageId), exception);
- }
- }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/WaterPressureAsphaltCoverFailureMechanismUpdateExtensions.cs
===================================================================
diff -u -r2fe46c62134fde70ada240fa952971444177be90 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/WaterPressureAsphaltCoverFailureMechanismUpdateExtensions.cs (.../WaterPressureAsphaltCoverFailureMechanismUpdateExtensions.cs) (revision 2fe46c62134fde70ada240fa952971444177be90)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/WaterPressureAsphaltCoverFailureMechanismUpdateExtensions.cs (.../WaterPressureAsphaltCoverFailureMechanismUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -45,7 +45,7 @@
/// - is null
///
/// When
- /// does not have a corresponding entity in .
+ /// does not have a corresponding entity in the database.
internal static void Update(this WaterPressureAsphaltCoverFailureMechanism mechanism, PersistenceRegistry registry, IRingtoetsEntities context)
{
if (context == null)
@@ -57,7 +57,10 @@
throw new ArgumentNullException("registry");
}
- FailureMechanismEntity entity = mechanism.GetCorrespondingFailureMechanismEntity(context);
+ FailureMechanismEntity entity = mechanism.GetCorrespondingEntity(
+ context.FailureMechanismEntities,
+ o => o.FailureMechanismEntityId);
+
entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
mechanism.UpdateFailureMechanismSections(registry, entity, context);
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r1cd3618f5f8916ef15992d69ec3b447b311c2f72 -r5b3736b5350315a520f72c90222af261ea651019
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 1cd3618f5f8916ef15992d69ec3b447b311c2f72)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -115,6 +115,7 @@
+
@@ -166,7 +167,6 @@
-
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IStorableExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IStorableExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IStorableExtensionsTest.cs (revision 5b3736b5350315a520f72c90222af261ea651019)
@@ -0,0 +1,169 @@
+// 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.ObjectModel;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Core.Common.Base.Storage;
+using NUnit.Framework;
+using Rhino.Mocks;
+
+namespace Application.Ringtoets.Storage.Test
+{
+ [TestFixture]
+ public class IStorableExtensionsTest
+ {
+ [Test]
+ [TestCase(0, true)]
+ [TestCase(-1, true)]
+ [TestCase(Int32.MinValue, true)]
+ [TestCase(1, false)]
+ [TestCase(5, false)]
+ [TestCase(Int32.MaxValue, false)]
+ public void IsNew_DifferentIds_ExpectedResult(int val, bool isNew)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var storable = mocks.StrictMock();
+ storable.Expect(s => s.StorageId).Return(val);
+ mocks.ReplayAll();
+
+ // Call
+ var result = storable.IsNew();
+
+ // Assert
+ Assert.AreEqual(isNew, result);
+ }
+
+ [Test]
+ public void Find_NoItemsInContext_ThrowsException()
+ {
+ // Setup
+ var storable = new SimpleStorable();
+ var set = new TestDbSet