Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves all available dataflows.
        /// </summary>
        private IComplexStructureQuery RetrieveDataflows()
        {
            var dataflowRefBean = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow));
            IRestStructureQuery structureQueryDataflow = new RESTStructureQueryCore(dataflowRefBean);

            IBuilder <IComplexStructureQuery, IRestStructureQuery> transformerDataFlow = new StructureQuery2ComplexQueryBuilder();

            IComplexStructureQuery complexStructureQueryDataflow = transformerDataFlow.Build(structureQueryDataflow);

            IList <SdmxStructureType> specificObjects = new List <SdmxStructureType>();

            specificObjects.Add(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd));

            IComplexStructureQueryMetadata complexStructureQueryMetadataWithDsd =
                new ComplexStructureQueryMetadataCore(false,
                                                      ComplexStructureQueryDetail.GetFromEnum(ComplexStructureQueryDetailEnumType.Full),
                                                      ComplexMaintainableQueryDetail.GetFromEnum(ComplexMaintainableQueryDetailEnumType.Full),
                                                      StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific),
                                                      specificObjects);

            IComplexStructureQuery complexStructureQueryTempDataflow = new ComplexStructureQueryCore(
                complexStructureQueryDataflow.StructureReference, complexStructureQueryMetadataWithDsd);

            return(complexStructureQueryTempDataflow);
        }
        public StructureQueryMetadataCore(
            StructureQueryDetail structureQueryDetail,
            StructureReferenceDetail structureReferenceDetail,
            SdmxStructureType specificStructureReference,
            bool isReturnLatest)
        {
            if (structureReferenceDetail == StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific)
                && specificStructureReference == null)
            {
                throw new SdmxSemmanticException("SpecificStructureReference is null and specific reference detail was requested");
            }

            if (specificStructureReference != null && !specificStructureReference.IsMaintainable)
            {
               throw new SdmxSemmanticException("SpecificStructureReference is not maintainable");
            }

            if (structureQueryDetail != StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Null))
            {
                this.structureQueryDetail = structureQueryDetail;
            }

            if (structureReferenceDetail != null)
            {
                this.structureReferenceDetail = structureReferenceDetail;
            }

            if (specificStructureReference != null)
            {
                this.specificStructureReference = specificStructureReference;
            }

            this.isReturnLatest = isReturnLatest;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ComplexIdentifiableReferenceCore"/> class.
        /// </summary>
        /// <param name="id">
        /// The id. 
        /// </param>
        /// <param name="structureType">
        /// The structure type. 
        /// </param>
        /// <param name="annotationRef">
        /// The annotation ref. 
        /// </param> 
        /// <param name="nameRef">
        /// The name ref. 
        /// </param>
        /// <param name="descriptionRef">
        /// The description ref. 
        /// </param>
        /// <param name="childReference">
        /// The child reference. 
        /// </param> 
        public ComplexIdentifiableReferenceCore(IComplexTextReference id, SdmxStructureType structureType,
			IComplexAnnotationReference annotationRef, IComplexTextReference nameRef, IComplexTextReference descriptionRef,
			IComplexIdentifiableReferenceObject childReference) 
	    	: base(structureType, annotationRef, nameRef, descriptionRef)
	    {	
	        	this._id = id;
	        	this._childReference = childReference;
	    }
Ejemplo n.º 4
0
        /// <summary>
        /// Builds an <see cref="TableInfo"/> from the specified <paramref name="buildFrom"/>
        /// </summary>
        /// <param name="buildFrom">The type to build from.</param>
        /// <returns>
        /// an <see cref="TableInfo"/> from the specified <paramref name="buildFrom"/>
        /// </returns>
        public TableInfo Build(Type buildFrom)
        {
            var propertyInfo      = buildFrom.GetProperty("ImmutableInstance");
            var returnType        = propertyInfo.GetGetMethod().ReturnType;
            var sdmxStructureType = SdmxStructureType.ParseClass(returnType);

            return(this.Build(sdmxStructureType));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IdentifiableRefObjetcImpl"/> class.
        /// </summary>
        /// <param name="maintainableParent">
        /// The maintainable parent.
        /// </param>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="targetStructureEnumType">
        /// The target structure enum type.
        /// </param>
        public IdentifiableRefObjetcImpl(
            IStructureReference maintainableParent, string id, SdmxStructureType targetStructureEnumType)
        {
            this._structureEnumType = targetStructureEnumType;
            this._maintainableParent = maintainableParent;
            this._id = id;

            Validate();
        }
Ejemplo n.º 6
0
		///////////////////////////////////////////////////////////////////////////////////////////////////
		////////////BUILD FROM V1 SCHEMA				 //////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////
		public ItemCore(
				XmlObject createdFrom,
				SdmxStructureType structureType,
				String id,
				String uri,
				IList<Org.Sdmx.Resources.SdmxMl.Schemas.V10.Common.TextType> name,
				IList<Org.Sdmx.Resources.SdmxMl.Schemas.V10.Common.TextType> description,
				Org.Sdmx.Resources.SdmxMl.Schemas.V10.Common.AnnotationsType annotationsType,
				IIdentifiableObject parent) {
		}
Ejemplo n.º 7
0
        /// <summary>
        /// Retrieves all available categorisations and category schemes.
        /// </summary>
        private IComplexStructureQuery RetrieveCategorySchemesAndCategorisations()
        {
            var catSch = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryScheme));
            IRestStructureQuery structureQueryCategoryScheme = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Parents), null, catSch, false);
            IBuilder <IComplexStructureQuery, IRestStructureQuery> transformerCategoryScheme = new StructureQuery2ComplexQueryBuilder();

            IComplexStructureQuery complexStructureQueryCategoryScheme = transformerCategoryScheme.Build(structureQueryCategoryScheme);

            return(complexStructureQueryCategoryScheme);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ComplexStructureReferenceCore"/> class.
        /// </summary>
        /// <param name="agencyId">
        /// The agency id. 
        /// </param>
        /// <param name="id">
        /// The id. 
        /// </param>
        /// <param name="versionRef">
        /// The version ref. 
        /// </param>
        /// <param name="structureType">
        /// The structure type. 
        /// </param>
        /// <param name="annotationRef">
        /// The annotation ref. 
        /// </param>
        /// <param name="nameRef">
        /// The name ref. 
        /// </param>
        /// <param name="descriptionRef">
        /// The description ref. 
        /// </param>
        /// <param name="childRef">
        /// The child ref. 
        /// </param>
        public ComplexStructureReferenceCore(IComplexTextReference agencyId, IComplexTextReference id,
            IComplexVersionReference versionRef, SdmxStructureType structureType, IComplexAnnotationReference annotationRef,
			IComplexTextReference nameRef, IComplexTextReference descriptionRef, IComplexIdentifiableReferenceObject childRef) 
		: base(structureType, annotationRef, nameRef, descriptionRef)
		{
		this._id = id;
		this._agencyId = agencyId;
		this._versionRef = versionRef;
		//TODO childRef defaults && null check...
		this._childRef = childRef;
	    }
        /// <summary>
        /// Deletes annotations for annotatoble with the specified <paramref name="annotableSysId"/> and the specified <paramref name="type"/>
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="annotableSysId">The annotable system identifier.</param>
        /// <param name="type">The type.</param>
        /// <param name="structureType">Type of the structure.</param>
        /// <returns>The number of annotations deleted.</returns>
        public int DeleteByType(DbTransactionState state, long annotableSysId, string type, SdmxStructureType structureType)
        {
            var annotationRelationTable = this._annotationRelationInfoBuilder.Build(structureType);

            var query = string.Format(
                CultureInfo.InvariantCulture,
                "DELETE FROM ANNOTATION WHERE ANN_ID IN (SELECT DISTINCT ANN_ID FROM {0} WHERE {1} = {{0}} AND TYPE={{1}})",
                annotationRelationTable.Table,
                annotationRelationTable.PrimaryKey);
            return state.Database.ExecuteNonQueryFormat(query, this._mappingStoreDatabase.CreateInParameter("p_id", DbType.Int64, annotableSysId), this._mappingStoreDatabase.CreateInParameter("p_type", DbType.String, type));
        }
