Example #1
0
		///////////////////////////////////////////////////////////////////////////////////////////////////
		////////////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>
        /// Initializes a new instance of the <see cref="CrossReferenceException"/> class.
        /// </summary>
        /// <param name="crossReference">The cross reference</param>
        public CrossReferenceException(ICrossReference crossReference)
            : base(ExceptionCode.ReferenceErrorUnresolvable, GetReferenceFromIdentifier(crossReference), crossReference != null ? crossReference.TargetUrn : null)
        {
            if (crossReference == null)
            {
                throw new ArgumentNullException("crossReference");
            }

            this._crossReference = crossReference;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////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="CodelistRefCore"/> class.
        /// </summary>
        /// <param name="codelistRefMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public CodelistRefCore(ICodelistRefMutableObject codelistRefMutableObject, ISdmxStructure parent)
            : base(codelistRefMutableObject, parent)
        {
            this.alias = codelistRefMutableObject.Alias;
            if (codelistRefMutableObject.CodelistReference != null)
            {
                this.codelistReference = new CrossReferenceImpl(this, codelistRefMutableObject.CodelistReference);
            }

            this.Validate();
        }
		public GroupObjectBaseCore(IGroup group, IDataStructureObjectBase keyFamily) : base(group) {
			this.dimension = new List<IDimensionObjectBase>();
			this.dimensionMap = new Dictionary<String, IDimensionObjectBase>();
			this.attachmentConstraintRef = group.AttachmentConstraintRef;
			/* foreach */
			foreach (String conceptId  in  group.DimensionRef) {
				IDimensionObjectBase dim = keyFamily.GetDimensionById(conceptId);
				dimension.Add(dim);
				dimensionMap.Add(conceptId,dim);
			}
			this.id = group.Id;
		}
 public DataSetReferenceCore(SetReferenceType sRefType, IMetadataTargetKeyValues parent)
     : base(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DatasetReference), parent)
 {
     this._datasetId = sRefType.ID;
     this._dataProviderReference = RefUtil.CreateReference(this, sRefType.DataProvider);
     try
     {
         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="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();
        }
Example #8
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECT                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ConceptCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        public ConceptCore(IConceptSchemeObject parent, IConceptMutableObject itemMutableObject)
            : base(itemMutableObject, parent)
        {
            if(itemMutableObject.CoreRepresentation != null && (itemMutableObject.CoreRepresentation.TextFormat != null || itemMutableObject.CoreRepresentation.Representation != null))
            {
                this.coreRepresentation = new RepresentationCore(itemMutableObject.CoreRepresentation, this);
            }

            if (itemMutableObject.IsoConceptReference != null)
            {
                this.isoConceptReference = new CrossReferenceImpl(this, itemMutableObject.IsoConceptReference);
            }

            this.parentConcept = itemMutableObject.ParentConcept;
            this.parentAgency = itemMutableObject.ParentAgency;
        }
Example #9
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS              //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="GroupCore"/> class.
        /// </summary>
        /// <param name="itemMutableObject">
        /// The agencyScheme. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public GroupCore(IGroupMutableObject itemMutableObject, ISdmxStructure parent)
            : base(itemMutableObject, parent)
        {
            this.dimensionRef = new List<string>();
            if (itemMutableObject.AttachmentConstraintRef != null)
            {
                this.attachmentConstraintRef = new CrossReferenceImpl(this, itemMutableObject.AttachmentConstraintRef);
            }

            if (itemMutableObject.DimensionRef != null)
            {
                this.dimensionRef = new List<string>(itemMutableObject.DimensionRef);
            }

            this.ValidateGroupAttributes();
        }
 public DataSetReferenceCore(IDataSetReferenceMutableObject mutableObject, IMetadataTargetKeyValues parent)
     : base(mutableObject, parent)
 {
     this._datasetId = mutableObject.DatasetId;
     if (mutableObject.DataProviderReference != null)
     {
         this._dataProviderReference = new CrossReferenceImpl(this, mutableObject.DataProviderReference);
         try
         {
             Validate();
         }
         catch (SdmxSemmanticException e)
         {
             throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
         }
     }
 }
Example #11
0
        /// <summary>
        /// Insert the specified <paramref name="maintainable"/> to the mapping store with <paramref name="state"/>
        /// </summary>
        /// <param name="state">
        /// The MAPPING STORE connection and transaction state
        /// </param>
        /// <param name="maintainable">
        /// The maintainable.
        /// </param>
        /// <returns>
        /// The <see cref="ArtefactImportStatus"/>.
        /// </returns>
        public override ArtefactImportStatus Insert(DbTransactionState state, IHierarchicalCodelistObject maintainable)
        {
            var codelistCache = new StructureCache();

            foreach (var codelistRef in maintainable.CodelistRef)
            {
                ICrossReference codelistReference = codelistRef.CodelistReference;

                ItemSchemeFinalStatus itemSchemeFinalStatus = codelistCache.GetStructure(state, codelistReference);
                var codelistMaintainableReference           = codelistReference.MaintainableReference;
                if (itemSchemeFinalStatus.FinalStatus.PrimaryKey <= 0)
                {
                    string message = string.Format(
                        "HierarchicalCodeList {0} uses the CodeList:\r\n ID: {1}\r\n VERSION:{2}\r\n AGENCY: {3}\r\n which doesn't exist in the Mapping Store",
                        maintainable.Id,
                        codelistMaintainableReference.MaintainableId,
                        codelistMaintainableReference.Version,
                        codelistMaintainableReference.AgencyId);
                    return(new ArtefactImportStatus(-1, new ImportMessage(ImportMessageStatus.Error, codelistReference, message)));
                }

                if (!itemSchemeFinalStatus.FinalStatus.IsFinal)
                {
                    string message = string.Format(
                        "HierarchicalCodeList {0} uses the CodeList:\r\n ID: {1}\r\n VERSION:{2}\r\n AGENCY: {3}\r\n which is not Final",
                        maintainable.Id,
                        codelistMaintainableReference.MaintainableId,
                        codelistMaintainableReference.Version,
                        codelistMaintainableReference.AgencyId);
                    return(new ArtefactImportStatus(-1, new ImportMessage(ImportMessageStatus.Error, codelistReference, message)));
                }
            }

            _log.DebugFormat(CultureInfo.InvariantCulture, "Importing artefact {0}", maintainable.Urn);
            var artefactStoredProcedure = _storedProcedures.InsertHcl;
            var artefactStatus          = this.InsertArtefactInternal(state, maintainable, artefactStoredProcedure);

            foreach (KeyValuePair <long, IHierarchy> hierarchy in this.InsertHierarchies(state, maintainable.Hierarchies, artefactStatus.PrimaryKeyValue))
            {
                var levelIds = this.InsertLevels(state, hierarchy.Value.Level, hierarchy.Key);
                this.InsertCodeReferences(state, hierarchy.Value.HierarchicalCodeObjects, hierarchy.Key, codelistCache, levelIds);
            }

            return(artefactStatus);
        }
Example #12
0
        public Concept(IConceptObject concept)
        {
            this._id = concept.Id;
            this._names = new List<TextTypeWrapper>();
            this._descriptions = new List<TextTypeWrapper>();

            foreach (var text in concept.Names)
                this._names.Add(new TextTypeWrapper(text.Locale, text.Value));
            foreach (var text in concept.Descriptions)
                this._descriptions.Add(new TextTypeWrapper(text.Locale, text.Value));

            this._coreRepresentation = concept.CoreRepresentation;
            this._isoConceptReference = concept.IsoConceptReference;
            this._parentAgency = concept.ParentAgency;
            this._parentConcept = concept.ParentConcept;
            this._uri = concept.Uri;
            this._urn = concept.Urn;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////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();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////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);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ConceptCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="concept">
        /// The sdmxObject. 
        /// </param>
        public ConceptCore(IConceptSchemeObject parent, ConceptType concept)
            : base(concept, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), parent)
        {
            if (concept.CoreRepresentation != null)
            {
                this.coreRepresentation = new RepresentationCore(concept.CoreRepresentation, this);
            }

            if (concept.ISOConceptReference != null)
            {
                this.isoConceptReference = new CrossReferenceImpl(
                    this, 
                    concept.ISOConceptReference.ConceptAgency, 
                    concept.ISOConceptReference.ConceptSchemeID, 
                    null, 
                    SdmxStructureEnumType.Concept, 
                    concept.ISOConceptReference.ConceptID);
            }

            var localItemReferenceType = concept.GetTypedParent<LocalConceptReferenceType>();
            if (localItemReferenceType != null)
            {
                if (ObjectUtil.ValidCollection(localItemReferenceType.URN))
                {
                    IStructureReference structureReference = new StructureReferenceImpl(localItemReferenceType.URN[0]);
                    this.parentConcept = structureReference.ChildReference.Id;
                    this.parentAgency = structureReference.MaintainableReference.AgencyId;
                }
                else
                {
                    this.parentConcept = localItemReferenceType.GetTypedRef<LocalConceptRefType>().id;
                    this.parentAgency = this.MaintainableParent.AgencyId;
                }
            }
        }
		///////////////////////////////////////////////////////////////////////////////////////////////////
		////////////BUILD FROM V1 SCHEMA                 //////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////

		/// <summary>
		/// Initializes a new instance of the <see cref="ComponentCore"/> class.
		/// </summary>
		/// <param name="createdFrom">
		/// The created from. 
		/// </param>
		/// <param name="structureType">
		/// The structure type. 
		/// </param>
		/// <param name="annotationType">
		/// The annotation type. 
		/// </param>
		/// <param name="codelistId">
		/// The codelist id. 
		/// </param>
		/// <param name="conceptId">
		/// The concept id. 
		/// </param>
		/// <param name="parent">
		/// The parent. 
		/// </param>
		protected internal ComponentCore(
			IXmlSerializable createdFrom, 
			SdmxStructureType structureType, 
			Org.Sdmx.Resources.SdmxMl.Schemas.V10.common.AnnotationsType annotationType, 
			string codelistId, 
			string conceptId, 
			ISdmxStructure parent)
			: base(createdFrom, structureType, conceptId, null, annotationType, parent)
		{
			if (!string.IsNullOrWhiteSpace(codelistId))
			{
				this.LocalRepresentation = new RepresentationCore(codelistId, this);
			}

			this._conceptRef = new CrossReferenceImpl(
				this, 
				this.MaintainableParent.AgencyId, 
				ConceptSchemeObject.DefaultSchemeVersion, 
				ConceptSchemeObject.DefaultSchemeVersion, 
				SdmxStructureEnumType.Concept, 
				conceptId);
			this.ValidateComponentAttributes();
		}
		///////////////////////////////////////////////////////////////////////////////////////////////////
		////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////

		/// <summary>
		/// Initializes a new instance of the <see cref="ComponentCore"/> class.
		/// </summary>
		/// <param name="createdFrom">
		/// The created from. 
		/// </param>
		/// <param name="structureType">
		/// The structure type. 
		/// </param>
		/// <param name="annotationType">
		/// The annotation type. 
		/// </param>
		/// <param name="textFormat">
		/// The text format. 
		/// </param>
		/// <param name="codelistAgency">
		/// The codelist agency. 
		/// </param>
		/// <param name="codelistId">
		/// The codelist id. 
		/// </param>
		/// <param name="codelistVersion">
		/// The codelist version. 
		/// </param>
		/// <param name="conceptSchemeAgency">
		/// The concept scheme agency. 
		/// </param>
		/// <param name="conceptSchemeId">
		/// The concept scheme id. 
		/// </param>
		/// <param name="conceptSchemeVersion">
		/// The concept scheme version. 
		/// </param>
		/// <param name="conceptAgency">
		/// The concept agency. 
		/// </param>
		/// <param name="conceptId">
		/// The concept id. 
		/// </param>
		/// <param name="parent">
		/// The parent. 
		/// </param>
		protected internal ComponentCore(
			IXmlSerializable createdFrom, 
			SdmxStructureType structureType, 
			AnnotationsType annotationType, 
			TextFormatType textFormat, 
			string codelistAgency, 
			string codelistId, 
			string codelistVersion, 
			string conceptSchemeAgency, 
			string conceptSchemeId, 
			string conceptSchemeVersion, 
			string conceptAgency, 
			string conceptId, 
			IIdentifiableObject parent)
			: base(createdFrom, structureType, conceptId, null, annotationType, parent)
		{
			if (string.IsNullOrWhiteSpace(conceptAgency))
			{
				conceptAgency = this.MaintainableParent.AgencyId;
			}

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

				this.LocalRepresentation = new RepresentationCore(
					textFormat, codelistAgency, codelistId, codelistVersion, this);
			}

			this._conceptRef = ConceptRefUtil.BuildConceptRef(
				this, conceptSchemeAgency, conceptSchemeId, conceptSchemeVersion, conceptAgency, conceptId);
			this.ValidateComponentAttributes();
		}
 /// <summary>
 /// Adds code references.
 /// </summary>
 /// <param name="constraintBean">
 /// The constraint object.
 /// </param>
 /// <param name="returnReferences">
 /// The returned references.
 /// </param>
 /// <param name="codelistRef">
 /// The code list reference object.
 /// </param>
 /// <param name="codeIds">
 /// The code ids.
 /// </param>
 private void AddCodeReferences(IContentConstraintObject constraintBean, ISet<ICrossReference> returnReferences, ICrossReference codelistRef, ICollection<string> codeIds)
 {
     string agencyId = codelistRef.AgencyId;
     string codelistId = codelistRef.MaintainableId;
     string version = codelistRef.Version;
     foreach (string codeId in codeIds)
     {
         ICrossReference codeRef = new CrossReferenceImpl(constraintBean, agencyId, codelistId, version, SdmxStructureEnumType.Code, codeId);
         returnReferences.Add(codeRef);
     }
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////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();
        }
