/// <summary>
 /// Initializes a new instance of the <see cref="DataRetrievalInfoTabular"/> class.
 /// </summary>
 /// <param name="mappingSet">
 /// The mapping set of the dataflow found in the sdmx query 
 /// </param>
 /// <param name="query">
 /// The current SDMX Query object 
 /// </param>
 /// <param name="connectionStringSettings">
 /// The Mapping Store connection string settings 
 /// </param>
 /// <param name="complexWriter">
 /// The tabular Writer. 
 /// </param>
 public DataRetrievalInfoComplex(
     MappingSetEntity mappingSet,
     IComplexDataQuery query,
     ConnectionStringSettings connectionStringSettings,
     IDataWriterEngine complexWriter)
     : base(mappingSet, query, connectionStringSettings, complexWriter)
 {
     this.Limit = query.DefaultLimit.HasValue ? query.DefaultLimit.Value : 0;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DataRetrievalInfoTabular"/> class.
 /// </summary>
 /// <param name="mappingSet">
 /// The mapping set of the dataflow found in the sdmx query 
 /// </param>
 /// <param name="query">
 /// The current SDMX Query object 
 /// </param>
 /// <param name="connectionStringSettings">
 /// The Mapping Store connection string settings 
 /// </param>
 /// <param name="tabularWriter">
 /// The tabular Writer. 
 /// </param>
 public DataRetrievalInfoTabular(
     MappingSetEntity mappingSet,
     IComplexDataQuery query,
     ConnectionStringSettings connectionStringSettings,
     ITabularWriter tabularWriter)
     : base(mappingSet, query, connectionStringSettings)
 {
     this._tabularWriter = tabularWriter;
 }
 public XDocument BuildComplexDataQuery(IComplexDataQuery complexDataQuery, IDataQueryFormat<XDocument> dataQueryFormat)
 {
     IComplexDataQueryBuilder builder = _factory.GetComplexDataQueryBuilder(dataQueryFormat);
     if (builder != null)
     {
         return builder.BuildComplexDataQuery(complexDataQuery);
     }
     throw new SdmxUnauthorisedException("Unsupported ComplexDataQueryFormat: " + dataQueryFormat);
 }
Exemple #4
0
        /// <summary>
        /// Sends the SDMX Query Request
        /// </summary>
        /// <param name="query">
        /// The SDMX Query
        /// </param>
        /// <param name="operation">
        /// The Web Service function
        /// </param>
        /// <param name="output">
        /// The output stream
        /// </param>
        private void SendSdmxQuery(IDataQuery query, SDMXWSFunctionV21 operation, string tempFileName)
        {
            IDataQueryFormat <XDocument>             queryFormat = new StructSpecificDataFormatV21();
            IBuilder <IComplexDataQuery, IDataQuery> transformer = new DataQuery2ComplexQueryBuilder(true);
            IComplexDataQuery complexDataQuery = transformer.Build(query);

            IComplexDataQueryBuilderManager complexDataQueryBuilderManager = new ComplexDataQueryBuilderManager(new ComplexDataQueryFactoryV21());
            var xdoc = complexDataQueryBuilderManager.BuildComplexDataQuery(complexDataQuery, queryFormat);
            var doc  = new XmlDocument();

            doc.LoadXml(xdoc.ToString());
            this.SendRequest(doc, operation, tempFileName);
        }
        /// <summary>
        /// Synchronously execute the given query expected to return 0 or 1 items.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query"></param>
        /// <returns></returns>
        public T ExecuteSingleQuery <T>(IComplexDataQuery <T> query)
        {
            using (var cn = new SqlConnection(this.connectionString))
            {
                var cmd = query.ConstructCommand(cn);
                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection | query.GetCustomCommandBehaviors(cn, cmd)))
                {
                    T row = query.Retrieve(cmd, dr);

                    return(row);
                }
            }
        }
        public XDocument BuildComplexDataQuery(IComplexDataQuery query)
        {
            var queryMessageType = new DataQueryType();

            queryMessageType.Header = new BasicHeaderType();
            V21Helper.SetHeader(queryMessageType.Header, null);

            var queryType = new Org.Sdmx.Resources.SdmxMl.Schemas.V21.Query.DataQueryType();

            var coreBuilder = new ComplexDataQueryCoreBuilderV21();
            coreBuilder.FillDataQueryType(queryType, query);
            queryMessageType.BaseDataQueryType = queryType;
            var queryMessageDocument = new StructureSpecificDataQuery(queryMessageType);

            return new XDocument(queryMessageDocument.Untyped);
        }
        public XDocument BuildComplexDataQuery(IComplexDataQuery query)
        {
            var queryMessageDocument = new GenericTimeSeriesDataQuery(new GenericTimeSeriesDataQueryType());

            queryMessageDocument.Content.Header = new BasicHeaderType();
            V21Helper.SetHeader(queryMessageDocument.Content.Header, null);

            var queryType = new DataQueryType();
            var coreBuilder = new ComplexDataQueryCoreBuilderV21();
            coreBuilder.FillDataQueryType(queryType, query);
            queryMessageDocument.Content.BaseDataQueryType = queryType;
            
            var xDocument = new XDocument(queryMessageDocument.Untyped);

            return xDocument;

        }
        /// <summary>
        /// Asynchronously execute the given query expected to return 0 or 1 items.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query"></param>
        /// <param name="factory"></param>
        /// <returns></returns>
        public async Task <T> ExecuteSingleQueryAsync <T>(IComplexDataQuery <T> query, TaskFactory <T> factory = null)
        {
            if (factory == null)
            {
                factory = new TaskFactory <T>();
            }

            using (var cn = new SqlConnection(this.connectionString))
            {
                var cmd = query.ConstructCommand(cn);
                cn.Open();

                using (SqlDataReader dr = await cmd.ExecuteReaderAsync(CommandBehavior.CloseConnection | query.GetCustomCommandBehaviors(cn, cmd)))
                {
                    T row = await query.RetrieveAsync(cmd, dr);

                    return(row);
                }
            }
        }
        /// <summary>
        /// Asynchronously execute the given query expected to return 0 or more rows.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query"></param>
        /// <param name="expectedCapacity"></param>
        /// <param name="factory"></param>
        /// <returns></returns>
        public async Task <T> ExecuteListQueryAsync <T>(IComplexDataQuery <T> query, int expectedCapacity = 10, TaskFactory <T> factory = null)
        {
            if (expectedCapacity < 0)
            {
                expectedCapacity = 0;
            }
            if (factory == null)
            {
                factory = new TaskFactory <T>();
            }

            using (var cn = new SqlConnection(this.connectionString))
            {
                var cmd = query.ConstructCommand(cn);
                cn.Open();

                using (SqlDataReader dr = await cmd.ExecuteReaderAsync(CommandBehavior.CloseConnection | query.GetCustomCommandBehaviors(cn, cmd)))
                {
                    return(await query.RetrieveAsync(cmd, dr, expectedCapacity));
                }
            }
        }
 /// <summary>
 /// Handles the explicit.
 /// </summary>
 /// <param name="complexDataQuery">The complex data query.</param>
 /// <param name="structure">The structure.</param>
 private static void HandleExplicit(IComplexDataQuery complexDataQuery, DataStructureRequestType structure)
 {
     if (complexDataQuery.HasExplicitMeasures())
     {
         structure.explicitMeasures = complexDataQuery.HasExplicitMeasures();
     }
 }
        /// <summary>
        /// Handles the selection groups.
        /// </summary>
        /// <param name="complexDataQuery">The complex data query.</param>
        /// <param name="whereType">Type of the where.</param>
        private static void HandleSelectionGroups(IComplexDataQuery complexDataQuery, DataParametersAndType whereType)
        {
            // TODO support for multiple selection groups. 
            IComplexDataQuerySelectionGroup complexDataQuerySelectionGroup = complexDataQuery.SelectionGroups.First();

            //Selections in SelectionGroups - at DataWhere Level
            if (complexDataQuerySelectionGroup.Selections != null)
            {
                HandleSelections(complexDataQuery, whereType, complexDataQuerySelectionGroup.Selections.Where(selection => selection.ShouldUseAnd()), new ParameterBuilderAnd());
            }

            //Time Dimension clause at DataWhere Level for Date From/To - optional
            if (complexDataQuerySelectionGroup.DateFrom != null || complexDataQuerySelectionGroup.DateTo != null)
            {
                HandleTime(whereType, complexDataQuerySelectionGroup);
            }

            //Primary Measure Value at DataWhere Level - Zero to more repetitions
            if (complexDataQuerySelectionGroup.PrimaryMeasureValue != null)
            {
                HandlePrimaryMeasure(whereType, complexDataQuerySelectionGroup, complexDataQuery);
            }

            //Selections in SelectionGroups - OR clauses at DataWhere Level
            if (complexDataQuerySelectionGroup.Selections != null)
            {
                HandleSelections(complexDataQuery, whereType, complexDataQuerySelectionGroup.Selections.Where(selection => !selection.ShouldUseAnd()), new ParameterBuilderOr());
            }
        }
        /// <summary>
        /// Handles the primary measure.
        /// </summary>
        /// <param name="whereType">Type of the where.</param>
        /// <param name="complexDataQuerySelectionGroup">The complex data query selection group.</param>
        /// <param name="complexDataQuery">The complex data query.</param>
        private static void HandlePrimaryMeasure(DataParametersType whereType, IComplexDataQuerySelectionGroup complexDataQuerySelectionGroup, IComplexDataQuery complexDataQuery)
        {
            var primaryMeasure = complexDataQuery.DataStructure.PrimaryMeasure;
            foreach (IComplexComponentValue primaryMeasureValue in complexDataQuerySelectionGroup.PrimaryMeasureValue)
            {
                var primaryMeasureValueType = new PrimaryMeasureValueType();
                SetOperatorAndValue(primaryMeasure, primaryMeasureValue, primaryMeasureValueType);

                whereType.PrimaryMeasureValue.Add(primaryMeasureValueType);
            }
        }
        /// <summary>
        /// Handles the selections.
        /// </summary>
        /// <param name="complexDataQuery">The complex data query.</param>
        /// <param name="whereType">Type of the where.</param>
        /// <param name="complexDataQuerySelections"></param>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxSemmanticException">
        /// Invalid structure type for component and 
        /// </exception>
        private static void HandleSelections(IComplexDataQuery complexDataQuery, DataParametersAndType whereType, IEnumerable<IComplexDataQuerySelection> complexDataQuerySelections, IParameterBuilder builder)
        {
            foreach (IComplexDataQuerySelection complexDataQuerySelection in complexDataQuerySelections)
            {
                builder.Reset();

                // Dimension Values inside an OR -or- AND clause
                foreach (IComplexComponentValue complexComponentValue in complexDataQuerySelection.Values)
                {
                    var component = complexDataQuery.DataStructure.GetComponent(complexDataQuerySelection.ComponentId);
                    if (component == null)
                    {
                        throw new SdmxSemmanticException(string.Format("Component with ID {0} does not exist in the DSD {1}", complexDataQuerySelection.ComponentId, complexDataQuery.DataStructure));
                    }

                    switch (component.StructureType.EnumType)
                    {
                        case SdmxStructureEnumType.Dimension:
                        case SdmxStructureEnumType.MeasureDimension:
                            {
                                var dimensionValueType = new DimensionValueType { ID = complexDataQuerySelection.ComponentId };
                                SetOperatorAndValue(component, complexComponentValue, dimensionValueType);
                                builder.AddDimension(dimensionValueType);
                            }

                            break;
                        case SdmxStructureEnumType.DataAttribute:
                            {
                                var attributeValueType = new AttributeValueType { ID = complexDataQuerySelection.ComponentId };
                                SetOperatorAndValue(component, complexComponentValue, attributeValueType);

                                builder.AddAttribute(attributeValueType);
                            }

                            break;
                        default:
                            throw new SdmxSemmanticException(string.Format("Invalid structure type for component ID : {1} Type {0} ", component.StructureType.EnumType, component.Urn));
                    }
                }

                builder.PopulateAndParameter(whereType);
            }
        }
        /// <summary>
        /// Handles the last updated time.
        /// </summary>
        /// <param name="complexDataQuery">The complex data query.</param>
        /// <param name="whereType">Type of the where.</param>
        private static void HandleLastUpdatedTime(IComplexDataQuery complexDataQuery, DataParametersType whereType)
        {
            foreach (var timeRange in complexDataQuery.LastUpdatedDateTimeRange)
            {
                var timeRangeValueType = new TimeRangeValueType();

                var startTimePeriodRangeType = new TimePeriodRangeType();

                startTimePeriodRangeType.isInclusive = timeRange.IsStartInclusive;
                startTimePeriodRangeType.TypedValue = timeRange.StartDate.DateInSdmxFormat;

                timeRangeValueType.StartPeriod = startTimePeriodRangeType;

                var endTimePeriodRangeType = new TimePeriodRangeType();

                endTimePeriodRangeType.isInclusive = timeRange.IsEndInclusive;
                endTimePeriodRangeType.TypedValue = timeRange.StartDate.DateInSdmxFormat;

                timeRangeValueType.EndPeriod = endTimePeriodRangeType;

                whereType.Updated.Add(timeRangeValueType);
            }
        }
