///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="DataSetTargetCore"/> class.
        /// </summary>
        /// <param name="itemMutableObject">
        /// The agencyScheme. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException"> Throws SdmxSemmanticException.
        /// </exception>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public DataSetTargetCore(IDataSetTargetMutableObject itemMutableObject, IMetadataTarget parent)
            : base(itemMutableObject, parent)
        {
            this.textType = TextType.GetFromEnum(TextEnumType.DataSetReference);
            try
            {
                this.textType = itemMutableObject.TextType;
            }
            catch (SdmxSemmanticException ex)
            {
                throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
            catch (Exception th)
            {
                throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException ex1)
            {
                throw new SdmxSemmanticException(ex1, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
            catch (Exception th1)
            {
                throw new SdmxException(th1, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataTargetMutableCore"/> class.
        /// </summary>
        /// <param name="objTarget">
        /// The obj target.
        /// </param>
        public MetadataTargetMutableCore(IMetadataTarget objTarget)
            : base(objTarget)
        {
            this._identifiableTarget = new List<IIdentifiableTargetMutableObject>();
            if (objTarget.KeyDescriptorValuesTarget != null)
            {
                this._keyDescriptorValuesTarget =
                    new KeyDescriptorValuesTargetMutableCore(objTarget.KeyDescriptorValuesTarget);
            }

            if (objTarget.DataSetTarget != null)
            {
                this._dataSetTarget = new DataSetTargetMutableCore(objTarget.DataSetTarget);
            }

            if (objTarget.ReportPeriodTarget != null)
            {
                this._reportPeriodTarget = new ReportPeriodTargetMutableCore(objTarget.ReportPeriodTarget);
            }

            if (objTarget.ConstraintContentTarget != null)
            {
                this._constraintContentTarget = new ConstraintContentTargetMutableCore(
                    objTarget.ConstraintContentTarget);
            }

            if (objTarget.IdentifiableTarget != null)
            {
                foreach (IIdentifiableTarget identifiableTarget in objTarget.IdentifiableTarget)
                {
                    this._identifiableTarget.Add(new IdentifiableTargetMutableCore(identifiableTarget));
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="IdentifiableTargetCore"/> class.
        /// </summary>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public IdentifiableTargetCore(IIdentifiableTargetMutableObject itemMutableObject, IMetadataTarget parent)
            : base(itemMutableObject, parent, false)
        {
            this.referencedStructureType = itemMutableObject.ReferencedStructureType;
            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="KeyDescriptorValuesTargetCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="itemMutableObject">
        /// The agencyScheme. 
        /// </param>
        /// <exception cref="SdmxSemmanticException"> Throws SdmxSemmanticException.
        /// </exception>
        public KeyDescriptorValuesTargetCore(IMetadataTarget parent, IKeyDescriptorValuesTargetMutableObject itemMutableObject)
            : base(itemMutableObject, parent)
        {
            this.textType = TextType.GetFromEnum(TextEnumType.KeyValues);
            try
            {
                this.textType = itemMutableObject.TextType;
            }
            catch (SdmxSemmanticException ex)
            {
                throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
            catch (Exception th)
            {
                throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }

            this.Validate();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ReportPeriodTargetCore"/> class.
        /// </summary>
        /// <param name="reportPeriodTargetType">
        /// The report period target type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        protected internal ReportPeriodTargetCore(ReportPeriodTargetType reportPeriodTargetType, IMetadataTarget parent)
            : base(
                reportPeriodTargetType, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ReportPeriodTarget), parent)
        {
            this.textType = TextType.GetFromEnum(TextEnumType.ObservationalTimePeriod);
            if (reportPeriodTargetType.LocalRepresentation != null)
            {
                RepresentationType repType = reportPeriodTargetType.LocalRepresentation;
                if (repType.TextFormat != null)
                {
                    if (repType.TextFormat.startTime != null)
                    {
                        this.startTime = new SdmxDateCore(repType.TextFormat.startTime.ToString());
                    }

                    if (repType.TextFormat.endTime != null)
                    {
                        this.endTime = new SdmxDateCore(repType.TextFormat.endTime.ToString());
                    }

                    if (repType.TextFormat.textType != null)
                    {
                        this.textType = TextTypeUtil.GetTextType(repType.TextFormat.textType);
                    }
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataTargetCore"/> class.
        /// </summary>
        /// <param name="partialTarget">The partial target.</param>
        /// <param name="fullTarget">The full target.</param>
        /// <param name="parent">The parent.</param>
        /// <exception cref="SdmxSemmanticException">Partial Target references undefined IdentifierComponentRef ' + identifierRef + '</exception>
        protected internal MetadataTargetCore(PartialTargetIdentifierType partialTarget, IMetadataTarget fullTarget, MetadataStructureDefinitionObjectCore parent)
            : base(partialTarget, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataTarget), partialTarget.id, partialTarget.uri, partialTarget.Annotations, parent)
        {
            if (partialTarget.IdentifierComponentRef != null)
            {
                foreach (var identifierRef in partialTarget.IdentifierComponentRef)
                {
                    if (!string.IsNullOrWhiteSpace(identifierRef))
                    {
                        var identifiableTarget = fullTarget.IdentifiableTarget.FirstOrDefault(target => string.Equals(target.Id, identifierRef));
                        if (identifiableTarget == null)
                        {
                            throw new SdmxSemmanticException("Partial Target references undefined IdentifierComponentRef '" + identifierRef + "'");
                        }

                        this._identifiableTarget.Add(new IdentifiableTargetCore(new IdentifiableTargetMutableCore(identifiableTarget), this));
                    }
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="IdentifiableTargetCore"/> class.
        /// </summary>
        /// <param name="identifiableTargetType">
        /// The identifiable target type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        protected internal IdentifiableTargetCore(
            IdentifiableObjectTargetType identifiableTargetType, IMetadataTarget parent)
            : base(
                identifiableTargetType, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.IdentifiableObjectTarget), 
                parent)
        {
            this.referencedStructureType = XmlobjectsEnumUtil.GetSdmxStructureType(identifiableTargetType.objectType);
            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="KeyDescriptorValuesTargetCore"/> class.
        /// </summary>
        /// <param name="target">
        /// The target. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        protected internal KeyDescriptorValuesTargetCore(KeyDescriptorValuesTargetType target, IMetadataTarget parent)
            : base(target, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DimensionDescriptorValuesTarget), parent)
        {
            this.textType = TextType.GetFromEnum(TextEnumType.KeyValues);
            if (target.LocalRepresentation != null)
            {
                RepresentationType repType = target.LocalRepresentation;
                if (repType.TextFormat != null)
                {
                    if (repType.TextFormat.textType != null)
                    {
                        this.textType = TextTypeUtil.GetTextType(repType.TextFormat.textType);
                    }
                }
            }

            this.Validate();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="DataSetTargetCore"/> class.
        /// </summary>
        /// <param name="datasetTargetTargetType">
        /// The dataset target target type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        protected internal DataSetTargetCore(DataSetTargetType datasetTargetTargetType, IMetadataTarget parent)
            : base(datasetTargetTargetType, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DatasetTarget), parent)
        {
            this.textType = TextType.GetFromEnum(TextEnumType.DataSetReference);
            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException ex)
            {
                throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
            catch (Exception th)
            {
                throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ConstraintContentTargetCore"/> class.
        /// </summary>
        /// <param name="target">
        /// The target. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        protected internal ConstraintContentTargetCore(ConstraintContentTargetType target, IMetadataTarget parent)
            : base(target, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConstraintContentTarget), parent)
        {
            this.Validate();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ConstraintContentTargetCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        public ConstraintContentTargetCore(IMetadataTarget parent, IConstraintContentTargetMutableObject itemMutableObject)
            : base(itemMutableObject, parent)
        {
            this.Validate();
        }