Ejemplo n.º 10
0
        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));
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Retrieves all available dataflows.
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        private string RetrieveDataflows()
        {
            var dataflowRefBean = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow));

            IRestStructureQuery            structureQuery = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific), SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd), dataflowRefBean, true);
            IStructureQueryFactory         factory        = new RestStructureQueryFactory();
            IStructureQueryBuilderManager  structureQueryBuilderManager = new StructureQueryBuilderManager(factory);
            IStructureQueryFormat <string> structureQueryFormat         = new RestQueryFormat();
            string request = structureQueryBuilderManager.BuildStructureQuery(structureQuery, structureQueryFormat);

            return(request);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Retrieves all available categorisations and category schemes.
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        private string RetrieveCategorySchemesAndCategorisations()
        {
            var catSch = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryScheme));
            IStructureQueryFormat <string> structureQueryFormat         = new RestQueryFormat();
            IRestStructureQuery            structureQueryCategoryScheme = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Parents), null, catSch, false);
            IStructureQueryFactory         factory = new RestStructureQueryFactory();

            IStructureQueryBuilderManager structureQueryBuilderManager = new StructureQueryBuilderManager(factory);
            string request = structureQueryBuilderManager.BuildStructureQuery(structureQueryCategoryScheme, structureQueryFormat);

            return(request);
        }
        /// <summary>
        /// Initialie a new instance of the <see cref="RetrievalManager"/> class.
        /// </summary>
        /// <param name="_dataFlowID">
        /// Dataflow ID
        /// </param>
        /// <param name="_versionType">Sdmx Version</param>
        public RetrievalManager(string _dataFlowID, SdmxSchemaEnumType _versionType)
        {
            try
            {
                this.DataFlowID  = _dataFlowID;
                this.VersionType = _versionType;
                DataStructureEngineObject ds      = new DataStructureEngineObject();
                ISDMXObjectBuilder        Builder = ds.CreateBuilder(new SdmxParsingObject(SdmxStructureEnumType.Dataflow)
                {
                    MaintainableId    = DataFlowID,
                    References        = StructureReferenceDetailEnumType.Specific,
                    SpecificReference = new List <SdmxStructureType>()
                    {
                        SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd),
                        SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme),
                    },
                    QueryDetail = StructureQueryDetailEnumType.Full,
                }, _versionType);

                Builder.Build();
                Builder.AddReferences();

                if (Builder._KeyFamily == null || Builder._KeyFamily.Count == 0)
                {
                    throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, new Exception(string.Format("Dsd Not found for Dataflow code: {0}", DataFlowID)));
                }

                //1DF = 1DSD
                this._dsd = Builder._KeyFamily[0];


                if (Builder._Dataflows.Count > 0)
                {
                    this.DataFlowTitle = Builder._Dataflows[0].Name;
                }
                else
                {
                    throw new Exception("No Dataflow Found");
                }
                this._sdmxObjects = Builder.CreateDSD();


                this.DataFlowID = Builder._Dataflows[0].Id;
                GetGroups();
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, ex);
                //non sono riuscito a cambiare il nome che è arrivato dalla query con quello effettivo della dsd
            }
        }
Ejemplo n.º 14
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="IdentifiableTargetCore"/> class.
        /// </summary>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public IdentifiableTargetCore(IIdentifiableTargetMutableObject itemMutableObject, IMetadataTarget parent)
            : base(itemMutableObject, parent, false)
        {
            this.referencedStructureType = itemMutableObject.ReferencedStructureType;
            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
Ejemplo n.º 15
0
        private string RetrieveDataflow(string id, string agency, string version)
        {
            IMaintainableRefObject df = new MaintainableRefObjectImpl(agency, id, version);
            var dataflowRefBean       = new StructureReferenceImpl(df, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow));

            IRestStructureQuery            structureQuery = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific), SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd), dataflowRefBean, true);
            IStructureQueryFactory         factory        = new RestStructureQueryFactory();
            IStructureQueryBuilderManager  structureQueryBuilderManager = new StructureQueryBuilderManager(factory);
            IStructureQueryFormat <string> structureQueryFormat         = new RestQueryFormat();
            string request = structureQueryBuilderManager.BuildStructureQuery(structureQuery, structureQueryFormat);

            return(request);
        }