Exemple #15
0
 /// <summary>
 /// Generates the response function.
 /// </summary>
 /// <param name="query">
 ///     The query.
 /// </param>
 /// <returns>
 /// The <see cref="Action"/> that will write the response.
 /// </returns>
 public Action <T, Queue <Action> > GenerateResponseFunction(IComplexDataQuery query)
 {
     return((writer, actions) => this._sdmxDataRetrievalWithWriter.GetData(query, this._dataWriterBuilder.Build(writer, actions)));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataRetrievalInfo"/> class.
        /// </summary>
        /// <param name="mappingSet">
        /// The mapping set of the dataflow found in the SDMX query 
        /// </param>
        /// <param name="query">
        /// The current SDMX Query object 
        /// </param>
        /// <param name="connectionStringSettings">
        /// The Mapping Store connection string settings 
        /// </param>
        public DataRetrievalInfo(MappingSetEntity mappingSet, IComplexDataQuery query, ConnectionStringSettings connectionStringSettings)
        {
            if (mappingSet == null)
            {
                throw new ArgumentNullException("mappingSet");
            }

            if (connectionStringSettings == null)
            {
                throw new ArgumentNullException("connectionStringSettings");
            }

            this._schemaVersion = SdmxSchemaEnumType.VersionTwoPointOne;
            this._mappingSet = mappingSet;
            this._complexQuery = query;
            this._connectionStringSettings = connectionStringSettings;
            this._limit = query.DefaultLimit.HasValue ? query.DefaultLimit.Value : 0;
            this._isTimePeriodAtObservation = DimensionObject.TimeDimensionFixedId.Equals(query.DimensionAtObservation);
            if (!this._isTimePeriodAtObservation)
            {
                this._dimensionAtObservation = query.DimensionAtObservation;
            }

            this.BuildMappings();
            this._buildEffectiveDimensionAtObservation = this.BuildEffectiveDimensionAtObservation();
        }
        public string GenerateSqlQuery(IComplexDataQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            try
            {
                // Get mapping set
                MappingSetEntity mappingSet = this.InitializeAdvanced(query);

                // build the data retrieval state
                var info = new DataRetrievalInfo(mappingSet, query, this._connectionStringSettings);

                // Generate sql using Tabular SQL Builder and put the sql query into info.SqlString
                //this.GenerateSql(info, _sqlBuilderTabular);

                // return the sql query
                return info.SqlString;
            }
            catch (DataRetrieverException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new DataRetrieverException(ex,
                    SdmxErrorCode.GetFromEnum(SdmxErrorCodeEnumType.SemanticError),
                    Resources.DataRetriever_GenerateSqlQuery_Could_not_generate_sql_query);
            }
        }
        /// <summary>
        /// Handles the structure request type
        /// </summary>
        /// <param name="complexDataQuery">The complex data query.</param>
        /// <param name="dataReturnDetails">The data return details.</param>
        private static void HandleStructure(IComplexDataQuery complexDataQuery, DataReturnDetailsType dataReturnDetails)
        {
            var structure = new DataStructureRequestType();
            dataReturnDetails.Structure.Add(structure);
            if (!string.IsNullOrWhiteSpace(complexDataQuery.DimensionAtObservation))
            {
                structure.dimensionAtObservation = complexDataQuery.DimensionAtObservation;
            }
            else
            {
                structure.dimensionAtObservation = DimensionObject.TimeDimensionFixedId;
            }

            HandleExplicit(complexDataQuery, structure);
            structure.structureID = DefaultStructureId;
            
            if (complexDataQuery.DataStructure != null)
            {
                RefBaseType structureRefernce = new StructureRefType();
                structureRefernce.agencyID = complexDataQuery.DataStructure.AgencyId;
                structureRefernce.id = complexDataQuery.DataStructure.Id;
                structureRefernce.version = complexDataQuery.DataStructure.Version;
                var structureType = new StructureReferenceType();
                structureType.SetTypedRef(structureRefernce);
                structure.Structure = structureType;
            }
            else if (complexDataQuery.ProvisionAgreement != null)
            {
                RefBaseType provisionAgreementReference = new ProvisionAgreementRefType();
                provisionAgreementReference.id = complexDataQuery.ProvisionAgreement.Id;
                provisionAgreementReference.agencyID = complexDataQuery.ProvisionAgreement.AgencyId;
                provisionAgreementReference.version = complexDataQuery.ProvisionAgreement.Version;
                var provisionAgreementReferenceType = new ProvisionAgreementReferenceType();
                provisionAgreementReferenceType.SetTypedRef(provisionAgreementReference);
                structure.ProvisionAgrement = provisionAgreementReferenceType;
            }
        }
        /// <summary>
        /// Handles the data provider.
        /// </summary>
        /// <param name="complexDataQuery">The complex data query.</param>
        /// <param name="whereType">Type of the where.</param>
        private static void HandleDataProvider(IComplexDataQuery complexDataQuery, DataParametersAndType whereType)
        {
            //if only one Data provider let alone otherwise encapsulate it in an Or clause
            if (complexDataQuery.DataProvider.Count == 1)
            {
                IDataProvider dataProvider = complexDataQuery.DataProvider.First();
                var dataProviderReferenceType = new DataProviderReferenceType();

                RefBaseType dataProviderRefType = new DataProviderRefType();

                dataProviderRefType.agencyID = dataProvider.CrossReferences.First().MaintainableReference.AgencyId;
                dataProviderRefType.id = dataProvider.Id;
                dataProviderRefType.maintainableParentID = dataProvider.MaintainableParent.Id;
                dataProviderRefType.maintainableParentVersion = dataProvider.MaintainableParent.Version;

                dataProviderReferenceType.Ref = dataProviderRefType;
                whereType.DataProvider.Add(dataProviderReferenceType);
            }
            else
            {
                var orForDataProviderType = new DataParametersOrType();

                foreach (IDataProvider dataProvider in complexDataQuery.DataProvider)
                {
                    RefBaseType dataProviderRefType = new DataProviderRefType();
                    dataProviderRefType.agencyID = dataProvider.CrossReferences.First().MaintainableReference.AgencyId;
                    dataProviderRefType.id = dataProvider.Id;
                    dataProviderRefType.maintainableParentID = dataProvider.MaintainableParent.Id;
                    dataProviderRefType.maintainableParentVersion = dataProvider.MaintainableParent.Version;
                    var dataProviderReferenceType = new DataProviderReferenceType { Ref = dataProviderRefType };
                    orForDataProviderType.DataProvider.Add(dataProviderReferenceType);
                }

                whereType.Or.Add(orForDataProviderType);
            }
        }
        /// <summary>
        /// Handles the dataflow.
        /// </summary>
        /// <param name="complexDataQuery">The complex data query.</param>
        /// <param name="whereType">Type of the where.</param>
        private static void HandleDataflow(IComplexDataQuery complexDataQuery, DataParametersAndType whereType)
        {
            var dataflowReferenceType = new DataflowReferenceType();

            RefBaseType dataflowRefType = new DataflowRefType();

            dataflowRefType.agencyID = complexDataQuery.Dataflow.AgencyId;
            dataflowRefType.id = complexDataQuery.Dataflow.Id;
            dataflowRefType.version = complexDataQuery.Dataflow.Version;
            dataflowReferenceType.Ref = dataflowRefType;
            whereType.Dataflow.Add(dataflowReferenceType);
        }
        /// <summary>
        /// Handles the provision agreement.
        /// </summary>
        /// <param name="complexDataQuery">The complex data query.</param>
        /// <param name="whereType">Type of the where.</param>
        private static void HandleProvisionAgreement(IComplexDataQuery complexDataQuery, DataParametersAndType whereType)
        {
            RefBaseType provisionReferenceType = new ProvisionAgreementRefType();

            provisionReferenceType.id = complexDataQuery.ProvisionAgreement.Id;
            provisionReferenceType.agencyID = complexDataQuery.ProvisionAgreement.AgencyId;
            provisionReferenceType.version = complexDataQuery.ProvisionAgreement.Version;

            var provisionAgreementReferenceType = new ProvisionAgreementReferenceType { Ref = provisionReferenceType };
            whereType.ProvisionAgreement.Add(provisionAgreementReferenceType);
        }
        private MappingSetEntity InitializeAdvanced(IComplexDataQuery query)
        {
            Logger.Info(Resources.DataRetriever_RetrieveData_Start_Initializing_Data_Retriever);
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            // Get the dataflow from the query
            IDataflowObject dataFlow = query.Dataflow;

            // get the mapping set and the keyfamilybean
            MappingSetEntity mappingSet = this.RetrieveMappingSet(dataFlow);

            // MAT-395
            if (mappingSet == null)
            {
                throw new DataRetrieverException(string.Format(CultureInfo.CurrentCulture, Resources.NoMappingForDataflowFormat1, dataFlow.Id),
                    SdmxErrorCode.GetFromEnum(SdmxErrorCodeEnumType.NoResultsFound));
            }

            //mappingSet = FilterMappingSet(query, mappingSet);

            Logger.Info(Resources.DataRetriever_RetrieveData_End_Data_Retriever_initialization);
            return mappingSet;
        }
        /// <summary>
        /// Fills the type of the data query.
        /// </summary>
        /// <param name="queryType">Type of the query.</param>
        /// <param name="complexDataQuery">The complex data query.</param>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxException">Too many Selection Groups in ComplexDataQuery max one supported.</exception>
        public void FillDataQueryType(DataQueryType queryType, IComplexDataQuery complexDataQuery)
        {
            var dataReturnDetailsType = new DataReturnDetailsType();
            queryType.ReturnDetails = dataReturnDetailsType;

            // TODO: check null in java
            if (complexDataQuery.DefaultLimit.HasValue && complexDataQuery.DefaultLimit.Value != 0)
            {
                dataReturnDetailsType.defaultLimit = complexDataQuery.DefaultLimit;
            }

            if (complexDataQuery.FirstNObservations.HasValue)
            {
                dataReturnDetailsType.FirstNObservations = complexDataQuery.FirstNObservations;
            }

            if (complexDataQuery.LastNObservations.HasValue)
            {
                dataReturnDetailsType.LastNObservations = complexDataQuery.LastNObservations;
            }
            if (complexDataQuery.DataQueryDetail != null)
            {
                dataReturnDetailsType.detail = complexDataQuery.DataQueryDetail.EnumType.ToString();
            }

            if (complexDataQuery.ObservationAction != null)
            {
                dataReturnDetailsType.observationAction = complexDataQuery.ObservationAction.EnumType.ToString();
            }

            HandleStructure(complexDataQuery, dataReturnDetailsType);
            var whereType = new DataParametersAndType();
            queryType.DataWhere = whereType;

            //DataSetId at DataWhere Leveln - Optional
            if (complexDataQuery.DatasetId != null)
            {
                var datasetIdType = new QueryIDType { TypedValue = complexDataQuery.DatasetId, @operator = complexDataQuery.DatasetIdOperator.Operator };

                whereType.DataSetID.Add(datasetIdType);

            }

            //DataProvider at DataWhere Level - Optional; 
            if (complexDataQuery.DataProvider != null && complexDataQuery.DataProvider.Count != 0)
            {
                HandleDataProvider(complexDataQuery, whereType);
            }

            //Dataflow at DataWhere Level - Optional
            if (complexDataQuery.Dataflow != null)
            {

                HandleDataflow(complexDataQuery, whereType);
            }

            //ProvisionAgreement at DataWhere Level - Optional  
            if (complexDataQuery.ProvisionAgreement != null)
            {

                HandleProvisionAgreement(complexDataQuery, whereType);
            }

            //Updated tag that can have 0 to 2 repetitions
            if (complexDataQuery.LastUpdatedDateTimeRange != null)
            {
                HandleLastUpdatedTime(complexDataQuery, whereType);
            }

            //Selection Groups - and clause (DataWhere)
            if (complexDataQuery.SelectionGroups != null && complexDataQuery.SelectionGroups.Count > 1)
            {
                throw new SdmxException("Too many Selection Groups in ComplexDataQuery max one supported.", SdmxErrorCode.GetFromEnum(SdmxErrorCodeEnumType.SemanticError));
            }

            if (complexDataQuery.SelectionGroups != null && complexDataQuery.SelectionGroups.Count != 0)
            {
                HandleSelectionGroups(complexDataQuery, whereType);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataRetrievalInfo"/> class.
        /// </summary>
        /// <param name="mappingSet">
        /// The mapping set of the dataflow found in the sdmx query 
        /// </param>
        /// <param name="query">
        /// The current SDMX Query object 
        /// </param>
        /// <param name="connectionStringSettings">
        /// The Mapping Store connection string settings 
        /// </param>
        public DataRetrievalInfo(MappingSetEntity mappingSet, IComplexDataQuery query, ConnectionStringSettings connectionStringSettings)
        {
            if (mappingSet == null)
            {
                throw new ArgumentNullException("mappingSet");
            }

            if (connectionStringSettings == null)
            {
                throw new ArgumentNullException("connectionStringSettings");
            }

            this._mappingSet = mappingSet;
            this._complexQuery = query;
            this._connectionStringSettings = connectionStringSettings;
            this._limit = query.FirstNObservations.HasValue ? query.FirstNObservations.Value : 0;
            //this._dimensionAtObservation = query.DimensionAtObservation();
            this._isTimePeriodAtObservation = DimensionObject.TimeDimensionFixedId.Equals(query.DimensionAtObservation);
            if (!this._isTimePeriodAtObservation)
            {
                this._dimensionAtObservation = query.DimensionAtObservation;
            }
            this.BuildMappings();
        }
 /// <summary>
 /// Gets the data.
 /// </summary>
 /// <param name="dataQuery">The data query.</param>
 /// <param name="dataWriter">The data writer.</param>
 public virtual void GetData(IComplexDataQuery dataQuery, IDataWriterEngine dataWriter)
 {
     this._advancedSdmxDataRetrievalWithWriter.GetData(dataQuery, dataWriter);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataRetrievalInfoSeries"/> class.
        /// </summary>
        /// <param name="mappingSet">
        /// The mapping set of the dataflow found in the sdmx query 
        /// </param>
        /// <param name="query">
        /// The current SDMX Query object 
        /// </param>
        /// <param name="connectionStringSettings">
        /// The Mapping Store connection string settings 
        /// </param>
        /// <param name="seriesWriter">
        /// The series Writer. 
        /// </param>
        public DataRetrievalInfoSeries(
            MappingSetEntity mappingSet,
            IComplexDataQuery query,
            ConnectionStringSettings connectionStringSettings,
            IDataWriterEngine seriesWriter)
            : base(mappingSet, query, connectionStringSettings)
        {
            this._seriesWriter = seriesWriter;
            this._seriesObsComponents = new List<IComponentMapping>();
            this._dataSetAttributes = new List<IComponentMapping>();
            this._groups = new Dictionary<GroupEntity, GroupInformation>();
            this._useDataSetSqlQuery = mappingSet.Dataflow.Dsd.Groups.Count > 0;
            this.BuildSeriesMappings();

            // add dimension mappings to groups
            this.BuildTimeSeriesGroupMappings();
        }
        /// <summary>
        ///     Gets the data.
        /// </summary>
        /// <param name="dataQuery">The data query.</param>
        /// <param name="dataWriter">The data writer.</param>
        /// <exception cref="SdmxNoResultsException">0 observations found (SDMX v2.1 behavior)</exception>
        /// <exception cref="SdmxResponseTooLargeException">Emulating default limit</exception>
        /// <exception cref="SdmxResponseSizeExceedsLimitException">Emulating server side limit</exception>
        /// <exception cref="SdmxSemmanticException">Invalid component in query</exception>
        public void GetData(IComplexDataQuery dataQuery, IDataWriterEngine dataWriter)
        {
            dataWriter.StartDataset(null, dataQuery.DataStructure, null);
            this.Validate(dataQuery, dataWriter);

            WriteData(dataQuery, dataWriter);
        }