Пример #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ConceptSchemeMapCore"/> class.
        /// </summary>
        /// <param name="conMapType">
        /// The con map type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public ConceptSchemeMapCore(ConceptSchemeMapType conMapType, IStructureSetObject parent)
            : base(conMapType, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptSchemeMap), parent)
        {
            this.SourceRef = RefUtil.CreateReference(this, conMapType.Source);
            this.TargetRef = RefUtil.CreateReference(this, conMapType.Target);

            if (conMapType.ItemAssociation != null)
            {
                foreach (ConceptMap conMap in conMapType.ItemAssociation)
                {
                    IItemMap item = new ItemMapCore(conMap.Source.GetTypedRef<LocalConceptRefType>().id, conMap.Target.GetTypedRef<LocalConceptRefType>().id, this);
                    this.AddInternalItem(item);
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        /// <summary>
        /// The process concept scheme map.
        /// </summary>
        /// <param name="structureSetType">
        /// The structure set type.
        /// </param>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        private void ProcessConceptSchemeMap(StructureSetType structureSetType, IItemSchemeMapObject buildFrom)
        {
            var conceptSchemeMap = new ConceptSchemeMapType();
            structureSetType.ConceptSchemeMap = conceptSchemeMap;

            string str0 = buildFrom.Id;
            if (!string.IsNullOrWhiteSpace(str0))
            {
                conceptSchemeMap.id = buildFrom.Id;
            }

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

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

            if (buildFrom.SourceRef != null)
            {
                var refType = new ConceptSchemeRefType();
                conceptSchemeMap.ConceptSchemeRef = refType;
                SetConceptSchemeRefAttributes(refType, buildFrom.SourceRef);
            }

            if (buildFrom.TargetRef != null)
            {
                var refType0 = new ConceptSchemeRefType();
                conceptSchemeMap.TargetConceptSchemeRef = refType0;
                SetConceptSchemeRefAttributes(refType0, buildFrom.TargetRef);
            }

            IList<IItemMap> itemMapBeans = buildFrom.Items;
            if (ObjectUtil.ValidCollection(itemMapBeans))
            {
                /* foreach */
                foreach (IItemMap itemMapBean in itemMapBeans)
                {
                    var conceptMaptype = new ConceptMapType();
                    conceptSchemeMap.ConceptMap.Add(conceptMaptype);
                    string str1 = itemMapBean.SourceId;
                    if (!string.IsNullOrWhiteSpace(str1))
                    {
                        conceptMaptype.ConceptID = itemMapBean.SourceId;
                    }

                    string str2 = itemMapBean.TargetId;
                    if (!string.IsNullOrWhiteSpace(str2))
                    {
                        conceptMaptype.TargetConceptID = itemMapBean.TargetId;
                    }
                }
            }

            if (this.HasAnnotations(buildFrom))
            {
                conceptSchemeMap.Annotations = this.GetAnnotationsType(buildFrom);
            }
        }