Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelDatabaseReader.cs =================================================================== diff -u -r0415d97c8733babb1a31bc11de23ee4b0c5038b6 -r3bf7e84ac84de7dd0be38be7e9f2372878e733f6 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelDatabaseReader.cs (.../StochasticSoilModelDatabaseReader.cs) (revision 0415d97c8733babb1a31bc11de23ee4b0c5038b6) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelDatabaseReader.cs (.../StochasticSoilModelDatabaseReader.cs) (revision 3bf7e84ac84de7dd0be38be7e9f2372878e733f6) @@ -35,7 +35,7 @@ namespace Ringtoets.Piping.IO.SoilProfile { /// - /// This class reads a soil database file and reads from this database. + /// This class reads a soil database file and reads from this database. /// public class StochasticSoilModelDatabaseReader : SqLiteDatabaseReaderBase { @@ -58,6 +58,11 @@ /// public StochasticSoilModelDatabaseReader(string databaseFilePath) : base(databaseFilePath) { + VerifyVersion(databaseFilePath); + } + + private void VerifyVersion(string databaseFilePath) + { using (var versionReader = new SoilDatabaseVersionReader(databaseFilePath)) { try @@ -73,11 +78,11 @@ } /// - /// Reads the of failure mechanism "Piping" from the databae. + /// Reads the of failure mechanism "Piping" from the databae. /// - /// List of , read from the database. + /// List of , read from the database. /// Thrown when failed to read the database. - public IEnumerable GetStochasticSoilModelSegmentOfPiping() + public IEnumerable GetStochasticSoilModelSegmentOfPiping() { var stochasticSoilModelSegmentsQuery = SoilDatabaseQueryBuilder.GetStochasticSoilModelOfMechanismQuery(); var sqliteParameter = new SQLiteParameter @@ -100,7 +105,7 @@ } catch (SQLiteException exception) { - var message = new FileReaderErrorMessageBuilder(Path).Build(Resources.StochasticSoilModelDatabaseReader_failed_to_read_database); + var message = new FileReaderErrorMessageBuilder(Path).Build(Resources.StochasticSoilModelDatabaseReader_Failed_to_read_database); throw new CriticalFileReadException(message, exception); } } @@ -114,10 +119,10 @@ base.Dispose(); } - private IEnumerable ReadStochasticSoilModels(SQLiteDataReader dataReader) + private IEnumerable ReadStochasticSoilModels(SQLiteDataReader dataReader) { - var segmentSoilModels = new List(); - StochasticSoilModelSegment currentStochasticSoilModelSegment = null; + var segmentSoilModels = new List(); + StochasticSoilModel currentStochasticSoilModelSegment = null; while (MoveNext(dataReader)) { // Read Points @@ -148,7 +153,7 @@ // Add segmentSoilModels.Add(segmentSoilModel); } - currentStochasticSoilModelSegment.SegmentPoints.Add(point2D); + currentStochasticSoilModelSegment.Geometry.Add(point2D); } return segmentSoilModels; } @@ -166,9 +171,9 @@ return true; } - private IEnumerable ReadStochasticSoilProfileProbability(long stochasticSoilModelId) + private IEnumerable ReadStochasticSoilProfileProbability(long stochasticSoilModelId) { - var probabilityList = new List(); + var probabilityList = new List(); try { long currentStochasticSoilModelId; @@ -194,7 +199,7 @@ { if (exception is FormatException || exception is OverflowException || exception is InvalidCastException) { - log.Warn(Resources.StochasticSoilModelDatabaseReader_failed_to_read_soil_model); + log.Warn(Resources.StochasticSoilModelDatabaseReader_Failed_to_read_soil_model); return null; } throw; @@ -207,7 +212,7 @@ return Convert.ToInt64(dataReader[StochasticSoilProfileDatabaseColumns.StochasticSoilModelId]); } - private static StochasticSoilProfileProbability ReadStochasticSoilProfileProbability(SQLiteDataReader dataReader) + private static StochasticSoilProfile ReadStochasticSoilProfileProbability(SQLiteDataReader dataReader) { var valueSoilProfile1DId = dataReader[StochasticSoilProfileDatabaseColumns.SoilProfile1DId]; var valueSoilProfile2DId = dataReader[StochasticSoilProfileDatabaseColumns.SoilProfile2DId]; @@ -218,23 +223,23 @@ if (!valueSoilProfile1DId.Equals(DBNull.Value)) { var soilProfileId = Convert.ToInt64(valueSoilProfile1DId); - return new StochasticSoilProfileProbability(probability, SoilProfileType.SoilProfile1D, soilProfileId); + return new StochasticSoilProfile(probability, SoilProfileType.SoilProfile1D, soilProfileId); } if (!valueSoilProfile2DId.Equals(DBNull.Value)) { var soilProfileId = Convert.ToInt64(valueSoilProfile2DId); - return new StochasticSoilProfileProbability(probability, SoilProfileType.SoilProfile2D, soilProfileId); + return new StochasticSoilProfile(probability, SoilProfileType.SoilProfile2D, soilProfileId); } - log.Warn(Resources.StochasticSoilModelDatabaseReader_failed_to_read_soil_model); + log.Warn(Resources.StochasticSoilModelDatabaseReader_Failed_to_read_soil_model); return null; } - private static StochasticSoilModelSegment ReadStochasticSoilModelSegment(SQLiteDataReader dataReader) + private static StochasticSoilModel ReadStochasticSoilModelSegment(SQLiteDataReader dataReader) { var stochasticSoilModelId = Convert.ToInt64(dataReader[StochasticSoilModelDatabaseColumns.StochasticSoilModelId]); var stochasticSoilModelName = Convert.ToString(dataReader[StochasticSoilModelDatabaseColumns.StochasticSoilModelName]); var segmentName = Convert.ToString(dataReader[SegmentDatabaseColumns.SegmentName]); - return new StochasticSoilModelSegment(stochasticSoilModelId, stochasticSoilModelName, segmentName); + return new StochasticSoilModel(stochasticSoilModelId, stochasticSoilModelName, segmentName); } private static Point2D ReadSegmentPoint(SQLiteDataReader dataReader)