예제 #1
0
        /// <summary>
        /// When this method is overridden it is used to retrieve Items of a ItemScheme and populate the output List
        /// </summary>
        /// <param name="itemScheme">
        ///     The <see cref="IItemSchemeMutableObject{T}"/> to fill with <see cref="IItemMutableObject"/>
        /// </param>
        /// <param name="parentSysId">
        ///     The primary key of the Item Scheme from Mapping Store table ARTEFACT.ART_ID field
        /// </param>
        protected virtual void FillItems(TMaintaible itemScheme, long parentSysId)
        {
            var itemQuery = new ItemSqlQuery(this._itemSqlQueryInfo, parentSysId);

            var itemMap = new Dictionary <long, TItem>();

            using (DbCommand command = this.ItemCommandBuilder.Build(itemQuery))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    int sysIdIdx = dataReader.GetOrdinal("SYSID");
                    int idIdx    = dataReader.GetOrdinal("ID");
                    int txtIdx   = dataReader.GetOrdinal("TEXT");
                    int langIdx  = dataReader.GetOrdinal("LANGUAGE");
                    int typeIdx  = dataReader.GetOrdinal("TYPE");
                    while (dataReader.Read())
                    {
                        long  sysId = DataReaderHelper.GetInt64(dataReader, sysIdIdx);
                        TItem item;
                        if (!itemMap.TryGetValue(sysId, out item))
                        {
                            item    = this.CreateItem();                             // we set them below.
                            item.Id = DataReaderHelper.GetString(dataReader, idIdx); // "ID"
                            itemScheme.AddItem(item);
                            itemMap.Add(sysId, item);
                        }

                        ReadLocalisedString(item, typeIdx, txtIdx, langIdx, dataReader);
                    }
                }
            }

            this.IdentifiableAnnotationRetrieverEngine.RetrieveAnnotations(parentSysId, itemMap);
        }
예제 #2
0
        /// <summary>
        /// Fill the specified <paramref name="itemSchemeBean"/> with parent items.
        /// </summary>
        /// <param name="itemSchemeBean">
        ///     The parent <see cref="IItemSchemeMutableObject{T}"/>
        /// </param>
        /// <param name="itemQuery">
        ///     The item Query.
        /// </param>
        protected void FillItemWithParent(TMaintaible itemSchemeBean, ItemSqlQuery itemQuery)
        {
            var allItems     = new Dictionary <long, TItem>();
            var orderedItems = new List <KeyValuePair <long, TItem> >();
            var childItems   = new Dictionary <long, long>();

            using (DbCommand command = this.ItemCommandBuilder.Build(itemQuery))
            {
                this.ReadItems(allItems, orderedItems, command, childItems);
            }

            this.FillParentItems(itemSchemeBean, childItems, allItems, orderedItems);

            this.IdentifiableAnnotationRetrieverEngine.RetrieveAnnotations(itemQuery.ParentSysId, allItems);
        }
예제 #3
0
        /// <summary>
        /// Retrieve and populate the <see cref="IHierarchicalCodelistMutableObject.Hierarchies"/> for the HCL with specified Primary KEY
        /// </summary>
        /// <param name="hierarchicalCodelistBean">
        /// The <see cref="IHierarchicalCodelistMutableObject"/> to populate
        /// </param>
        /// <param name="sysId">
        /// The HCL Mapping store Primary KEY
        /// </param>
        private void FillHierarchy(IHierarchicalCodelistMutableObject hierarchicalCodelistBean, long sysId)
        {
            // ReSharper restore SuggestBaseTypeForParameter
            var sysIdArtefacts = new Dictionary <long, IHierarchyMutableObject>();
            var itemSqlQuery   = new ItemSqlQuery(this._hierarchyQueryInfo, sysId);

            using (DbCommand command = this._itemCommandBuilder.Build(itemSqlQuery))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    int sysIdIdx = dataReader.GetOrdinal("SYSID");
                    int idIdx    = dataReader.GetOrdinal("ID");

                    int txtIdx  = dataReader.GetOrdinal("TEXT");
                    int langIdx = dataReader.GetOrdinal("LANGUAGE");
                    int typeIdx = dataReader.GetOrdinal("TYPE");
                    while (dataReader.Read())
                    {
                        long hierarchySysId = DataReaderHelper.GetInt64(dataReader, sysIdIdx);
                        IHierarchyMutableObject artefact;
                        if (!sysIdArtefacts.TryGetValue(hierarchySysId, out artefact))
                        {
                            artefact = new HierarchyMutableCore {
                                Id = DataReaderHelper.GetString(dataReader, idIdx)
                            };

                            sysIdArtefacts.Add(hierarchySysId, artefact);
                        }

                        ReadLocalisedString(artefact, typeIdx, txtIdx, langIdx, dataReader);
                    }
                }
            }

            this._hierarchyAnnotationRetrieverEngine.RetrieveAnnotations(sysId, sysIdArtefacts);

            foreach (KeyValuePair <long, IHierarchyMutableObject> sysIdArtefact in sysIdArtefacts)
            {
                long hid = sysIdArtefact.Key;
                IHierarchyMutableObject artefact = sysIdArtefact.Value;

                this.FillLevel(artefact, hid);
                this.FillCodeRef(artefact, hid);
                hierarchicalCodelistBean.AddHierarchies(artefact);
            }
        }
예제 #4
0
        /// <summary>
        /// When this method is overridden it is used to retrieve Items of a ItemScheme and populate the output List
        /// </summary>
        /// <param name="itemScheme">
        ///     The <see cref="IItemSchemeMutableObject{T}"/> to fill with <see cref="IItemMutableObject"/>
        /// </param>
        /// <param name="parentSysId">
        ///     The primary key of the Item Scheme from Mapping Store table ARTEFACT.ART_ID field
        /// </param>
        protected override void FillItems(ICodelistMutableObject itemScheme, long parentSysId)
        {
            var itemQuery = new ItemSqlQuery(this.ItemSqlQueryInfo, parentSysId);

            this.FillItemWithParent(itemScheme, itemQuery);
        }