Пример #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ReportStructureCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="rs">
        /// The rs. 
        /// </param>
        /// <exception cref="SdmxSemmanticException"> Throws SdmxSemmanticException.
        /// </exception>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public ReportStructureCore(IMetadataStructureDefinitionObject parent, IReportStructureMutableObject rs)
            : base(rs, parent)
        {
            this.metadataAttributes = new List<IMetadataAttributeObject>();
            this.targetMetadatas = new List<string>();
            try
            {
                if (rs.MetadataAttributes != null)
                {
                    foreach (IMetadataAttributeMutableObject currentMa in rs.MetadataAttributes)
                    {
                        this.metadataAttributes.Add(new MetadataAttributeObjectCore(this, currentMa));
                    }
                }

                if (rs.TargetMetadatas != null)
                {
                    this.targetMetadatas = new List<string>(rs.TargetMetadatas);
                }
            }
            catch (Exception th)
            {
                throw new SdmxSemmanticException(th, ExceptionCode.ObjectStructureConstructionError, this);
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        /// <summary>
        /// The update references.
        /// </summary>
        /// <param name="maintianable">
        /// The maintianable.
        /// </param>
        /// <param name="updateReferences">
        /// The update references.
        /// </param>
        /// <param name="newVersionNumber">
        /// The new version number.
        /// </param>
        /// <returns>
        /// The <see cref="IMetadataStructureDefinitionObject"/>.
        /// </returns>
        public IMetadataStructureDefinitionObject UpdateReferences(
            IMetadataStructureDefinitionObject maintianable,
            IDictionary<IStructureReference, IStructureReference> updateReferences,
            string newVersionNumber)
        {
            IMetadataStructureDefinitionMutableObject msdMutable = maintianable.MutableInstance;
            msdMutable.Version = newVersionNumber;

            if (msdMutable.MetadataTargets != null)
            {
                foreach (IMetadataTargetMutableObject metadataTarget in msdMutable.MetadataTargets)
                {
                    if (metadataTarget.IdentifiableTarget != null)
                    {
                        foreach (
                            IIdentifiableTargetMutableObject identifiableTarget in
                                metadataTarget.IdentifiableTarget)
                        {
                            UpdateRepresentationReference(identifiableTarget.Representation, updateReferences);

                            if (identifiableTarget.ConceptRef != null)
                            {
                                IStructureReference structureReference = updateReferences[identifiableTarget.ConceptRef];
                                if (structureReference != null)
                                {
                                    identifiableTarget.ConceptRef = structureReference;
                                }
                            }
                        }
                    }
                }
            }
            if (msdMutable.ReportStructures != null)
            {
                foreach (IReportStructureMutableObject rs in msdMutable.ReportStructures)
                {
                    this.UpdateMetadataAttributes(rs.MetadataAttributes, updateReferences);
                }
            }
            return msdMutable.ImmutableInstance;
        }
        public MetadataSetBaseCore(IMetadataSet builtFrom, IIdentifiableRetrievalManager retrievalManager)
            : base(builtFrom)
        {
            this.reports = new List<IMetadataReportBase>();
			this.builtFrom = builtFrom;
			this.metadataStructure = retrievalManager.GetIdentifiableObject<IMetadataStructureDefinitionObject>(
					builtFrom.MsdReference,
					typeof(IMetadataStructureDefinitionObject));
			if (builtFrom.DataProviderReference != null) {
                this.dataProvider = retrievalManager.GetIdentifiableObject<IDataProvider>(
						builtFrom.DataProviderReference,
						typeof(IDataProvider));
			}
			if (builtFrom.Reports != null) {
				/* foreach */
				foreach (IMetadataReport metadataReport  in  builtFrom.Reports) {
					IReportStructure rs = GetReportStructure(metadataReport,
							metadataStructure.ReportStructures);
					this.reports.Add(new MetadataReportBaseCore(rs, metadataReport, retrievalManager));
				}
			}
		}
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataTargetCore"/> class.
        /// </summary>
        /// <param name="fullTarget">The SDMX v2.0 full target identifier.</param>
        /// <param name="parent">The parent.</param>
        protected internal MetadataTargetCore(FullTargetIdentifierType fullTarget, IMetadataStructureDefinitionObject parent)
            : base(fullTarget, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataTarget), fullTarget.id, fullTarget.uri, fullTarget.Annotations, parent)
        {
            if (fullTarget.IdentifierComponent != null)
            {
                foreach (var currentIdentifier in fullTarget.IdentifierComponent)
                {
                    var identifiableTarget = new IdentifiableTargetMutableCore() { Id = currentIdentifier.id, Uri = currentIdentifier.uri };
                    if (currentIdentifier.Annotations != null && currentIdentifier.Annotations.Annotation != null)
                    {
                        foreach (var annotationType in currentIdentifier.Annotations.Annotation)
                        {
                            var annotation = new AnnotationMutableCore { Title = annotationType.AnnotationTitle, Type = annotationType.AnnotationType1, Uri = annotationType.AnnotationURL };
                            foreach (var textType in annotationType.AnnotationText)
                            {
                                annotation.AddText(textType.lang, textType.TypedValue);
                            }

                            identifiableTarget.AddAnnotation(annotation);
                        }
                    }

                    if (currentIdentifier.RepresentationScheme != null)
                    {
                        var id = currentIdentifier.RepresentationScheme.representationScheme;
                        var agency = currentIdentifier.RepresentationScheme.representationSchemeAgency;
                        var schemaType = XmlobjectsEnumUtil.GetSdmxStructureTypeFromRepresentationSchemeTypeV20(currentIdentifier.RepresentationScheme.representationSchemeType1);

                        // Only on .NET
                        var version = currentIdentifier.RepresentationScheme.RepresentationSchemeVersionEstat ?? MaintainableObject.DefaultVersion;

                        var representation = new RepresentationMutableCore();
                        var representationRef = new StructureReferenceImpl(new MaintainableRefObjectImpl(agency, id, version), schemaType);
                        representation.Representation = representationRef;
                        identifiableTarget.Representation = representation;
                    }

                    if (currentIdentifier.TargetObjectClass != null)
                    {
                        identifiableTarget.ReferencedStructureType = XmlobjectsEnumUtil.GetSdmxStructureType(currentIdentifier.TargetObjectClass);
                    }

                    this._identifiableTarget.Add(new IdentifiableTargetCore(identifiableTarget, this));
                }
            }
        }
Пример #5
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataTargetCore"/> class.
        /// </summary>
        /// <param name="metadataTarget">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        protected internal MetadataTargetCore(MetadataTargetType metadataTarget, IMetadataStructureDefinitionObject parent)
            : base(metadataTarget, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataTarget), parent)
        {
            if (ObjectUtil.ValidCollection(metadataTarget.KeyDescriptorValuesTarget))
            {
                if (metadataTarget.KeyDescriptorValuesTarget.Count > 1)
                {
                    throw new SdmxSemmanticException(
                        "Metadata Target can not have more then one KeyDescriptorValuesTarget");
                }

                this.keyDescriptorValuesTarget =
                    new KeyDescriptorValuesTargetCore(metadataTarget.KeyDescriptorValuesTarget[0].Content, this);
            }

            if (ObjectUtil.ValidCollection(metadataTarget.DataSetTarget))
            {
                if (metadataTarget.DataSetTarget.Count > 1)
                {
                    throw new SdmxSemmanticException("Metadata Target can not have more then one DataSetTarget");
                }

                this.dataSetTarget = new DataSetTargetCore(metadataTarget.DataSetTarget[0].Content, this);
            }

            if (ObjectUtil.ValidCollection(metadataTarget.ReportPeriodTarget))
            {
                if (metadataTarget.ReportPeriodTarget.Count > 1)
                {
                    throw new SdmxSemmanticException("Metadata Target can not have more then one ReportPeriodTarget");
                }

                this.reportPeriodTarget = new ReportPeriodTargetCore(metadataTarget.ReportPeriodTarget[0].Content, this);
            }

            if (ObjectUtil.ValidCollection(metadataTarget.ConstraintContentTarget))
            {
                if (metadataTarget.DataSetTarget.Count > 1)
                {
                    throw new SdmxSemmanticException("Metadata Target can not have more then one ConstraintContentTarget");
                }

                this.constraintContentTarget = new ConstraintContentTargetCore(
                    metadataTarget.ConstraintContentTarget[0].Content, this);
            }

            if (metadataTarget.IdentifiableObjectTarget != null)
            {
                foreach (IdentifiableObjectTarget currentTarget in metadataTarget.IdentifiableObjectTarget)
                {
                    this._identifiableTarget.Add(new IdentifiableTargetCore(currentTarget.Content, this));
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ReportStructureCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="rs">
        /// The rs. 
        /// </param>
        /// <exception cref="SdmxSemmanticException"> Throws SdmxSemmanticException.
        /// </exception>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public ReportStructureCore(
            IMetadataStructureDefinitionObject parent, 
            Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.ReportStructureType rs)
            : base(
                rs, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ReportStructure), 
                rs.id, 
                rs.uri, 
                rs.Annotations, 
                parent)
        {
            this.metadataAttributes = new List<IMetadataAttributeObject>();
            this.targetMetadatas = new List<string>();
            try
            {
                foreach (MetadataAttributeType currentMa in rs.MetadataAttribute)
                {
                    this.metadataAttributes.Add(new MetadataAttributeObjectCore(this, currentMa));
                }

                if (!string.IsNullOrWhiteSpace(rs.target))
                {
                    this.targetMetadatas.Add(rs.target);
                }
            }
            catch (Exception th)
            {
                throw new SdmxSemmanticException(th, ExceptionCode.ObjectStructureConstructionError, this);
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ReportStructureCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="rs">
        /// The rs. 
        /// </param>
        /// <exception cref="SdmxSemmanticException"> Throws SdmxSemmanticException.
        /// </exception>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public ReportStructureCore(IMetadataStructureDefinitionObject parent, ReportStructureType rs)
            : base(rs, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ReportStructure), parent)
        {
            this.metadataAttributes = new List<IMetadataAttributeObject>();
            this.targetMetadatas = new List<string>();
            try
            {
                foreach (MetadataAttribute currentMa in rs.Component)
                {
                    this.metadataAttributes.Add(new MetadataAttributeObjectCore(currentMa.Content, this));
                }

                if (rs.MetadataTarget != null)
                {
                    foreach (LocalMetadataTargetReferenceType localReference in rs.MetadataTarget)
                    {
                        this.targetMetadatas.Add(RefUtil.CreateLocalIdReference(localReference));
                    }
                }
            }
            catch (Exception th)
            {
                throw new SdmxSemmanticException(th, ExceptionCode.ObjectStructureConstructionError, this);
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }