public void GetData(IDataQuery dataQuery, IDataWriterEngine writerEngine) {
			// process query clauses
			// ...
			// write sample response of query results based on Chapter3 data writing
			SampleDataWriter writer = new SampleDataWriter();
			writer.WriteSampleData(dataQuery.DataStructure, dataQuery.Dataflow, writerEngine);
		}
        /// <summary>
        ///     Gets the data.
        /// </summary>
        /// <param name="dataQuery">The data query.</param>
        /// <param name="dataWriter">The data writer.</param>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxNoResultsException">0 observations found (SDMX v2.1 behavior)</exception>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxResponseTooLargeException">Emulating default limit</exception>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxResponseSizeExceedsLimitException">Emulating server side limit</exception>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxSemmanticException">Invalid component in query</exception>
        /// <exception cref="SdmxNoResultsException">Invalid component in query</exception>
        public void GetData(IDataQuery dataQuery, IDataWriterEngine dataWriter)
        {
            dataWriter.StartDataset(null, dataQuery.DataStructure, null);
            this.Validate(dataQuery, dataWriter);

            WriteData(dataQuery, dataWriter);
        }
 /// <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;
 }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DelayedDataWriterEngine" /> class.
        /// </summary>
        /// <param name="dataWriterEngine">The data writer engine.</param>
        /// <param name="actions">The actions.</param>
        public DelayedDataWriterEngine(IDataWriterEngine dataWriterEngine, Queue <Action> actions)
        {
            if (dataWriterEngine == null)
            {
                throw new ArgumentNullException("dataWriterEngine");
            }

            this._dataWriterEngine = dataWriterEngine;
            this._actions          = actions ?? new Queue <Action>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DelayedDataWriterEngine" /> class.
        /// </summary>
        /// <param name="dataWriterEngine">The data writer engine.</param>
        /// <param name="actions">The actions.</param>
        public DelayedDataWriterEngine(IDataWriterEngine dataWriterEngine, Queue<Action> actions)
        {
            if (dataWriterEngine == null)
            {
                throw new ArgumentNullException("dataWriterEngine");
            }

            this._dataWriterEngine = dataWriterEngine;
            this._actions = actions ?? new Queue<Action>();
        }
Exemple #6
0
        /// <summary>
        /// Write a TimeSeries Data in FLAT format
        /// </summary>
        /// <param name="dataWriterEngine">input structure contains data</param>
        private void WriteFlatData(IDataWriterEngine dataWriterEngine)
        {
            try
            {
                dataWriterEngine.StartSeries();
                bool AddedDatasetAttribute   = false;
                List <DataMessageObject> dmo = _tableResponse.GetNext();
                do
                {
                    if (dmo == null)
                    {
                        break;
                    }

                    //Aggiungo gli Attributi di Dataset
                    if (!AddedDatasetAttribute)
                    {
                        foreach (DataMessageObject seriesAttribute in dmo.FindAll(att => OnlyDatasetAttribute(att)))
                        {
                            dataWriterEngine.WriteAttributeValue(seriesAttribute.ColImpl.ConceptObjectCode, seriesAttribute.Val.ToString());
                        }
                        AddedDatasetAttribute = true;
                    }


                    //OBSERVATION
                    DataMessageObject val  = dmo.Find(dimV => dimV.ColImpl.ConceptType == ConceptTypeEnum.Attribute && ((IAttributeConcept)dimV.ColImpl).IsValueAttribute);
                    DataMessageObject time = dmo.Find(dimT => dimT.ColImpl.ConceptType == ConceptTypeEnum.Dimension && ((IDimensionConcept)dimT.ColImpl).DimensionType == DimensionTypeEnum.Time);
                    dataWriterEngine.WriteObservation(time.Val.ToString(), val.Val.ToString());


                    foreach (DataMessageObject seriesKey in dmo.FindAll(dim => OnlySeriesKey(dim)))
                    {
                        dataWriterEngine.WriteSeriesKeyValue(seriesKey.ColImpl.ConceptObjectCode, seriesKey.Val.ToString());
                    }

                    foreach (DataMessageObject seriesAttribute in dmo.FindAll(att => OnlySeriesAttribute(att)))
                    {
                        dataWriterEngine.WriteAttributeValue(seriesAttribute.ColImpl.ConceptObjectCode, seriesAttribute.Val.ToString());
                    }
                    foreach (DataMessageObject seriesAttribute in dmo.FindAll(att => OnlyObservationAttribute(att)))
                    {
                        dataWriterEngine.WriteAttributeValue(seriesAttribute.ColImpl.ConceptObjectCode, seriesAttribute.Val.ToString());
                    }

                    dmo = _tableResponse.GetNext();
                } while (dmo != null);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.ErrorWriteFlatData, ex);
            }
        }
	    public void WriteSampleData(IDataStructureObject dsd, IDataflowObject dataflow, IDataWriterEngine dwe) {
			dwe.StartDataset(dataflow, dsd, null);
			
			dwe.StartSeries();
			dwe.WriteSeriesKeyValue("COUNTRY", "UK");
			dwe.WriteSeriesKeyValue("INDICATOR", "E_P");
			dwe.WriteObservation("2000", "18,22");
			dwe.WriteObservation("2000-02", "17,63");
			
			dwe.StartSeries();
			dwe.WriteSeriesKeyValue("COUNTRY", "FR");
			dwe.WriteSeriesKeyValue("INDICATOR", "E_P");
			dwe.WriteObservation("2000", "22,22");
			dwe.WriteObservation("2000-Q3", "15,63");
			
			dwe.Close();
		}
        public void writeSampleData(IDataStructureObject dsd, IDataflowObject dataflow, IDataWriterEngine dwe){
           //Step 1. Writing sample data. 
            //1)	Start the dataset
            dwe.StartDataset(dataflow, dsd, null);

            //2)	Start the dataset series
            dwe.StartSeries();

            //3)	Write dimensions
            dwe.WriteSeriesKeyValue("FREQ", "Q");
            dwe.WriteSeriesKeyValue("REF_AREA","IT");
            dwe.WriteSeriesKeyValue("ADJUSTMENT","W");
            dwe.WriteSeriesKeyValue("STS_INDICATOR","E_P");
            dwe.WriteSeriesKeyValue("STS_ACTIVITY","NS0020");
            dwe.WriteSeriesKeyValue("STS_INSTITUTION","1");
            dwe.WriteSeriesKeyValue("STS_BASE_YEAR","2000");

            //4)	Write Attribute at Series Level
            dwe.WriteAttributeValue("TIME_FORMAT", "P3M");

            //5)	Write the observations
            dwe.WriteObservation("2000-Q1", "18,22");
            dwe.WriteObservation("2000-Q2", "17,63");

            //6)	Write Attribute at Observation Level
            dwe.WriteAttributeValue("OBS_STATUS", "C");

            //7)	Repeat the steps from 2 to 6 to create another dataset series 
            dwe.StartSeries();
            dwe.WriteSeriesKeyValue("FREQ", "M");
            dwe.WriteSeriesKeyValue("REF_AREA", "SP");
            dwe.WriteSeriesKeyValue("ADJUSTMENT", "N");
            dwe.WriteSeriesKeyValue("STS_INDICATOR", "PROD");
            dwe.WriteSeriesKeyValue("STS_ACTIVITY", "NS0030");
            dwe.WriteSeriesKeyValue("STS_INSTITUTION", "1");
            dwe.WriteSeriesKeyValue("STS_BASE_YEAR", "2001");
            dwe.WriteAttributeValue("TIME_FORMAT", "P1M");
            dwe.WriteObservation("2000-01", "18,22");
            dwe.WriteObservation("2000-02", "17,63");
            dwe.WriteAttributeValue("OBS_STATUS", "S");

            //8)	Close the dataset
            dwe.Close();

        }
        /// <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>
        /// <param name="sdmxSchemaVersion">The SDMX schema version.</param>
        public DataRetrievalInfoSeries(MappingSetEntity mappingSet, IDataQuery query, ConnectionStringSettings connectionStringSettings, IDataWriterEngine seriesWriter, SdmxSchemaEnumType sdmxSchemaVersion)
            : base(mappingSet, query, connectionStringSettings, sdmxSchemaVersion)
        {
            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>
 public virtual void GetData(IDataQuery dataQuery, IDataWriterEngine dataWriter)
 {
     this._dataRetrievalWithWriter.GetData(dataQuery, dataWriter);
 }
Exemple #11
0
        /// <summary>
        /// Write a DataMessage in XmlWriter calling WriteTimeSeriesData or WriteFlatData or WriteCrossSectional
        /// </summary>
        /// <param name="writer">Stream Destination</param>
        public override void WriteDataMessage(IFlyWriter writer)
        {
            try
            {
                IDataWriterEngine dataWriterEngine = null;
                switch (MessageType)
                {
                case MessageTypeEnum.GenericData_21:
                    dataWriterEngine = new GenericDataWriterEngine(writer.__SdmxXml, SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwoPointOne));
                    break;

                case MessageTypeEnum.GenericTimeSeries_21:
                    dataWriterEngine = new GenericDataWriterEngine(writer.__SdmxXml, SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwoPointOne));
                    break;

                case MessageTypeEnum.StructureSpecific_21:
                    dataWriterEngine = new CompactDataWriterEngine(writer.__SdmxXml, SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwoPointOne));
                    break;

                case MessageTypeEnum.StructureSpecificTimeSeries_21:
                    dataWriterEngine = new CompactDataWriterEngine(writer.__SdmxXml, SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwoPointOne));
                    break;
                }

                isFlat = false;
                if (!string.IsNullOrEmpty(this.DimensionAtObservation) && this.DimensionAtObservation == "AllDimensions")
                {
                    isFlat = true;
                }


                //Da capire!!!! perche in teoria le crossSectional dovrebbero essere GenericData_21 e StructureSpecific_21 mentre le atre 2 sono TimeSeries
                //Ma le CommonApi non supportano le TimeSeries e quelle che in teoria sono Cross in realtà sono TimeSeries

                //WriteCrossSectional(ref writer);
                //return;

                if (dataWriterEngine == null)
                {
                    throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, new Exception("No Type Message recognized"));
                }


                // write header
                IHeader header = FlyConfiguration.HeaderSettings.GetHeader();
                dataWriterEngine.WriteHeader(header);

                // start dataset
                DataStructureObjectImpl dsd = _retrievalManager._dsd;
                dataWriterEngine.StartDataset(null, dsd.Immutated, null);

                // Aggiungo dataset Title
                if (FlyConfiguration.DatasetTitle && !string.IsNullOrEmpty(this._retrievalManager.DataFlowTitle))
                {
                    dataWriterEngine.WriteAttributeValue("Title", this._retrievalManager.DataFlowTitle);
                }

                //GROUPS
                if (_retrievalManager.Groups != null && _retrievalManager.Groups.Count > 0)
                {
                    foreach (DataGroupObject group in _retrievalManager.Groups)
                    {
                        dataWriterEngine.StartGroup(group.GroupId);
                        foreach (GroupReferenceObject GroupKey in group.DimensionReferences)
                        {
                            dataWriterEngine.WriteGroupKeyValue(GroupKey.ConceptCode, GroupKey.ConceptValue.ToString());
                        }

                        foreach (GroupReferenceObject GroupAttribute in group.AttributeReferences)
                        {
                            dataWriterEngine.WriteAttributeValue(GroupAttribute.ConceptCode, GroupAttribute.ConceptValue.ToString());
                        }
                    }
                }

                this.LastSeriesKey = null;
                if (isFlat)
                {
                    WriteFlatData(dataWriterEngine);
                }
                else
                {
                    WriteTimeSeriesData(dataWriterEngine);
                }
                dataWriterEngine.Close();
                writer.__SdmxXml.Flush();
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.ErrorWriteDataMessage, ex);
            }
        }
        /// <summary>
        ///     Validates the specified data query.
        /// </summary>
        /// <param name="dataQuery">The data query.</param>
        /// <param name="dataWriter">The data writer.</param>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxNoResultsException">0 observations found (SDMX v2.1 behavior)</exception>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxResponseTooLargeException">Emulating default limit</exception>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxResponseSizeExceedsLimitException">Emulating server side limit</exception>
        /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxSemmanticException">Invalid component in query</exception>
        private void Validate(IBaseDataQuery dataQuery, IDataWriterEngine dataWriter)
        {
            switch (dataQuery.Dataflow.Id)
            {
                case Dataflows.NoResults:
                    if (this._sdmxSchema == SdmxSchemaEnumType.VersionTwoPointOne)
                    {
                        throw new SdmxNoResultsException("0 observations found (SDMX v2.1 behavior)");
                    }

                    break;
                case Dataflows.ResponseTooLarge:
                    WriteData(dataQuery, dataWriter);
                    throw new SdmxResponseTooLargeException("Emulating default limit");
                case Dataflows.ResponseExceedsLimit:
                    WriteData(dataQuery, dataWriter);
                    throw new SdmxResponseSizeExceedsLimitException("Emulating server side limit");
                case Dataflows.Semantic:
                    throw new SdmxSemmanticException("Invalid component in query");
            }
        }
 private static void WriteSeriesKey(string dimAtObs, string dimensionId, IDataWriterEngine dataWriter, string dimensionValue, List<string> currentKey)
 {
     if (!string.Equals(dimensionId, dimAtObs))
     {
         dataWriter.WriteSeriesKeyValue(dimensionId, dimensionValue);
         currentKey.Add(dimensionValue);
     }
 }
 /// <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>
        /// Write a DataMessage in XmlWriter
        /// </summary>
        /// <param name="writer">Stream Destination</param>
        public override void WriteDataMessage(IFlyWriter writer)
        {
            try
            {
                IDataWriterEngine dataWriterEngine = null;
                switch (MessageType)
                {
                case MessageTypeEnum.Compact_20:
                    dataWriterEngine = new CompactDataWriterEngine(writer.__SdmxXml, SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwo));
                    break;

                case MessageTypeEnum.Generic_20:
                    dataWriterEngine = new GenericDataWriterEngine(writer.__SdmxXml, SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwo));
                    break;

                case MessageTypeEnum.CrossSectional_20:
                    break;
                }

                if (dataWriterEngine == null)
                {
                    throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, new Exception("No Type Message recognized"));
                }


                // write header
                dataWriterEngine.WriteHeader(FlyConfiguration.HeaderSettings.GetHeader());

                // start dataset
                DataStructureObjectImpl dsd = _retrievalManager._dsd;
                dataWriterEngine.StartDataset(null, dsd.Immutated, null);

                // Aggiungo dataset Title
                if (FlyConfiguration.DatasetTitle && !string.IsNullOrEmpty(this._retrievalManager.DataFlowTitle))
                {
                    dataWriterEngine.WriteAttributeValue("Title", this._retrievalManager.DataFlowTitle);
                }



                this.LastSeriesKey = null;
                List <DataMessageObject> dmo = _tableResponse.GetNext();

                if (dmo != null)
                {
                    //Aggiungo gli Attributi di Dataset
                    foreach (DataMessageObject seriesAttribute in dmo.FindAll(att => OnlyDatasetAttribute(att)))
                    {
                        dataWriterEngine.WriteAttributeValue(seriesAttribute.ColImpl.ConceptObjectCode, seriesAttribute.Val.ToString());
                    }


                    //GROUPS
                    if (_retrievalManager.Groups != null && _retrievalManager.Groups.Count > 0)
                    {
                        foreach (DataGroupObject group in _retrievalManager.Groups)
                        {
                            dataWriterEngine.StartGroup(group.GroupId);
                            foreach (GroupReferenceObject GroupKey in group.DimensionReferences)
                            {
                                dataWriterEngine.WriteGroupKeyValue(GroupKey.ConceptCode, GroupKey.ConceptValue.ToString());
                            }

                            foreach (GroupReferenceObject GroupAttribute in group.AttributeReferences)
                            {
                                dataWriterEngine.WriteAttributeValue(GroupAttribute.ConceptCode, GroupAttribute.ConceptValue.ToString());
                            }
                        }
                    }

                    do
                    {
                        if (dmo == null)
                        {
                            break;
                        }

                        //SERIE
                        if (CheckChanged(dmo))
                        {
                            dataWriterEngine.StartSeries();

                            foreach (DataMessageObject seriesKey in dmo.FindAll(dim => OnlySeriesKey(dim)))
                            {
                                dataWriterEngine.WriteSeriesKeyValue(seriesKey.ColImpl.ConceptObjectCode, seriesKey.Val.ToString());
                            }

                            foreach (DataMessageObject seriesAttribute in dmo.FindAll(att => OnlySeriesAttribute(att)))
                            {
                                dataWriterEngine.WriteAttributeValue(seriesAttribute.ColImpl.ConceptObjectCode, seriesAttribute.Val.ToString());
                            }
                        }

                        //OBSERVATION
                        DataMessageObject val  = dmo.Find(dimV => dimV.ColImpl.ConceptType == ConceptTypeEnum.Attribute && ((IAttributeConcept)dimV.ColImpl).IsValueAttribute);
                        DataMessageObject time = dmo.Find(dimT => dimT.ColImpl.ConceptType == ConceptTypeEnum.Dimension && ((IDimensionConcept)dimT.ColImpl).DimensionType == DimensionTypeEnum.Time);
                        dataWriterEngine.WriteObservation(time.Val.ToString(), val.Val.ToString());

                        foreach (DataMessageObject seriesAttribute in dmo.FindAll(att => OnlyObservationAttribute(att)))
                        {
                            if (seriesAttribute.Val.ToString() != String.Empty)
                            {
                                dataWriterEngine.WriteAttributeValue(seriesAttribute.ColImpl.ConceptObjectCode, seriesAttribute.Val.ToString());
                            }
                        }

                        dmo = _tableResponse.GetNext();
                    } while (dmo != null);
                }

                dataWriterEngine.Close();
                writer.__SdmxXml.Flush();
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.ErrorWriteDataMessage, ex);
            }
        }
