コード例 #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);
        }
コード例 #2
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);
        }
コード例 #3
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)
        {
            Logger.InfoFormat(
                CultureInfo.InvariantCulture,
                Resources.InfoGettingStructureFormat3,
                dataflow.AgencyId,
                dataflow.Id,
                dataflow.Version);
            ISdmxObjects structure = new SdmxObjectsImpl();

            try
            {
                ISdmxObjects responseConceptScheme = new SdmxObjectsImpl();
                ISdmxObjects response = new SdmxObjectsImpl();

                IDataStructureObject dsd = NsiClientHelper.GetDsdFromDataflow(dataflow, dataStructures);
                structure.AddDataStructure(dsd);

                NsiClientValidation.CheckifStructureComplete(structure, dataflow);
                IEnumerable <IStructureReference> conceptRefs = NsiClientHelper.BuildConceptSchemeRequest(structure.DataStructures.First());
                foreach (var structureReference in conceptRefs)
                {
                    IRestStructureQuery structureQueryConceptScheme = new RESTStructureQueryCore(structureReference);
                    IBuilder <IComplexStructureQuery, IRestStructureQuery> transformerCategoryScheme = new StructureQuery2ComplexQueryBuilder();
                    IComplexStructureQuery complexStructureQueryConceptScheme = transformerCategoryScheme.Build(structureQueryConceptScheme);
                    responseConceptScheme = this.SendQueryStructureRequest(complexStructureQueryConceptScheme, SDMXWSFunctionV21.GetConceptScheme);
                    response.Merge(responseConceptScheme);
                }
                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);
        }
コード例 #4
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;
        }
コード例 #5
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;
        }