Example #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CategoryMock"/> class.
 /// </summary>
 /// <param name="crossReference">
 /// The cross reference.
 /// </param>
 public CategoryMock(ICrossReference crossReference)
 {
     this._crossReference = crossReference;
     this._categorisation = this._crossReference.ReferencedFrom as ICategorisationObject;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CrossReferenceException"/> class. 
 /// </summary>
 /// <param name="info">
 /// The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown. 
 /// </param>
 /// <param name="context">
 /// The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination. 
 /// </param>
 /// <exception cref="T:System.ArgumentNullException">
 /// The <paramref name="info"/> parameter is null. 
 /// </exception>
 /// <exception cref="T:System.Runtime.Serialization.SerializationException">
 /// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). 
 /// </exception>
 protected CrossReferenceException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this._crossReference = (ICrossReference)info.GetValue("_crossReference", typeof(ICrossReference));
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////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();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        #region Constructors and Destructors

        /// <summary>
        ///   Initializes a new instance of the <see cref="ReferenceValueObjectCore" /> class.
        /// </summary>
        /// <param name="parent"> The parent. </param>
        /// <param name="type"> The type. </param>
        public ReferenceValueObjectCore(ITarget parent, ReferenceValueType type)
            : base(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataReferenceValue), parent)
        {
            this.dataKeys = new List<IDataKey>();
            this.id = type.id;
            if (type.ConstraintContentReference != null)
            {
                this.constraintReference = RefUtil.CreateReference(this, type.ConstraintContentReference);
            }

            if (type.ObjectReference != null)
            {
                this.identifiableReference = RefUtil.CreateReference(this, type.ObjectReference);
            }

            if (type.DataSetReference != null)
            {
                this.datasetId = type.DataSetReference.ID;
                this.identifiableReference = RefUtil.CreateReference(this, type.DataSetReference.DataProvider);
            }

            if (type.DataKey != null)
            {
                foreach (var cvst in type.DataKey.GetTypedKeyValue<DataKeyValueType>())
                {
                    this.dataKeys.Add(new DataKeyObjectCore(this, cvst));
                }
            }

            if (type.ReportPeriod != null)
            {
                reportPeriod = new SdmxDateCore(type.ReportPeriod.ToString());
            }

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

        /// <summary>
        /// Initializes a new instance of the <see cref="GroupCore"/> class.
        /// </summary>
        /// <param name="group">
        /// The group. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public GroupCore(GroupType group, ISdmxStructure parent)
            : base(group, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Group), parent)
        {
            this.dimensionRef = new List<string>();
            if (group.AttachmentConstraint != null)
            {
                this.attachmentConstraintRef = RefUtil.CreateReference(this, group.AttachmentConstraint);
            }

            if (group.GroupDimension != null)
            {
                this.dimensionRef = new List<string>();
                foreach (GroupDimension each in group.GroupDimension)
                {
                    this.dimensionRef.Add(RefUtil.CreateLocalIdReference(each.DimensionReference));
                }
            }

            this.ValidateGroupAttributes();
        }
        /// <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();
        }
        /// <summary>
        /// Populate the <paramref name="metadataflowRef"/>  from <paramref name="crossReference"/>
        /// </summary>
        /// <param name="crossReference">
        /// The cross reference.
        /// </param>
        /// <param name="metadataflowRef">
        /// The metadataflow reference.
        /// </param>
        internal void PopulateMetadataflowRef(ICrossReference crossReference, MetadataflowRefType metadataflowRef)
        {
            IMaintainableRefObject maintRef = crossReference.MaintainableReference;
            {
                metadataflowRef.URN = crossReference.TargetUrn;
            }

            string str1 = maintRef.AgencyId;
            if (!string.IsNullOrWhiteSpace(str1))
            {
                metadataflowRef.AgencyID = maintRef.AgencyId;
            }

            string str2 = maintRef.MaintainableId;
            if (!string.IsNullOrWhiteSpace(str2))
            {
                metadataflowRef.MetadataflowID = maintRef.MaintainableId;
            }

            string str3 = maintRef.Version;
            if (!string.IsNullOrWhiteSpace(str3))
            {
                metadataflowRef.Version = maintRef.Version;
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////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="DataAndMetadataSetReferenceCore"/> class.
        /// </summary>
        /// <param name="crossReference">
        /// The cross reference. 
        /// </param>
        /// <param name="id1">
        /// The id 1. 
        /// </param>
        /// <param name="isIsDataSetReference2">
        /// The is is data set reference 2. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public DataAndMetadataSetReferenceCore(
            ICrossReference crossReference, string id1, bool isIsDataSetReference2)
        {
            this._icrossReference = crossReference;
            this._id = id1;
            this._isIsDataSetReference = isIsDataSetReference2;
            if (crossReference == null)
            {
                throw new SdmxSemmanticException(
                    "DataAndMetadataSetReferenceCore expects IcrossReference (null was provided)");
            }

            if (id1 == null)
            {
                throw new SdmxSemmanticException("DataAndMetadataSetReferenceCore expects id (null was provided)");
            }
        }
        /// <summary>
        /// Populate the <paramref name="dataProviderRef"/>  from <paramref name="crossReference"/>
        /// </summary>
        /// <param name="crossReference">
        /// The cross reference.
        /// </param>
        /// <param name="dataProviderRef">
        /// The data Provider reference.
        /// </param>
        internal void PopulateDataproviderRef(ICrossReference crossReference, DataProviderRefType dataProviderRef)
        {
            IMaintainableRefObject maintRef = crossReference.MaintainableReference;
            {
                dataProviderRef.URN = crossReference.TargetUrn;
            }

            string str1 = maintRef.AgencyId;
            if (!string.IsNullOrWhiteSpace(str1))
            {
                dataProviderRef.OrganisationSchemeAgencyID = maintRef.AgencyId;
            }

            string str2 = maintRef.MaintainableId;
            if (!string.IsNullOrWhiteSpace(str2))
            {
                dataProviderRef.OrganisationSchemeID = maintRef.MaintainableId;
            }

            string str3 = maintRef.Version;
            if (!string.IsNullOrWhiteSpace(str3))
            {
                dataProviderRef.Version = maintRef.Version;
            }

            string str4 = crossReference.ChildReference.Id;
            if (!string.IsNullOrWhiteSpace(str4))
            {
                dataProviderRef.DataProviderID = crossReference.ChildReference.Id;
            }
        }
 /// <summary>
 /// Adds components to the component map.
 /// </summary>
 /// <param name="retrievalManager">
 /// The retrieval manager
 /// </param>
 /// <param name="crossRef">
 /// The cross reference object
 /// </param>
 /// <param name="componentMap">
 /// The components map
 /// </param>
 private void AddComponenents(ISdmxObjectRetrievalManager retrievalManager, ICrossReference crossRef, IDictionary<String, IComponent> componentMap)
 {
     switch (crossRef.TargetReference.EnumType)
     {
         case SdmxStructureEnumType.ProvisionAgreement:
             IProvisionAgreementObject prov = retrievalManager.GetMaintainableObject<IProvisionAgreementObject>(crossRef);
             if (prov == null)
             {
                 prov = _beanRetrievalManager.GetMaintainableObject<IProvisionAgreementObject>(crossRef);
                 if (prov == null)
                     throw new CrossReferenceException(crossRef);
             }
             crossRef = prov.StructureUseage;  //Drop through to the next switch statement
             break;
         case SdmxStructureEnumType.Dataflow:
             IDataflowObject flow = retrievalManager.GetMaintainableObject<IDataflowObject>(crossRef);
             if (flow == null)
             {
                 flow = _beanRetrievalManager.GetMaintainableObject<IDataflowObject>(crossRef);
                 if (flow == null)
                     throw new CrossReferenceException(crossRef);
             }
             crossRef = flow.DataStructureRef;  //Drop through to the next switch statement
             break;
         case SdmxStructureEnumType.Dsd:
             IDataStructureObject dsd = retrievalManager.GetMaintainableObject<IDataStructureObject>(crossRef);
             if (dsd == null)
             {
                 dsd = _beanRetrievalManager.GetMaintainableObject<IDataStructureObject>(crossRef);
                 if (dsd == null)
                     throw new CrossReferenceException(crossRef);
             }
             foreach (IComponent currentComponent in dsd.Components)
                 componentMap.Add(currentComponent.Id, currentComponent);
             break;
     }
 }
 /// <summary>
 /// Resolves an identifiable reference
 /// </summary>
 /// <param name="crossReference"> Cross-reference object
 /// </param>
 /// <returns>
 /// SdmxException Not Implemented
 /// </returns>
 public IIdentifiableObject GetIdentifiableObject(ICrossReference crossReference)
 {
     throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetMaintainableFromSdmxObject, null);
 }
