示例#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="ComplexAnnotationReferenceCore"/> class.
        /// </summary>
        /// <param name="returnMatchedArtefact">
        /// The return matched artefatc. 
        /// </param>
        /// <param name="queryDetail">
        /// The query detail. 
        /// </param>
        /// <param name="referencesQueryDetail">
        /// The references query detail. 
        /// </param>
        /// <param name="referenceDetail">
        /// The reference detail. 
        /// </param>
        /// <param name="referenceSpecificStructures">
        /// The reference specific structures. 
        /// </param>
        public ComplexStructureQueryMetadataCore(bool returnMatchedArtefact, ComplexStructureQueryDetail queryDetail, 
            ComplexMaintainableQueryDetail referencesQueryDetail, StructureReferenceDetail referenceDetail,
            IList<SdmxStructureType> referenceSpecificStructures) 
        {
		
	  	   this._returnMatchedArtefact = returnMatchedArtefact;
		   if (queryDetail != null) 
           {
	 		this._queryDetail = queryDetail;
	       }

	  	   if (referencesQueryDetail != null)
		   this._referencesQueryDetail = referencesQueryDetail;
		
		   if (referenceDetail == null) 
           {
		    	throw new SdmxSemmanticException("Reference Detail cannot be null.");
	  	   }
		
		  this._referenceDetail = referenceDetail;
		  this._referenceSpecificStructures = referenceSpecificStructures;
	   }
示例#4
0
 /// <summary>
 /// Returns the <see cref="IResolver" /> for the specified <paramref name="referenceDetailType"/>.
 /// </summary>
 /// <param name="referenceDetailType">Type of the reference detail.</param>
 /// <param name="crossReferenceManager">The cross reference manager.</param>
 /// <param name="specificStructureTypes">The specific object structure types.</param>
 /// <returns>The <see cref="IResolver" /> for the specified <paramref name="referenceDetailType"/>; otherwise null</returns>
 public IResolver GetResolver(StructureReferenceDetail referenceDetailType, IAuthCrossReferenceMutableRetrievalManager crossReferenceManager, params SdmxStructureType[] specificStructureTypes)
 {
     switch (referenceDetailType.EnumType)
     {
         case StructureReferenceDetailEnumType.Null:
         case StructureReferenceDetailEnumType.None:
             return new NoneResolver();
         case StructureReferenceDetailEnumType.Parents:
             return new ParentsResolver(crossReferenceManager);
         case StructureReferenceDetailEnumType.ParentsSiblings:
             return new ParentsAndSiblingsResolver(crossReferenceManager);
         case StructureReferenceDetailEnumType.Children:
             return new ChildrenResolver(crossReferenceManager);
         case StructureReferenceDetailEnumType.Descendants:
             return new DescendantsResolver(crossReferenceManager);
         case StructureReferenceDetailEnumType.All:
             return new AllResolver(crossReferenceManager);
         case StructureReferenceDetailEnumType.Specific:
             return new SpecificResolver(crossReferenceManager, specificStructureTypes);
         default:
             throw new ArgumentOutOfRangeException(referenceDetailType.EnumType.ToString());
     }
 }
        /// <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;
	     }
示例#6
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);
        }
示例#7
0
        /// <summary>
        /// Gets a bean with data about the key family for specified dataflow.
        /// </summary>
        /// <param name="dataflow">
        /// The dataflow
        /// </param>
        /// <param name="dataStructures">
        /// The data Structures.
        /// </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();

                IStructureQueryFormat <string> structureQueryFormat = new RestQueryFormat();
                IStructureQueryFactory         factory = new RestStructureQueryFactory();
                IStructureQueryBuilderManager  structureQueryBuilderManager = new StructureQueryBuilderManager(factory);

                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 structureQuery = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.None), null, structureReference, false);
                    string request = structureQueryBuilderManager.BuildStructureQuery(structureQuery, structureQueryFormat);
                    responseConceptScheme = this.SendQueryStructureRequest(request);
                    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
        /// <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);
        }
示例#9
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>
        /// Initializes a new instance of the <see cref="ComplexAnnotationReferenceCore" /> class.
        /// </summary>
        /// <param name="returnMatchedArtefact">The return matched artefact.</param>
        /// <param name="processConstraints">if set to <c>true</c> [process constraints].</param>
        /// <param name="queryDetail">The query detail.</param>
        /// <param name="referencesQueryDetail">The references query detail.</param>
        /// <param name="referenceDetail">The reference detail.</param>
        /// <param name="referenceSpecificStructures">The reference specific structures.</param>
        public ComplexStructureQueryMetadataCore(bool returnMatchedArtefact, bool processConstraints, ComplexStructureQueryDetail queryDetail,
            ComplexMaintainableQueryDetail referencesQueryDetail, StructureReferenceDetail referenceDetail,
            IList<SdmxStructureType> referenceSpecificStructures)

            : this(returnMatchedArtefact, queryDetail, referencesQueryDetail, referenceDetail, referenceSpecificStructures)
        {
            this._processConstraints = processConstraints;
        }
        private void ParserQueryParameters(IDictionary<string, string> queryParameters)
        {
            if (queryParameters != null)
            {
                foreach (string key in queryParameters.Keys)
                {
                    string value = queryParameters[key];
                    if (key.Equals("detail", StringComparison.OrdinalIgnoreCase))
                    {
                        var structureQueryDetailEnum = StructureQueryDetailEnumType.Full;
                        if (!Enum.TryParse(value, true, out structureQueryDetailEnum))
                        {
                            structureQueryDetail = StructureQueryDetail.GetFromEnum(structureQueryDetailEnum);
                            throw new SdmxSemmanticException("unable to parse value for key " + key);
                        }
                      
                        structureQueryDetail = StructureQueryDetail.GetFromEnum(structureQueryDetailEnum);
                    }
                    else if (key.Equals("references", StringComparison.OrdinalIgnoreCase))
                    {
                        try
                        {
                            structureReferenceDetail = StructureReferenceDetail.ParseString(value);

                            if (structureReferenceDetail.EnumType == StructureReferenceDetailEnumType.Specific)
                            {
                                specificStructureReference = SdmxStructureType.ParseClass(value);
                            }
                        }
                        catch (SdmxSemmanticException e)
                        {
                            throw new SdmxSemmanticException("unable to parse value for key " + key, e);
                        }
                    }
                    else
                    {
                        throw new SdmxSemmanticException("Unknown query parameter : " + key);
                    }
                }
            }
        }
示例#12
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 Dataflow
            // Get dataflows
            ISdmxObjects responseDataflows = new SdmxObjectsImpl();
            string       requestDataFlows  = this.RetrieveDataflow(DataflowId, DatafloAgency, DatafloVersion);
            responseDataflows = this.SendQueryStructureRequest(requestDataFlows);
            // 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 = this._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();

                IStructureQueryFormat <string> structureQueryFormat = new RestQueryFormat();
                IStructureQueryFactory         factory = new RestStructureQueryFactory();
                IStructureQueryBuilderManager  structureQueryBuilderManager = new StructureQueryBuilderManager(factory);

                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 structureQuery = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.None), null, structureReference, false);
                    string request = structureQueryBuilderManager.BuildStructureQuery(structureQuery, structureQueryFormat);
                    responseConceptScheme = this.SendQueryStructureRequest(request);
                    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);
        }
示例#13
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);
        }