Ejemplo n.º 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="artefact"></param>
        /// <param name="sysId"></param>
        private void PopulateConstraintGeneral(IContentConstraintMutableObject artefact, long sysId)
        {
            var inParameter = MappingStoreDb.CreateInParameter(ParameterNameConstants.IdParameter, DbType.Int64, sysId);

            using (DbCommand command = MappingStoreDb.GetSqlStringCommandParam(ContentConstraintConstant.SqlConsInfo, inParameter))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    bool bGeneral = true;

                    artefact.ReleaseCalendar      = new ReleaseCalendarMutableCore();
                    artefact.ConstraintAttachment = new ContentConstraintAttachmentMutableCore();

                    while (dataReader.Read())
                    {
                        if (bGeneral)
                        {
                            if (dataReader["PERIODICITY"] != DBNull.Value)
                            {
                                artefact.ReleaseCalendar.Periodicity = dataReader["PERIODICITY"].ToString();
                            }

                            if (dataReader["OFFSET"] != DBNull.Value)
                            {
                                artefact.ReleaseCalendar.Offset = dataReader["OFFSET"].ToString();
                            }

                            if (dataReader["TOLERANCE"] != DBNull.Value)
                            {
                                artefact.ReleaseCalendar.Tolerance = dataReader["TOLERANCE"].ToString();
                            }

                            if (String.IsNullOrEmpty(artefact.ReleaseCalendar.Periodicity))
                            {
                                artefact.ReleaseCalendar = null;
                            }

                            bGeneral = false;
                        }


                        IStructureReference structRef = new StructureReferenceImpl(dataReader["AGENCY"].ToString(),
                                                                                   dataReader["ID"].ToString(), dataReader["VERSION"].ToString(),
                                                                                   SdmxStructureType.GetFromEnum((SdmxStructureEnumType)Enum.Parse(typeof(SdmxStructureEnumType), dataReader["ARTEFACT_TYPE"].ToString())),
                                                                                   new string[] { });

                        artefact.ConstraintAttachment.AddStructureReference(structRef);
                    }
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Retrieves the urn map.
        /// </summary>
        /// <param name="sdmxStructure">The SDMX structure.</param>
        /// <returns>
        /// The map between System ID to URN
        /// </returns>
        public IDictionary <long, string> RetrievesUrnMap(SdmxStructureType sdmxStructure)
        {
            string query;

            if (sdmxStructure.IsMaintainable)
            {
                TableInfo tableInfo = this._tableInfoBuilder.Build(sdmxStructure);
                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT A.ART_ID as SYSID, A.AGENCY, A.ID, A.VERSION FROM ARTEFACT_VIEW A WHERE A.ART_ID in (SELECT {0} FROM {1})",
                    tableInfo.PrimaryKey,
                    tableInfo.Table);
                IDictionary <long, string> dictionary = new Dictionary <long, string>();
                foreach (dynamic o in this._mappingStoreDatabase.Query(query))
                {
                    long sysid = o.SYSID;

                    Uri generateUrn = sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION);
                    var result      = new KeyValuePair <long, string>(sysid, generateUrn.ToString());
                    dictionary.Add(result);
                }

                return(dictionary);
            }
            else
            {
                var itemTableInfo = this._itemTableInfoBuilder.Build(sdmxStructure);
                if (itemTableInfo == null)
                {
                    throw new NotImplementedException(sdmxStructure.ToString());
                }

                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT I.ITEM_ID as SYSID, A.AGENCY, A.ID, A.VERSION, I.ID as IID FROM ARTEFACT_VIEW A INNER JOIN {1} T ON A.ART_ID = T.{2} INNER JOIN ITEM I ON I.ITEM_ID = T.{0}",
                    itemTableInfo.PrimaryKey,
                    itemTableInfo.Table,
                    itemTableInfo.ForeignKey);
                IDictionary <long, string> dictionary = new Dictionary <long, string>();
                foreach (dynamic o in this._mappingStoreDatabase.Query(query))
                {
                    Uri  generateUrn = sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION, o.IID);
                    long systemId    = o.SYSID;
                    var  result      = new KeyValuePair <long, string>(systemId, generateUrn.ToString());
                    dictionary.Add(result);
                }

                return(dictionary);
            }
        }
        /// <summary>
        /// Build concept scheme requests from the concept scheme references of the specified KeyFamilyBean object
        /// </summary>
        /// <param name="kf">
        /// The KeyFamily to look for concept Scheme references
        /// </param>
        /// <returns>
        /// A list of concept scheme requests
        /// </returns>
        public static IEnumerable <IStructureReference> BuildConceptSchemeRequest(IDataStructureObject kf)
        {
            var conceptSchemeSet = new Dictionary <string, object>();
            var ret      = new List <IStructureReference>();
            var crossDsd = kf as ICrossSectionalDataStructureObject;

            List <IComponent> components = new List <IComponent>();

            components.AddRange(kf.GetDimensions());
            components.AddRange(kf.Attributes);
            if (kf.PrimaryMeasure != null)
            {
                components.Add(kf.PrimaryMeasure);
            }
            if (crossDsd != null)
            {
                components.AddRange(crossDsd.CrossSectionalMeasures);
            }

            ICollection <IComponent> comps = components;

            foreach (IComponent comp in comps)
            {
                string key = Utils.MakeKey(comp.ConceptRef.MaintainableReference.MaintainableId, comp.ConceptRef.MaintainableReference.Version, comp.ConceptRef.MaintainableReference.AgencyId);
                if (!conceptSchemeSet.ContainsKey(key))
                {
                    // create concept ref


                    var conceptSchemeRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme))
                    {
                        MaintainableId = comp.ConceptRef.MaintainableReference.MaintainableId,
                        AgencyId       = comp.ConceptRef.MaintainableReference.AgencyId,
                        Version        = comp.ConceptRef.MaintainableReference.Version
                    };

                    // add it to request
                    ret.Add(conceptSchemeRef);

                    // added it to set of visited concept schemes
                    conceptSchemeSet.Add(key, null);
                }
            }

            return(ret);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Gets a bean with data about the key family for specified dataflow.
        /// </summary>
        /// <param name="dataflow">
        /// The dataflow
        /// </param>
        /// <returns>
        /// a <c>StructureBean</c> instance with requested data; the result is never <c>null</c> or  incomplete, instead an exception is throwed away if something goes wrong and not all required data is successfully retrieved
        /// </returns>
        /// <remarks>
        /// The resulted bean will contain exactly one key family, but also will include any concepts and codelists referenced by the key family.
        /// </remarks>
        public ISdmxObjects GetStructure(IDataflowObject dataflow, ISet <IDataStructureObject> dataStructures, bool resolseRef = false)
        {
            Logger.InfoFormat(
                CultureInfo.InvariantCulture,
                Resources.InfoGettingStructureFormat3,
                dataflow.AgencyId,
                dataflow.Id,
                dataflow.Version);
            ISdmxObjects structure;

            var keyFamilyRefBean = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd))
            {
                MaintainableId = dataflow.DataStructureRef.MaintainableReference.MaintainableId,
                AgencyId       = dataflow.DataStructureRef.MaintainableReference.AgencyId,
                Version        = dataflow.DataStructureRef.MaintainableReference.Version
            };

            try
            {
                ISdmxObjects response;

                structure = this.SendQueryStructureRequest(keyFamilyRefBean, false);
                NsiClientValidation.CheckifStructureComplete(structure, dataflow);
                IEnumerable <IStructureReference> conceptRefs = NsiClientHelper.BuildConceptSchemeRequest(structure.DataStructures.First());
                response = this.SendQueryStructureRequest(conceptRefs, false);

                structure.Merge(response);

                NsiClientValidation.CheckConcepts(structure);
                Logger.Info(Resources.InfoSuccess);
            }
            catch (NsiClientException e)
            {
                Logger.Error(Resources.ExceptionGettingStructure);
                Logger.Error(e.Message, e);
                throw;
            }
            catch (Exception e)
            {
                Logger.Error(Resources.ExceptionGettingStructure);
                Logger.Error(e.Message, e);
                throw new NsiClientException(Resources.ExceptionGettingStructure, e);
            }

            return(structure);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Retrieves all available categorisations.
        /// </summary>
        /// <returns>
        ///   a list of &amp;lt;c&amp;gt;ISdmxObjects&amp;lt;/c&amp;gt; instances; the result won&amp;apos;t be &amp;lt;c&amp;gt;null&amp;lt;/c&amp;gt; if there are no
        ///   dataflows, instead an empty list will be returned
        /// </returns>
        public ISdmxObjects RetrieveCategorisations()
        {
            Logger.Info(Resources.InfoGettingCategorySchemes);

            ISdmxObjects response = new SdmxObjectsImpl();

            //get dataflows
            var dataflowRefBean = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow));
            //get category scheme
            var catSch = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryScheme));

            IList <IStructureReference> refs = new List <IStructureReference>();

            refs.Add(catSch);
            refs.Add(dataflowRefBean);
            try
            {
                response = this.SendQueryStructureRequest(refs, false);

                if (response.CategorySchemes != null && response.Dataflows != null)
                {
                    Logger.Info(Resources.InfoSuccess);
                }
            }
            catch (NsiClientException e)
            {
                Logger.Error(Resources.ExceptionGettingDataflow);
                Logger.Error(e.Message, e);
                throw;
            }
            catch (DataflowException e)
            {
                throw;
            }
            catch (Exception e)
            {
                Logger.Error(Resources.ExceptionGettingDataflow);
                Logger.Error(e.Message, e);
                throw new NsiClientException(Resources.ExceptionGettingDataflow, e);
            }
            if (response.Dataflows != null && response.Dataflows.Count == 0)
            {
                throw new DataflowException(Resources.NoResultsFound);
            }
            return(response);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Retrieves the urn map.
        /// </summary>
        /// <param name="sdmxStructure">The SDMX structure.</param>
        /// <returns>
        /// The map between System ID to URN
        /// </returns>
        public IDictionary <string, long> RetrievesUrnToSysIdMap(SdmxStructureType sdmxStructure)
        {
            string query;

            if (sdmxStructure.IsMaintainable)
            {
                TableInfo tableInfo = this._tableInfoBuilder.Build(sdmxStructure);
                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT A.ART_ID as SYSID, A.AGENCY, A.ID, A.VERSION FROM ARTEFACT_VIEW A WHERE A.ART_ID in (SELECT {0} FROM {1})",
                    tableInfo.PrimaryKey,
                    tableInfo.Table);
                IDictionary <string, long> dictionary = new Dictionary <string, long>(StringComparer.Ordinal);
                foreach (var result in this._mappingStoreDatabase.Query(query).Select(o => new KeyValuePair <string, long>(sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION).ToString(), o.SYSID)))
                {
                    Debug.Assert(!dictionary.ContainsKey(result.Key), "Already got key : {0}", result.Key);
                    dictionary.Add(result);
                }

                return(dictionary);
            }
            else
            {
                var itemTableInfo = this._itemTableInfoBuilder.Build(sdmxStructure);
                if (itemTableInfo == null)
                {
                    throw new NotImplementedException(sdmxStructure.ToString());
                }

                query = string.Format(
                    CultureInfo.InvariantCulture,
                    "SELECT I.ITEM_ID as SYSID, A.AGENCY, A.ID, A.VERSION, I.ID as IID FROM ARTEFACT_VIEW A INNER JOIN {1} T ON A.ART_ID = T.{2} INNER JOIN ITEM I ON I.ITEM_ID = T.{0}",
                    itemTableInfo.PrimaryKey,
                    itemTableInfo.Table,
                    itemTableInfo.ForeignKey);
                IDictionary <string, long> dictionary = new Dictionary <string, long>(StringComparer.Ordinal);
                foreach (var result in this._mappingStoreDatabase.Query(query).Select(o => new KeyValuePair <string, long>(sdmxStructure.GenerateUrn(o.AGENCY, o.ID, o.VERSION, o.IID).ToString(), o.SYSID)))
                {
                    dictionary.Add(result);
                }

                return(dictionary);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Gets a bean with data about the codelist for specified dataflow and component.
        /// The dataflow can be retrieved from <see cref="RetrieveTree"/> and the component from <see cref="GetStructure"/>
        /// </summary>
        /// <param name="dataflow">
        /// The dataflow
        /// </param>
        /// <param name="component">
        /// The component
        /// </param>
        /// <param name="criteria">
        /// The criteria includes a set of Member and MemberValue(s) for each dimension. The Member has componentRef the dimension conceptRef and the MemberValue(s) specify the selected codes for this dimension.
        /// </param>
        /// <returns>
        /// A <c>CodeListBean</c> with the requested data
        /// </returns>
        public ICodelistObject GetCodelist(
            IDataflowObject dataflow,
            IDataStructureObject dsd,
            IComponent component,
            List <IContentConstraintMutableObject> criterias,
            bool Constrained)
        {
            var codelistRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList));
            var dimension   = component as IDimension;

            if (dimension != null && dimension.TimeDimension)
            {
                codelistRef.MaintainableId = CustomCodelistConstants.TimePeriodCodeList;
                codelistRef.AgencyId       = CustomCodelistConstants.Agency;
                codelistRef.Version        = CustomCodelistConstants.Version;
            }
            else if (dimension != null && dimension.MeasureDimension && dsd is ICrossSectionalDataStructureObject)
            {
                var crossDsd = dsd as ICrossSectionalDataStructureObject;
                codelistRef.MaintainableId = crossDsd.GetCodelistForMeasureDimension(dimension.Id).MaintainableReference.MaintainableId;
                codelistRef.AgencyId       = crossDsd.GetCodelistForMeasureDimension(dimension.Id).MaintainableReference.AgencyId;
                codelistRef.Version        = crossDsd.GetCodelistForMeasureDimension(dimension.Id).MaintainableReference.Version;
            }
            else
            {
                if (component.HasCodedRepresentation())
                {
                    codelistRef.MaintainableId = component.Representation.Representation.MaintainableReference.MaintainableId;
                    codelistRef.AgencyId       = component.Representation.Representation.MaintainableReference.AgencyId;
                    codelistRef.Version        = component.Representation.Representation.MaintainableReference.Version;
                }
            }

            string info = string.Format(
                CultureInfo.InvariantCulture,
                Resources.InfoPartialCodelistFormat3,
                Utils.MakeKey(dataflow),
                component.ConceptRef,
                Utils.MakeKey(codelistRef));

            return(this.GetCodelist(dataflow, codelistRef, criterias, info, Constrained));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Get the maximum number of observations that can be retrieved given the specified criteria
        /// </summary>
        /// <param name="dataflow">
        /// The dataflow
        /// </param>
        /// <param name="criteria">
        /// The criteria includes a set of Member and MemberValue(s) for each dimension. Each member should have member values else they shouldn't be included. It can be null
        /// </param>
        /// <returns>
        /// The maximum number of observations or -1 if it can't be parsed or it is not available
        /// </returns>
        /// <exception cref="NsiClientException">
        /// NSI WS communication error or parsing error
        /// </exception>
        public int GetDataflowDataCount(IDataflowObject dataflow, IContentConstraintMutableObject criteria)
        {
            int count;
            List <IContentConstraintMutableObject> criterias = new List <IContentConstraintMutableObject>();

            if (criteria == null)
            {
                criteria = new ContentConstraintMutableCore();
            }

            criteria.Id = CustomCodelistConstants.CountCodeList;
            criteria.AddName("en", "name");
            criteria.AgencyId = "agency";
            criterias.Add(criteria);

            var codelistRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList))
            {
                MaintainableId = CustomCodelistConstants.CountCodeList,
                AgencyId       = CustomCodelistConstants.Agency,
                Version        = CustomCodelistConstants.Version
            };
            string info = string.Format(CultureInfo.InvariantCulture, Resources.InfoCountFormat2, Utils.MakeKey(dataflow), Utils.MakeKey(codelistRef));

            try
            {
                ICodelistObject countCodelist = this.GetCodelist(dataflow, codelistRef, criterias, info, true);
                if (!CustomCodelistConstants.IsCountCodeList(countCodelist) ||
                    !int.TryParse(countCodelist.Items[0].Id, out count))
                {
                    Logger.WarnFormat(CultureInfo.InvariantCulture, Resources.ExceptionParsingCountCodelistFormat0, info);

                    throw new NsiClientException("Error parsing the count codelist for " + info);
                }
            }
            catch (NsiClientException ex)
            {
                Logger.Warn(ex.Message, ex);
                count = -1;
            }

            return(count);
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Generic method for retrieving <see cref="IStructureReference"/> based objects
 /// </summary>
 /// <param name="outList">
 /// The output list
 /// </param>
 /// <param name="command">
 /// The current <see cref="DbCommand"/>
 /// </param>
 /// <param name="structureType">
 /// The structure Type.
 /// </param>
 protected void RetrieveRef(ICollection <IStructureReference> outList, DbCommand command, SdmxStructureEnumType structureType)
 {
     _log.DebugFormat("RetrieveRef of {0} SQL : {1}", structureType, command.CommandText);
     using (IDataReader dataReader = this._mappingStoreDb.ExecuteReader(command))
     {
         int idField      = dataReader.GetOrdinal("ID");
         int agencyField  = dataReader.GetOrdinal("AGENCY");
         int versionField = dataReader.GetOrdinal("VERSION");
         while (dataReader.Read())
         {
             var item = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(structureType))
             {
                 MaintainableId = DataReaderHelper.GetString(dataReader, idField),
                 Version        = DataReaderHelper.GetString(dataReader, versionField),
                 AgencyId       = DataReaderHelper.GetString(dataReader, agencyField)
             };
             outList.Add(item);
         }
     }
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Returns the referenced from inner joins to use with <see cref="ArtefactParentsSqlBuilder"/>
        /// </summary>
        /// <param name="structureEnumType">
        ///     The structure  type.
        /// </param>
        /// <returns>
        /// The referenced from inner joins
        /// </returns>
        protected override string GetReferencedFromInnerJoins(SdmxStructureEnumType structureEnumType)
        {
            string innerJoin = null;

            switch (structureEnumType)
            {
            case SdmxStructureEnumType.Category:
            case SdmxStructureEnumType.CategoryScheme:
                innerJoin = CategorySchemeConstant.ReferencedByCategorisation;
                break;

            default:
                if (SdmxStructureType.GetFromEnum(structureEnumType).IsMaintainable)
                {
                    innerJoin = CategorisationConstant.ReferencedByCategorisation;
                }

                break;
            }

            return(innerJoin);
        }
       /// <summary>
       /// Initializes a new instance of the <see cref="ComplexNameableReferenceCore"/> class.
       /// </summary>
       /// <param name="structureType">
       /// The structure type. 
       /// </param>
       /// <param name="annotationRef">
       /// The annotation ref. 
       /// </param>
       /// <param name="nameRef">
       /// The name ref. 
       /// </param>
       /// <param name="descriptionRef">
       /// The description ref. 
       /// </param>
        public ComplexNameableReferenceCore(SdmxStructureType structureType, IComplexAnnotationReference annotationRef,
			IComplexTextReference nameRef, IComplexTextReference descriptionRef)
        {
		
	  	   if ( structureType == null )
           {
		    	throw new SdmxSemmanticException("Null structure type provided for reference in query.");
		   }
		
		   this._structureType = structureType;	
		   if (annotationRef != null) 
           {
		    	this._annotationRef = annotationRef;
		   }
	  	   if (nameRef != null) 
           {
		    	this._nameRef = nameRef;	
		   }
		   if (descriptionRef != null) 
           {
			    this._descriptionRef = descriptionRef;
		   }
	  }
        /// <summary>
        /// Initializes a new instance of the <see cref="RESTStructureQueryCore"/> class. 
        /// </summary>
        /// <param name="structureQueryDetail">
        /// The structure query detail. 
        /// </param>
        /// <param name="structureReferenceDetail">
        /// The structure reference detail. 
        /// </param>
        /// <param name="specificStructureReference">
        /// The specific structure reference. 
        /// </param>
        /// <param name="structureReference">
        /// The structure reference. 
        /// </param>
        /// <param name="returnLatest">
        /// The return last. 
        /// </param>
	    public RESTStructureQueryCore(StructureQueryDetail structureQueryDetail, StructureReferenceDetail structureReferenceDetail,
			SdmxStructureType specificStructureReference, IStructureReference structureReference, bool returnLatest)
         {
		       this._structureQueryMetadata = new StructureQueryMetadataCore(structureQueryDetail, structureReferenceDetail, specificStructureReference, returnLatest);
		       this._structureReference = structureReference;
	     }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotableMutableCore"/> class.
 /// </summary>
 /// <param name="structureType">
 /// The structure type. 
 /// </param>
 protected AnnotableMutableCore(SdmxStructureType structureType)
     : base(structureType)
 {
     this._annotations = new List<IAnnotationMutableObject>();
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Deletes annotations for annotatoble with the specified <paramref name="annotableSysId"/> and the specified <paramref name="type"/>
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="annotableSysId">The annotable system identifier.</param>
        /// <param name="type">The type.</param>
        /// <param name="structureType">Type of the structure.</param>
        /// <returns>The number of annotations deleted.</returns>
        public int DeleteByType(DbTransactionState state, long annotableSysId, string type, SdmxStructureType structureType)
        {
            var annotationRelationTable = this._annotationRelationInfoBuilder.Build(structureType);

            var query = string.Format(
                CultureInfo.InvariantCulture,
                "DELETE FROM ANNOTATION WHERE ANN_ID IN (SELECT DISTINCT ANN_ID FROM {0} WHERE {1} = {{0}} AND TYPE={{1}})",
                annotationRelationTable.Table,
                annotationRelationTable.PrimaryKey);

            return(state.Database.ExecuteNonQueryFormat(query, this._mappingStoreDatabase.CreateInParameter("p_id", DbType.Int64, annotableSysId), this._mappingStoreDatabase.CreateInParameter("p_type", DbType.String, type)));
        }
 /// <summary>
 /// Gets the unique identifier.
 /// </summary>
 /// <param name="targetObj">The target object.</param>
 /// <param name="id">The unique identifier.</param>
 /// <returns>
 /// The ID.
 /// </returns>
 private static string GetID(SdmxStructureType targetObj, string id)
 {
     return targetObj.HasFixedId ? targetObj.FixedId : id;
 }
Ejemplo n.º 31
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////VALIDATION                             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Methods

        /// <summary>
        ///   The validate.
        /// </summary>
        /// <exception cref="SdmxSemmanticException">Throws Validate exception.</exception>
        private void Validate()
        {
            // Sanity Check, make sure we can build both ways
            string objIdEnum = XmlobjectsEnumUtil.BuildV21(this.referencedStructureType);
            this.referencedStructureType = XmlobjectsEnumUtil.GetSdmxStructureTypeV21(objIdEnum);

            if (this.LocalRepresentation == null)
            {
                // Create a Local Representation if one doesn't exist. The schema insists on there being an Identifiable Reference
                ITextFormatMutableObject textFormatMutable = new TextFormatMutableCore();
                textFormatMutable.TextType = TextType.GetFromEnum(TextEnumType.IdentifiableReference);
                IRepresentationMutableObject representationMutable = new RepresentationMutableCore();
                representationMutable.TextFormat = textFormatMutable;
                this.LocalRepresentation = new RepresentationCore(representationMutable, this);
                return;
            }

            if (this.LocalRepresentation.Representation == null)
            {
                // Create a local representation if one doesn't exist. The schema insists on there being an Identifiable Reference 
                if (this.LocalRepresentation == null || this.LocalRepresentation.TextFormat == null
                    || this.LocalRepresentation.TextFormat.TextType.EnumType != TextEnumType.IdentifiableReference)
                {
                    ITextFormatMutableObject textFormatMutable = new TextFormatMutableCore();
                    textFormatMutable.TextType = TextType.GetFromEnum(TextEnumType.IdentifiableReference);
                    IRepresentationMutableObject representationMutable = new RepresentationMutableCore();
                    representationMutable.TextFormat = textFormatMutable;
                    this.LocalRepresentation = new RepresentationCore(representationMutable, this);
                }
            }
            else
            {
                if (this.LocalRepresentation.TextFormat != null)
                {
                    throw new SdmxSemmanticException(
                        "Can not have both TextFormat and Representation set on IdentifiableObjectTarget");
                }
            }

            if (this.referencedStructureType == null)
            {
                throw new SdmxSemmanticException("Identifiable target is missing Target CategorisationStructure Type (objectType)");
            }
        }
Ejemplo n.º 32
0
        // ///////////////////////////////////////////////////////////////////////////////////////////////////
        // ////////////BUILD FROM READER                    //////////////////////////////////////////////////
        // ///////////////////////////////////////////////////////////////////////////////////////////////////    
        // public AnnotableCore(SdmxStructureType structure, SdmxReader reader, ISdmxStructure parent) {
        // super(structure, parent);
        // string currentElement = reader.getCurrentElement();
        // if(reader.peek().equals("Annotations")) {
        // reader.moveNextElement();
        // while(reader.peek().equals("Annotation")) {
        // reader.moveNextElement();
        // annotations.add(new AnnotationObjectCore(reader, this));
        // }
        // reader.moveBackToElement(currentElement);
        // }
        // }

        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////    

        /// <summary>
        ///   Initializes a new instance of the <see cref="AnnotableCore" /> class.
        /// </summary>
        /// <param name="createdFrom"> The created from. </param>
        /// <param name="structureType"> The structure type. </param>
        /// <param name="parent"> The parent. </param>
        protected internal AnnotableCore(
            AnnotableType createdFrom, SdmxStructureType structureType, ISdmxStructure parent)
            : base(structureType, parent)
        {
            this.annotations = new List<IAnnotation>();
            if (createdFrom != null)
            {
                Annotations annotations1 = createdFrom.Annotations;
                if (annotations1 != null && annotations1.Annotation != null)
                {
                    IList<AnnotationType> annotationType = annotations1.Annotation;
                    if (annotationType != null)
                    {
                        foreach (AnnotationType currentAnnotation in annotationType)
                        {
                            this.annotations.Add(new AnnotationObjectCore(currentAnnotation, this));
                        }
                    }
                }
            }
        }
Ejemplo n.º 33
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="IdentifiableTargetCore"/> class.
        /// </summary>
        /// <param name="identifiableTargetType">
        /// The identifiable target type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        protected internal IdentifiableTargetCore(
            IdentifiableObjectTargetType identifiableTargetType, IMetadataTarget parent)
            : base(
                identifiableTargetType, 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.IdentifiableObjectTarget), 
                parent)
        {
            this.referencedStructureType = XmlobjectsEnumUtil.GetSdmxStructureType(identifiableTargetType.objectType);
            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM ITSELF, CREATES STUB OBJECT //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////    
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="SdmxStructureCore"/> class.
        /// </summary>
        /// <param name="structureType">
        /// The structure type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        protected internal SdmxStructureCore(SdmxStructureType structureType, ISdmxStructure parent)
            : base(structureType, parent)
        {
            this.StructureType = structureType;
            this._parent = parent;
        }
		///////////////////////////////////////////////////////////////////////////////////////////////////
		////////////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();
		}
        /**
	     * builds an identifiable reference from XML bean values.
	     * @param itemWhereType 
	     * @param itemType the type of the item
	     * @return null if the itemWhereType is null
	     */
        private IComplexIdentifiableReferenceObject BuildIdentifiableReference(ItemWhereType itemWhereType, SdmxStructureType itemType)
        {
            if (itemWhereType == null)
            {
                return null;
            }

            QueryIDType idType = itemWhereType.ID;
            IComplexTextReference id = null;
            if (idType != null)
            {
                id = BuildTextReference(null, [email protected](), idType.ToString());
            }

            IComplexAnnotationReference annotationRef = BuildAnnotationReference(itemWhereType.Annotation);

            QueryTextType nameType = itemWhereType.Name;
            IComplexTextReference nameRef = null;
            if (nameType != null)
            {
                nameRef = BuildTextReference(nameType.lang, [email protected](), nameType.ToString());
            }

            QueryTextType descriptionType = itemWhereType.Description;
            IComplexTextReference descriptionRef = null;
            if (descriptionType != null)
            {
                descriptionRef = BuildTextReference(descriptionType.lang, [email protected](), descriptionType.ToString());
            }

            IComplexIdentifiableReferenceObject childRef = null;
            IList<ItemWhere> itemWhereList = itemWhereType.ItemWhere;
            if (itemWhereList != null && (itemWhereList.Count > 0))
            { // this should be the case only for the Categories, ReportingTaxonomies.
                if (itemWhereList.Count > 1)
                {
                    //TODO warning or error that is not supported?????
                }
                childRef = BuildIdentifiableReference(itemWhereList[0].Content, itemType);
            }

            return new ComplexIdentifiableReferenceCore(id, itemType, annotationRef, nameRef, descriptionRef, childRef);
        }
        private DataStructureObjectImpl BuildDataStructure(string _foundedDataflowId)
        {
            try
            {
                string ConceptSchemeId = string.Format(FlyConfiguration.ConceptSchemeFormat, _foundedDataflowId);
                List <IComponentMutableObject> components = new List <IComponentMutableObject>();

                if (!this.ReferencesObject.Concepts.ContainsKey(ConceptSchemeId))
                {
                    ConceptSchemeManager gdf = new ConceptSchemeManager((ISdmxParsingObject)this.parsingObject.Clone(), this.versionTypeResp);
                    ReferencesObject.Concepts.Add(string.Format(FlyConfiguration.ConceptSchemeFormat, _foundedDataflowId), gdf.GetConceptList(_foundedDataflowId));
                }
                if (!this.ReferencesObject.Concepts.ContainsKey(ConceptSchemeId))
                {
                    throw new Exception("ConceptScheme not found");
                }

                List <IConceptObjectImpl> conceptsObject = this.ReferencesObject.Concepts[ConceptSchemeId];
                if (!this.parsingObject.ReturnStub)
                {
                    foreach (IConceptObjectImpl _concept in conceptsObject)
                    {
                        //Cerco la giusta Codelist
                        ICodelistMutableObject _CodelistAssociata = null;
                        if (this.ReferencesObject.Codelists != null)
                        {
                            _CodelistAssociata = this.ReferencesObject.Codelists.Find(cl => cl.Id.ToUpper() == _concept.CodelistCode);
                        }
                        // CodelistBuilder _CodelistAssociata = this._Codelists.Find(cl => cl.Concept.ConceptObjectCode == _concept.ConceptObjectCode);
                        //Capire se è un attribute/Dimension
                        if (_CodelistAssociata == null)
                        {
                            CodelistManager cm = new CodelistManager((ISdmxParsingObject)this.parsingObject.Clone(), this.versionTypeResp);
                            if (!String.IsNullOrEmpty(_concept.CodelistCode))
                            {
                                cm.parsingObject.MaintainableId = string.Format(FlyConfiguration.CodelistFormat, _concept.CodelistCode.Substring(3));
                            }
                            else
                            {
                                cm.parsingObject.MaintainableId = null;
                            }
                            cm.parsingObject.QueryDetail = StructureQueryDetailEnumType.AllStubs;
                            cm.BuildCodelist(_foundedDataflowId, _concept);
                            if (cm.ReferencesObject.Codelists != null && cm.ReferencesObject.Codelists.Count > 0)
                            {
                                _CodelistAssociata = cm.ReferencesObject.Codelists[0];
                            }
                        }

                        if (_CodelistAssociata != null)
                        {
                            _concept.ConceptDSDInfo = new ConceptDSDInfoObject()
                            {
                                CodelistId      = _CodelistAssociata.Id,
                                CodelistAgency  = _CodelistAssociata.AgencyId,
                                CodelistVersion = _CodelistAssociata.Version
                            };
                        }

                        switch (_concept.ConceptType)
                        {
                        case ConceptTypeEnum.Dimension:
                            //Se è una Dimension Capire che tipologia di Dimension è Frequency/Time
                            switch (((IDimensionConcept)_concept).DimensionType)
                            {
                            case DimensionTypeEnum.Dimension:
                                DimensionMutableCore dim = new DimensionMutableCore();
                                dim.ConceptRef = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.Id);
                                dim.Id         = _concept.Id;
                                if (_CodelistAssociata != null)
                                {
                                    dim.Representation = new RepresentationMutableCore()
                                    {
                                        Representation = ReferenceBuilder.CreateCodelistReference(_CodelistAssociata.Id),
                                    };
                                }
                                components.Add(dim);
                                break;

                            case DimensionTypeEnum.Time:
                                DimensionMutableCore TimeDim = new DimensionMutableCore();
                                TimeDim.ConceptRef    = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.ConceptObjectCode);
                                TimeDim.Id            = _concept.ConceptObjectCode;
                                TimeDim.TimeDimension = true;
                                components.Add(TimeDim);

                                break;

                            case DimensionTypeEnum.Frequency:
                                DimensionMutableCore FreqDim = new DimensionMutableCore();
                                FreqDim.ConceptRef = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.ConceptObjectCode);
                                if (_CodelistAssociata != null)
                                {
                                    FreqDim.Representation = new RepresentationMutableCore()
                                    {          ////Si da per scontato che la frequency la codelist ce l'abbia
                                        Representation = ReferenceBuilder.CreateCodelistReference(_CodelistAssociata.Id),
                                    };
                                }
                                FreqDim.Id = _concept.ConceptObjectCode;
                                FreqDim.FrequencyDimension = true;

                                if (FreqDim.ConceptRole != null)
                                {
                                    FreqDim.ConceptRole.Add(new StructureReferenceImpl("ESTAT", "ESTAT_CONCEPT_ROLES_SCHEME", "0.1", SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), new List <string> {
                                        "FREQUENCY"
                                    }));
                                }

                                components.Add(FreqDim);
                                break;

                            default:
                                break;
                            }

                            break;

                        case ConceptTypeEnum.Attribute:

                            AttributeMutableCore attr = new AttributeMutableCore();
                            attr.ConceptRef = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.ConceptObjectCode);
                            if (_CodelistAssociata != null)
                            {
                                IRepresentationMutableObject representation = new RepresentationMutableCore();
                                representation.Representation = ReferenceBuilder.CreateCodelistReference(_CodelistAssociata.Id);
                                attr.Representation           = representation;
                            }
                            //Aggiungo attributi all'attribute AssignmentStatus e AttachmentLevel
                            attr.AssignmentStatus = ((IAttributeConcept)_concept).AssignmentStatusType.ToString();
                            attr.AttachmentLevel  = ((IAttributeConcept)_concept).AttributeAttachmentLevelType;
                            if (attr.AttachmentLevel == AttributeAttachmentLevel.DimensionGroup)
                            {
                                foreach (var dimref in ((IAttributeConcept)_concept).GetDimensionsReference(ReferencesObject.Concepts[ConceptSchemeId]))
                                {
                                    attr.DimensionReferences.Add(dimref);
                                }
                            }
                            if (attr.AttachmentLevel == AttributeAttachmentLevel.Group)
                            {
                                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.AttributeErrorAttachmentGroup);
                            }

                            //if (_CodelistAssociata.CodesObjects == null || _CodelistAssociata.CodesObjects.Count == 0)
                            //{//levo dall'attribute la referenza alla codelist
                            //    attr.Representation = null;
                            //}

                            if (((IAttributeConcept)_concept).IsValueAttribute)
                            {
                                PrimaryMeasureMutableCore PrimaryMeasure = new PrimaryMeasureMutableCore();    //SdmxStructureType.GetFromEnum(SdmxStructureEnumType.PrimaryMeasure));
                                PrimaryMeasure.ConceptRef = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.ConceptObjectCode);
                                components.Add(PrimaryMeasure);
                            }
                            else
                            {
                                components.Add(attr);
                            }
                            break;
                        }
                    }
                }
                this.ReferencesObject.Codelists = null;
                DataStructureBuilder _DataStructureBuilder = new DataStructureBuilder(conceptsObject, this.parsingObject, this.versionTypeResp);
                _DataStructureBuilder.Code  = string.Format(FlyConfiguration.DsdFormat, _foundedDataflowId);
                _DataStructureBuilder.Names = new List <SdmxObjectNameDescription>();
                foreach (var nome in ReferencesObject.FoundedDataflows.Find(df => df.Id == _foundedDataflowId).Names)
                {
                    _DataStructureBuilder.Names.Add(new SdmxObjectNameDescription()
                    {
                        Lingua = nome.Locale, Name = nome.Value
                    });
                }

                return(_DataStructureBuilder.BuildDataStructure(components, null, FlyConfiguration.MainAgencyId, FlyConfiguration.Version));
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateImmutable, ex);
            }
        }
        /// <summary>
        /// Gets a set of all MaintainableObjects of type T that match the reference parameters in the IMaintainableRefObject argument.
        /// An empty Set will be returned if there are no matches to the query
        /// </summary>
        /// <typeparam name="T">The type of the maintainable. It is constraint  </typeparam>
        /// <param name="maintainableInterface">The maintainable interface.</param>
        /// <param name="maintainableReference">Contains the identifiers of the structures to returns, can include wild-carded values (null indicates a wild-card).</param>
        /// <returns>
        /// The set of <see cref="IMaintainableObject" /> .
        /// </returns>
        /// <remarks>This method exists only for compatibility reasons with Java implementation of this interface which uses raw types and unchecked generics.</remarks>
        public ISet <T> GetMaintainableObjects <T>(Type maintainableInterface, IMaintainableRefObject maintainableReference) where T : ISdmxObject
        {
            SdmxStructureType type = SdmxStructureType.ParseClass(maintainableInterface);

            return(new HashSet <T>(GetMaintainablesOfType <IMaintainableObject>(type, maintainableReference, false, false).Cast <T>()));
        }
