Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -raf521f167fabb7052a06e6a3d12575d3c3f18ab4 -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision af521f167fabb7052a06e6a3d12575d3c3f18ab4) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -57,6 +57,7 @@ + RingtoetsEntities.tt @@ -79,9 +80,9 @@ - + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/IEntityConverter.cs =================================================================== diff -u -rbd8a3e95f0145815fa6724a162404a76c9dc9f5a -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/IEntityConverter.cs (.../IEntityConverter.cs) (revision bd8a3e95f0145815fa6724a162404a76c9dc9f5a) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/IEntityConverter.cs (.../IEntityConverter.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -27,7 +27,7 @@ /// /// Interface for entity converters. /// - public interface IEntityConverter where TEntity : class where TModel : IStorable + public interface IEntityConverter where TEntity : class { /// /// Converts to . Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/ReferenceLineConverter.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/ReferenceLineConverter.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/ReferenceLineConverter.cs (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Application.Ringtoets.Storage.DbContext; +using Core.Common.Base.Geometry; +using Ringtoets.Common.Data; + +namespace Application.Ringtoets.Storage.Converters +{ + public class ReferenceLineConverter : IEntityConverter> + { + public ReferenceLine ConvertEntityToModel(ICollection entityCollection) + { + var line = new ReferenceLine(); + + var geometry = entityCollection.Select(entity => new Point2D(decimal.ToDouble(entity.X), decimal.ToDouble(entity.Y))); + line.SetGeometry(geometry); + + return line; + } + + public ReferenceLine ConvertEntityToModel(ICollection entity, Func model) + { + throw new NotImplementedException(); + } + + public void ConvertModelToEntity(ReferenceLine modelObject, ICollection entity) + { + entity.Clear(); + foreach (Point2D point in modelObject.Points) + { + entity.Add(new ReferenceLinePointEntity + { + X = Convert.ToDecimal(point.X), + Y = Convert.ToDecimal(point.Y), + Order = entity.Count + }); + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ReferenceLinePointEntity.cs =================================================================== diff -u -r2ae1c9433c3c28b32105b9778b682b5e512a0f00 -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ReferenceLinePointEntity.cs (.../ReferenceLinePointEntity.cs) (revision 2ae1c9433c3c28b32105b9778b682b5e512a0f00) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ReferenceLinePointEntity.cs (.../ReferenceLinePointEntity.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -35,11 +35,10 @@ public partial class ReferenceLinePointEntity { - public long ReferenceLinePointEntityId { get; set; } - public Nullable DikeAssessmentSectionEntityId { get; set; } - public Nullable X { get; set; } - public Nullable Y { get; set; } - public Nullable Order { get; set; } + public long DikeAssessmentSectionEntityId { get; set; } + public decimal X { get; set; } + public decimal Y { get; set; } + public int Order { get; set; } public virtual DikeAssessmentSectionEntity DikeAssessmentSectionEntity { get; set; } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs =================================================================== diff -u -radfa3c3e4d889f4038d1add832f3ea16aaeaadac -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision adfa3c3e4d889f4038d1add832f3ea16aaeaadac) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -56,7 +56,7 @@ public virtual IDbSet FailureMechanismEntities { get; set; } public virtual IDbSet HydraulicLocationEntities { get; set; } public virtual IDbSet ProjectEntities { get; set; } - public virtual IDbSet ReferenceLinePointEntities { get; set; } public virtual IDbSet Versions { get; set; } + public virtual IDbSet ReferenceLinePointEntities { get; set; } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs =================================================================== diff -u -r306028f53543223cc68a988fe9c82b7341e78948 -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs (.../RingtoetsEntities.Designer.cs) (revision 306028f53543223cc68a988fe9c82b7341e78948) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs (.../RingtoetsEntities.Designer.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -1,4 +1,4 @@ -// T4 code generation is enabled for model 'D:\Repos\Ringtoets\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 -r306028f53543223cc68a988fe9c82b7341e78948 -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision 306028f53543223cc68a988fe9c82b7341e78948) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -45,15 +45,19 @@ + - + + + + - - - - - + + + + @@ -101,7 +105,7 @@ - + @@ -117,8 +121,15 @@ - + + SELECT +[ReferenceLinePointEntity].[DikeAssessmentSectionEntityId] AS [DikeAssessmentSectionEntityId], +[ReferenceLinePointEntity].[X] AS [X], +[ReferenceLinePointEntity].[Y] AS [Y], +[ReferenceLinePointEntity].[Order] AS [Order] +FROM [ReferenceLinePointEntity] AS [ReferenceLinePointEntity] + @@ -145,8 +156,8 @@ - + @@ -211,17 +222,6 @@ - - - - - - - - - - - @@ -231,6 +231,19 @@ + + + + + + + + + + + + + @@ -268,7 +281,7 @@ - + @@ -329,17 +342,6 @@ - - - - - - - - - - - @@ -350,6 +352,16 @@ + + + + + + + + + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram =================================================================== diff -u -r306028f53543223cc68a988fe9c82b7341e78948 -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision 306028f53543223cc68a988fe9c82b7341e78948) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -5,12 +5,12 @@ - + - - + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs =================================================================== diff -u -r85ecb76bfcd0433fbe2498591c474d7fe70750e3 -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs (.../DikeAssessmentSectionEntityPersistor.cs) (revision 85ecb76bfcd0433fbe2498591c474d7fe70750e3) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs (.../DikeAssessmentSectionEntityPersistor.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -36,7 +36,7 @@ /// /// Persistor for . /// - public class DikeAssessmentSectionEntityPersistor : IPersistor + public class DikeAssessmentSectionEntityPersistor { private readonly IRingtoetsEntities dbContext; private readonly DikeAssessmentSectionEntityConverter converter; @@ -88,6 +88,9 @@ } } + var referenceLinePointPersistor = new ReferenceLinePersistor(); + dikeAssessmentSection.ReferenceLine = referenceLinePointPersistor.LoadModel(entity.ReferenceLinePointEntities); + return dikeAssessmentSection; } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/FailureMechanismEntityPersistorBase.cs =================================================================== diff -u -r85ecb76bfcd0433fbe2498591c474d7fe70750e3 -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/FailureMechanismEntityPersistorBase.cs (.../FailureMechanismEntityPersistorBase.cs) (revision 85ecb76bfcd0433fbe2498591c474d7fe70750e3) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/FailureMechanismEntityPersistorBase.cs (.../FailureMechanismEntityPersistorBase.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -35,7 +35,7 @@ /// /// Persistor for classes derived from . /// - public abstract class FailureMechanismEntityPersistorBase : IPersistor where T : IFailureMechanism + public abstract class FailureMechanismEntityPersistorBase where T : IFailureMechanism { private readonly IRingtoetsEntities dbContext; private readonly Dictionary insertedList = new Dictionary(); @@ -136,6 +136,11 @@ } } + /// + /// Loads a new model of type based on the . + /// + /// Database entity containing information for the new model. + /// A new instance of type . public virtual T LoadModel(FailureMechanismEntity entity, Func model) { return converter.ConvertEntityToModel(entity, model); Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/HydraulicLocationEntityPersistor.cs =================================================================== diff -u -r85ecb76bfcd0433fbe2498591c474d7fe70750e3 -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/HydraulicLocationEntityPersistor.cs (.../HydraulicLocationEntityPersistor.cs) (revision 85ecb76bfcd0433fbe2498591c474d7fe70750e3) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/HydraulicLocationEntityPersistor.cs (.../HydraulicLocationEntityPersistor.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -33,7 +33,7 @@ /// /// The persistor for . /// - public class HydraulicLocationEntityPersistor : IPersistor + public class HydraulicLocationEntityPersistor { private readonly IRingtoetsEntities ringtoetsContext; private readonly HydraulicLocationConverter converter; Fisheye: Tag 4670af35a2cb3c8b78d68a25804c3b620da19ddb refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/IPersistor.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectEntityPersistor.cs =================================================================== diff -u -r85ecb76bfcd0433fbe2498591c474d7fe70750e3 -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectEntityPersistor.cs (.../ProjectEntityPersistor.cs) (revision 85ecb76bfcd0433fbe2498591c474d7fe70750e3) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectEntityPersistor.cs (.../ProjectEntityPersistor.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -36,7 +36,7 @@ /// /// Persistor for . /// - public class ProjectEntityPersistor : IPersistor + public class ProjectEntityPersistor { private readonly IRingtoetsEntities dbContext; private readonly IDbSet dbSet; @@ -87,7 +87,7 @@ /// The parentNavigationProperty is read-only. public void InsertModel(Project project) { - InsertModel(dbSet.Local, project, 0); + InsertModel(dbSet.Local, project); } /// @@ -104,11 +104,45 @@ /// The parentNavigationProperty is read-only. public void UpdateModel(Project model) { - UpdateModel(dbSet.Local, model, 0); + UpdateModel(dbSet.Local, model); } - public void UpdateModel(ICollection parentNavigationProperty, Project model, int order) + /// + /// Removes all entities from that are not marked as 'updated'. + /// + /// List where objects can be searched. Usually, this collection is a navigation property of a . + /// Thrown when the is read-only. + public void RemoveUnModifiedEntries(ICollection parentNavigationProperty) { + var originalList = parentNavigationProperty.ToList(); + foreach (var u in modifiedList) + { + originalList.Remove(u); + } + + foreach (var toDelete in originalList) + { + // If id = 0, the entity is marked as inserted + if (toDelete.ProjectEntityId > 0) + { + dbContext.ProjectEntities.Remove(toDelete); + } + } + + modifiedList.Clear(); + } + + /// + /// Perform actions that can only be executed after has been called. + /// + public void PerformPostSaveActions() + { + UpdateStorageIdsInModel(); + dikeAssessmentSectionEntityPersistor.PerformPostSaveActions(); + } + + private void UpdateModel(ICollection parentNavigationProperty, Project model) + { if (model == null) { throw new ArgumentNullException("model", "Cannot update databaseSet when no project is set."); @@ -132,7 +166,7 @@ UpdateChildren(model, entity); } - public void InsertModel(ICollection parentNavigationProperty, Project project, int order) + private void InsertModel(ICollection parentNavigationProperty, Project project) { if (project == null) { @@ -153,42 +187,8 @@ InsertChildren(project, entity); } - /// - /// Removes all entities from that are not marked as 'updated'. - /// - /// List where objects can be searched. Usually, this collection is a navigation property of a . - /// Thrown when the is read-only. - public void RemoveUnModifiedEntries(ICollection parentNavigationProperty) + private Project LoadModel(ProjectEntity entity, Func model) { - var originalList = parentNavigationProperty.ToList(); - foreach (var u in modifiedList) - { - originalList.Remove(u); - } - - foreach (var toDelete in originalList) - { - // If id = 0, the entity is marked as inserted - if (toDelete.ProjectEntityId > 0) - { - dbContext.ProjectEntities.Remove(toDelete); - } - } - - modifiedList.Clear(); - } - - /// - /// Perform actions that can only be executed after has been called. - /// - public void PerformPostSaveActions() - { - UpdateStorageIdsInModel(); - dikeAssessmentSectionEntityPersistor.PerformPostSaveActions(); - } - - public Project LoadModel(ProjectEntity entity, Func model) - { if (entity == null) { return null; Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ReferenceLinePersistor.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ReferenceLinePersistor.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ReferenceLinePersistor.cs (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using Application.Ringtoets.Storage.Converters; +using Application.Ringtoets.Storage.DbContext; +using Ringtoets.Common.Data; + +namespace Application.Ringtoets.Storage.Persistors +{ + public class ReferenceLinePersistor + { + private readonly ReferenceLineConverter converter = new ReferenceLineConverter(); + + /// + /// Updates a (new) entity based on the values of . + /// + /// The entity to update. + /// The model to use to update the entity. + public void UpdateModel(ICollection parentNavigationProperty, ReferenceLine model) + { + } + + /// + /// Inserts a new entity based on the values of . + /// + /// The collection where the new entity is added. + /// The model to use to update the entity. + public void InsertModel(ICollection parentNavigationProperty, ReferenceLine model) + { + } + + /// + /// Creates a new based on the information in . + /// + /// The database entity containing the information to set on the new model. + /// A new with properties set from the database. + public ReferenceLine LoadModel(ICollection entity) + { + return converter.ConvertEntityToModel(entity); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikeAssessmentSectionEntityPersistorTest.cs =================================================================== diff -u -rb50153c7b2f1c9c34f4575a599605f68844f43ca -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikeAssessmentSectionEntityPersistorTest.cs (.../DikeAssessmentSectionEntityPersistorTest.cs) (revision b50153c7b2f1c9c34f4575a599605f68844f43ca) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikeAssessmentSectionEntityPersistorTest.cs (.../DikeAssessmentSectionEntityPersistorTest.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -53,7 +53,6 @@ // Assert Assert.IsInstanceOf(persistor); - Assert.IsInstanceOf>(persistor); mockRepository.VerifyAll(); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/HydraulicLocationEntityPersistorTest.cs =================================================================== diff -u -rb50153c7b2f1c9c34f4575a599605f68844f43ca -r4670af35a2cb3c8b78d68a25804c3b620da19ddb --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/HydraulicLocationEntityPersistorTest.cs (.../HydraulicLocationEntityPersistorTest.cs) (revision b50153c7b2f1c9c34f4575a599605f68844f43ca) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/HydraulicLocationEntityPersistorTest.cs (.../HydraulicLocationEntityPersistorTest.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb) @@ -68,7 +68,8 @@ HydraulicLocationEntityPersistor persistor = new HydraulicLocationEntityPersistor(ringtoetsEntities); // Assert - Assert.IsInstanceOf>(persistor); + Assert.IsInstanceOf(persistor); + mocks.VerifyAll(); }