예제 #1
0
        /// <summary>
        /// Execute SDMX Query against the NSI WS to retrieve SDMX-ML Data as a Stream
        /// </summary>
        /// <param name="query">
        /// The SDMX Query to execute
        /// </param>
        /// <param name="operationName">
        /// The type of operation, GetCompactData or GetCrossSectionalData
        /// </param>
        /// <param name="observationLimit">
        /// The maximum number of observations to return
        /// </param>
        /// <param name="tempFileName">
        /// The temporary fila name
        /// </param>
        public void ExecuteQuery(IDataQuery query, SDMXWSFunction operationName, int observationLimit, string tempFileName)
        {
            query = new DataQueryFluentBuilder().Initialize(query.DataStructure, query.Dataflow)
                .WithDataQuerySelectionGroup(query.SelectionGroups).Build();

             this.ExecuteQuery(query, operationName, tempFileName);
        }
예제 #2
0
        /// <summary>
        /// Execute SDMX Query against the NSI WS to retrieve SDMX-ML Data as a Stream
        /// </summary>
        /// <param name="query">
        /// The SDMX Query to execute
        /// </param>
        /// <param name="operationName">
        /// The type of operation, GetCompactData or GetCrossSectionalData
        /// </param>
        /// <param name="observationLimit">
        /// The maximum number of observations to return
        /// </param>
        /// <returns>
        /// The SDMX-ML data as a stream.
        /// </returns>
        public void ExecuteQuery(IDataQuery query, SDMXWSFunction operationName, int observationLimit, string tempFileName)
        {
            query = new DataQueryFluentBuilder().Initialize(query.DataStructure, query.Dataflow)
                .WithOrderAsc(true)
                .WithDataQuerySelectionGroup(query.SelectionGroups).WithMaxObservations(observationLimit).
                WithDataProviders(query.DataProvider).WithDataQueryDetail(query.DataQueryDetail).
                WithDimensionAtObservation(query.DimensionAtObservation).Build();

               this.ExecuteQuery(query, operationName, tempFileName);
        }
        /*
        internal List<DataCriteria> InitCriteria(IDataStructureObject kf, Dictionary<string, List<string>> Criteria)
        {
            List<DataCriteria> criterias = new List<DataCriteria>();
            foreach (IComponent comp in kf.Components.Where(c => Criteria.ContainsKey(c.Id)))
            {
                criterias.Add(new DataCriteria() { component = comp.Id, values = Criteria[comp.Id] });
            }

            foreach (IComponent comp in kf.DimensionList.Dimensions.Where(c => !Criteria.ContainsKey(c.Id)))
            {
                criterias.Add(new DataCriteria() { component = comp.Id, values = Criteria[comp.Id] });
            }
            return criterias;
        }
        */
        public IDataQuery CreateQueryBean(IDataflowObject df, IDataStructureObject kf, List<DataCriteria> Criterias)
        {
            ISet<IDataQuerySelection> selections = new HashSet<IDataQuerySelection>();
            string startTime = String.Empty;
            string endTime = String.Empty;

            // Under the DataWhere only one child MUST reside.
            foreach (var queryComponent in Criterias)
            {
                if (queryComponent != null)
                {

                    if (!string.IsNullOrEmpty(queryComponent.component) && queryComponent.component != kf.TimeDimension.Id)
                    {
                        //if (queryComponent.values.Count > 0) baco 25/11/2015
                        if (queryComponent.values.Count > 0 && !string.IsNullOrEmpty(queryComponent.values[0]))
                        {
                            ISet<string> valuern = new HashSet<string>();
                            foreach (string c in queryComponent.values)
                            {
                                if (!string.IsNullOrEmpty(c))
                                    valuern.Add((c));
                            }
                            IDataQuerySelection selection = new DataQueryDimensionSelectionImpl(queryComponent.component, valuern);
                            selections.Add(selection);
                        }
                    }
                    else if (!string.IsNullOrEmpty(queryComponent.component) && queryComponent.component == kf.TimeDimension.Id)
                    {
                        if (queryComponent.values.Count > 0 && !string.IsNullOrEmpty(queryComponent.values[0]))
                        {
                            startTime = queryComponent.values[0];
                            //if (queryComponent.values.Count > 1 && !string.IsNullOrEmpty(queryComponent.values[1]))
                            if (queryComponent.values.Count > 1 && !string.IsNullOrEmpty(queryComponent.values[queryComponent.values.Count-1]))
                                endTime = queryComponent.values[queryComponent.values.Count - 1];
                        }
                    }
                }
            }
            IDataQuerySelectionGroup sel = new DataQuerySelectionGroupImpl(selections, null, null);
            if ((string.IsNullOrEmpty(startTime)) && (!string.IsNullOrEmpty(endTime)))
            {
                sel = new DataQuerySelectionGroupImpl(selections, new SdmxDateCore(endTime), new SdmxDateCore(endTime));
            }
            else if ((!string.IsNullOrEmpty(startTime)) && (string.IsNullOrEmpty(endTime)))
            {
                sel = new DataQuerySelectionGroupImpl(selections, new SdmxDateCore(startTime), new SdmxDateCore(startTime));
            }
            else if ((!string.IsNullOrEmpty(startTime)) && (!string.IsNullOrEmpty(endTime)))
            {
                sel = new DataQuerySelectionGroupImpl(selections, new SdmxDateCore(startTime), new SdmxDateCore(endTime));
            }
            IList<IDataQuerySelectionGroup> selGroup = new List<IDataQuerySelectionGroup>();
            selGroup.Add(sel);
            IDataQuery query;
            if (DataObjConfiguration._TypeEndpoint == EndpointType.REST)
            {
                query = new DataQueryFluentBuilder().Initialize(kf, df).
                      WithDataQuerySelectionGroup(selGroup).Build();
            }
            else
            {
                query = new DataQueryFluentBuilder().Initialize(kf, df).
                       WithOrderAsc(true).
                       WithMaxObservations(MaximumObservations).
                       WithDataQuerySelectionGroup(selGroup).Build();
            }
            return query;
        }