Ejemplo n.º 39
0
 /// <summary>
 /// Check if <paramref name="structureType"/> requires authentication
 /// </summary>
 /// <param name="structureType">
 /// The structure type.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public static bool NeedsAuth(this SdmxStructureType structureType)
 {
     return(structureType != null && NeedsAuth(structureType.EnumType));
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////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)
        {
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Check if the specified <paramref name="structureEnumType"/> is in <paramref name="sdmxStructureTypes"/>.
 /// </summary>
 /// <param name="sdmxStructureTypes">
 /// The SDMX structure types.
 /// </param>
 /// <param name="structureEnumType">
 /// The structure type.
 /// </param>
 /// <returns>
 /// True if <paramref name="structureEnumType"/> is in <paramref name="sdmxStructureTypes"/> or if <paramref name="sdmxStructureTypes"/> is empty; otherwise false.
 /// </returns>
 public static bool HasStructure(this ISet <SdmxStructureType> sdmxStructureTypes, SdmxStructureType structureEnumType)
 {
     return(sdmxStructureTypes.Count == 0 || sdmxStructureTypes.Contains(structureEnumType));
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////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)
        {
        }
Ejemplo n.º 43
0
        /// <summary>
        /// The verify types.
        /// </summary>
        /// <param name="allowedTypes">
        /// The allowed types. 
        /// </param>
        /// <param name="actualType">
        /// The actual type. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        private void VerifyTypes(ISet<SdmxStructureType> allowedTypes, SdmxStructureType actualType)
        {
            if (!allowedTypes.Contains(actualType))
            {
                string allowedTypesStr = string.Empty;

                foreach (SdmxStructureType currentType in allowedTypes)
                {
                    allowedTypesStr += currentType + ",";
                }

                allowedTypesStr = allowedTypesStr.Substring(0, (allowedTypesStr.Length - 2) - 0);

                throw new SdmxSemmanticException(
                    "Disallowed concept map type '" + actualType + "' allowed types are '" + allowedTypesStr + "'");
            }
        }
Ejemplo n.º 44
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ItemSchemeMapCore"/> 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>
        protected ItemSchemeMapCore(
            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)
        {
            this._items = new List<IItemMap>();
        }
Ejemplo n.º 45
0
        public ISdmxObjects GetStructure(string DataflowId, string DatafloAgency, string DatafloVersion, bool resolseRef = false)
        {
            Logger.InfoFormat(
                CultureInfo.InvariantCulture,
                Resources.InfoGettingStructureFormat3,
                DatafloAgency,
                DataflowId,
                DatafloVersion);

            #region Dataflow
            ISdmxObjects responseDF      = new SdmxObjectsImpl();
            var          dataflowRefBean = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow))
            {
                MaintainableId = DataflowId,
                AgencyId       = DatafloAgency,
                Version        = DatafloVersion
            };
            IList <IStructureReference> refs = new List <IStructureReference>();
            refs.Add(dataflowRefBean);
            responseDF = this.SendQueryStructureRequest(refs, false);
            if (responseDF.Dataflows == null || responseDF.Dataflows.Count == 0)
            {
                throw new Exception("Dataflow not found");
            }
            #endregion
            IDataflowObject dataflow = responseDF.Dataflows.First();

            ISdmxObjects structure;

            var keyFamilyRefBean = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd))
            {
                MaintainableId = dataflow.DataStructureRef.MaintainableReference.MaintainableId,
                AgencyId       = dataflow.DataStructureRef.MaintainableReference.AgencyId,
                Version        = dataflow.DataStructureRef.MaintainableReference.Version
            };

            try
            {
                ISdmxObjects response;

                structure = this.SendQueryStructureRequest(keyFamilyRefBean, resolseRef);
                NsiClientValidation.CheckifStructureComplete(structure, dataflow);
                IEnumerable <IStructureReference> conceptRefs = NsiClientHelper.BuildConceptSchemeRequest(structure.DataStructures.First());
                response = this.SendQueryStructureRequest(conceptRefs, resolseRef);

                structure.Merge(responseDF);
                structure.Merge(response);

                NsiClientValidation.CheckConcepts(structure);
                Logger.Info(Resources.InfoSuccess);
            }
            catch (NsiClientException e)
            {
                Logger.Error(Resources.ExceptionGettingStructure);
                Logger.Error(e.Message, e);
                throw;
            }
            catch (Exception e)
            {
                Logger.Error(Resources.ExceptionGettingStructure);
                Logger.Error(e.Message, e);
                throw new NsiClientException(Resources.ExceptionGettingStructure, e);
            }

            return(structure);
        }
