Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -radfa3c3e4d889f4038d1add832f3ea16aaeaadac -r92a966a0a5ae5144b90b89be0cdf30c5eea25d7d --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision adfa3c3e4d889f4038d1add832f3ea16aaeaadac) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 92a966a0a5ae5144b90b89be0cdf30c5eea25d7d) @@ -76,6 +76,8 @@ + + @@ -124,6 +126,11 @@ {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data + + {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} + Ringtoets.HydraRing.Data + False + {11F1F874-45AF-43E4-8AE5-15A5C9593E28} Ringtoets.Integration.Data Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/DikeAssessmentSectionEntityConverter.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -r92a966a0a5ae5144b90b89be0cdf30c5eea25d7d --- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/DikeAssessmentSectionEntityConverter.cs (.../DikeAssessmentSectionEntityConverter.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/DikeAssessmentSectionEntityConverter.cs (.../DikeAssessmentSectionEntityConverter.cs) (revision 92a966a0a5ae5144b90b89be0cdf30c5eea25d7d) @@ -21,6 +21,7 @@ using System; using Application.Ringtoets.Storage.DbContext; +using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; namespace Application.Ringtoets.Storage.Converters @@ -53,6 +54,15 @@ } }; + if (entity.HydraulicDatabaseLocation != null && entity.HydraulicDatabaseVersion != null) + { + dikeAssessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = entity.HydraulicDatabaseLocation, + Version = entity.HydraulicDatabaseVersion + }; + } + return dikeAssessmentSection; } @@ -78,6 +88,12 @@ entity.DikeAssessmentSectionEntityId = modelObject.StorageId; entity.Name = modelObject.Name; entity.Norm = modelObject.FailureMechanismContribution.Norm; + + if (modelObject.HydraulicBoundaryDatabase != null) + { + entity.HydraulicDatabaseLocation = modelObject.HydraulicBoundaryDatabase.FilePath; + entity.HydraulicDatabaseVersion = modelObject.HydraulicBoundaryDatabase.Version; + } } } } \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs =================================================================== diff -u -r8dec462b18aff76313f2836309ef24ddd2f70b50 -r92a966a0a5ae5144b90b89be0cdf30c5eea25d7d --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs (.../DikeAssessmentSectionEntityPersistor.cs) (revision 8dec462b18aff76313f2836309ef24ddd2f70b50) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs (.../DikeAssessmentSectionEntityPersistor.cs) (revision 92a966a0a5ae5144b90b89be0cdf30c5eea25d7d) @@ -43,6 +43,7 @@ private readonly ICollection modifiedList = new List(); private readonly DikesPipingFailureMechanismEntityPersistor dikePipingFailureMechanismEntityPersistor; + private readonly HydraulicLocationEntityPersistor hydraulicLocationEntityPersistor; /// /// New instance of . @@ -60,6 +61,7 @@ converter = new DikeAssessmentSectionEntityConverter(); dikePipingFailureMechanismEntityPersistor = new DikesPipingFailureMechanismEntityPersistor(dbContext); + hydraulicLocationEntityPersistor = new HydraulicLocationEntityPersistor(dbContext); } /// @@ -71,6 +73,11 @@ { var dikeAssessmentSection = converter.ConvertEntityToModel(entity); + foreach (var hydraulicLocationEntity in entity.HydraulicLocationEntities) + { + hydraulicLocationEntityPersistor.LoadModel(hydraulicLocationEntity, dikeAssessmentSection.HydraulicBoundaryDatabase.Locations); + } + foreach (var failureMechanismEntity in entity.FailureMechanismEntities) { if (failureMechanismEntity.FailureMechanismType == (int) FailureMechanismType.DikesPipingFailureMechanism) Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikesPipingFailureMechanismEntityPersistor.cs =================================================================== diff -u -r8dec462b18aff76313f2836309ef24ddd2f70b50 -r92a966a0a5ae5144b90b89be0cdf30c5eea25d7d --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikesPipingFailureMechanismEntityPersistor.cs (.../DikesPipingFailureMechanismEntityPersistor.cs) (revision 8dec462b18aff76313f2836309ef24ddd2f70b50) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikesPipingFailureMechanismEntityPersistor.cs (.../DikesPipingFailureMechanismEntityPersistor.cs) (revision 92a966a0a5ae5144b90b89be0cdf30c5eea25d7d) @@ -21,6 +21,7 @@ using System; using Application.Ringtoets.Storage.DbContext; +using Ringtoets.Common.Data; using Ringtoets.Piping.Data; namespace Application.Ringtoets.Storage.Persistors @@ -47,7 +48,7 @@ /// is null. /// /// Thrown when is not of type . - public void LoadModel(FailureMechanismEntity entity, PipingFailureMechanism model) + public override void LoadModel(FailureMechanismEntity entity, IFailureMechanism model) { ConvertEntityToModel(entity, model); if (entity.FailureMechanismType != (int) FailureMechanismType.DikesPipingFailureMechanism) Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/FailureMechanismEntityPersistorBase.cs =================================================================== diff -u -r8dec462b18aff76313f2836309ef24ddd2f70b50 -r92a966a0a5ae5144b90b89be0cdf30c5eea25d7d --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/FailureMechanismEntityPersistorBase.cs (.../FailureMechanismEntityPersistorBase.cs) (revision 8dec462b18aff76313f2836309ef24ddd2f70b50) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/FailureMechanismEntityPersistorBase.cs (.../FailureMechanismEntityPersistorBase.cs) (revision 92a966a0a5ae5144b90b89be0cdf30c5eea25d7d) @@ -34,7 +34,7 @@ /// /// Persistor for classes derived from . /// - public abstract class FailureMechanismEntityPersistorBase + public abstract class FailureMechanismEntityPersistorBase : ICollectionPersistor { private readonly IRingtoetsEntities dbContext; private readonly Dictionary insertedList = new Dictionary(); @@ -91,6 +91,8 @@ insertedList.Clear(); } + public abstract void LoadModel(FailureMechanismEntity entity, IFailureMechanism model); + /// /// Ensures that the model is added as in the . /// @@ -178,7 +180,7 @@ /// is null. /// is null. /// - protected static void ConvertEntityToModel(FailureMechanismEntity entity, IFailureMechanism model) + public void ConvertEntityToModel(FailureMechanismEntity entity, IFailureMechanism model) { if (entity == null) { @@ -199,7 +201,7 @@ /// Thrown when: /// is null. /// - private static void ConvertModelToEntity(IFailureMechanism model, FailureMechanismEntity entity) + public void ConvertModelToEntity(IFailureMechanism model, FailureMechanismEntity entity) { if (model == null) { Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/HydraulicLocationEntityPersistor.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/HydraulicLocationEntityPersistor.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/HydraulicLocationEntityPersistor.cs (revision 92a966a0a5ae5144b90b89be0cdf30c5eea25d7d) @@ -0,0 +1,72 @@ +// 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.Collections.Generic; +using Application.Ringtoets.Storage.DbContext; +using Ringtoets.HydraRing.Data; + +namespace Application.Ringtoets.Storage.Persistors +{ + public class HydraulicLocationEntityPersistor : ICollectionPersistor> + { + private readonly IRingtoetsEntities ringtoetsContext; + + public HydraulicLocationEntityPersistor(IRingtoetsEntities ringtoetsContext) + { + this.ringtoetsContext = ringtoetsContext; + } + + public void RemoveUnModifiedEntries(ICollection parentNavigationProperty) + { + throw new System.NotImplementedException(); + } + + public void PerformPostSaveActions() + { + throw new System.NotImplementedException(); + } + + public void LoadModel(HydraulicLocationEntity entity, ICollection model) + { + throw new System.NotImplementedException(); + } + + public void InsertModel(ICollection parentNavigationProperty, ICollection model) + { + throw new System.NotImplementedException(); + } + + public void UpdateModel(ICollection parentNavigationProperty, ICollection model) + { + throw new System.NotImplementedException(); + } + + public void ConvertEntityToModel(HydraulicLocationEntity entity, ICollection model) + { + throw new System.NotImplementedException(); + } + + public void ConvertModelToEntity(ICollection model, HydraulicLocationEntity entity) + { + throw new System.NotImplementedException(); + } + } +} Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ICollectionPersistor.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ICollectionPersistor.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ICollectionPersistor.cs (revision 92a966a0a5ae5144b90b89be0cdf30c5eea25d7d) @@ -0,0 +1,98 @@ +// 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.Data.Entity; +using System.Linq; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Exceptions; +using Core.Common.Base.Storage; +using Ringtoets.Common.Data; +using Ringtoets.Piping.Data; + +namespace Application.Ringtoets.Storage.Persistors +{ + public interface ICollectionPersistor where TEntity : class + { + /// + /// All unmodified in will be removed. + /// + /// List where objects can be searched. Usually, this collection is a navigation property of a . + /// Thrown when the is read-only. + void RemoveUnModifiedEntries(ICollection parentNavigationProperty); + + /// + /// Perform actions that can only be executed after has been called. + /// + void PerformPostSaveActions(); + + void LoadModel(TEntity entity, TModel model); + + /// + /// Ensures that the model is added as in the . + /// + /// Collection where objects can be added. Usually, this collection is a navigation property of a . + /// to be saved in the storage. + /// Thrown when: + /// is null. + /// is null. + /// + void InsertModel(ICollection parentNavigationProperty, TModel model); + + /// + /// Ensures that the is set as in the . + /// + /// Collection where objects can be searched and added. Usually, this collection is a navigation property of a . + /// to be saved in the storage. + /// Thrown when: + /// is null. + /// is null. + /// + /// Thrown when the is read-only. + /// Thrown when the storageId of > 0 and: + /// More than one element found in that should have been unique. + /// No such element exists in . + /// + void UpdateModel(ICollection parentNavigationProperty, TModel model); + + /// + /// Updates the from . + /// + /// The to update from. + /// The to update. + /// Thrown when: + /// is null. + /// is null. + /// + void ConvertEntityToModel(TEntity entity, TModel model); + + /// + /// Updates the from . + /// + /// The to update from. + /// The to update. + /// Thrown when: + /// is null. + /// + void ConvertModelToEntity(TModel model, TEntity entity); + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs =================================================================== diff -u -ra159e1199947de7db3ccd318cfa827d5865061a5 -r92a966a0a5ae5144b90b89be0cdf30c5eea25d7d --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs (.../HydraulicBoundaryLocation.cs) (revision a159e1199947de7db3ccd318cfa827d5865061a5) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs (.../HydraulicBoundaryLocation.cs) (revision 92a966a0a5ae5144b90b89be0cdf30c5eea25d7d) @@ -22,13 +22,14 @@ using System; using Core.Common.Base; using Core.Common.Base.Geometry; +using Core.Common.Base.Storage; namespace Ringtoets.HydraRing.Data { /// /// Location of an hydraulic boundary. /// - public class HydraulicBoundaryLocation : Observable + public class HydraulicBoundaryLocation : Observable, IStorable { /// /// Creates a new instance of . @@ -74,5 +75,10 @@ { return Name; } + + /// + /// Gets or sets the unique identifier for the storage of the class. + /// + public long StorageId { get; set; } } } \ No newline at end of file