예제 #4
0
        /// <summary>
        /// Create a SDMX Model Query for <see cref="SessionQuery.Dataflow"/> from the criteria at <see cref="SessionQuery._queryComponentIndex"/>
        /// </summary>
        /// <returns>
        /// A QueryBean object
        /// </returns>
        public IDataQuery CreateQueryBean()
        {
            if (!this._sessionQuery.IsDataflowSet)
            {
                throw new InvalidOperationException("Dataflow is not set");
            }

            ISet<IDataQuerySelection> selections = new HashSet<IDataQuerySelection>();
            string startTime = String.Empty;
            string endTime = String.Empty;

            // Under the DataWhere only one child MUST reside.
            foreach (var queryComponent in this._sessionQuery.GetQueryComponents())
            {
                if (queryComponent != null)
                {
                    IComponent component = queryComponent.GetKeyFamilyComponent();
                    var dimension = component as IDimension;

                    if (dimension != null && !dimension.TimeDimension)
                    {
                        IDataQuerySelection selection = this.AddDimensionToQuery(queryComponent, component);
                        selections.Add(selection);
                    }
                    else if (dimension != null && dimension.TimeDimension)
                    {
                        if (!string.IsNullOrEmpty(queryComponent.StartDate))
                        {
                            startTime = queryComponent.StartDate;
                            endTime = queryComponent.EndDate;
                        }
                    }
                }
            }
            IDataQuerySelectionGroup sel = new DataQuerySelectionGroupImpl(selections, null, null);
            if ((string.IsNullOrEmpty(startTime)) && (!string.IsNullOrEmpty(endTime)))
            {
                sel = new DataQuerySelectionGroupImpl(selections, null, new SdmxDateCore(endTime));
            }
            else if ((!string.IsNullOrEmpty(startTime)) && (string.IsNullOrEmpty(endTime)))
            {
                sel = new DataQuerySelectionGroupImpl(selections, new SdmxDateCore(startTime), null);
            }
            else if ((!string.IsNullOrEmpty(startTime)) && (!string.IsNullOrEmpty(endTime)))
            {
                sel = new DataQuerySelectionGroupImpl(selections, new SdmxDateCore(startTime), new SdmxDateCore(endTime));
            }
            IList<IDataQuerySelectionGroup> selGroup = new List<IDataQuerySelectionGroup>();
            selGroup.Add(sel);
            IDataQuery query;
            if (_sessionQuery.EndPointType == EndpointType.REST)
            {
                query = new DataQueryFluentBuilder().Initialize(_sessionQuery.KeyFamily, _sessionQuery.Dataflow).
                      WithDataQuerySelectionGroup(selGroup).Build();
            }
            else
            {
                query = new DataQueryFluentBuilder().Initialize(_sessionQuery.KeyFamily, _sessionQuery.Dataflow).
                       WithOrderAsc(true).
                       WithMaxObservations(_sessionQuery.MaximumObservations).
                       WithDataQuerySelectionGroup(selGroup).Build();
            }
            return query;
        }
 private IDataQuery CreateQueryBean(IDataflowObject df, IDataStructureObject kf)
 {
     IDataQuery query;
     if (DataObjConfiguration._TypeEndpoint == EndpointType.REST)
     {
         query = new DataQueryFluentBuilder().Initialize(kf, df).Build();
     }
     else
     {
         query = new DataQueryFluentBuilder().Initialize(kf, df).
                WithOrderAsc(true).
                WithMaxObservations(MaximumObservations).Build();
     }
     return query;
 }