Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves the urn map.
        /// </summary>
        /// <param name="sdmxStructure">The SDMX structure.</param>
        /// <returns>
        /// The map between System ID to URN
        /// </returns>
        public IDictionary <long, string> RetrievesUrnMap(SdmxStructureType sdmxStructure)
        {
            string query;

            if (sdmxStructure.IsMaintainable)
            {
                TableInfo tableInfo = this._tableInfoBuilder.Build(sdmxStructure);
                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT A.ART_ID as SYSID, A.AGENCY, A.ID, A.VERSION FROM ARTEFACT_VIEW A WHERE A.ART_ID in (SELECT {0} FROM {1})",
                    tableInfo.PrimaryKey,
                    tableInfo.Table);
                IDictionary <long, string> dictionary = new Dictionary <long, string>();
                foreach (dynamic o in this._mappingStoreDatabase.Query(query))
                {
                    long sysid = o.SYSID;

                    Uri generateUrn = sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION);
                    var result      = new KeyValuePair <long, string>(sysid, generateUrn.ToString());
                    dictionary.Add(result);
                }

                return(dictionary);
            }
            else
            {
                var itemTableInfo = this._itemTableInfoBuilder.Build(sdmxStructure);
                if (itemTableInfo == null)
                {
                    throw new NotImplementedException(sdmxStructure.ToString());
                }

                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT I.ITEM_ID as SYSID, A.AGENCY, A.ID, A.VERSION, I.ID as IID FROM ARTEFACT_VIEW A INNER JOIN {1} T ON A.ART_ID = T.{2} INNER JOIN ITEM I ON I.ITEM_ID = T.{0}",
                    itemTableInfo.PrimaryKey,
                    itemTableInfo.Table,
                    itemTableInfo.ForeignKey);
                IDictionary <long, string> dictionary = new Dictionary <long, string>();
                foreach (dynamic o in this._mappingStoreDatabase.Query(query))
                {
                    Uri  generateUrn = sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION, o.IID);
                    long systemId    = o.SYSID;
                    var  result      = new KeyValuePair <long, string>(systemId, generateUrn.ToString());
                    dictionary.Add(result);
                }

                return(dictionary);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieves the urn map.
        /// </summary>
        /// <param name="sdmxStructure">The SDMX structure.</param>
        /// <returns>
        /// The map between System ID to URN
        /// </returns>
        public IDictionary <string, long> RetrievesUrnToSysIdMap(SdmxStructureType sdmxStructure)
        {
            string query;

            if (sdmxStructure.IsMaintainable)
            {
                TableInfo tableInfo = this._tableInfoBuilder.Build(sdmxStructure);
                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT A.ART_ID as SYSID, A.AGENCY, A.ID, A.VERSION FROM ARTEFACT_VIEW A WHERE A.ART_ID in (SELECT {0} FROM {1})",
                    tableInfo.PrimaryKey,
                    tableInfo.Table);
                IDictionary <string, long> dictionary = new Dictionary <string, long>(StringComparer.Ordinal);
                foreach (var result in this._mappingStoreDatabase.Query(query).Select(o => new KeyValuePair <string, long>(sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION).ToString(), o.SYSID)))
                {
                    Debug.Assert(!dictionary.ContainsKey(result.Key), "Already got key : {0}", result.Key);
                    dictionary.Add(result);
                }

                return(dictionary);
            }
            else
            {
                var itemTableInfo = this._itemTableInfoBuilder.Build(sdmxStructure);
                if (itemTableInfo == null)
                {
                    throw new NotImplementedException(sdmxStructure.ToString());
                }

                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT I.ITEM_ID as SYSID, A.AGENCY, A.ID, A.VERSION, I.ID as IID FROM ARTEFACT_VIEW A INNER JOIN {1} T ON A.ART_ID = T.{2} INNER JOIN ITEM I ON I.ITEM_ID = T.{0}",
                    itemTableInfo.PrimaryKey,
                    itemTableInfo.Table,
                    itemTableInfo.ForeignKey);
                IDictionary <string, long> dictionary = new Dictionary <string, long>(StringComparer.Ordinal);
                foreach (var result in this._mappingStoreDatabase.Query(query).Select(o => new KeyValuePair <string, long>(sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION, o.IID).ToString(), o.SYSID)))
                {
                    dictionary.Add(result);
                }

                return(dictionary);
            }
        }
        /// <summary>
        /// Retrieves the urn map.
        /// </summary>
        /// <param name="sdmxStructure">The SDMX structure.</param>
        /// <returns>
        /// The map between System ID to URN
        /// </returns>
        public IDictionary<string, long> RetrievesUrnToSysIdMap(SdmxStructureType sdmxStructure)
        {
            string query;
            if (sdmxStructure.IsMaintainable)
            {
                TableInfo tableInfo = this._tableInfoBuilder.Build(sdmxStructure);
                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT A.ART_ID as SYSID, A.AGENCY, A.ID, A.VERSION FROM ARTEFACT_VIEW A WHERE A.ART_ID in (SELECT {0} FROM {1})",
                    tableInfo.PrimaryKey,
                    tableInfo.Table);
                IDictionary<string, long> dictionary = new Dictionary<string, long>(StringComparer.Ordinal);
                foreach (var result in this._mappingStoreDatabase.Query(query).Select(o => new KeyValuePair<string, long>(sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION).ToString(), o.SYSID)))
                {
                    Debug.Assert(!dictionary.ContainsKey(result.Key), "Already got key : {0}", result.Key);
                    dictionary.Add(result);
                }

                return dictionary;
            }
            else
            {
                var itemTableInfo = this._itemTableInfoBuilder.Build(sdmxStructure);
                if (itemTableInfo == null)
                {
                    throw new NotImplementedException(sdmxStructure.ToString());
                }

                query = string.Format(
                   CultureInfo.InvariantCulture,
                    "SELECT I.ITEM_ID as SYSID, A.AGENCY, A.ID, A.VERSION, I.ID as IID FROM ARTEFACT_VIEW A INNER JOIN {1} T ON A.ART_ID = T.{2} INNER JOIN ITEM I ON I.ITEM_ID = T.{0}",
                   itemTableInfo.PrimaryKey,
                   itemTableInfo.Table,
                   itemTableInfo.ForeignKey);
                IDictionary<string, long> dictionary = new Dictionary<string, long>(StringComparer.Ordinal);
                foreach (var result in this._mappingStoreDatabase.Query(query).Select(o => new KeyValuePair<string, long>(sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION, o.IID).ToString(), o.SYSID)))
                {
                    dictionary.Add(result);
                }

                return dictionary;
            }
        }
        /// <summary>
        /// Retrieves the urn map.
        /// </summary>
        /// <param name="sdmxStructure">The SDMX structure.</param>
        /// <returns>
        /// The map between System ID to URN
        /// </returns>
        public IDictionary<long, string> RetrievesUrnMap(SdmxStructureType sdmxStructure)
        {
            string query;
            if (sdmxStructure.IsMaintainable)
            {
                TableInfo tableInfo = this._tableInfoBuilder.Build(sdmxStructure);
                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT A.ART_ID as SYSID, A.AGENCY, A.ID, A.VERSION FROM ARTEFACT_VIEW A WHERE A.ART_ID in (SELECT {0} FROM {1})",
                    tableInfo.PrimaryKey,
                    tableInfo.Table);
                IDictionary<long, string> dictionary = new Dictionary<long, string>();
                foreach (dynamic o in this._mappingStoreDatabase.Query(query))
                {
                    long sysid = o.SYSID;

                    Uri generateUrn = sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION);
                    var result = new KeyValuePair<long, string>(sysid, generateUrn.ToString());
                    dictionary.Add(result);
                }

                return dictionary;
            }
            else
            {
                var itemTableInfo = this._itemTableInfoBuilder.Build(sdmxStructure);
                if (itemTableInfo == null)
                {
                    throw new NotImplementedException(sdmxStructure.ToString());
                }

                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT I.ITEM_ID as SYSID, A.AGENCY, A.ID, A.VERSION, I.ID as IID FROM ARTEFACT_VIEW A INNER JOIN {1} T ON A.ART_ID = T.{2} INNER JOIN ITEM I ON I.ITEM_ID = T.{0}",
                    itemTableInfo.PrimaryKey,
                    itemTableInfo.Table,
                    itemTableInfo.ForeignKey);
                IDictionary<long, string> dictionary = new Dictionary<long, string>();
                foreach (dynamic o in this._mappingStoreDatabase.Query(query))
                {
                    Uri generateUrn = sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION, o.IID);
                    long systemId = o.SYSID;
                    var result = new KeyValuePair<long, string>(systemId, generateUrn.ToString());
                    dictionary.Add(result);
                }

                return dictionary;
            }
        }