//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2022, Hiperscan GmbH Dresden, Germany
//
//    This program 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 <http://www.gnu.org/licenses/>.


using System;
using System.IO;

using Hiperscan.Common.I18n;
using Hiperscan.Spectroscopy.IO;
using Hiperscan.Unix;

namespace Hiperscan.ApoIdentCommon.ApoConfig
{
    public partial class ProfileSettings
    {
        public const string QUERY_DIR = ".QueryMetaData";

        public void CheckMissingArchive() => this.ArchiveMissing = false == FileIO.ExistsDirectory(this.Archive);

        public void CreateMetaDataDir()
        {
            if (CatalogLocale.GetLocaleType() != CatalogLocale.LocaleType.Unknown)
            {
                FileIO.CreateDirectoryIfNotExists(this.LocalizedMetaDir, FileAttributes.Hidden);
            }
        }

        public string Archive { get; set; }

        public string ArchiveYearDir
        {
            get
            {
                return Path.Combine(this.Archive, DateTime.Now.ToString("yyyy"));
            }
        }

        public string ArchiveReferencingDir
        {
            get
            {
                return Path.Combine(this.Archive, SpectrumDirNames.REFERENCING);
            }
        }

        public string ArchiveQueryDir
        {
            get
            {
                return Path.Combine(this.ArchiveYearDir, ProfileSettings.QUERY_DIR);
            }
        }

        public string LocalizedMetaDir
        {
            get
            {
                return Path.Combine(this.Archive,
                                    ".meta",
                                    CatalogLocale.GetLocaleType().ToString());
            }
        }

        public string ModelClassExtensionFile
        {
            get
            {
                return Path.Combine(this.LocalizedMetaDir, "user_defined_substances.xml");
            }
        }

        public string AdditionalTestAutoCompletionFile
        {
            get
            {
                return Path.Combine(this.LocalizedMetaDir, "additional_test_auto_completion.xml");
            }
        }

        public string BakAutoCompletionFile
        {
            get
            {
                return Path.Combine(this.LocalizedMetaDir, "bak_auto_completion.xml");
            }
        }

        public string GracePeriodAutoCompletionFile
        {
            get
            {
                return Path.Combine(this.LocalizedMetaDir, "grace_period_auto_completion.xml");
            }
        }
    }
}
