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

        /// <summary>
        /// Initializes a new instance of the <see cref="ReportPeriodTargetCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public ReportPeriodTargetCore(IIdentifiableObject parent, IReportPeriodTargetMutableObject itemMutableObject)
            : base(itemMutableObject, parent)
        {
            this.textType = TextType.GetFromEnum(TextEnumType.ObservationalTimePeriod);
            if (itemMutableObject.StartTime != null)
            {
                this.startTime = new SdmxDateCore(itemMutableObject.StartTime, TimeFormatEnumType.DateTime);
            }

            if (itemMutableObject.EndTime != null)
            {
                this.endTime = new SdmxDateCore(itemMutableObject.EndTime, TimeFormatEnumType.DateTime);
            }

            if (itemMutableObject.TextType != null)
            {
                this.textType = itemMutableObject.TextType;
            }

            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="ComputationCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="mutableObject">
        /// The mutable object. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public ComputationCore(IIdentifiableObject parent, IComputationMutableObject mutableObject)
            : base(mutableObject, parent)
        {
            this.description = new List<ITextTypeWrapper>();
            this.localId = mutableObject.LocalId;
            this.softwareLanguage = mutableObject.SoftwareLanguage;
            this.softwarePackage = mutableObject.SoftwarePackage;
            this.softwareVersion = mutableObject.SoftwareVersion;
            if (mutableObject.Descriptions != null)
            {
                foreach (ITextTypeWrapperMutableObject currentTT in mutableObject.Descriptions)
                {
                    if (!string.IsNullOrWhiteSpace(currentTT.Value))
                    {
                        this.description.Add(new TextTypeWrapperImpl(currentTT, this));
                    }
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException ex)
            {
                throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this);
            }
            catch (Exception th)
            {
                throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this);
            }
        }
		public CategorisationObjectBaseCore(ICategorisationObject categorisation0,
				ISdmxObjectRetrievalManager retMan) : base(categorisation0) {
			IMaintainableObject maint = retMan.GetMaintainable(categorisation0
					.StructureReference);
			IMaintainableObject cs = retMan.GetMaintainable(categorisation0
					.CategoryReference);
			/* foreach */
			foreach (IIdentifiableObject ident  in  cs.IdentifiableComposites) {
				if (categorisation0.CategoryReference.IsMatch(ident)) {
					category = (ICategoryObject) ident;
					break;
				}
			}
			if (categorisation0.StructureReference.TargetReference.IsMaintainable && categorisation0.StructureReference.IsMatch(maint)) {
				structure = maint;
			} else {
				foreach (IIdentifiableObject ident1  in  maint.IdentifiableComposites) {
					if (categorisation0.StructureReference.IsMatch(ident1)) {
						structure = ident1;
						break;
					}
				}
			}
			if (structure == null) {
				throw new ReferenceException(categorisation0.StructureReference);
			}
			if (category == null) {
				throw new ReferenceException(categorisation0.CategoryReference);
			}
		}
		///////////////////////////////////////////////////////////////////////////////////////////////////
		////////////BUILD FROM MUTABLE OBJECTS              //////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////
		#region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentCore" /> class.
        /// </summary>
        /// <param name="itemMutableObject">The agencyScheme.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="validateComponentAttributes">if set to <c>true</c> [validate component attributes].</param>
        /// <exception cref="SdmxException">Throws Validate exception.</exception>
		protected internal ComponentCore(IComponentMutableObject itemMutableObject, IIdentifiableObject parent, bool validateComponentAttributes = true)
			: base(itemMutableObject, parent)
		{
			try
			{
				if (itemMutableObject.Representation != null)
				{
					this.LocalRepresentation = new RepresentationCore(itemMutableObject.Representation, this);
				}

				if (itemMutableObject.ConceptRef != null)
				{
					this._conceptRef = new CrossReferenceImpl(this, itemMutableObject.ConceptRef);
				}
			}
			catch (Exception th)
			{
                throw new SdmxException("IsError creating component: " + this, th);
			}

            if (validateComponentAttributes)
            {
                this.ValidateComponentAttributes();
            }
        }
        /// <summary>
        /// Adds a bean to the container as long as the urn of the bean to add is not contained in the set of URNs.
        ///     <p/>
        ///     If successfully added, will add the bean urn to the set of urns
        /// </summary>
        /// <param name="beans">
        /// container to add to
        /// </param>
        /// <param name="urns">
        /// to exclude
        /// </param>
        /// <param name="bean">
        /// to add to the beans container
        /// </param>
        protected internal void AddIfNotDuplicateURN(ISdmxObjects beans, ISet<Uri> urns, IIdentifiableObject bean)
        {
            if (!urns.Add(bean.Urn))
            {
                throw new SdmxSemmanticException(ExceptionCode.DuplicateUrn, bean.Urn);
            }

            beans.AddIdentifiable(bean);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="InputOutputCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="mutableObject">
        /// The mutable object. 
        /// </param>
        public InputOutputCore(IIdentifiableObject parent, IInputOutputMutableObject mutableObject)
            : base(mutableObject, parent)
        {
            this.localId = mutableObject.LocalId;
            if (mutableObject.StructureReference != null)
            {
                this.structureReference = new CrossReferenceImpl(this, mutableObject.StructureReference);
            }

            this.Validate();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IdentifiableMutableCore"/> class.
        /// </summary>
        /// <param name="objTarget">
        /// The obj target. 
        /// </param>
        protected IdentifiableMutableCore(IIdentifiableObject objTarget)
            : base(objTarget)
        {
            this._id = objTarget.Id;
            if (objTarget.Uri != null)
            {
                this._uri = objTarget.Uri;
            }

            this._urn = objTarget.Urn;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="InputOutputCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="xmlType">
        /// The xml type. 
        /// </param>
        public InputOutputCore(IIdentifiableObject parent, InputOutputType xmlType)
            : base(xmlType, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Computation), parent)
        {
            this.localId = xmlType.localID;
            if (xmlType.ObjectReference != null)
            {
                this.structureReference = RefUtil.CreateReference(this, xmlType.ObjectReference);
            }

            this.Validate();
        }
        private readonly IList<IItemMap> _items; // Package Protected

        #endregion

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

        /// <summary>
        /// Initializes a new instance of the <see cref="ItemSchemeMapCore"/> class.
        /// </summary>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <param name="structureType">
        /// The structure type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        protected ItemSchemeMapCore(IItemSchemeMapMutableObject itemMutableObject, SdmxStructureType structureType, IIdentifiableObject parent)
            : base(itemMutableObject, parent)
        {
            this._items = new List<IItemMap>();
            if (itemMutableObject.Items != null)
            {
                foreach (IItemMapMutableObject item in itemMutableObject.Items)
                {
                    this._items.Add(new ItemMapCore(item, this));
                }
            }
        }
Beispiel #10
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CategoryCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="category">
        /// The sdmxObject. 
        /// </param>
        public CategoryCore(IIdentifiableObject parent, CategoryType category)
            : base(category, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Category), parent)
        {
            this._categories = new List<ICategoryObject>();
            if (category.Item != null)
            {
                foreach (Category currentCat in category.Item)
                {
                    this._categories.Add(new CategoryCore(this, currentCat.Content));
                }
            }
        }
		public ReferenceValueObjectBaseCore(IReferenceValue builtFrom,
				IIdentifiableRetrievalManager retrievalManager) : base(builtFrom) {
			this.builtFrom = builtFrom;
			if (builtFrom.IdentifiableReference != null) {
				identifiableReference = retrievalManager.GetIdentifiableObject(builtFrom.GetIdentifiableReference());
			}
			if (builtFrom.ContentConstraintReference != null) {
				contentConstraintReference = retrievalManager.GetIdentifiableObject<IContentConstraintObject>(
						builtFrom.ContentConstraintReference,
						typeof(IContentConstraintObject));
			}
		}
Beispiel #12
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="CategoryCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        public CategoryCore(IIdentifiableObject parent, ICategoryMutableObject itemMutableObject)
            : base(itemMutableObject, parent)
        {
            this._categories = new List<ICategoryObject>();
            if (itemMutableObject.Items != null)
            {
                foreach (ICategoryMutableObject currentCat in itemMutableObject.Items)
                {
                    this._categories.Add(new CategoryCore(this, currentCat));
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECT                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////    
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="LevelCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="levelMutable">
        /// The level mutable. 
        /// </param>
        public LevelCore(IIdentifiableObject parent, ILevelMutableObject levelMutable)
            : base(levelMutable, parent)
        {
            if (levelMutable.CodingFormat != null)
            {
                this.textFormat = new TextFormatObjectCore(levelMutable.CodingFormat, this);
            }

            if (levelMutable.ChildLevel != null)
            {
                this.childLevel = new LevelCore(this, levelMutable.ChildLevel);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="SchemeMapCore"/> class.
        /// </summary>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        internal SchemeMapCore(ISchemeMapMutableObject itemMutableObject, IIdentifiableObject parent)
            : base(itemMutableObject, parent)
        {
            if (itemMutableObject.SourceRef != null)
            {
                this.sourceRef = new CrossReferenceImpl(this, itemMutableObject.SourceRef);
            }

            if (itemMutableObject.TargetRef != null)
            {
                this.targetRef = new CrossReferenceImpl(this, itemMutableObject.TargetRef);
            }
        }
Beispiel #15
0
        private static IList <INode> GetIdentifiableChildren(INode node)
        {
            var identifiableChildren = new List <INode>();

            foreach (INode child in node.Children)
            {
                IIdentifiableObject identifiableChild = child as IIdentifiableObject;
                if (identifiableChild != null)
                {
                    identifiableChildren.Add(identifiableChild);
                }
            }
            return(identifiableChildren);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECT                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationCore"/> class.
        /// </summary>
        /// <param name="representationMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public RepresentationCore(IRepresentationMutableObject representationMutableObject, IIdentifiableObject parent)
            : base(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.LocalRepresentation), parent)
        {
            if (representationMutableObject.TextFormat != null)
            {
                this.textFormat = new TextFormatObjectCore(representationMutableObject.TextFormat, this);
            }

            if (representationMutableObject.Representation != null)
            {
                this.representation = new CrossReferenceImpl(this, representationMutableObject.Representation);
            }

            this.Validate();
        }
Beispiel #17
0
        /// <summary>
        /// Run common artefact import command.
        /// </summary>
        /// <param name="artefact">
        /// The artefact.
        /// </param>
        /// <param name="command">
        /// The command.
        /// </param>
        /// <param name="artefactStoredProcedure">
        /// The artefact stored procedure.
        /// </param>
        /// <returns>
        /// The <see cref="long"/>.
        /// </returns>
        protected long RunIdentifiableArterfactCommand(IIdentifiableObject artefact, DbCommand command, ArtefactProcedurebase artefactStoredProcedure)
        {
            DbParameter idParameter = artefactStoredProcedure.CreateIdParameter(command);

            idParameter.Value = artefact.Id ?? (object)DBNull.Value;

            DbParameter outputParameter = artefactStoredProcedure.CreateOutputParameter(command);

            command.ExecuteNonQuery();

            var artID = (long)outputParameter.Value;

            _annotationInsertEngine.Insert(new DbTransactionState(command.Transaction, this._database), artID, _insertArtefactAnnotation, artefact.Annotations);

            return(artID);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ReportingCategoryCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="reportingCategory">
        /// The reporting category. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public ReportingCategoryCore(IIdentifiableObject parent, IReportingCategoryMutableObject reportingCategory)
            : base(reportingCategory, parent)
        {
            this.structuralMetadata = new List<ICrossReference>();
            this.provisioningMetadata = new List<ICrossReference>();
            this.reportingCategories = new List<IReportingCategoryObject>();

            if (reportingCategory.ProvisioningMetadata != null)
            {
                foreach (IStructureReference structureReference in reportingCategory.ProvisioningMetadata)
                {
                    this.provisioningMetadata.Add(new CrossReferenceImpl(this, structureReference));
                }
            }

            if (reportingCategory.StructuralMetadata != null)
            {
                foreach (IStructureReference structureReference in reportingCategory.StructuralMetadata)
                {
                    this.structuralMetadata.Add(new CrossReferenceImpl(this, structureReference));
                }
            }

            if (reportingCategory.Items != null)
            {
                foreach (IReportingCategoryMutableObject reportingCategoryMutableObject in reportingCategory.Items)
                {
                    this.reportingCategories.Add(new ReportingCategoryCore(this, reportingCategoryMutableObject));
                }
            }

            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);
            }
        }
        /// <summary>
        /// The assemble identifiable.
        /// </summary>
        /// <param name="assembleInto">
        /// The assemble into.
        /// </param>
        /// <param name="assembleFrom">
        /// The assemble from.
        /// </param>
        public void AssembleIdentifiable(IdentifiableType assembleInto, IIdentifiableObject assembleFrom)
        {
            if (this.HasAnnotations(assembleFrom))
            {
                assembleInto.Annotations = new Annotations(this.GetAnnotationsType(assembleFrom));
            }

            string str0 = assembleFrom.Id;
            if (!string.IsNullOrWhiteSpace(str0))
            {
                assembleInto.id = assembleFrom.Id;
            }

            if (assembleFrom.Uri != null)
            {
                assembleInto.uri = assembleFrom.Uri;
            }

            assembleInto.urn = assembleFrom.Urn;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECT                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////    
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataAttributeObjectCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public MetadataAttributeObjectCore(IIdentifiableObject parent, IMetadataAttributeMutableObject itemMutableObject)
            : base(itemMutableObject, parent)
        {
            this.metadataAttributes = new List<IMetadataAttributeObject>();
            this.presentational = TertiaryBool.GetFromEnum(TertiaryBoolEnumType.Unset);
            try
            {
                if (itemMutableObject.MetadataAttributes != null)
                {
                    foreach (IMetadataAttributeMutableObject currentMa in itemMutableObject.MetadataAttributes)
                    {
                        this.metadataAttributes.Add(new MetadataAttributeObjectCore(this, currentMa));
                    }
                }

                if (itemMutableObject.MinOccurs != null)
                {
                    this.minOccurs = itemMutableObject.MinOccurs;
                }

                if (itemMutableObject.MaxOccurs != null)
                {
                    this.maxOccurs = itemMutableObject.MaxOccurs;
                }

                this.presentational = itemMutableObject.Presentational;
            }
            catch (Exception th)
            {
                throw new SdmxSemmanticException("IsError creating structure: " + this, th);
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECT                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////    
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataTargetCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.Throws Validate exception.
        /// </exception>
        public MetadataTargetCore(IIdentifiableObject parent, IMetadataTargetMutableObject itemMutableObject)
            : base(itemMutableObject, parent)
        {
            if (itemMutableObject.ConstraintContentTarget != null)
            {
                this.constraintContentTarget = new ConstraintContentTargetCore(this, itemMutableObject.ConstraintContentTarget);
            }

            if (itemMutableObject.KeyDescriptorValuesTarget != null)
            {
                this.keyDescriptorValuesTarget = new KeyDescriptorValuesTargetCore(this, itemMutableObject.KeyDescriptorValuesTarget);
            }

            if (itemMutableObject.DataSetTarget != null)
            {
                this.dataSetTarget = new DataSetTargetCore(itemMutableObject.DataSetTarget, this);
            }

            if (itemMutableObject.ReportPeriodTarget != null)
            {
                this.reportPeriodTarget = new ReportPeriodTargetCore(this, itemMutableObject.ReportPeriodTarget);
            }

            if (itemMutableObject.IdentifiableTarget != null)
            {
                foreach (IIdentifiableTargetMutableObject identifiableTargetMutableObject in itemMutableObject.IdentifiableTarget)
                {
                    this._identifiableTarget.Add(new IdentifiableTargetCore(identifiableTargetMutableObject, this));
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        /// <summary>
        /// The build concept ref.
        /// </summary>
        /// <param name="referencedFrom">
        /// The referenced from.
        /// </param>
        /// <param name="conceptSchemeAgency">
        /// The concept scheme agency.
        /// </param>
        /// <param name="conceptSchemeId">
        /// The concept scheme id.
        /// </param>
        /// <param name="conceptSchemeVersion">
        /// The concept scheme version1.
        /// </param>
        /// <param name="conceptAgency">
        /// The concept agency.
        /// </param>
        /// <param name="conceptId">
        /// The concept id.
        /// </param>
        /// <returns>
        /// The <see cref="ICrossReference"/>.
        /// </returns>
        /// <exception cref="ArgumentException">Throws ArgumentOutOfRangeException
        /// </exception>
        public static ICrossReference BuildConceptRef(
            IIdentifiableObject referencedFrom, 
            string conceptSchemeAgency, 
            string conceptSchemeId, 
            string conceptSchemeVersion, 
            string conceptAgency, 
            string conceptId)
        {
            bool isFreeStanding = string.IsNullOrWhiteSpace(conceptSchemeId);

            if (ObjectUtil.ValidOneString(conceptId, conceptSchemeAgency, conceptSchemeId, conceptSchemeVersion))
            {
                if (string.IsNullOrWhiteSpace(conceptSchemeAgency))
                {
                    conceptSchemeAgency = conceptAgency;
                }

                if (isFreeStanding)
                {
                    return new CrossReferenceImpl(
                        referencedFrom, 
                        conceptSchemeAgency, 
                        ConceptSchemeObject.DefaultSchemeId, 
                        ConceptSchemeObject.DefaultSchemeVersion, 
                        SdmxStructureEnumType.Concept, 
                        conceptId);
                }
                return new CrossReferenceImpl(
                    referencedFrom, 
                    conceptSchemeAgency, 
                    conceptSchemeId, 
                    conceptSchemeVersion, 
                    SdmxStructureEnumType.Concept, 
                    conceptId);
            }

            // TODO Exception
            throw new ArgumentException("Concept Reference missing parameters");
        }
Beispiel #23
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="LevelCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="levels">
        /// The levels. 
        /// </param>
        /// <param name="pos">
        /// The pos. 
        /// </param>
        public LevelCore(IIdentifiableObject parent, IList<LevelType> levels, int pos)
            : base(
                GetLevel(levels, pos), 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Level), 
                GetLevel(levels, pos).id, 
                null, 
                GetLevel(levels, pos).Name, 
                GetLevel(levels, pos).Description, 
                GetLevel(levels, pos).Annotations, 
                parent)
        {
            LevelType level = GetLevel(levels, pos);
            if (level.CodingType != null)
            {
                this.textFormat = new TextFormatObjectCore(level.CodingType, this);
            }

            if (levels.Count > pos + 1)
            {
                this.childLevel = new LevelCore(this, levels, ++pos);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="SchemeMapCore"/> class.
        /// </summary>
        /// <param name="createdFrom">
        /// The created from. 
        /// </param>
        /// <param name="structureType">
        /// The structure type. 
        /// </param>
        /// <param name="id">
        /// The id. 
        /// </param>
        /// <param name="uri">
        /// The uri. 
        /// </param>
        /// <param name="name">
        /// The name. 
        /// </param>
        /// <param name="description">
        /// The description. 
        /// </param>
        /// <param name="annotationsType">
        /// The annotations type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        internal SchemeMapCore(
            IXmlSerializable createdFrom, 
            SdmxStructureType structureType, 
            string id, 
            Uri uri, 
            IList<TextType> name, 
            IList<TextType> description, 
            AnnotationsType annotationsType, 
            IIdentifiableObject parent)
            : base(createdFrom, structureType, id, uri, name, description, annotationsType, parent)
        {
        }
Beispiel #25
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CategoryCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="category">
        /// The sdmxObject. 
        /// </param>
        public CategoryCore(
            IIdentifiableObject parent, Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.CategoryType category)
            : base(
                category, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Category), 
                category.id, 
                category.uri, 
                category.Name, 
                category.Description, 
                category.Annotations, 
                parent)
        {
            this._categories = new List<ICategoryObject>();
            if (category.Category != null)
            {
                foreach (Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.CategoryType currentCat in category.Category)
                {
                    this._categories.Add(new CategoryCore(this, currentCat));
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="SchemeMapCore"/> class.
        /// </summary>
        /// <param name="createdFrom">
        /// The created from. 
        /// </param>
        /// <param name="structureType">
        /// The structure type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        internal SchemeMapCore(NameableType createdFrom, SdmxStructureType structureType, IIdentifiableObject parent)
            : base(createdFrom, structureType, parent)
        {
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ReportingCategoryCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="category">
        /// The category. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public ReportingCategoryCore(IIdentifiableObject parent, CategoryType category)
            : base(
                category, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ReportingCategory), 
                category.id, 
                category.uri, 
                category.Name, 
                category.Description, 
                category.Annotations, 
                parent)
        {
            this.structuralMetadata = new List<ICrossReference>();
            this.provisioningMetadata = new List<ICrossReference>();
            this.reportingCategories = new List<IReportingCategoryObject>();

            if (category.DataflowRef != null)
            {
                foreach (DataflowRefType dataflowRefType in category.DataflowRef)
                {
                    if (dataflowRefType.URN != null)
                    {
                        this.provisioningMetadata.Add(new CrossReferenceImpl(this, dataflowRefType.URN));
                    }
                    else
                    {
                        this.provisioningMetadata.Add(
                            new CrossReferenceImpl(
                                this, 
                                dataflowRefType.AgencyID, 
                                dataflowRefType.DataflowID, 
                                dataflowRefType.Version, 
                                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow)));
                    }
                }
            }

            if (category.MetadataflowRef != null)
            {
                foreach (MetadataflowRefType mdfRef in category.MetadataflowRef)
                {
                    if (mdfRef.URN != null)
                    {
                        this.provisioningMetadata.Add(new CrossReferenceImpl(this, mdfRef.URN));
                    }
                    else
                    {
                        this.provisioningMetadata.Add(
                            new CrossReferenceImpl(
                                this, 
                                mdfRef.AgencyID, 
                                mdfRef.MetadataflowID, 
                                mdfRef.Version, 
                                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataFlow)));
                    }
                }
            }

            if (category.Category != null)
            {
                foreach (CategoryType childCategory in category.Category)
                {
                    this.reportingCategories.Add(new ReportingCategoryCore(this, childCategory));
                }
            }

            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="ReportingCategoryCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="category">
        /// The category. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public ReportingCategoryCore(IIdentifiableObject parent, ReportingCategoryType category)
            : base(category, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ReportingCategory), parent)
        {
            this.structuralMetadata = new List<ICrossReference>();
            this.provisioningMetadata = new List<ICrossReference>();
            this.reportingCategories = new List<IReportingCategoryObject>();

            if (category.ProvisioningMetadata != null)
            {
                foreach (StructureUsageReferenceType structureUsageReferenceType in category.ProvisioningMetadata)
                {
                    this.provisioningMetadata.Add(RefUtil.CreateReference(this, structureUsageReferenceType));
                }
            }

            if (category.StructuralMetadata != null)
            {
                foreach (StructureReferenceType structureReferenceType in category.StructuralMetadata)
                {
                    this.structuralMetadata.Add(RefUtil.CreateReference(this, structureReferenceType));
                }
            }

            if (category.Item != null)
            {
                foreach (ReportingCategory childCategory in category.Item)
                {
                    this.reportingCategories.Add(new ReportingCategoryCore(this, childCategory.Content));
                }
            }

            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 V1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationCore"/> class.
        /// </summary>
        /// <param name="codelistId">
        /// The codelist id. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        protected internal RepresentationCore(string codelistId, IIdentifiableObject parent)
            : base(_localRepresentation, parent)
        {
            if (!string.IsNullOrWhiteSpace(codelistId))
            {
                this.representation = new CrossReferenceImpl(
                    this, 
                    parent.MaintainableParent.AgencyId, 
                    codelistId, 
                    null, 
                    SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList));
            }

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

        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationCore"/> class.
        /// </summary>
        /// <param name="textFormat0">
        /// The text format 0. 
        /// </param>
        /// <param name="codelistAgency">
        /// The codelist agency. 
        /// </param>
        /// <param name="codelistId">
        /// The codelist id. 
        /// </param>
        /// <param name="codelistVersion">
        /// The codelist version. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public RepresentationCore(
            TextFormatType textFormat0, 
            string codelistAgency, 
            string codelistId, 
            string codelistVersion, 
            IIdentifiableObject parent)
            : base(_localRepresentation, parent)
        {
            if (textFormat0 != null)
            {
                this.textFormat = new TextFormatObjectCore(textFormat0, this);
            }

            if (ObjectUtil.ValidOneString(codelistAgency, codelistId, codelistVersion))
            {
                if (string.IsNullOrWhiteSpace(codelistAgency))
                {
                    codelistAgency = this.MaintainableParent.AgencyId;
                }

                SdmxStructureType structureType = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList);
                if (parent.MaintainableParent is ICrossSectionalDataStructureObject)
                {
                    if (parent is IDimension)
                    {
                        if (((IDimension)parent).MeasureDimension)
                        {
                            structureType = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme);
                        }
                    }
                }

                this.representation = new CrossReferenceImpl(
                    this, codelistAgency, codelistId, codelistVersion, structureType);
            }

            this.Validate();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationCore"/> class.
        /// </summary>
        /// <param name="representationType">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public RepresentationCore(RepresentationType representationType, IIdentifiableObject parent)
            : base(_localRepresentation, parent)
        {
            if (representationType.TextFormat != null)
            {
                this.textFormat = new TextFormatObjectCore(representationType.TextFormat, this);
            }

            ItemSchemeReferenceBaseType reference;
            if (representationType.CodelistEnumeration != null)
            {
                reference = representationType.CodelistEnumeration;
            }
            else
            {
                reference = representationType.ConceptSchemeEnumeration;
            }

            if (reference != null)
            {
                this.representation = RefUtil.CreateReference(this, reference);
                if (representationType.EnumerationFormat != null)
                {
                    this.textFormat = new TextFormatObjectCore(representationType.EnumerationFormat, this);
                }
            }

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

        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationCore"/> class.
        /// </summary>
        /// <param name="conceptRepresentation">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public RepresentationCore(ConceptRepresentation conceptRepresentation, IIdentifiableObject parent)
            : base(_localRepresentation, parent)
        {
            if (conceptRepresentation.TextFormat != null)
            {
                this.textFormat = new TextFormatObjectCore(conceptRepresentation.TextFormat, this);
            }

            if (conceptRepresentation.Enumeration != null)
            {
                this.representation = RefUtil.CreateReference(this, conceptRepresentation.Enumeration);
                if (conceptRepresentation.EnumerationFormat != null)
                {
                    this.textFormat = new TextFormatObjectCore(conceptRepresentation.EnumerationFormat, this);
                }
            }

            this.Validate();
        }