Exemplo n.º 1
0
        /// <summary>
        /// Declares a new empty virtual dataset with the given Name.  This will not have any virtual columns and will not be tied to any underlying tables.
        ///
        /// <para>The preferred method of getting a Catalogue is to use <see cref="TableInfoImporter"/> and <see cref="ForwardEngineerCatalogue"/></para>
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="name"></param>
        public Catalogue(ICatalogueRepository repository, string name)
        {
            var loggingServer = repository.GetServerDefaults().GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID);

            repository.InsertAndHydrate(this, new Dictionary <string, object>()
            {
                { "Name", name },
                { "LiveLoggingServer_ID", loggingServer == null ? (object)DBNull.Value:loggingServer.ID }
            });

            if (ID == 0 || string.IsNullOrWhiteSpace(Name) || Repository != repository)
            {
                throw new ArgumentException("Repository failed to properly hydrate this class");
            }

            //default values
            if (Folder == null)
            {
                Folder = new CatalogueFolder(this, "\\");
            }

            //if there is a default logging server
            if (LiveLoggingServer_ID == null)
            {
                var liveLoggingServer = repository.GetServerDefaults().GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID);

                if (liveLoggingServer != null)
                {
                    LiveLoggingServer_ID = liveLoggingServer.ID;
                }
            }


            ClearAllInjections();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns true if the passed value is resident in a subfolder of this one.
        /// </summary>
        /// <param name="potentialParent"></param>
        /// <returns></returns>
        public bool IsSubFolderOf(CatalogueFolder potentialParent)
        {
            if (potentialParent == null)
            {
                return(false);
            }

            //they are the same folder so not subfoldres
            if (Path.Equals(potentialParent.Path))
            {
                return(false);
            }

            //we contain the potential parents path therefore we are a child of them
            return(Path.StartsWith(potentialParent.Path));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a single runtime instance of the Catalogue based on the current state of the row read from the DbDataReader (does not advance the reader)
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="r"></param>
        internal Catalogue(ICatalogueRepository repository, DbDataReader r)
            : base(repository, r)
        {
            if (r["LoadMetadata_ID"] != DBNull.Value)
            {
                LoadMetadata_ID = int.Parse(r["LoadMetadata_ID"].ToString());
            }

            Acronym     = r["Acronym"].ToString();
            Name        = r["Name"].ToString();
            Description = r["Description"].ToString();

            //detailed info url with support for invalid urls
            Detail_Page_URL = ParseUrl(r, "Detail_Page_URL");

            LoggingDataTask = r["LoggingDataTask"] as string;

            if (r["LiveLoggingServer_ID"] == DBNull.Value)
            {
                LiveLoggingServer_ID = null;
            }
            else
            {
                LiveLoggingServer_ID = (int)r["LiveLoggingServer_ID"];
            }

            ////Type - with handling for invalid enum values listed in database
            object type = r["Type"];

            if (type == null || type == DBNull.Value)
            {
                Type = CatalogueType.Unknown;
            }
            else
            {
                CatalogueType typeAsEnum;

                if (CatalogueType.TryParse(type.ToString(), true, out typeAsEnum))
                {
                    Type = typeAsEnum;
                }
                else
                {
                    throw new Exception(" r[\"Type\"] had value " + type + " which is not contained in Enum CatalogueType");
                }
            }

            //Periodicity - with handling for invalid enum values listed in database
            object periodicity = r["Periodicity"];

            if (periodicity == null || periodicity == DBNull.Value)
            {
                Periodicity = CataloguePeriodicity.Unknown;
            }
            else
            {
                CataloguePeriodicity periodicityAsEnum;

                if (CataloguePeriodicity.TryParse(periodicity.ToString(), true, out periodicityAsEnum))
                {
                    Periodicity = periodicityAsEnum;
                }
                else
                {
                    throw new Exception(" r[\"Periodicity\"] had value " + periodicity + " which is not contained in Enum CataloguePeriodicity");
                }
            }

            object granularity = r["Granularity"];

            if (granularity == null || granularity == DBNull.Value)
            {
                Granularity = CatalogueGranularity.Unknown;
            }
            else
            {
                CatalogueGranularity granularityAsEnum;

                if (CatalogueGranularity.TryParse(granularity.ToString(), true, out granularityAsEnum))
                {
                    Granularity = granularityAsEnum;
                }
                else
                {
                    throw new Exception(" r[\"granularity\"] had value " + granularity + " which is not contained in Enum CatalogueGranularity");
                }
            }

            Geographical_coverage = r["Geographical_coverage"].ToString();
            Background_summary    = r["Background_summary"].ToString();
            Search_keywords       = r["Search_keywords"].ToString();
            Update_freq           = r["Update_freq"].ToString();
            Update_sched          = r["Update_sched"].ToString();
            Time_coverage         = r["Time_coverage"].ToString();
            SubjectNumbers        = r["SubjectNumbers"].ToString();

            object dt = r["Last_revision_date"];

            if (dt == null || dt == DBNull.Value)
            {
                Last_revision_date = null;
            }
            else
            {
                Last_revision_date = (DateTime)dt;
            }

            Contact_details      = r["Contact_details"].ToString();
            Resource_owner       = r["Resource_owner"].ToString();
            Attribution_citation = r["Attribution_citation"].ToString();
            Access_options       = r["Access_options"].ToString();

            Country_of_origin                = r["Country_of_origin"].ToString();
            Data_standards                   = r["Data_standards"].ToString();
            Administrative_contact_name      = r["Administrative_contact_name"].ToString();
            Administrative_contact_email     = r["Administrative_contact_email"].ToString();
            Administrative_contact_telephone = r["Administrative_contact_telephone"].ToString();
            Administrative_contact_address   = r["Administrative_contact_address"].ToString();
            Ethics_approver                  = r["Ethics_approver"].ToString();
            Source_of_data_collection        = r["Source_of_data_collection"].ToString();

            if (r["Explicit_consent"] != null && r["Explicit_consent"] != DBNull.Value)
            {
                Explicit_consent = (bool)r["Explicit_consent"];
            }

            TimeCoverage_ExtractionInformation_ID  = ObjectToNullableInt(r["TimeCoverage_ExtractionInformation_ID"]);
            PivotCategory_ExtractionInformation_ID = ObjectToNullableInt(r["PivotCategory_ExtractionInformation_ID"]);

            object oDatasetStartDate = r["DatasetStartDate"];

            if (oDatasetStartDate == null || oDatasetStartDate == DBNull.Value)
            {
                DatasetStartDate = null;
            }
            else
            {
                DatasetStartDate = (DateTime)oDatasetStartDate;
            }


            ValidatorXML = r["ValidatorXML"] as string;

            Ticket = r["Ticket"] as string;

            //detailed info url with support for invalid urls
            API_access_URL       = ParseUrl(r, "API_access_URL");
            Browse_URL           = ParseUrl(r, "Browse_URL");
            Bulk_Download_URL    = ParseUrl(r, "Bulk_Download_URL");
            Query_tool_URL       = ParseUrl(r, "Query_tool_URL");
            Source_URL           = ParseUrl(r, "Source_URL");
            IsDeprecated         = (bool)r["IsDeprecated"];
            IsInternalDataset    = (bool)r["IsInternalDataset"];
            IsColdStorageDataset = (bool)r["IsColdStorageDataset"];

            Folder = new CatalogueFolder(this, r["Folder"].ToString());

            ClearAllInjections();
        }