Ejemplo n.º 46
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////    

        /// <summary>
        ///   Initializes a new instance of the <see cref="AnnotableCore" /> class.
        /// </summary>
        /// <param name="createdFrom"> The created from. </param>
        /// <param name="annotationType"> The annotation type. </param>
        /// <param name="structureType"> The structure type. </param>
        /// <param name="parent"> The parent. </param>
        protected internal AnnotableCore(
            IXmlSerializable createdFrom,
            Org.Sdmx.Resources.SdmxMl.Schemas.V10.common.AnnotationsType annotationType,
            SdmxStructureType structureType,
            ISdmxStructure parent)
            : base(structureType, parent)
        {
            this.annotations = new List<IAnnotation>();
            if (annotationType != null && annotationType.Annotation != null)
            {
                foreach (Org.Sdmx.Resources.SdmxMl.Schemas.V10.common.AnnotationType currentAnnotation in
                    annotationType.Annotation)
                {
                    this.annotations.Add(new AnnotationObjectCore(currentAnnotation, this));
                }
            }
        }
Ejemplo n.º 47
0
        /// <summary>
        /// Gets a bean with data about the codelist for specified dataflow and codelist ref.
        /// The dataflow can be retrieved from <see cref="RetrieveDataflow"/>
        /// </summary>
        /// <param name="dataflow">
        /// The dataflow
        /// </param>
        /// <param name="codelistRef">
        /// The codelist reference
        /// </param>
        /// <param name="criteria">
        /// The criteria includes a set of Member and MemberValue(s) for each dimension.
        /// </param>
        /// <param name="info">
        /// Some helper information used for logging
        /// </param>
        /// <returns>
        /// The partial codelist.
        /// </returns>
        private ICodelistObject GetCodelist(
            IDataflowObject dataflow,
            IStructureReference codelistRef,
            List <IContentConstraintMutableObject> criterias,
            string info,
            bool Constrained)
        {
            ICodelistObject codelist;

            var refs = new List <IStructureReference>();

            refs.Add(codelistRef);

            if (Constrained)
            {
                var dataflowRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow))
                {
                    MaintainableId = dataflow.Id,
                    AgencyId       = dataflow.AgencyId,
                    Version        = dataflow.Version,
                };

                foreach (var criteria in criterias)
                {
                    var dataflowRefBean = new ConstrainableStructureReference(dataflowRef, criteria.ImmutableInstance);

                    Logger.InfoFormat(CultureInfo.InvariantCulture, Resources.InfoGettingCodelistFormat1, info);

                    refs.Add(dataflowRefBean);
                }
            }

            try
            {
                ISdmxObjects response;

                response = this.SendQueryStructureRequest(refs, false);

                if (response.Codelists.Count != 1)
                {
                    string message = string.Format(
                        CultureInfo.InvariantCulture, Resources.ExceptionInvalidNumberOfCodeListsFormat1, info);
                    Logger.Error(message);
                    throw new NsiClientException(message);
                }

                codelist = response.Codelists.First();
                if (codelist.Items.Count == 0)
                {
                    string message = string.Format(
                        CultureInfo.InvariantCulture, Resources.ExceptionZeroCodesFormat1, info);
                    Logger.Error(message);
                    throw new NsiClientException(message);
                }
            }
            catch (NsiClientException e)
            {
                string message = string.Format(
                    CultureInfo.InvariantCulture, Resources.ExceptionGetCodelistFormat2, info, e.Message);
                Logger.Error(message);
                Logger.Error(e.Message, e);
                throw;
            }
            catch (DataflowException e)
            {
                throw;
            }
            catch (Exception e)
            {
                string message = string.Format(
                    CultureInfo.InvariantCulture, Resources.ExceptionGetCodelistFormat2, info, e.Message);
                Logger.Error(message);
                Logger.Error(e.Message, e);
                throw new NsiClientException(message, e);
            }

            return(codelist);
        }