Exemple #16
0
        /// <summary>
        /// Write a TimeSeries Data
        /// </summary>
        /// <param name="dataWriterEngine">input structure contains data</param>
        private void WriteTimeSeriesData(IDataWriterEngine dataWriterEngine)
        {
            //TODO: MAX - FORSE E' QUESTA LA PARTE DA MODIFICARE!!

            try
            {
                bool AddedDatasetAttribute   = false;
                List <DataMessageObject> dmo = _tableResponse.GetNext();
                do
                {
                    if (dmo == null)
                    {
                        break;
                    }

                    //Aggiungo gli Attributi di Dataset
                    if (!AddedDatasetAttribute)
                    {
                        foreach (DataMessageObject seriesAttribute in dmo.FindAll(att => OnlyDatasetAttribute(att)))
                        {
                            dataWriterEngine.WriteAttributeValue(seriesAttribute.ColImpl.ConceptObjectCode, seriesAttribute.Val.ToString());
                        }
                        AddedDatasetAttribute = true;
                    }


                    //SERIE
                    if (CheckChanged(dmo))
                    {
                        dataWriterEngine.StartSeries();

                        foreach (DataMessageObject seriesKey in dmo.FindAll(dim => OnlySeriesKey(dim)))
                        {
                            dataWriterEngine.WriteSeriesKeyValue(seriesKey.ColImpl.ConceptObjectCode, seriesKey.Val.ToString());
                        }

                        foreach (DataMessageObject seriesAttribute in dmo.FindAll(att => OnlySeriesAttribute(att)))
                        {
                            dataWriterEngine.WriteAttributeValue(seriesAttribute.ColImpl.ConceptObjectCode, seriesAttribute.Val.ToString());
                        }
                    }

                    //OBSERVATION
                    DataMessageObject val = dmo.Find(dimV => dimV.ColImpl.ConceptType == ConceptTypeEnum.Attribute && ((IAttributeConcept)dimV.ColImpl).IsValueAttribute);

                    DataMessageObject ObsVal = null;
                    if (string.IsNullOrEmpty(DimensionAtObservation) || new List <string> {
                        "TIME_PERIOD", "ALLDIMENSIONS"
                    }.Contains(DimensionAtObservation.Trim().ToUpper()))
                    {
                        ObsVal = dmo.Find(dimT => dimT.ColImpl.ConceptType == ConceptTypeEnum.Dimension && ((IDimensionConcept)dimT.ColImpl).DimensionType == DimensionTypeEnum.Time);
                        dataWriterEngine.WriteObservation(ObsVal.Val.ToString(), val.Val.ToString());
                    }
                    else
                    {
                        ObsVal = dmo.Find(dimT => dimT.ColImpl.Id.Trim().ToUpper() == DimensionAtObservation.Trim().ToUpper());
                        dataWriterEngine.WriteObservation(ObsVal.ColImpl.Id, ObsVal.Val.ToString(), val.Val.ToString());
                    }

                    foreach (DataMessageObject seriesAttribute in dmo.FindAll(att => OnlyObservationAttribute(att)))
                    {
                        if (seriesAttribute.Val.ToString() != String.Empty)
                        {
                            dataWriterEngine.WriteAttributeValue(seriesAttribute.ColImpl.ConceptObjectCode, seriesAttribute.Val.ToString());
                        }
                    }

                    dmo = _tableResponse.GetNext();
                } while (dmo != null);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.ErrorWriteTimeSeriesData, ex);
            }
        }
        /// <summary>
        ///     Writes the data.
        /// </summary>
        /// <param name="dataQuery">The data query.</param>
        /// <param name="dataWriter">The data writer.</param>
        private static void WriteData(IBaseDataQuery dataQuery, IDataWriterEngine dataWriter)
        {
            if (dataQuery.DataQueryDetail.EnumType == DataQueryDetailEnumType.NoData || dataQuery.DataQueryDetail.EnumType == DataQueryDetailEnumType.Full)
            {
                if (dataQuery.Dataflow.Id.Equals("TEST_GROUPS"))
                {
                    dataWriter.StartGroup("Sibling");
                    dataWriter.WriteGroupKeyValue("REF_AREA", "LU");
                    dataWriter.WriteGroupKeyValue("ADJUSTMENT", "N");
                    dataWriter.WriteGroupKeyValue("STS_INDICATOR", "PROD");
                    dataWriter.WriteGroupKeyValue("STS_ACTIVITY", "NS0030");
                    dataWriter.WriteGroupKeyValue("STS_INSTITUTION", "1");
                    dataWriter.WriteGroupKeyValue("STS_BASE_YEAR", "2000");

                    dataWriter.WriteAttributeValue("DECIMALS", "1");
                    dataWriter.WriteAttributeValue("UNIT", "UNIT");
                }
            }

            // TODO support dimension at observation != TIME_PERIOD
            dataWriter.StartSeries();
            dataWriter.WriteSeriesKeyValue("FREQ", "M");
            dataWriter.WriteSeriesKeyValue("REF_AREA", "LU");
            dataWriter.WriteSeriesKeyValue("ADJUSTMENT", "N");
            dataWriter.WriteSeriesKeyValue("STS_INDICATOR", "PROD");
            dataWriter.WriteSeriesKeyValue("STS_ACTIVITY", "NS0030");
            dataWriter.WriteSeriesKeyValue("STS_INSTITUTION", "1");
            dataWriter.WriteSeriesKeyValue("STS_BASE_YEAR", "2000");
            if (dataQuery.DataQueryDetail.EnumType == DataQueryDetailEnumType.NoData || dataQuery.DataQueryDetail.EnumType == DataQueryDetailEnumType.Full)
            {
                dataWriter.WriteAttributeValue("TIME_FORMAT", "P1M");
            }

            var startDate = new DateTime(2010, 01, 01);
            if (dataQuery.DataQueryDetail.EnumType == DataQueryDetailEnumType.Full || dataQuery.DataQueryDetail.EnumType == DataQueryDetailEnumType.DataOnly)
            {
                int firstObsCount = 5;
                if (dataQuery.FirstNObservations.HasValue)
                {
                    firstObsCount = Math.Min(firstObsCount, dataQuery.FirstNObservations.Value);
                }

                for (int i = 0; i < firstObsCount; i++)
                {
                    dataWriter.WriteObservation(startDate.AddMonths(i), "1.0", TimeFormat.GetFromEnum(TimeFormatEnumType.Month));
                    if (dataQuery.DataQueryDetail.EnumType == DataQueryDetailEnumType.Full)
                    {
                        dataWriter.WriteAttributeValue("OBS_STATUS", "A");
                    }
                }

                if (dataQuery.LastNObservations.HasValue)
                {
                    int lastObsStart = Math.Max(5 - dataQuery.LastNObservations.Value, firstObsCount);

                    for (int i = lastObsStart; i < 5; i++)
                    {
                        dataWriter.WriteObservation(startDate.AddMonths(i), "1.0", TimeFormat.GetFromEnum(TimeFormatEnumType.Month));
                        if (dataQuery.DataQueryDetail.EnumType == DataQueryDetailEnumType.Full)
                        {
                            dataWriter.WriteAttributeValue("OBS_STATUS", "A");
                        }
                    }
                }
            }
        }