Exemplo n.º 1
0
        /// <summary>
        /// Retrieve cross sectional attachments.
        /// </summary>
        /// <param name="dataReader">
        ///     The data reader.
        /// </param>
        /// <param name="crossDataSet">
        ///     The list of components attached to cross-sectional data set.
        /// </param>
        /// <param name="conceptRef">
        ///     The concept id.
        /// </param>
        /// <param name="crossGroup">
        ///     The list of components attached to cross-sectional group.
        /// </param>
        /// <param name="crossSection">
        ///     The list of components attached to cross-sectional section.
        /// </param>
        /// <param name="crossObs">
        ///     The list of components attached to cross-sectional observation level
        /// </param>
        private static void RetrieveCrossSectionalAttachments(IDataRecord dataReader, ISet <string> crossDataSet, string conceptRef, ISet <string> crossGroup, ISet <string> crossSection, ISet <string> crossObs)
        {
            TertiaryBool crossSectionalAttachDataSet = DataReaderHelper.GetTristate(dataReader, "XS_ATTLEVEL_DS");

            if (crossSectionalAttachDataSet.IsTrue)
            {
                crossDataSet.Add(conceptRef);
            }

            TertiaryBool crossSectionalAttachGroup = DataReaderHelper.GetTristate(dataReader, "XS_ATTLEVEL_GROUP");

            if (crossSectionalAttachGroup.IsTrue)
            {
                crossGroup.Add(conceptRef);
            }

            TertiaryBool crossSectionalAttachSection = DataReaderHelper.GetTristate(dataReader, "XS_ATTLEVEL_SECTION");

            if (crossSectionalAttachSection.IsTrue)
            {
                crossSection.Add(conceptRef);
            }

            TertiaryBool crossSectionalAttachObservation = DataReaderHelper.GetTristate(dataReader, "XS_ATTLEVEL_OBS");

            if (crossSectionalAttachObservation.IsTrue)
            {
                crossObs.Add(conceptRef);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieve the common <see cref="IMaintainableMutableObject"/> information from Mapping Store ARTEFACT table. This method does not retrieve the Names and Description
        /// </summary>
        /// <param name="sqlQuery">
        /// The SQL Query for artefacts
        /// </param>
        /// <param name="detail">
        /// The structure query detail
        /// </param>
        /// <param name="commandBuilder">
        /// The command Builder.
        /// </param>
        /// <param name="retrieveDetails">
        /// The method to retrieve details of the artefacts
        /// </param>
        /// <param name="extraFields">
        /// The extra Fields.
        /// </param>
        /// <returns>
        /// A dictionary with key the primary key in Mapping Store
        /// </returns>
        protected ISet <T> RetrieveArtefacts(ArtefactSqlQuery sqlQuery, ComplexStructureQueryDetailEnumType detail, Func <ArtefactSqlQuery, DbCommand> commandBuilder = null, Func <T, long, T> retrieveDetails = null, Action <T, IDataReader> extraFields = null)
        {
            commandBuilder  = commandBuilder ?? this.CommandBuilder.Build;
            retrieveDetails = retrieveDetails ?? this.RetrieveDetails;
            var artefactPkPairs = new List <KeyValuePair <T, long> >();

            using (DbCommand command = commandBuilder(sqlQuery))
            {
                _log.InfoFormat(CultureInfo.InvariantCulture, "Executing Query: '{0}' with '{1}'", command.CommandText, sqlQuery.MaintainableRef);
                using (IDataReader dataReader = this._mappingStoreDb.ExecuteReader(command))
                {
                    int sysIdIdx     = dataReader.GetOrdinal("SYSID");
                    int idIdx        = dataReader.GetOrdinal("ID");
                    int version1Idx  = dataReader.GetOrdinal("VERSION");
                    int agencyIdx    = dataReader.GetOrdinal("AGENCY");
                    int validFromIdx = dataReader.GetOrdinal("VALID_FROM");
                    int validToIdx   = dataReader.GetOrdinal("VALID_TO");
                    int isFinalIdx   = dataReader.GetOrdinal("IS_FINAL");
                    int txtIdx       = dataReader.GetOrdinal("TEXT");
                    int langIdx      = dataReader.GetOrdinal("LANGUAGE");
                    int typeIdx      = dataReader.GetOrdinal("TYPE");
                    var artefactMap  = new Dictionary <long, T>();
                    while (dataReader.Read())
                    {
                        long sysId = DataReaderHelper.GetInt64(dataReader, sysIdIdx);
                        T    artefact;
                        if (!artefactMap.TryGetValue(sysId, out artefact))
                        {
                            artefact = this.CreateArtefact();
                            artefact.FinalStructure = DataReaderHelper.GetTristate(dataReader, isFinalIdx);
                            artefact.EndDate        = DataReaderHelper.GetStringDate(dataReader, validToIdx);
                            artefact.StartDate      = DataReaderHelper.GetStringDate(dataReader, validFromIdx);
                            artefact.Version        = DataReaderHelper.GetString(dataReader, version1Idx);
                            artefact.AgencyId       = DataReaderHelper.GetString(dataReader, agencyIdx);
                            artefact.Id             = DataReaderHelper.GetString(dataReader, idIdx);
                            this.HandleArtefactExtraFields(artefact, dataReader);

                            if (extraFields != null)
                            {
                                extraFields(artefact, dataReader);
                            }

                            artefactPkPairs.Add(new KeyValuePair <T, long>(artefact, sysId));
                            artefactMap.Add(sysId, artefact);
                        }

                        if (!artefact.IsDefault())
                        {
                            ReadLocalisedString(artefact, typeIdx, txtIdx, langIdx, dataReader, detail);
                        }
                    }
                }
            }

            if (artefactPkPairs.Count < 1)
            {
                _log.InfoFormat(CultureInfo.InvariantCulture, "No artefacts retrieved for : '{0}'", sqlQuery.MaintainableRef);
                return(new HashSet <T>());
            }

            return(HandleDetailLevel(detail, retrieveDetails, artefactPkPairs));
        }