Example #32
0
 /// <summary>
 /// Generate a key using the following format AgencyID+ID+Version
 /// </summary>
 /// <param name="reference">
 /// The artefact reference to generate the key for
 /// </param>
 /// <returns>
 /// The key
 /// </returns>
 public static string MakeKey(ICrossReference reference)
 {
     return(MakeKey(reference.MaintainableReference.MaintainableId, reference.MaintainableReference.AgencyId, reference.MaintainableReference.Version));
 }
        /// <summary>
        /// Gets the reference from identifier.
        /// </summary>
        /// <param name="crossReference">The cross reference.</param>
        /// <returns>A string containing the URN or the <see cref="ISdmxObject"/> it referenced</returns>
        private static string GetReferenceFromIdentifier(ICrossReference crossReference)
        {
            if (crossReference == null)
            {
                throw new ArgumentNullException("crossReference");
            }

            var parentIdentifiable = crossReference.ReferencedFrom.GetParent<IIdentifiableObject>(true);
            if (parentIdentifiable != null)
            {
                return parentIdentifiable.Urn.ToString();
            }

            return crossReference.ReferencedFrom.ToString();
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="ComponentCore"/> class.
		/// </summary>
		/// <param name="createdFrom">
		/// The created from. 
		/// </param>
		/// <param name="structureType">
		/// The structure type. 
		/// </param>
		/// <param name="parent">
		/// The parent. 
		/// </param>
		protected internal ComponentCore(
			ComponentType createdFrom, SdmxStructureType structureType, IIdentifiableObject parent)
			: base(createdFrom, structureType, parent)
		{
			var simpleDataStructureRepresentationType = createdFrom.GetTypedLocalRepresentation<SimpleDataStructureRepresentationType>();
			if (simpleDataStructureRepresentationType != null)
			{
				this.LocalRepresentation = new RepresentationCore(simpleDataStructureRepresentationType, this);
			}

			if (createdFrom.ConceptIdentity != null)
			{
				this._conceptRef = RefUtil.CreateReference(this, createdFrom.ConceptIdentity);
			}

			// FUNC 2.1 put in Concept Identifity = conceptRef
			this.ValidateComponentAttributes();
		}