Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r85053cd7be8aa42587cc2b0e25d6b98b5a5c2893 -r6946691cf40fe32509dcaaa5266600b165954319
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 85053cd7be8aa42587cc2b0e25d6b98b5a5c2893)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -63,6 +63,11 @@
Properties\GlobalAssembly.cs
+
+
+
+ RingtoetsEntities.tt
+
@@ -112,6 +117,10 @@
{c90b77da-e421-43cc-b82e-529651bc21ac}
Core.Common.Version
+
+ {11F1F874-45AF-43E4-8AE5-15A5C9593E28}
+ Ringtoets.Integration.Data
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/DikeAssessmentSectionEntityConverter.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/DikeAssessmentSectionEntityConverter.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/DikeAssessmentSectionEntityConverter.cs (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -0,0 +1,63 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Ringtoets.Integration.Data;
+
+namespace Application.Ringtoets.Storage.Converters
+{
+ ///
+ /// Converter for to
+ /// and to .
+ ///
+ public class DikeAssessmentSectionEntityConverter : IEntityConverter
+ {
+ ///
+ /// Converts to .
+ ///
+ /// The to convert.
+ /// A new instance of , based on the properties of .
+ /// Thrown when is null.
+ public DikeAssessmentSection ConvertEntityToModel(DikeAssessmentSectionEntity entity)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+ var dikeAssessmentSection = new DikeAssessmentSection
+ {
+ StorageId = entity.DikeAssessmentSectionEntityId,
+ Name = entity.Name
+ };
+
+ if (entity.Norm != null)
+ {
+ dikeAssessmentSection.FailureMechanismContribution.Norm = entity.Norm.Value;
+ }
+
+ return dikeAssessmentSection;
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The to convert.
+ /// A reference to the to be saved.
+ /// Thrown when:
+ /// - is null
+ /// - is null.
+ ///
+ public void ConvertModelToEntity(DikeAssessmentSection modelObject, DikeAssessmentSectionEntity entity)
+ {
+ if (modelObject == null)
+ {
+ throw new ArgumentNullException("modelObject");
+ }
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+ entity.DikeAssessmentSectionEntityId = modelObject.StorageId;
+ entity.Name = modelObject.Name;
+ entity.Norm = modelObject.FailureMechanismContribution.Norm;
+ }
+ }
+}
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/IEntityConverter.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/IEntityConverter.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/IEntityConverter.cs (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -0,0 +1,19 @@
+namespace Application.Ringtoets.Storage.Converters
+{
+ public interface IEntityConverter
+ {
+ ///
+ /// Converts to .
+ ///
+ /// The to convert.
+ /// A new instance of , based on the properties of .
+ T1 ConvertEntityToModel(T2 entity);
+
+ ///
+ /// Converts to .
+ ///
+ /// The to convert.
+ /// A reference to the to be saved.
+ void ConvertModelToEntity(T1 modelObject, T2 entity);
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql
===================================================================
diff -u -rbcbae879035d5472efff973990ba1194e38b2ea5 -r6946691cf40fe32509dcaaa5266600b165954319
--- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision bcbae879035d5472efff973990ba1194e38b2ea5)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -1,5 +1,5 @@
--
--- File generated with SQLiteStudio v3.0.7 on Fri Jan 15 14:48:04 2016
+-- File generated with SQLiteStudio v3.0.7 on Mon Jan 25 12:12:02 2016
--
-- Text encoding used: windows-1252
--
@@ -8,11 +8,41 @@
-- Table: Version
DROP TABLE IF EXISTS Version;
-CREATE TABLE Version (VersionId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FromVersion VARCHAR (50), ToVersion VARCHAR (50), Timestamp NUMERIC);
+CREATE TABLE Version (
+ VersionId INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ FromVersion VARCHAR (50),
+ ToVersion VARCHAR (50),
+ Timestamp NUMERIC
+);
+
+
+-- Table: DikeAssessmentSectionEntity
+DROP TABLE IF EXISTS DikeAssessmentSectionEntity;
+
+CREATE TABLE DikeAssessmentSectionEntity (
+ DikeAssessmentSectionEntityId INTEGER PRIMARY KEY AUTOINCREMENT
+ NOT NULL,
+ ProjectEntityId INTEGER REFERENCES ProjectEntity (ProjectEntityId) ON DELETE CASCADE
+ ON UPDATE CASCADE
+ NOT NULL,
+ Name VARCHAR (1024),
+ Norm INT
+);
+
+
-- Table: ProjectEntity
DROP TABLE IF EXISTS ProjectEntity;
-CREATE TABLE ProjectEntity (ProjectEntityId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Name VARCHAR (1024), Description VARCHAR (1024), LastUpdated INTEGER DEFAULT (CURRENT_TIMESTAMP));
+CREATE TABLE ProjectEntity (
+ ProjectEntityId INTEGER NOT NULL
+ PRIMARY KEY AUTOINCREMENT,
+ Name VARCHAR (1024),
+ Description VARCHAR (1024),
+ LastUpdated INTEGER DEFAULT (CURRENT_TIMESTAMP)
+);
+
+
COMMIT TRANSACTION;
PRAGMA foreign_keys = on;
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DikeAssessmentSectionEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DikeAssessmentSectionEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DikeAssessmentSectionEntity.cs (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -0,0 +1,24 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ using System;
+ using System.Collections.Generic;
+
+ public partial class DikeAssessmentSectionEntity
+ {
+ public long DikeAssessmentSectionEntityId { get; set; }
+ public long ProjectEntityId { get; set; }
+ public string Name { get; set; }
+ public Nullable Norm { get; set; }
+
+ public virtual ProjectEntity ProjectEntity { get; set; }
+ }
+}
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ProjectEntity.cs
===================================================================
diff -u -ra01c8d560f9fc30520fc717d83888a3bf6974cc9 -r6946691cf40fe32509dcaaa5266600b165954319
--- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ProjectEntity.cs (.../ProjectEntity.cs) (revision a01c8d560f9fc30520fc717d83888a3bf6974cc9)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/ProjectEntity.cs (.../ProjectEntity.cs) (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -14,9 +14,18 @@
public partial class ProjectEntity
{
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+ public ProjectEntity()
+ {
+ this.DikeAssessmentSectionEntities = new HashSet();
+ }
+
public long ProjectEntityId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Nullable LastUpdated { get; set; }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public virtual ICollection DikeAssessmentSectionEntities { get; set; }
}
}
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs
===================================================================
diff -u -ra01c8d560f9fc30520fc717d83888a3bf6974cc9 -r6946691cf40fe32509dcaaa5266600b165954319
--- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision a01c8d560f9fc30520fc717d83888a3bf6974cc9)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Context.cs (.../RingtoetsEntities.Context.cs) (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -27,5 +27,6 @@
public virtual IDbSet ProjectEntities { get; set; }
public virtual IDbSet Versions { get; set; }
+ public virtual IDbSet DikeAssessmentSectionEntities { get; set; }
}
}
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs
===================================================================
diff -u -rf104a6357c644e0ddb7c9fd94271cc7e14d49c59 -r6946691cf40fe32509dcaaa5266600b165954319
--- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs (.../RingtoetsEntities.Designer.cs) (revision f104a6357c644e0ddb7c9fd94271cc7e14d49c59)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs (.../RingtoetsEntities.Designer.cs) (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -1,4 +1,4 @@
-// T4 code generation is enabled for model 'Application\Ringtoets\src\Application.Ringtoets.Storage\DbContext\RingtoetsEntities.edmx'.
+// T4 code generation is enabled for model 'D:\Projects\WTI\trunk\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 -rf104a6357c644e0ddb7c9fd94271cc7e14d49c59 -r6946691cf40fe32509dcaaa5266600b165954319
--- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision f104a6357c644e0ddb7c9fd94271cc7e14d49c59)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -4,7 +4,16 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -23,9 +32,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -39,6 +65,7 @@
+
@@ -52,7 +79,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -79,6 +133,16 @@
+
+
+
+
+
+
+
+
+
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram
===================================================================
diff -u -ra01c8d560f9fc30520fc717d83888a3bf6974cc9 -r6946691cf40fe32509dcaaa5266600b165954319
--- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision a01c8d560f9fc30520fc717d83888a3bf6974cc9)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -7,6 +7,8 @@
+
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Ringtoets.rtd
===================================================================
diff -u -rf104a6357c644e0ddb7c9fd94271cc7e14d49c59 -r6946691cf40fe32509dcaaa5266600b165954319
Binary files differ
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r468ee58c212f14704baa1992fe906da456448ff5 -r6946691cf40fe32509dcaaa5266600b165954319
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 468ee58c212f14704baa1992fe906da456448ff5)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -71,6 +71,8 @@
+
+
@@ -91,6 +93,10 @@
{D749EE4C-CE50-4C17-BF01-9A953028C126}
Core.Common.TestUtil
+
+ {11f1f874-45af-43e4-8ae5-15a5c9593e28}
+ Ringtoets.Integration.Data
+
{50963f12-448c-41ba-a62c-cdb0ab8d21e0}
Application.Ringtoets.Storage
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converter/DikeAssessmentSectionEntityConverterTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converter/DikeAssessmentSectionEntityConverterTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converter/DikeAssessmentSectionEntityConverterTest.cs (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -0,0 +1,110 @@
+using System;
+using Application.Ringtoets.Storage.Converters;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+using Ringtoets.Integration.Data;
+
+namespace Application.Ringtoets.Storage.Test.Converter
+{
+ [TestFixture]
+ public class DikeAssessmentSectionEntityConverterTest
+ {
+ [Test]
+ public void ConvertEntityToModel_NullEntity_ThrowsArgumentNullException()
+ {
+ // SetUp
+ DikeAssessmentSectionEntityConverter converter = new DikeAssessmentSectionEntityConverter();
+
+ // Call
+ TestDelegate test = () => converter.ConvertEntityToModel(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void ConvertEntityToModel_ValidDikeAssessmentSectionEntity_ReturnsTheDikeAssessmentSectionEntityAsDikeAssessmentSection()
+ {
+ // SetUp
+ const long storageId = 1234L;
+ const long projectId = 1L;
+ const int norm = 30000;
+ const string name = "test";
+ DikeAssessmentSectionEntity dikeAssessmentSectionEntity = new DikeAssessmentSectionEntity()
+ {
+ DikeAssessmentSectionEntityId = storageId,
+ Name = name,
+ ProjectEntityId = projectId,
+ Norm = norm
+ };
+ DikeAssessmentSectionEntityConverter converter = new DikeAssessmentSectionEntityConverter();
+
+ // Call
+ DikeAssessmentSection assessmentSection = converter.ConvertEntityToModel(dikeAssessmentSectionEntity);
+
+ // Assert
+ Assert.AreNotEqual(dikeAssessmentSectionEntity, assessmentSection);
+ Assert.AreEqual(storageId, assessmentSection.StorageId);
+ Assert.AreEqual(name, assessmentSection.Name);
+ Assert.AreEqual(norm, assessmentSection.FailureMechanismContribution.Norm);
+ }
+
+ [Test]
+ public void ConvertModelToEntity_NullEntity_ThrowsArgumentNullException()
+ {
+ // SetUp
+ DikeAssessmentSectionEntityConverter converter = new DikeAssessmentSectionEntityConverter();
+ DikeAssessmentSection dikeAssessmentSection = new DikeAssessmentSection();
+
+ // Call
+ TestDelegate test = () => converter.ConvertModelToEntity(dikeAssessmentSection, null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void ConvertModelToEntity_NullModel_ThrowsArgumentNullException()
+ {
+ // SetUp
+ DikeAssessmentSectionEntityConverter converter = new DikeAssessmentSectionEntityConverter();
+ DikeAssessmentSectionEntity dikeAssessmentSectionEntity = new DikeAssessmentSectionEntity();
+
+ // Call
+ TestDelegate test = () => converter.ConvertModelToEntity(null, dikeAssessmentSectionEntity);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void ConvertModelToEntity_ValidDikeAssessmentSection_UpdatesTheDikeAssessmentSectionAsDikeAssessmentSectionEntity()
+ {
+ // SetUp
+ const long storageId = 1234L;
+ const long projectId = 1L;
+ const int norm = 30000;
+ const string name = "test";
+ DikeAssessmentSection dikeAssessmentSection = new DikeAssessmentSection
+ {
+ StorageId = storageId,
+ Name = name
+ };
+ dikeAssessmentSection.FailureMechanismContribution.Norm = norm;
+ DikeAssessmentSectionEntity dikeAssessmentSectionEntity = new DikeAssessmentSectionEntity
+ {
+ ProjectEntityId = projectId
+ };
+ DikeAssessmentSectionEntityConverter converter = new DikeAssessmentSectionEntityConverter();
+
+ // Call
+ converter.ConvertModelToEntity(dikeAssessmentSection, dikeAssessmentSectionEntity);
+
+ // Assert
+ Assert.AreNotEqual(dikeAssessmentSectionEntity, dikeAssessmentSection);
+ Assert.AreEqual(storageId, dikeAssessmentSection.StorageId);
+ Assert.AreEqual(name, dikeAssessmentSection.Name);
+ Assert.AreEqual(norm, dikeAssessmentSection.FailureMechanismContribution.Norm);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/DbContext/DbSet.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/DbContext/DbSet.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/DbContext/DbSet.cs (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using System.Data.Entity;
+using System.Linq;
+using Rhino.Mocks;
+
+namespace Application.Ringtoets.Storage.Test.DbContext
+{
+ public static class DbSet {
+ public static IDbSet GetDbSetTest(IList data) where T : class
+ {
+ var queryable = data.AsQueryable();
+
+ var dbSet = MockRepository.GenerateMock, IQueryable>();
+
+ dbSet.Stub(m => m.Provider).Return(queryable.Provider);
+ dbSet.Stub(m => m.Expression).Return(queryable.Expression);
+ dbSet.Stub(m => m.ElementType).Return(queryable.ElementType);
+ dbSet.Stub(m => m.GetEnumerator()).Return(queryable.GetEnumerator());
+ return dbSet;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/test-data/DatabaseFiles/ValidRingtoetsDatabase.rtd
===================================================================
diff -u -rf104a6357c644e0ddb7c9fd94271cc7e14d49c59 -r6946691cf40fe32509dcaaa5266600b165954319
Binary files differ
Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/AssessmentSectionBase.cs
===================================================================
diff -u -r75aa4fefacf584d5172dc3bdffd348b0aacb05a4 -r6946691cf40fe32509dcaaa5266600b165954319
--- Ringtoets/Integration/src/Ringtoets.Integration.Data/AssessmentSectionBase.cs (.../AssessmentSectionBase.cs) (revision 75aa4fefacf584d5172dc3bdffd348b0aacb05a4)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Data/AssessmentSectionBase.cs (.../AssessmentSectionBase.cs) (revision 6946691cf40fe32509dcaaa5266600b165954319)
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Core.Common.Base;
-
+using Core.Common.Base.Storage;
using Ringtoets.Common.Data;
using Ringtoets.Common.Placeholder;
using Ringtoets.Integration.Data.Contribution;
@@ -12,7 +12,7 @@
///
/// Base implementation of assessment sections.
///
- public abstract class AssessmentSectionBase : Observable
+ public abstract class AssessmentSectionBase : Observable, IStorable
{
///
/// Initializes a new instance of the class.
@@ -48,5 +48,10 @@
/// Gets the failure mechanisms corresponding to the assessment section.
///
public abstract IEnumerable GetFailureMechanisms();
+
+ ///
+ /// Gets or sets the unique identifier for the storage of the class.
+ ///
+ public long StorageId { get; set; }
}
}
\ No newline at end of file