public void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { this._dimensionAtObservation = this.GetDimensionAtObservation(header); _jsonDataWriter.Formatting = Formatting.None; _jsonDataWriter.WritePropertyName("dataSets"); _jsonDataWriter.WriteStartArray(); _jsonDataWriter.WriteStartObject(); _jsonDataWriter.WritePropertyName("actions"); _jsonDataWriter.WriteValue("Information"); }
protected virtual string GetDimensionAtObservation(IDatasetHeader header) { string dimensionAtObservation = DimensionObject.TimeDimensionFixedId; if (header != null && (header.DataStructureReference != null && !string.IsNullOrWhiteSpace(header.DataStructureReference.DimensionAtObservation))) { dimensionAtObservation = header.DataStructureReference.DimensionAtObservation; } return dimensionAtObservation; }
protected virtual string GetDimensionAtObservation(IDatasetHeader header) { string dimensionAtObservation = DimensionObject.TimeDimensionFixedId; if (header != null && (header.DataStructureReference != null && !string.IsNullOrWhiteSpace(header.DataStructureReference.DimensionAtObservation))) { dimensionAtObservation = header.DataStructureReference.DimensionAtObservation; } return(dimensionAtObservation); }
public void StartDataset(string dsdName, IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { string appPath = System.Web.HttpRuntime.AppDomainAppPath; string giorno = System.Web.HttpContext.Current.Timestamp.Day.ToString(); string ora = System.Web.HttpContext.Current.Timestamp.Hour.ToString(); string min = System.Web.HttpContext.Current.Timestamp.Minute.ToString(); string secondi = System.Web.HttpContext.Current.Timestamp.Second.ToString(); string ms = System.Web.HttpContext.Current.Timestamp.Millisecond.ToString(); string namedir = giorno + ora + min + secondi + ms; dirPath = appPath + namedir; DirectoryInfo MyRoot = new DirectoryInfo(@appPath); MyRoot.CreateSubdirectory(namedir); IList<IDimension> dimensions = dsd.GetDimensions(SdmxStructureEnumType.Dimension); string[] ordinamento1 = new string[dimensions.Count]; string[] ordinamento2 = new string[dsd.Components.Count]; ordine = new string[dimensions.Count]; ordineser = new string[dimensions.Count]; int indord = 0; string valoredati = ""; IList<IDimension> dimensions1 = dsd.GetDimensions(SdmxStructureEnumType.Dimension); foreach (IDimension dim in dimensions1) { _CsvZipDataWriter.WriteValue(dim.Id + "_code,"); valoredati += dim.Id + "_code,"; ordine[indord] = dim.Id; indord++; } valoredati += "VALUE,date"; string newLinedati = string.Format("{0}{1}", valoredati, Environment.NewLine); csvdati.Append(newLinedati); }
public void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, DataRetrievalInfoSeries info) { base.StartDataset(dataflow, dsd, header, info); }
/// <summary> /// Conditionally start the DataSet if <see cref="_startedDataSet"/> is false /// </summary> /// <param name="header"> /// The dataset header /// </param> protected override void WriteFormatDataSet(IDatasetHeader header) { if (this._startedDataSet) { this.EndGroup(); this.EndObservation(); this.EndSeries(); this.EndDataSet(); } NamespacePrefixPair dataSetNS = this.TargetSchema.EnumType != SdmxSchemaEnumType.VersionTwoPointOne ? this.Namespaces.DataSetStructureSpecific : this.Namespaces.Message; this.WriteStartElement(dataSetNS, ElementNameTable.DataSet); this.WriteDataSetHeader(header); this._startedDataSet = true; }
/// <summary> /// Sets the current dataflow. /// </summary> /// <param name="currentDataflow"> /// The current dataflow. /// </param> private void SetCurrentDataflow(IDataflowObject currentDataflow) { this._currentDataflow = currentDataflow; // If the current dataset header does not reference a Dataflow then amend it if (this._datasetHeader == null) { this._datasetHeader = new DatasetHeaderCore(Guid.NewGuid().ToString(), DatasetActionEnumType.Information, new DatasetStructureReferenceCore(currentDataflow.AsReference)); } else if (this._datasetHeader.DataProviderReference == null) { IDatasetStructureReference datasetStructureReference = new DatasetStructureReferenceCore(currentDataflow.AsReference); this._datasetHeader = this._datasetHeader.ModifyDataStructureReference(datasetStructureReference); } if (this._defaultDsd != null && this._defaultDsd.Urn.Equals(currentDataflow.DataStructureRef.TargetUrn)) { this.SetCurrentDsd(this._defaultDsd); } else if (this._objectRetrieval != null) { this.SetCurrentDsd(this._objectRetrieval.GetMaintainableObject<IDataStructureObject>(currentDataflow.DataStructureRef.MaintainableReference) as ICrossSectionalDataStructureObject); } }
/// <summary> /// Moves the next <see cref="IKeyable"/>. /// </summary> /// <returns>true if there is a next <see cref="IKeyable"/>.</returns> protected bool MoveNextKeyableInternal() { while (this._runAheadParser.Read()) { switch (this._runAheadParser.NodeType) { case XmlNodeType.Element: { string nodeName = this._runAheadParser.LocalName; if (ElementNameTable.DataSet.Is(nodeName)) { this._datasetHeader = new DatasetHeaderCore(this._runAheadParser, this.Header); this.ProcessAttributes(this._dataSetConcepts, this._dataSetAttributes); this.DetermineCurrentDataStructure(); } else if (ElementNameTable.Group.Is(nodeName)) { this.ProcessAttributes(this._groupConcepts, this._groupAttributes); } else if (ElementNameTable.Section.Is(nodeName)) { this.ProcessAttributes(this._sectionConcepts, this._sectionAttributes); } else if (this.IsMeasureNode(nodeName)) { this.ProcessObservation(nodeName); this.BuildCurrentKey(); this.BuildCurrentObservation(); this._observationSetFromKeyable = true; return true; } } break; case XmlNodeType.EndElement: { string nodeName = this._runAheadParser.LocalName; this.ResetComponentMaps(nodeName); if (this._observationValue != null) { if (ElementNameTable.Section.Is(nodeName) || ElementNameTable.Group.Is(nodeName) || ElementNameTable.DataSet.Is(nodeName)) { return false; } } if (ElementNameTable.CrossSectionalData.Is(nodeName)) { return false; } } break; } } return true; }
/// <summary> /// Writes the DataSet element /// </summary> /// <param name="header"> /// The dataset header /// </param> protected abstract void WriteFormatDataSet(IDatasetHeader header);
/// <summary> /// Starts a dataset with the data conforming to the DSD /// </summary> /// <param name="dataflow"> /// dataflow (optional) The dataflow can be provided to give extra information about the dataset /// </param> /// <param name="dataStructure"> /// The <see cref="IDataStructureObject"/> for which the dataset will be created /// </param> /// <param name="header"> /// The <see cref="IDatasetHeader"/> of the dataset /// </param> /// <param name="annotations"> /// The annotations. /// </param> /// <exception cref="System.ArgumentNullException"> /// if the <paramref name="dataflow"/> is null /// </exception> public virtual void StartDataset(IDataflowObject dataflow, IDataStructureObject dataStructure, IDatasetHeader header, params IAnnotation[] annotations) { if (dataStructure == null) { throw new ArgumentNullException("dataStructure"); } this._componentIdMapping = new Dictionary<string, string>(StringComparer.Ordinal); foreach (IComponent currentComponent in dataStructure.Components) { this._componentIdMapping[currentComponent.Id] = this.GetComponentId(currentComponent); } this._keyFamilyBean = dataStructure; if (!this._startedHeader) { this._dimensionAtObservation = this.GetDimensionAtObservation(header); this.WriteMessageTag(); var headerWriter = new HeaderWriter(this.SdmxMLWriter, this.Namespaces, this.TargetSchema); headerWriter.WriteHeader(this._header, this._dimensionAtObservation, dataStructure); this.ParseAction(this._header); if (this.IsDeleteMessage) { this._defaultObs = null; } this._startedHeader = true; } this.WriteFormatDataSet(header); this._startedDataSet = true; }
protected override void WriteFormatDataSet(IDatasetHeader header, DataRetrievalInfoSeries info) { if (this._startedDataSet) { return; } this._dimensionAtObservation = this.GetDimensionAtObservation(header); this.RDFWriteMessageTag(MessageElement, this.Namespaces); this.WriteStartElement(this.Namespaces.RDF, RDFElementNameTable.RDF); this.RDFWriteProvenance(info.MappingSet.DataSet.Description.ToString(), RDFConstants.RdfDataset); this.RDFWriterStrucInfo(info.MappingSet.DataSet.Description.ToString(), info.MappingSet.Dataflow.Dsd.Id.ToString()); this._startedDataSet = true; }
/// <summary> /// Gets the dimension at observation. /// </summary> /// <param name="header"> /// The dataset header. /// </param> /// <returns> /// The dimension at observation /// </returns> protected override string GetDimensionAtObservation(IDatasetHeader header) { return null; }
public void StartDataset(string dsdName, IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { myDsplStructure._info.Names = new List<DsplStructure.Name>(); myDsplStructure._info.Descriptions = new List<DsplStructure.Name>(); myDsplStructure._info.Languages = new List<DsplStructure.Languages>(); myDsplStructure._provider.Names = new List<DsplStructure.Name>(); foreach (var item in dataflow.Names) { var names = new DsplStructure.Name(); names.name = item.Value; names.lang = item.Locale; //info myDsplStructure._info.Names.Add(names); myDsplStructure._info.url = GetWebConfigInfo("urlAddress"); //provider myDsplStructure._provider.Names.Add(names); myDsplStructure._provider.url = GetWebConfigInfo("urlAddress"); } myDsplStructure._info.Languages = VerifyNames(dataflow); myDsplStructure._info.description= dsdName; var topic = new DsplStructure.Topic(); topic.id = dataflow.Name.PadRight(64); topic.Names = new List<DsplStructure.Name>(); foreach (var item in dataflow.Names) { var names = new DsplStructure.Name(); names.name = item.Value; names.lang = item.Locale; topic.Names.Add(names); } myDsplStructure._topics.Add(topic); var table = new DsplStructure.Table(); var colonne = new DsplStructure.Column(); string appPath = System.Web.HttpRuntime.AppDomainAppPath; string giorno = System.Web.HttpContext.Current.Timestamp.Day.ToString(); string ora = System.Web.HttpContext.Current.Timestamp.Hour.ToString(); string min = System.Web.HttpContext.Current.Timestamp.Minute.ToString(); string secondi = System.Web.HttpContext.Current.Timestamp.Second.ToString(); string ms = System.Web.HttpContext.Current.Timestamp.Millisecond.ToString(); string namedir = giorno + ora + min + secondi + ms; dirPath = appPath + namedir; DirectoryInfo MyRoot = new DirectoryInfo(@appPath); MyRoot.CreateSubdirectory(namedir); IList<IDimension> dimensions = dsd.GetDimensions(SdmxStructureEnumType.Dimension); string[] ordinamento1 = new string[dimensions.Count]; string[] ordinamento2 = new string[dsd.Components.Count]; string codelist = ""; string agenzia = ""; string versione = ""; var concept = new DsplStructure.Concept(); // metrics concept.id = "VALUE"; concept.type = "float"; //Pietro concept.infoconcept.Names = new List<DsplStructure.Name>(); concept.infoconcept.Descriptions = new List<DsplStructure.Name>(); foreach (var item in dataflow.Names) { var names = new DsplStructure.Name(); names.lang = item.Locale; names.name = item.Value; concept.infoconcept.Names.Add(names); } myDsplStructure._concepts.Add(concept); var slices = new DsplStructure.Slice(); slices.id = "DATI"; slices.dimension = new List<String>(); int indord = 0; foreach (IDimension dim in dimensions) { ISet<ICrossReference> isr = dim.Representation.CrossReferences; foreach (var x in isr) { codelist = x.MaintainableReference.MaintainableId; agenzia = x.MaintainableReference.AgencyId; versione = x.MaintainableReference.Version; } string IDDimension = dim.ConceptRef.FullId.ToString(); if (dim.FrequencyDimension == true) freqfieldcode = codelist; slices.dimension.Add(dim.Id + "_code"); colonne.id = dim.Id; colonne.type = "string"; table.columntable = new List<DsplStructure.Column>(); string namefiledim = ""; StringBuilder csv = new StringBuilder(); trovato = false; using (DsplMetadataEngine GetCodelists = new DsplMetadataEngine(agenzia, codelist, versione)) { ISet<ICodelistObject> codelists = GetCodelists.GetCodelistStruc(); if (codelists.Count > 0) { namefiledim = dirPath + "\\" + dim.Id.ToLower() + ".csv"; string headLine = ""; bool BheadLine = true; foreach (ICodelistObject codelistBean in codelists) { concept = new DsplStructure.Concept(); concept.id = dim.Id + "_code"; concept.type = "string"; concept.infoconcept.Names = new List<DsplStructure.Name>(); concept.infoconcept.Descriptions = new List<DsplStructure.Name>(); concept.infoconcept.Languages = new List<DsplStructure.Languages>(); foreach (var item in codelistBean.Names) { var names = new DsplStructure.Name(); var langs = new DsplStructure.Languages(); langs.lang = item.Locale; names.lang = item.Locale; names.name = item.Value; concept.infoconcept.Languages.Add(langs); concept.infoconcept.Names.Add(names); } foreach (var item in codelistBean.Descriptions) { var names = new DsplStructure.Name(); names.lang = item.Locale; names.name = item.Value; concept.infoconcept.Descriptions.Add(names); } if (concept.infoconcept.Languages.Count != myDsplStructure._info.Languages.Count) { AdjustLanguages(concept.infoconcept); AdjustNames(concept.infoconcept, concept.infoconcept.Names[0].name); } if (BheadLine) { foreach (var item in concept.infoconcept.Languages) { headLine = headLine + "name_" + item.lang + ","; BheadLine = false; } } concept.table = dim.Id; myDsplStructure._concepts.Add(concept); string valore = ""; string newLine = ""; IList<ICode> codes = codelistBean.Items; if (codes.Count > 0) { foreach (ICode codeBean in codes) { var hasParent = VerifyParentCode(codes); var codelisNames = new DsplStructure.Codelists(); codelisNames.Names = new List<DsplStructure.Name>(); codelisNames.Languages = new List<DsplStructure.Languages>(); foreach (var item in concept.infoconcept.Names) { foreach (var codeName in codeBean.Names) { if (item.lang == codeName.Locale) { var names = new DsplStructure.Name(); var Lang = new DsplStructure.Languages(); Lang.lang = codeName.Locale; names.lang = codeName.Locale; names.name = codeName.Value.Replace('"', ' '); codelisNames.id = codeBean.Id; codelisNames.Names.Add(names); codelisNames.Languages.Add(Lang); } } } if (codelisNames.Languages.Count != myDsplStructure._info.Languages.Count) { AdjustNames(codelisNames, codelisNames.Names[0].name); } if (hasParent) { trovato = true; var pc = codeBean.ParentCode; foreach (var value in codelisNames.Names) { valore = valore + value.name.Replace(',','.') + ","; } valore = valore + codelisNames.id + "," + pc; } else { foreach (var value in codelisNames.Names) { valore = valore + value.name.Replace(',', '.') + ","; } valore = valore + codelisNames.id; } newLine = string.Format("{0}{1}", valore, Environment.NewLine); valore = ""; csv.Append(newLine); } } if (trovato == true) { valore = headLine + dim.Id + "_code,parent"; } else { valore = headLine + dim.Id + "_code"; } table.id = dim.Id; foreach (var item in headLine.Split(',')) { if (item != "") { colonne.id = item; colonne.type = "string"; colonne.value = ""; table.columntable.Add(colonne); } } colonne.id = dim.Id + "_code"; colonne.type = "string"; colonne.value = ""; table.columntable.Add(colonne); if (trovato == true) { colonne.id = "parent"; colonne.type = "string"; colonne.value = ""; table.columntable.Add(colonne); } table.datafile_filename = dim.Id.ToLower() + ".csv"; myDsplStructure._tables.Add(table); newLine = string.Format("{0}{1}", valore, Environment.NewLine); csv.Insert(0, newLine); } } } File.WriteAllText(namefiledim, csv.ToString()); } table.id = "DATI_TBL"; colonne.value = ""; table.columntable = new List<DsplStructure.Column>(); string valoredati = ""; IList<IDimension> dimensions1 = dsd.GetDimensions(SdmxStructureEnumType.Dimension); foreach (IDimension dim in dimensions1) { if (!dim.Id.Equals("FREQ")) { _dsplDataWriter.WriteValue(dim.Id + "_code,"); valoredati += dim.Id + "_code,"; colonne.id = dim.Id + "_code"; colonne.type = "string"; table.columntable.Add(colonne); ordine[indord] = dim.Id; indord++; } } _dsplDataWriter.WriteValue("FREQ_code,"); colonne.id = "FREQ_code"; colonne.type = "string"; table.columntable.Add(colonne); ordine[indord] = "FREQ"; _dsplDataWriter.WriteValue("date,"); _dsplDataWriter.WriteValue("VALUE"); slices.metric = "VALUE"; colonne.id = "VALUE"; colonne.type = "float"; table.columntable.Add(colonne); table.datafile_filename = "DATI.csv"; myDsplStructure._tables.Add(table); _dsplDataWriter.WriteValue("\n"); slices.table = "DATI_TBL"; myDsplStructure._slices.Add(slices); valoredati += "FREQ_code,VALUE,date"; string newLinedati = string.Format("{0}{1}", valoredati, Environment.NewLine); csvdati.Append(newLinedati); }
/// <summary> /// Starts a dataset with the data conforming to the DSD /// </summary> /// <param name="dataflow">Optional. The dataflow can be provided to give extra information about the dataset.</param> /// <param name="dsd">The data structure is used to know the dimensionality of the data</param> /// <param name="header">Dataset header containing, amongst others, the dataset action, reporting dates, /// dimension at observation if null then the dimension at observation is assumed to be TIME_PERIOD and the dataset action is assumed to be INFORMATION</param> /// <param name="annotations">Any additional annotations that are attached to the dataset, can be null if no annotations exist</param> /// <exception cref="T:System.ArgumentException">if the DSD is null</exception> public void StartDataset(string dsdName, IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { this._actions.Enqueue(() => this._dataWriterEngine.StartDataset(dsdName, dataflow, dsd, header, annotations)); IList<IDimension> dimensions = dsd.GetDimensions(SdmxStructureEnumType.Dimension); string[] ordinamento1 = new string[dimensions.Count]; string[] ordinamento2 = new string[dsd.Components.Count]; }
/// <summary> /// Starts a dataset with the data conforming to the DSD /// </summary> /// <param name="dataflow">dataflow (optional) The dataflow can be provided to give extra information about the dataset </param> /// <param name="dsd"> /// The data structure object. /// </param> /// <param name="header"> /// Dataset header /// </param> /// <param name="annotations"> (optional) any additional annotations that are attached to the dataset, can be null if no annotations exist</param> /// <exception cref="System.ArgumentException"> /// if the <paramref name="dsd"/> is null /// </exception> public void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { if (dsd == null) { throw new ArgumentNullException("dsd"); } this.SetupKeyFamily(dsd); this.ParseAction(this._header.Action ?? header.Action); this._headerWriter = new GesmesHeaderWriter(this._writer, dsd, this._header); this._headerWriter.WriteHeader(this._isDeleteMessage); this._segmentCount = this._headerWriter.SegmentCount; this.StartDataSet(); }
public void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, DataRetrievalInfoSeries info) { this._actions.Enqueue(() => this._dataWriterEngine.StartDataset(dataflow, dsd, header, info)); }
/// <summary> /// Starts a dataset with the data conforming to the DSD /// </summary> /// <param name="dataflow">Optional. The dataflow can be provided to give extra information about the dataset.</param> /// <param name="dsd">The data structure is used to know the dimensionality of the data</param> /// <param name="header">Dataset header containing, amongst others, the dataset action, reporting dates, /// dimension at observation if null then the dimension at observation is assumed to be TIME_PERIOD and the dataset action is assumed to be INFORMATION</param> /// <param name="annotations">Any additional annotations that are attached to the dataset, can be null if no annotations exist</param> /// <exception cref="T:System.ArgumentException">if the DSD is null</exception> public void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { this._actions.Enqueue(() => this._dataWriterEngine.StartDataset(dataflow, dsd, header, annotations)); }
/// <summary> /// Starts a dataset with the data conforming to the <paramref name="dsd"/> /// </summary> /// <param name="dataflow"> /// The <see cref="IDataflowObject"/> /// </param> /// <param name="dsd"> /// The <see cref="ICrossSectionalDataStructureObject"/> /// </param> /// <param name="header"> /// The Dataset attributes /// </param> /// <exception cref="System.ArgumentNullException"> /// if the <paramref name="dsd"/> is null /// </exception> public void StartDataset(IDataflowObject dataflow, ICrossSectionalDataStructureObject dsd, IDatasetHeader header) { if (dsd == null) { throw new ArgumentNullException("dsd"); } base.StartDataset(null, dsd, header); }
/// <summary> /// Starts a dataset with the data conforming to the <paramref name="dsd" /> /// </summary> /// <param name="dataflow">The <see cref="T:Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IDataflowObject" /></param> /// <param name="dsd">The <see cref="T:Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.ICrossSectionalDataStructureObject" /></param> /// <param name="header">The Dataset attributes</param> /// <exception cref="T:System.ArgumentNullException">if the <paramref name="dsd" /> is null</exception> public void StartDataset(IDataflowObject dataflow, ICrossSectionalDataStructureObject dsd, IDatasetHeader header) { this._actions.Enqueue(() => this._dataWriterEngine.StartDataset(dataflow, dsd, header)); }
/// <summary> /// Conditionally start the DataSet if <see cref="_startedDataSet"/> is false /// </summary> /// <param name="header"> /// The Dataset header /// </param> protected override void WriteFormatDataSet(IDatasetHeader header) { if (this._startedDataSet) { return; } this.WriteStartElement(this.Namespaces.DataSetStructureSpecific, ElementNameTable.DataSet); this.WriteDataSetHeader(header); this._startedDataSet = true; }
/// <summary> /// Starts a dataset with the data conforming to the DSD /// </summary> /// <param name="dataflow">Optional. The dataflow can be provided to give extra information about the dataset.</param> /// <param name="dsd">The <see cref="IDataStructureObject" /> for which the dataset will be created</param> /// <param name="header">The <see cref="IDatasetHeader" /> of the dataset</param> /// <param name="annotations">Any additional annotations that are attached to the dataset, can be null if no annotations exist</param> /// <exception cref="System.ArgumentNullException">if the <paramref name="dsd" /> is null</exception> public override void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { this.CheckDisposed(); base.StartDataset(dataflow, dsd, header); if (dsd == null) { throw new ArgumentNullException("dsd"); } switch (this.TargetSchema.EnumType) { case SdmxSchemaEnumType.VersionOne: case SdmxSchemaEnumType.VersionTwo: WriterHelper.ValidateErrors(Validator.ValidateForCompact(dsd)); break; case SdmxSchemaEnumType.VersionTwoPointOne: this._isCrossSectional = DimensionObject.TimeDimensionFixedId.Equals(this.DimensionAtObservation); this._isFlat = this.DimensionAtObservation.Equals(Api.Constants.DimensionAtObservation.GetFromEnum(DimensionAtObservationEnumType.All).Value); if (!this._isFlat) { IDimension dimension = dsd.GetDimension(this.DimensionAtObservation); if (dimension == null) { throw new ArgumentNullException( "Can not start dataset. The dimension at observation has been set to '" + this.DimensionAtObservation + "', but this dimension does not exist in the datastructure '" + dsd.Urn + "'"); } } break; } }
public void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { this._dimensionAtObservation = this.GetDimensionAtObservation(header); //_jsonDataWriter.Formatting = Formatting.Indented; bool isIndented = Convert.ToBoolean(ConfigurationManager.AppSettings["isIndented"]); if (isIndented == true) { _jsonDataWriter.Formatting = Formatting.Indented; } _jsonDataWriter.WritePropertyName("dataSets"); _jsonDataWriter.WriteStartArray(); _jsonDataWriter.WriteStartObject(); _jsonDataWriter.WritePropertyName("actions"); _jsonDataWriter.WriteValue("Information"); }
/// <summary> /// Gets the dimension at observation. /// </summary> /// <param name="header"> /// The dataset header. /// </param> /// <returns> /// The dimension at observation /// </returns> protected virtual string GetDimensionAtObservation(IDatasetHeader header) { string dimensionAtObservation = DimensionObject.TimeDimensionFixedId; if (header != null && this.TargetSchema.EnumType == SdmxSchemaEnumType.VersionTwoPointOne && (header.DataStructureReference != null && !string.IsNullOrWhiteSpace(header.DataStructureReference.DimensionAtObservation))) { dimensionAtObservation = header.DataStructureReference.DimensionAtObservation; } return dimensionAtObservation; }
/// <summary> /// Starts a dataset with the data conforming to the DSD /// </summary> /// <param name="dataflow">Optional. The dataflow can be provided to give extra information about the dataset.</param> /// <param name="dsd">The <see cref="IDataStructureObject" /> for which the dataset will be created</param> /// <param name="header">The <see cref="IHeader" /> of the dataset</param> /// <param name="annotations">Any additional annotations that are attached to the dataset, can be null if no annotations exist</param> /// <exception cref="System.ArgumentNullException">if the <paramref name="dsd" /> is null</exception> public override void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { base.StartDataset(dataflow, dsd, header, annotations); if (this.IsTwoPointOne) { this.WriteAnnotations(ElementNameTable.AnnotationType, annotations); } else { this._datasetAnnotations = annotations; } if (this.IsFlat) { this._writeObservationMethod = this.WriteObservation21Flat; } }
/// <summary> /// Writes the dataset attributes. /// </summary> /// <param name="header"> /// The dataset header. /// </param> protected void WriteDataSetHeader(IDatasetHeader header) { // populate dataset header if (header != null) { this.TryWriteAttribute(AttributeNameTable.publicationPeriod, header.PublicationPeriod); // PublicationYear seems to default to -1. if (header.PublicationYear > 0) { this.TryWriteAttribute(AttributeNameTable.publicationYear, header.PublicationYear); } this.TryWriteAttribute(AttributeNameTable.validFrom, header.ValidFrom); this.TryWriteAttribute(AttributeNameTable.validTo, header.ValidTo); //// TODO MessageGroup support } if (this.TargetSchema.EnumType == SdmxSchemaEnumType.VersionTwoPointOne) { switch (this.DataFormatType) { case BaseDataFormatEnumType.Compact: this.WriteAttributeString( this.Namespaces.StructureSpecific21, AttributeNameTable.dataScope, "DataStructure"); this.WriteAttributeString( this.Namespaces.Xsi, AttributeNameTable.type, this.Namespaces.DataSetStructureSpecific.Prefix + ":DataSetType"); this.WriteAttributeString( this.Namespaces.StructureSpecific21, AttributeNameTable.structureRef, GetRef(this.KeyFamily)); break; case BaseDataFormatEnumType.Generic: this.WriteAttributeString(AttributeNameTable.structureRef, GetRef(this.KeyFamily)); break; } } }
/// <summary> /// Conditionally start the DataSet if <see cref="_startedDataSet"/> is false /// </summary> /// <param name="header"> /// The dataset header /// </param> protected override void WriteFormatDataSet(IDatasetHeader header) { if (this._startedDataSet) { return; } this._dimensionAtObservation = this.GetDimensionAtObservation(header); this.WriteStartElement(this.Namespaces.Message, ElementNameTable.DataSet); this.WriteDataSetHeader(header); if (this.TargetSchema.EnumType != SdmxSchemaEnumType.VersionTwoPointOne) { this.TryToWriteElement(this.Namespaces.Generic, ElementNameTable.KeyFamilyRef, this.KeyFamily.Id); } this._startedDataSet = true; }
/// <summary> /// Sets the current DSD. /// </summary> /// <param name="currentDsd"> /// The current DSD. /// </param> protected void SetCurrentDsd(ICrossSectionalDataStructureObject currentDsd) { this._currentDsd = currentDsd; foreach (var component in currentDsd.Components) { this._conceptToComponentId[component.ConceptRef.FullId] = component.Id; } this._availableDimensions.AddRange(currentDsd.GetDimensions(SdmxStructureEnumType.Dimension).Select(dimension => dimension.Id)); this._availableMeasureDimensions.AddRange(currentDsd.GetDimensions(SdmxStructureEnumType.MeasureDimension).Select(dimension => dimension.Id)); this._availableCrossSectionalMeasures.AddRange(currentDsd.CrossSectionalMeasures.Select(measure => measure.Id)); this._primaryMeasure = currentDsd.PrimaryMeasure.Id; if (currentDsd.TimeDimension != null) { this._timeDimensionId = currentDsd.TimeDimension.Id; } // If the current dataset header does not reference a DSD then amend it var datasetHeader = this._datasetHeader; if (datasetHeader != null && datasetHeader.DataStructureReference == null) { IDatasetStructureReference datasetStructureReference = new DatasetStructureReferenceCore(currentDsd.AsReference); this._datasetHeader = this._datasetHeader.ModifyDataStructureReference(datasetStructureReference); } }
/// <summary> /// Sets the current DSD. /// </summary> /// <param name="currentDsd"> /// The current DSD. /// </param> protected virtual void SetCurrentDsd(IDataStructureObject currentDsd) { this._currentDsd = currentDsd; // If the current dataset header does not reference a DSD then amend it if (this._datasetHeader.DataStructureReference == null) { IDatasetStructureReference datasetStructureReference = new DatasetStructureReferenceCore(currentDsd.AsReference); this._datasetHeader = this._datasetHeader.ModifyDataStructureReference(datasetStructureReference); } }
/// <summary> /// Starts a dataset with the data conforming to the DSD /// </summary> /// <param name="dataflow">Optional. The dataflow can be provided to give extra information about the dataset.</param> /// <param name="dsd">The <see cref="IDataStructureObject" /> for which the dataset will be created</param> /// <param name="header">The <see cref="IHeader" /> of the dataset</param> /// <param name="annotations">Any additional annotations that are attached to the dataset, can be null if no annotations exist</param> /// <exception cref="System.ArgumentNullException">if the <paramref name="dsd" /> is null</exception> public override void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { base.StartDataset(dataflow, dsd, header, annotations); this._primaryMeasureConcept = this.GetComponentId(dsd.PrimaryMeasure); this._compactNs = this.TargetSchema.EnumType != SdmxSchemaEnumType.VersionTwoPointOne ? this.Namespaces.DataSetStructureSpecific : NamespacePrefixPair.Empty; this._obsConcept = this.IsTwoPointOne ? this.DimensionAtObservation : ConceptRefUtil.GetConceptId(this.KeyFamily.TimeDimension.ConceptRef); if (this.IsTwoPointOne) { this.WriteAnnotations(ElementNameTable.AnnotationType, annotations); } else { this._datasetAnnotations = annotations; } }
/// <summary> /// Starts a dataset with the data conforming to the <paramref name="dsd" /> /// </summary> /// <param name="dataflow">The <see cref="T:Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IDataflowObject" /></param> /// <param name="dsd">The <see cref="T:Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.ICrossSectionalDataStructureObject" /></param> /// <param name="header">The Dataset attributes</param> /// <exception cref="T:System.ArgumentNullException">if the <paramref name="dsd" /> is null</exception> public void StartDataset(IDataflowObject dataflow, ICrossSectionalDataStructureObject dsd, IDatasetHeader header) { switch (this._delayBehavior) { case DataWriterDelayBehavior.UntilFirstStartDataSet: this.RunQueue(); this._dataWriterEngine.StartDataset(dataflow, dsd, header); break; default: this._actions.Enqueue(() => this._dataWriterEngine.StartDataset(dataflow, dsd, header)); break; } }
/// <summary> /// Starts a dataset with the data conforming to the DSD /// </summary> /// <param name="dataflow">Optional. The dataflow can be provided to give extra information about the dataset.</param> /// <param name="dsd">The data structure is used to know the dimensionality of the data</param> /// <param name="header">Dataset header containing, amongst others, the dataset action, reporting dates, /// dimension at observation if null then the dimension at observation is assumed to be TIME_PERIOD and the dataset action is assumed to be INFORMATION</param> /// <param name="annotations">Any additional annotations that are attached to the dataset, can be null if no annotations exist</param> /// <exception cref="ArgumentNullException"><paramref name="dsd"/> is <see langword="null" />.</exception> public void StartDataset(IDataflowObject dataflow, IDataStructureObject dsd, IDatasetHeader header, params IAnnotation[] annotations) { if (dsd == null) { throw new ArgumentNullException("dsd"); } switch (this._delayBehavior) { case DataWriterDelayBehavior.UntilFirstStartDataSet: this.RunQueue(); this._dataWriterEngine.StartDataset(dataflow, dsd, header, annotations); break; default: this._actions.Enqueue(() => this._dataWriterEngine.StartDataset(dataflow, dsd, header, annotations)); break; } }