コード例 #6
0
        public ISdmxObjects GetStructure(string DataflowId, string DatafloAgency, string DatafloVersion, bool resolseRef = false)
        {
            Logger.InfoFormat(
                    CultureInfo.InvariantCulture,
                    Resources.InfoGettingStructureFormat3,
                    DatafloAgency,
                    DataflowId,
                    DatafloVersion);
            ISdmxObjects structure = new SdmxObjectsImpl();

            #region GetDataflow
            //Get dataflows
            ISdmxObjects responseDataflows = new SdmxObjectsImpl();
            IComplexStructureQuery complexStructureQueryDataflow = RetrieveDataflow(DataflowId, DatafloAgency, DatafloVersion);
            responseDataflows = this.SendQueryStructureRequest(complexStructureQueryDataflow, SDMXWSFunctionV21.GetDataflow);
            //Remove from structure (ISdmxObjects) the DSDS built with SDMX v2.0
            var structureSdmxV20DSD = responseDataflows.DataStructures.Where(o => o.Annotations.Any(a => a.FromAnnotation() == CustomAnnotationType.SDMXv20Only)).ToArray();
            foreach (var sdmxV20Only in structureSdmxV20DSD)
            {
                responseDataflows.RemoveDataStructure(sdmxV20Only);
            }

            // DSDS with annotation
            var sdmxV20onlyReferences = structureSdmxV20DSD.Select(o => o.AsReference).ToArray();

            // Add the DSDS built with Sdmx V2.0
            ISdmxObjects responseDSD = new SdmxObjectsImpl();
            if (sdmxV20onlyReferences.Length > 0)
            {
                responseDSD = _nsiClientWs.SendQueryStructureRequest(sdmxV20onlyReferences, false);
                responseDataflows.Merge(responseDSD);
            }
            if (responseDataflows.Dataflows == null || responseDataflows.Dataflows.Count == 0)
                throw new Exception("Dataflow not found");
            #endregion

            try
            {
                IDataflowObject dataflow = responseDataflows.Dataflows.First();
                ISdmxObjects responseConceptScheme = new SdmxObjectsImpl();
                ISdmxObjects response = new SdmxObjectsImpl();

                IDataStructureObject dsd = NsiClientHelper.GetDsdFromDataflow(dataflow, responseDataflows.DataStructures);
                structure.AddDataStructure(dsd);

                NsiClientValidation.CheckifStructureComplete(structure, dataflow);
                IEnumerable<IStructureReference> conceptRefs = NsiClientHelper.BuildConceptSchemeRequest(structure.DataStructures.First());
                foreach (var structureReference in conceptRefs)
                {
                    IRestStructureQuery structureQueryConceptScheme = new RESTStructureQueryCore(structureReference);
                    IBuilder<IComplexStructureQuery, IRestStructureQuery> transformerCategoryScheme = new StructureQuery2ComplexQueryBuilder();
                    IComplexStructureQuery complexStructureQueryConceptScheme = transformerCategoryScheme.Build(structureQueryConceptScheme);
                    responseConceptScheme = this.SendQueryStructureRequest(complexStructureQueryConceptScheme, SDMXWSFunctionV21.GetConceptScheme);
                    response.Merge(responseConceptScheme);
                }
                structure.Merge(responseDataflows);
                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;
        }
コード例 #7
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 = new SdmxObjectsImpl();

            try
            {
                ISdmxObjects responseConceptScheme = new SdmxObjectsImpl();
                ISdmxObjects response = new SdmxObjectsImpl();

                IDataStructureObject dsd = NsiClientHelper.GetDsdFromDataflow(dataflow, dataStructures);
                structure.AddDataStructure(dsd);

                NsiClientValidation.CheckifStructureComplete(structure, dataflow);
                IEnumerable<IStructureReference> conceptRefs = NsiClientHelper.BuildConceptSchemeRequest(structure.DataStructures.First());
                foreach (var structureReference in conceptRefs)
                {
                    IRestStructureQuery structureQueryConceptScheme = new RESTStructureQueryCore(structureReference);
                    IBuilder<IComplexStructureQuery, IRestStructureQuery> transformerCategoryScheme = new StructureQuery2ComplexQueryBuilder();
                    IComplexStructureQuery complexStructureQueryConceptScheme = transformerCategoryScheme.Build(structureQueryConceptScheme);
                    responseConceptScheme = this.SendQueryStructureRequest(complexStructureQueryConceptScheme, SDMXWSFunctionV21.GetConceptScheme);
                    response.Merge(responseConceptScheme);
                }
                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;
        }
コード例 #8
0
        public ISdmxObjects GetStructure(string DataflowId, string DatafloAgency, string DatafloVersion, bool resolseRef = false)
        {
            Logger.InfoFormat(
                CultureInfo.InvariantCulture,
                Resources.InfoGettingStructureFormat3,
                DatafloAgency,
                DataflowId,
                DatafloVersion);
            ISdmxObjects structure = new SdmxObjectsImpl();

            #region GetDataflow
            //Get dataflows
            ISdmxObjects           responseDataflows             = new SdmxObjectsImpl();
            IComplexStructureQuery complexStructureQueryDataflow = RetrieveDataflow(DataflowId, DatafloAgency, DatafloVersion);
            responseDataflows = this.SendQueryStructureRequest(complexStructureQueryDataflow, SDMXWSFunctionV21.GetDataflow);
            //Remove from structure (ISdmxObjects) the DSDS built with SDMX v2.0
            var structureSdmxV20DSD = responseDataflows.DataStructures.Where(o => o.Annotations.Any(a => a.FromAnnotation() == CustomAnnotationType.SDMXv20Only)).ToArray();
            foreach (var sdmxV20Only in structureSdmxV20DSD)
            {
                responseDataflows.RemoveDataStructure(sdmxV20Only);
            }

            // DSDS with annotation
            var sdmxV20onlyReferences = structureSdmxV20DSD.Select(o => o.AsReference).ToArray();

            // Add the DSDS built with Sdmx V2.0
            ISdmxObjects responseDSD = new SdmxObjectsImpl();
            if (sdmxV20onlyReferences.Length > 0)
            {
                responseDSD = _nsiClientWs.SendQueryStructureRequest(sdmxV20onlyReferences, false);
                responseDataflows.Merge(responseDSD);
            }
            if (responseDataflows.Dataflows == null || responseDataflows.Dataflows.Count == 0)
            {
                throw new Exception("Dataflow not found");
            }
            #endregion

            try
            {
                IDataflowObject dataflow = responseDataflows.Dataflows.First();
                ISdmxObjects    responseConceptScheme = new SdmxObjectsImpl();
                ISdmxObjects    response = new SdmxObjectsImpl();

                IDataStructureObject dsd = NsiClientHelper.GetDsdFromDataflow(dataflow, responseDataflows.DataStructures);
                structure.AddDataStructure(dsd);

                NsiClientValidation.CheckifStructureComplete(structure, dataflow);
                IEnumerable <IStructureReference> conceptRefs = NsiClientHelper.BuildConceptSchemeRequest(structure.DataStructures.First());
                foreach (var structureReference in conceptRefs)
                {
                    IRestStructureQuery structureQueryConceptScheme = new RESTStructureQueryCore(structureReference);
                    IBuilder <IComplexStructureQuery, IRestStructureQuery> transformerCategoryScheme = new StructureQuery2ComplexQueryBuilder();
                    IComplexStructureQuery complexStructureQueryConceptScheme = transformerCategoryScheme.Build(structureQueryConceptScheme);
                    responseConceptScheme = this.SendQueryStructureRequest(complexStructureQueryConceptScheme, SDMXWSFunctionV21.GetConceptScheme);
                    response.Merge(responseConceptScheme);
                }
                structure.Merge(responseDataflows);
                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);
        }