Ejemplo n.º 48
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="ItemSchemeMapCore"/> class.
        /// </summary>
        /// <param name="createdFrom">
        /// The created from. 
        /// </param>
        /// <param name="structureType">
        /// The structure type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        protected ItemSchemeMapCore(NameableType createdFrom, SdmxStructureType structureType, IIdentifiableObject parent)
            : base(createdFrom, structureType, parent)
        {
            this._items = new List<IItemMap>();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ItemSchemeMapMutableCore"/> class.
 /// </summary>
 /// <param name="structureType">
 /// The structure type. 
 /// </param>
 public ItemSchemeMapMutableCore(SdmxStructureType structureType)
     : base(structureType)
 {
     this.items = new List<IItemMapMutableObject>();
 }
 protected OrganisationMutableObjectCore(SdmxStructureType structureType)
     : base(structureType)
 {
 }
Ejemplo n.º 51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CrossReferenceImpl"/> class.
 /// </summary>
 /// <param name="referencedFrom">
 /// The referenced from. 
 /// </param>
 /// <param name="agencyId">
 /// The agency id. 
 /// </param>
 /// <param name="maintainableId">
 /// The maintainable id. 
 /// </param>
 /// <param name="version">
 /// The version. 
 /// </param>
 /// <param name="structureType">
 /// The structure type. 
 /// </param>
 public CrossReferenceImpl(
     ISdmxObject referencedFrom, 
     string agencyId, 
     string maintainableId, 
     string version, 
     SdmxStructureType structureType)
     : base(agencyId, maintainableId, version, structureType)
 {
     this._referencedFrom = referencedFrom;
     this.ValidateReference();
 }
        /// <summary>
        ///     An empty Set will be returned if there are no matches to the query
        /// </summary>
        /// <param name="maintainableReference">
        /// Contains the identifiers of the structures to returns, can include widcarded values (null indicates a wildcard).
        /// </param>
        /// <param name="returnStub">
        /// If true then a stub object will be returned
        /// </param>
        /// /// <param name="returnLatest">
        /// If true then the latest version is returned, regardless of whether version information is supplied
        /// </param>
        /// <returns>
        /// The set of <see cref="IMaintainableObject"/> .
        /// </returns>
        public ISet <T> GetMaintainableObjects <T>(IMaintainableRefObject maintainableReference, bool returnStub, bool returnLatest) where T : IMaintainableObject
        {
            ISet <T> returnSet;

            if (returnLatest)
            {
                maintainableReference = new MaintainableRefObjectImpl(maintainableReference.AgencyId, maintainableReference.MaintainableId, null);
            }

            SdmxStructureType   type = SdmxStructureType.ParseClass(typeof(T));
            IStructureReference sRef = new StructureReferenceImpl(maintainableReference, type);

            switch (sRef.TargetReference.EnumType)
            {
            //case SdmxStructureEnumType.AgencyScheme:
            //    returnSet = new HashSet<T>(base.GetAgencySchemeObjects(maintainableReference, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.DataConsumerScheme:
            //    returnSet = new HashSet<T>(this.GetDataConsumerSchemeObjects(maintainableReference, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.AttachmentConstraint:
            //    returnSet = new HashSet<T>(this.GetAttachmentConstraints(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            case SdmxStructureEnumType.ContentConstraint:
                returnSet = new HashSet <T>(this.GetContentConstraints(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            //case SdmxStructureEnumType.DataProviderScheme:
            //    returnSet = new HashSet<T>(this.GetDataProviderSchemeObjects(maintainableReference, returnStub).Cast<T>());
            //    break;
            case SdmxStructureEnumType.Categorisation:
                returnSet = new HashSet <T>(this.GetCategorisationObjects(maintainableReference, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.CategoryScheme:
                returnSet = new HashSet <T>(this.GetCategorySchemeObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.CodeList:
                returnSet = new HashSet <T>(this.GetCodelistObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.ConceptScheme:
                returnSet = new HashSet <T>(this.GetConceptSchemeObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.Dataflow:
                returnSet = new HashSet <T>(this.GetDataflowObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.HierarchicalCodelist:
                returnSet = new HashSet <T>(this.GetHierarchicCodeListObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            case SdmxStructureEnumType.Dsd:
                returnSet = new HashSet <T>(this.GetDataStructureObjects(maintainableReference, returnLatest, returnStub).Cast <T>());
                break;

            //case SdmxStructureEnumType.MetadataFlow:
            //    returnSet = new HashSet<T>(this.GetMetadataflowObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.Msd:
            //    returnSet = new HashSet<T>(this.GetMetadataStructureObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.OrganisationUnitScheme:
            //    returnSet = new HashSet<T>(this.GetOrganisationUnitSchemeObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.Process:
            //    returnSet = new HashSet<T>(this.GetProcessObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.ReportingTaxonomy:
            //    returnSet = new HashSet<T>(this.GetReportingTaxonomyObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.StructureSet:
            //    returnSet = new HashSet<T>(this.GetStructureSetObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            //case SdmxStructureEnumType.ProvisionAgreement:
            //    returnSet = new HashSet<T>(this.GetProvisionAgreementObjects(maintainableReference, returnLatest, returnStub).Cast<T>());
            //    break;
            default:
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.RetrivalParsingError, new Exception(sRef.TargetReference.EnumType.ToString()));
            }

            //if (returnStub && _serviceRetrievalManager != null)
            //{
            //    ISet<T> stubSet = new HashSet<T>();
            //    foreach (T returnItm in returnSet)
            //    {
            //        if (returnItm.IsExternalReference.IsTrue)
            //            stubSet.Add(returnItm);
            //        else
            //            stubSet.Add((T)_serviceRetrievalManager.CreateStub(returnItm));
            //    }
            //    returnSet = stubSet;
            //}
            return(returnSet);
        }
		///////////////////////////////////////////////////////////////////////////////////////////////////
		////////////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();
		}
Ejemplo n.º 54
0
 /// <summary>
 /// Returns a value indicating whether categorisations are needed. (For <c>SDMX v2.0</c>)
 /// </summary>
 /// <param name="structureType">
 /// The structure Type.
 /// </param>
 /// <returns>
 /// True if categorisations are needed. (For <c>SDMX v2.0</c>); otherwise false.
 /// </returns>
 public static bool NeedsCategorisation(this SdmxStructureType structureType)
 {
     return(structureType.IsOneOf(SdmxStructureEnumType.Dataflow, SdmxStructureEnumType.CategoryScheme));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NameableMutableCore"/> class.
 /// </summary>
 /// <param name="structureType">
 /// The structure type. 
 /// </param>
 protected NameableMutableCore(SdmxStructureType structureType)
     : base(structureType)
 {
 }
Ejemplo n.º 56
0
 /// <summary>
 /// Check if <paramref name="structureType"/> is one of <paramref name="structureTypes"/>.
 /// </summary>
 /// <param name="structureType">
 /// The structure type.
 /// </param>
 /// <param name="structureTypes">
 /// The structure types.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public static bool IsOneOf(this SdmxStructureType structureType, params SdmxStructureEnumType[] structureTypes)
 {
     return(structureType != null && IsOneOf(structureType.EnumType, structureTypes));
 }
		/// <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();
		}