/// <summary>
        /// The process category scheme map.
        /// </summary>
        /// <param name="structureSetType">
        /// The structure set type.
        /// </param>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        private void ProcessCategorySchemeMap(StructureSetType structureSetType, ICategorySchemeMapObject buildFrom)
        {
            var catSchemeMap = new CategorySchemeMapType();
            structureSetType.CategorySchemeMap = catSchemeMap;

            string value = buildFrom.Id;
            if (!string.IsNullOrWhiteSpace(value))
            {
                catSchemeMap.id = buildFrom.Id;
            }

            IList<ITextTypeWrapper> names = buildFrom.Names;
            if (ObjectUtil.ValidCollection(names))
            {
                catSchemeMap.Name = this.GetTextType(names);
            }

            IList<ITextTypeWrapper> descriptions = buildFrom.Descriptions;
            if (ObjectUtil.ValidCollection(descriptions))
            {
                catSchemeMap.Description = this.GetTextType(descriptions);
            }

            if (buildFrom.SourceRef != null)
            {
                var catRefType = new CategorySchemeRefType();
                catSchemeMap.CategorySchemeRef = catRefType;
                SetCategorySchemeRefAttributes(catRefType, buildFrom.SourceRef);
            }

            if (buildFrom.TargetRef != null)
            {
                var catRefType0 = new CategorySchemeRefType();
                catSchemeMap.TargetCategorySchemeRef = catRefType0;
                SetCategorySchemeRefAttributes(catRefType0, buildFrom.TargetRef);
            }

            IList<ICategoryMap> categoryMapBeans = buildFrom.CategoryMaps;
            if (ObjectUtil.ValidCollection(categoryMapBeans))
            {
                /* foreach */
                foreach (ICategoryMap categoryMapBean in categoryMapBeans)
                {
                    var categoryMapType = new CategoryMapType();
                    catSchemeMap.CategoryMap.Add(categoryMapType);
                    string value1 = categoryMapBean.Alias;
                    if (!string.IsNullOrWhiteSpace(value1))
                    {
                        categoryMapType.categoryAlias = categoryMapBean.Alias;
                    }

                    if (categoryMapBean.SourceId != null)
                    {
                        var categoryIdType = new CategoryIDType();
                        categoryMapType.CategoryID = categoryIdType;
                        SetCategoryIdAttributes(categoryIdType, categoryMapBean.SourceId);
                    }

                    if (categoryMapBean.TargetId != null)
                    {
                        var categoryIdType1 = new CategoryIDType();

                        categoryMapType.TargetCategoryID = categoryIdType1;
                        SetCategoryIdAttributes(categoryIdType1, categoryMapBean.TargetId);
                    }
                }
            }

            if (this.HasAnnotations(buildFrom))
            {
                catSchemeMap.Annotations = this.GetAnnotationsType(buildFrom);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// The populate category id list.
 /// </summary>
 /// <param name="catIdList">
 /// The cat id list. 
 /// </param>
 /// <param name="currentIdType">
 /// The current id type. 
 /// </param>
 private static void PopulateCategoryIdList(ICollection<string> catIdList, CategoryIDType currentIdType)
 {
     // TODO possibly use RefUtl.GetCateogryIds
     while (currentIdType != null)
     {
         catIdList.Add(currentIdType.ID);
         currentIdType = currentIdType.CategoryID;
     }
 }
        /// <summary>
        /// Sets category id attributes.
        /// </summary>
        /// <param name="categoryIdType">
        /// The category id type.
        /// </param>
        /// <param name="categoryIds">
        /// The category id list.
        /// </param>
        private static void SetCategoryIdAttributes(CategoryIDType categoryIdType, IList<string> categoryIds)
        {
            if (categoryIds == null)
            {
                return;
            }

            int currentPos = 0;

            while (categoryIds.Count > currentPos)
            {
                categoryIdType.ID = categoryIds[currentPos];

                // FIXME TODO java bug ?
                // in 0.9.1 current pos remains the same.
                currentPos++;
                if (categoryIds.Count > currentPos)
                {
                    var subType = new CategoryIDType();
                    categoryIdType.CategoryID = subType;
                    categoryIdType = subType;
                }
            }

            // Original recursive
            ////if (categoryIds.Count > currentPos)
            ////{
            ////    categoryIdType.ID = categoryIds[currentPos];
            ////     nextPos = ++currentPos;
            ////    if (categoryIds.Count > nextPos)
            ////    {
            ////        var subType = new CategoryIDType();
            ////        categoryIdType.CategoryID = subType;
            ////        this.SetCategoryIdAttributes(subType, categoryIds, nextPos);
            ////    }
            ////}
        }