// 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 Core.Common.Utils; using Migration.Scripts.Data.Exceptions; namespace Migration.Scripts.Data { /// /// Class that provides methods for the creating an for a specific version. /// public abstract class CreateScript { protected readonly string CreateQuery; private readonly string version; /// /// Creates a new instance of the class. /// /// The version was designed for. /// The SQL query that belongs to . /// Thrown when: /// /// is empty or null, /// is empty, null, or consist out of only whitespace characters. /// protected CreateScript(string version, string query) { if (string.IsNullOrEmpty(version)) { throw new ArgumentException(@"Version must have a value.", nameof(version)); } if (string.IsNullOrWhiteSpace(query)) { throw new ArgumentException(@"Query must have a value.", nameof(query)); } this.version = version; CreateQuery = query; } /// /// Creates a new at . /// /// The location to store the . /// A new . /// Thrown when : /// /// is empty or null, /// consists out of only whitespace characters, /// contains an invalid character, /// ends with a directory or path separator (empty file name), /// is not writable. /// /// Thrown when creating /// failed. public IVersionedFile CreateEmptyVersionedFile(string location) { IOUtils.ValidateFilePathIsWritable(location); return GetEmptyVersionedFile(location); } /// /// Gets the version was created for. /// /// The version. public string Version() { return version; } /// /// Creates a new at . /// /// The location to store the . /// A new . /// The has been verified in . /// Thrown when creating /// failed. protected abstract IVersionedFile GetEmptyVersionedFile(string location); } }