public void ReadingStructures(String structureFile, SdmxSchemaEnumType schema, String output){ // Step 2. Implementing a helper class that parses DSD, Dataflow and writes datasets. //1) Call the method getXmlWriter XmlWriter xmlWriter = this.getXmlWriter(output); //2) Obtain IDataWriterEngine IDataWriterEngine compactWriter = new CompactDataWriterEngine(xmlWriter,SdmxSchema.GetFromEnum(schema)); //3) Read a structure file from a stream this.spm = new StructureParsingManager(); ISdmxObjects structureObjects = new SdmxObjectsImpl(); using (FileStream stream = File.Open(structureFile, FileMode.Open, FileAccess.Read)) { using (IReadableDataLocation rdl = new ReadableDataLocationTmp(stream)) { IStructureWorkspace structureWorkspace = this.spm.ParseStructures(rdl); structureObjects = structureWorkspace.GetStructureObjects(false); } } //4) The IMaintainableRefObject is used to reference structures that extend the IMaintainableObject Interface. IMaintainableRefObject dsdRef = new MaintainableRefObjectImpl("ESTAT", "STS", "2.2"); IMaintainableRefObject flowRef = new MaintainableRefObjectImpl("ESTAT", "SSTSCONS_PROD_A", "1.0"); //5) Get the DataStructure and the Dataflow ISet<IDataStructureObject> dsd = structureObjects.GetDataStructures(dsdRef); ISet<IDataflowObject> dataflow = structureObjects.GetDataflows(flowRef); //6) After obtaining our IDataWriterEngine, and the IDataStructureObject that we wish to create data for, we can write the dataset SampleDataWriter sampleDataWriter = new SampleDataWriter(); sampleDataWriter.writeSampleData(dsd.FirstOrDefault(), dataflow.FirstOrDefault(), compactWriter); xmlWriter.Close(); }
/// <summary> /// Gets the SDMX objects. /// </summary> /// <param name="stream">The stream.</param> /// <param name="parsingManager">The parsing manager.</param> /// <returns>The <see cref="ISdmxObjects" />.</returns> public static ISdmxObjects GetSdmxObjects(this Stream stream, IStructureParsingManager parsingManager) { using (IReadableDataLocation dataLocation = _dataLocationFactory.GetReadableDataLocation(stream)) { return dataLocation.GetSdmxObjects(parsingManager); } }
/// <summary> /// Initializes a new instance of the <see cref="SdmxDataModelProvider"/> class. /// </summary> /// <param name="rootModel">The root data model.</param> /// <param name="namespaceName">The namespace name.</param> private SdmxDataModelProvider(IDataModelProvider rootModel, string namespaceName) : base(rootModel) { this.Namespace = namespaceName; this._structureParsingManager = new StructureParsingManager(); this._dataLocationFactory = new ReadableDataLocationFactory(); }
public void readStructures(String structureFile, SdmxSchemaEnumType schema) { IReadableDataLocation rdl = new FileReadableDataLocation(structureFile); spm = new StructureParsingManager(SdmxSchemaEnumType.VersionTwoPointOne); IStructureWorkspace workspace = spm.ParseStructures(rdl); ISdmxObjects sdmxObjects = workspace.GetStructureObjects(false); ISet<IMaintainableObject> maintainables = sdmxObjects.GetAllMaintainables(); foreach (IMaintainableObject m in maintainables) { Console.WriteLine(m.Urn); Console.WriteLine(m.StructureType.StructureType + " - " + m.Name); Console.WriteLine(" --- "); } }
/// <summary> /// Initializes a new instance of the <see cref="StructureValidationManager"/> class. /// </summary> /// <param name="structureParsingManager"> /// The structure parsing manager. /// </param> /// <param name="structureWritingManager"> /// The structure writing manager. /// </param> /// <param name="readableDataLocationFactory"> /// The readable data location factory. /// </param> public StructureValidationManager(IStructureParsingManager structureParsingManager, IStructureWriterManager structureWritingManager, IReadableDataLocationFactory readableDataLocationFactory) { this._structureParsingManager = structureParsingManager ?? new StructureParsingManager(); this._structureWritingManager = structureWritingManager ?? new StructureWriterManager(); this._readableDataLocationFactory = readableDataLocationFactory ?? new ReadableDataLocationFactory(); }
/// <summary> /// Initializes a new instance of the <see cref="StructureValidationManager"/> class. /// </summary> /// <param name="sdmxSchema"> /// The sdmx schema. /// </param> public StructureValidationManager(SdmxSchemaEnumType sdmxSchema) : base(sdmxSchema) { this._structureWritingManager = new StructureWriterManager(); this._structureParsingManager = new StructureParsingManager(sdmxSchema); }
public void Init() { dataQueryParseManager = new DataQueryParseManager(SdmxSchemaEnumType.Null); parsingManager = new StructureParsingManager(); }
public void Init() { IStructureWorkspace structureWorkspace; IDataflowObject dataflowObject; IDataStructureObject dataStructureObject; dataQueryParseManager = new DataQueryParseManager(SdmxSchemaEnumType.Null); parsingManager = new StructureParsingManager(); beanRetrivalManager = new Mock<ISdmxObjectRetrievalManager>(); using (var fileDataFlowReadableDataLocation = new FileReadableDataLocation(FileDataFlow)) { structureWorkspace = parsingManager.ParseStructures(fileDataFlowReadableDataLocation); ISdmxObjects structureBeans = structureWorkspace.GetStructureObjects(false); dataflowObject = structureBeans.Dataflows.First(); Assert.IsNotNull(dataflowObject); } using (var fileKeybeanReadableDataLocation = new FileReadableDataLocation(FilekeyBean)) { structureWorkspace = parsingManager.ParseStructures(fileKeybeanReadableDataLocation); ISdmxObjects structureBeans = structureWorkspace.GetStructureObjects(false); dataStructureObject = structureBeans.DataStructures.First(); Assert.IsNotNull(dataStructureObject); } beanRetrivalManager.Setup(m => m.GetMaintainableObject<IDataflowObject>(It.IsAny<IMaintainableRefObject>())).Returns(dataflowObject); beanRetrivalManager.Setup(m => m.GetMaintainableObject<IDataStructureObject>(It.IsAny<IMaintainableRefObject>())).Returns(dataStructureObject); }
public ReadingStructures() { this._structureParsingManager = new StructureParsingManager(); this._dataLocationFactory = new ReadableDataLocationFactory(); }
public void Setup() { this._writerManager = new StructureWriterManager(); this._parsingManager = new StructureParsingManager(); }
/// <summary> /// Initializes a new instance of the <see cref="Chapter4ReadingData"/> class. /// </summary> /// <param name="dataReaderManager"> /// The data Reader Manager. /// </param> /// <param name="rdlFactory"> /// The <see cref="IReadableDataLocationFactory"/>. /// </param> /// <param name="structureParsingManager"> /// The structure Parsing Manager. /// </param> public Chapter4ReadingData(IDataReaderManager dataReaderManager, IReadableDataLocationFactory rdlFactory, IStructureParsingManager structureParsingManager) { this._dataReaderManager = dataReaderManager; this._rdlFactory = rdlFactory; this._structureParsingManager = structureParsingManager; }
/// <summary> /// Gets the SDMX objects. /// </summary> /// <param name="file">The file.</param> /// <param name="parsingManager">The parsing manager.</param> /// <returns>The <see cref="ISdmxObjects" />.</returns> public static ISdmxObjects GetSdmxObjects(this FileInfo file, IStructureParsingManager parsingManager) { using (IReadableDataLocation dataLocation = _dataLocationFactory.GetReadableDataLocation(file)) { return dataLocation.GetSdmxObjects(parsingManager); } }
/// <summary> /// Gets the SDMX objects. /// </summary> /// <param name="dataLocation">The data location.</param> /// <param name="parsingManager">The parsing manager.</param> /// <returns>The <see cref="ISdmxObjects"/>.</returns> public static ISdmxObjects GetSdmxObjects(this IReadableDataLocation dataLocation, IStructureParsingManager parsingManager) { IStructureWorkspace structureWorkspace = parsingManager.ParseStructures(dataLocation); return structureWorkspace.GetStructureObjects(false); }