/// <summary> /// Initializes a new instance of the <see cref="StructureVersionIncrementManager" /> class. /// </summary> /// <param name="beanRetrievalManager">The bean retrieval manager.</param> /// <param name="crossReferenceReversionEngine">The cross reference reversion engine.</param> /// <param name="crossReferencingRetrievalManager">The cross referencing retrieval manager.</param> /// <param name="structureVersionRetrievalManager">The structure version retrieval manager.</param> public StructureVersionIncrementManager(ISdmxObjectRetrievalManager beanRetrievalManager, ICrossReferenceReversionEngine crossReferenceReversionEngine, ICrossReferencingRetrievalManager crossReferencingRetrievalManager, IStructureVersionRetrievalManager structureVersionRetrievalManager) { this._beanRetrievalManager = beanRetrievalManager; this._crossReferenceReversionEngine = crossReferenceReversionEngine ?? new CrossReferenceReversionEngine(); this._crossReferencingRetrievalManager = crossReferencingRetrievalManager; this._structureVersionRetrievalManager = structureVersionRetrievalManager; }
/// <summary> /// Initializes a new instance of the <see cref="TestXS"/> class. /// </summary> /// <param name="name"> /// The name. /// </param> public TestXS(string name) { var connectionString = ConfigurationManager.ConnectionStrings [name]; this._dataRetrieval = new DataRetrieverCore(new HeaderImpl("TestXS", "ZZ9"), connectionString, SdmxSchemaEnumType.VersionTwo); this._dataQueryParseManager = new DataQueryParseManager(SdmxSchemaEnumType.VersionTwo); this._retrievalManager = new MappingStoreSdmxObjectRetrievalManager(connectionString); }
/// <summary> /// Build data query from the specified <paramref name="queryType"/> /// </summary> /// <param name="queryType"> /// The query type. /// </param> /// <param name="structureRetrievalManager"> /// The structure retrieval manager. /// </param> /// <returns> /// The data query from the specified <paramref name="queryType"/> /// </returns> public IList<IDataQuery> BuildDataQuery( QueryType queryType, ISdmxObjectRetrievalManager structureRetrievalManager) { IList<IDataQuery> returnList = new List<IDataQuery>(); foreach (DataWhereType dataWhere in queryType.DataWhere) { // TODO java 0.9.9 no support for default limit. Opened : http://www.metadatatechnology.com/mantis/view.php?id=1427 DataQueryProcessor dataQueryProcessor = null; if (queryType.defaultLimit.HasValue && queryType.defaultLimit.Value < int.MaxValue) { int limit = decimal.ToInt32(queryType.defaultLimit.Value); dataQueryProcessor = new DataQueryProcessor(limit); } else { dataQueryProcessor = new DataQueryProcessor(); } returnList.Add(dataQueryProcessor.BuildDataQuery(dataWhere, structureRetrievalManager)); } return returnList; }
public TestTimeRange(string connectionName) { var connectionString = ConfigurationManager.ConnectionStrings[connectionName]; this._dataRetrievalRest = new DataRetrieverCore(new HeaderImpl("TEST_ID", "TEST_SENDER"), connectionString, SdmxSchemaEnumType.VersionTwo); this._retrievalManager = new MappingStoreSdmxObjectRetrievalManager(connectionString); this._dataQueryParseManager = new DataQueryParseManager(SdmxSchemaEnumType.Null); }
public CategorisationObjectBaseCore(ICategorisationObject categorisation0, ISdmxObjectRetrievalManager retMan) : base(categorisation0) { IMaintainableObject maint = retMan.GetMaintainable(categorisation0 .StructureReference); IMaintainableObject cs = retMan.GetMaintainable(categorisation0 .CategoryReference); /* foreach */ foreach (IIdentifiableObject ident in cs.IdentifiableComposites) { if (categorisation0.CategoryReference.IsMatch(ident)) { category = (ICategoryObject) ident; break; } } if (categorisation0.StructureReference.TargetReference.IsMaintainable && categorisation0.StructureReference.IsMatch(maint)) { structure = maint; } else { foreach (IIdentifiableObject ident1 in maint.IdentifiableComposites) { if (categorisation0.StructureReference.IsMatch(ident1)) { structure = ident1; break; } } } if (structure == null) { throw new ReferenceException(categorisation0.StructureReference); } if (category == null) { throw new ReferenceException(categorisation0.CategoryReference); } }
/// <summary> /// Builds a data query from a <c>dataWhereType</c> /// </summary> /// <param name="queryType"> /// - the IXML to build the domain object (DataQuery) from /// </param> /// <param name="structureRetrievalManager"> /// optional, if supplied the retrieval manager to use to retrieve the Dataflow and Provider defined by the /// <paramref name="queryType"/> /// </param> /// <returns> /// a data query from a <c>dataWhereType</c> /// </returns> public virtual IList<IDataQuery> BuildDataQuery( QueryType queryType, ISdmxObjectRetrievalManager structureRetrievalManager) { throw new SdmxNotImplementedException("DataQueryBuilder.buildDataQuery (Version 1.0 SDMX)"); ////throw new UnsupportedException( //// ExceptionCode.Unsupported, "DataQueryBuilder.buildDataQuery (Version 1.0 SDMX)"); }
/// <summary> /// Builds a data query from a <c>dataWhereType</c>. Not implemented /// </summary> /// <param name="dataWhereType"> /// - the IXML to build the domain object (DataQuery) from /// </param> /// <param name="structureRetrievalManager"> /// optional, if supplied the retrieval manager to use to retrieve the Dataflow and Provider defined by the /// <paramref name="dataWhereType"/> /// </param> /// <exception cref="NotImplementedException"> /// DataQueryBuilder.buildDataQuery (Version 1.0 SDMX) /// </exception> /// <returns> /// a data query from a <c>dataWhereType</c> /// </returns> public virtual IDataQuery BuildDataQuery( DataWhereType dataWhereType, ISdmxObjectRetrievalManager structureRetrievalManager) { throw new SdmxNotImplementedException("DataQueryBuilder.buildDataQuery (Version 1.0 SDMX)"); //// FUNC Support 1.0 data query ////throw new UnsupportedException( //// ExceptionCode.Unsupported, "DataQueryBuilder.buildDataQuery (Version 1.0 SDMX)"); }
/// <summary> /// Initializes a new instance of the <see cref="CrossReferencedRetrievalManager"/> class. /// </summary> /// <param name="sdmxObjectRetrievalManager">The SDMX object retrieval manager.</param> public CrossReferencedRetrievalManager(ISdmxObjectRetrievalManager sdmxObjectRetrievalManager) { if (sdmxObjectRetrievalManager == null) { throw new ArgumentNullException("sdmxObjectRetrievalManager"); } this._sdmxObjectRetrievalManager = sdmxObjectRetrievalManager; }
/// <summary> /// Initializes a new instance of the <see cref="AbstractRetrievalManager"/> class. /// </summary> /// <param name="sdmxObjectRetrievalManager"> /// The sdmx object retrieval manager. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="sdmxObjectRetrievalManager"/> is null /// </exception> protected AbstractRetrievalManager(ISdmxObjectRetrievalManager sdmxObjectRetrievalManager) { if (sdmxObjectRetrievalManager == null) { throw new ArgumentNullException("sdmxObjectRetrievalManager"); } this._sdmxObjectRetrievalManager = sdmxObjectRetrievalManager; }
/// <summary> /// Initializes a new instance of the <see cref="SimpleDataController{TWriter}" /> class. /// </summary> /// <param name="decoratedController">The decorated Controller.</param> /// <param name="sdmxRetrievalManager">The sdmx Retrieval Manager.</param> /// <exception cref="System.ArgumentNullException"><see cref="_sdmxRetrievalManager"/> is null</exception> public SimpleDataController(IController <IDataQuery, TWriter> decoratedController, ISdmxObjectRetrievalManager sdmxRetrievalManager) : base(decoratedController) { if (sdmxRetrievalManager == null) { throw new ArgumentNullException("sdmxRetrievalManager"); } this._sdmxRetrievalManager = sdmxRetrievalManager; }
/// <summary> /// Builds a <see cref="IDataQuery"/> list from a message that contains one or more data queries /// </summary> /// <param name="dataQueryLocation"> /// The data location /// </param> /// <param name="beanRetrievalManager"> /// optional, if given will retrieve the key family bean the query is for /// </param> /// <returns> /// a <see cref="IDataQuery"/> list /// </returns> public IList<IDataQuery> BuildDataQuery( IReadableDataLocation dataQueryLocation, ISdmxObjectRetrievalManager beanRetrievalManager) { this._log.Debug("DataParseManagerImpl.buildDataQuery"); using (ISdmxXmlStream xmlStream = new SdmxXmlStream(dataQueryLocation)) { LoggingUtil.Debug(this._log, "Schema Version Determined to be : " + xmlStream.SdmxVersion); return this.BuildDataQuery(xmlStream, beanRetrievalManager); } }
/// <summary> /// Returns the set of cross referenced structures from this maintainable. /// </summary> /// <param name="retrievalManager"> /// The retrieval manager /// </param> /// <param name="maintainable"> /// The maintainable object /// </param> /// <returns> /// The cross references set. /// </returns> public ISet<ICrossReference> GetCrossReferences(ISdmxObjectRetrievalManager retrievalManager, IMaintainableObject maintainable) { switch (maintainable.StructureType.EnumType) { case SdmxStructureEnumType.ContentConstraint: return GetCrossReferences(retrievalManager, (IContentConstraintObject)maintainable); default: return maintainable.CrossReferences; } }
/// <summary> /// Initializes a new instance of the <see cref="AdvancedDataController{TWriter}" /> class. /// </summary> /// <param name="operation">The operation.</param> /// <param name="decoratedController">The decorated Controller.</param> /// <param name="sdmxRetrievalManager">The sdmx Retrieval Manager.</param> /// <exception cref="System.ArgumentNullException"><see cref="_sdmxRetrievalManager"/> is null.</exception> /// <exception cref="SdmxSemmanticException">Operation not accepted with query used</exception> public AdvancedDataController(SoapOperation operation, IController <IComplexDataQuery, TWriter> decoratedController, ISdmxObjectRetrievalManager sdmxRetrievalManager) : base(decoratedController) { if (sdmxRetrievalManager == null) { throw new ArgumentNullException("sdmxRetrievalManager"); } this._sdmxRetrievalManager = sdmxRetrievalManager; this._rootNode = operation.GetQueryRootElementV21(); }
/// <summary> /// Builds a data query from a <c>dataWhereType</c> /// </summary> /// <param name="queryType"> /// - the IXML to build the domain object (DataQuery) from /// </param> /// <param name="structureRetrievalManager"> /// optional, if supplied the retrieval manager to use to retrieve the Dataflow and Provider defined by the /// <paramref name="queryType"/> /// </param> /// <returns> /// a data query from a <c>dataWhereType</c> /// </returns> public virtual IList<IDataQuery> BuildDataQuery( Org.Sdmx.Resources.SdmxMl.Schemas.V20.query.QueryType queryType, ISdmxObjectRetrievalManager structureRetrievalManager) { return this._dataQueryBuilderV2.BuildDataQuery(queryType, structureRetrievalManager); }
public virtual IList<IComplexDataQuery> BuildComplexDataQuery( Org.Sdmx.Resources.SdmxMl.Schemas.V21.Query.DataQueryType dataQueryType, ISdmxObjectRetrievalManager structureRetrievalManager) { return this._dataQueryBuilderV21.BuildComplexDataQuery(dataQueryType, structureRetrievalManager); }
/// <summary> /// Build from a REST query and a bean retrival manager /// </summary> /// <param name="dataQuery"></param> /// <param name="retrievalManager"></param> /// <exception cref="SdmxSemmanticException"></exception> public DataQueryImpl(IRestDataQuery dataQuery, ISdmxObjectRetrievalManager retrievalManager) { this._lastUpdated = dataQuery.UpdatedAfter; this._dataQueryDetail = dataQuery.QueryDetail ?? DataQueryDetail.GetFromEnum(DataQueryDetailEnumType.Full); base.FirstNObservations = dataQuery.FirstNObservations; base.LastNObservations = dataQuery.LastNObsertations; if (ObjectUtil.ValidString(dataQuery.DimensionAtObservation)) { this.DimensionAtObservation = dataQuery.DimensionAtObservation; } base.Dataflow = retrievalManager.GetMaintainableObject<IDataflowObject>(dataQuery.FlowRef.MaintainableReference); if (base.Dataflow == null) { throw new SdmxNoResultsException("Data Flow could not be found for query : " + dataQuery.FlowRef); } base.DataStructure = retrievalManager.GetMaintainableObject<IDataStructureObject>(base.Dataflow.DataStructureRef.MaintainableReference); if (base.DataStructure == null) { throw new SdmxNoResultsException("DSD could not be found for query : " + base.Dataflow.DataStructureRef); } ISet<IDataProvider> dataProviders = new HashSet<IDataProvider>(); if (dataQuery.ProviderRef != null) { ISet<IDataProviderScheme> dataProviderSchemes = retrievalManager.GetMaintainableObjects<IDataProviderScheme>(dataQuery.ProviderRef.MaintainableReference); foreach (IDataProviderScheme currentDpScheme in dataProviderSchemes) { foreach (IDataProvider dataProvider in currentDpScheme.Items) { if (dataProvider.Id.Equals(dataQuery.ProviderRef.ChildReference.Id)) { dataProviders.Add(dataProvider); } } } } ISet<IDataQuerySelection> selections = new HashSet<IDataQuerySelection>(); if (dataQuery.QueryList.Count > 0) { int i = 0; foreach (IDimension dimension in base.DataStructure.GetDimensions(SdmxStructureEnumType.Dimension, SdmxStructureEnumType.MeasureDimension).OrderBy(dimension => dimension.Position)) { if (dataQuery.QueryList.Count <= i) { throw new SdmxSemmanticException( "Not enough key values in query, expecting " + base.DataStructure.GetDimensions(SdmxStructureEnumType.Dimension, SdmxStructureEnumType.MeasureDimension).Count + " got " + dataQuery.QueryList.Count); } ISet<string> queriesForDimension = dataQuery.QueryList[i]; if (queriesForDimension != null && queriesForDimension.Count > 0) { IDataQuerySelection selectionsForDimension = new DataQueryDimensionSelectionImpl( dimension.Id, new HashSet<string>(queriesForDimension)); selections.Add(selectionsForDimension); } i++; } } if (ObjectUtil.ValidCollection(selections) || dataQuery.StartPeriod != null || dataQuery.EndPeriod != null) { _dataQuerySelectionGroups.Add( new DataQuerySelectionGroupImpl(selections, dataQuery.StartPeriod, dataQuery.EndPeriod)); } ValidateQuery(); }
/// <summary> /// Obtains a DataReaderEngine that is capable of reading the data which is exposed via the ReadableDataLocation /// </summary> /// <param name="sourceData"> /// The source data, giving access to an InputStream of the data. /// </param> /// <param name="retrievalManager"> /// The retrieval Manager. It is used to obtain the <see cref="IDataStructureObject"/> that describe the data. /// </param> /// <returns> /// The <see cref="IDataReaderEngine"/>; otherwise null if the <paramref name="sourceData"/> cannot be read. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="sourceData"/> is null -or- <paramref name="retrievalManager"/> is null /// </exception> public IDataReaderEngine GetDataReaderEngine(IReadableDataLocation sourceData, ISdmxObjectRetrievalManager retrievalManager) { //// TODO check with MT why the two methods are so different. IDataFormat dataFormat = null; try { dataFormat = this._dataInformationManager.GetDataType(sourceData); } catch (Exception e) { _log.Error("While trying to get the data format", e); } if (dataFormat != null && dataFormat.SdmxDataFormat != null) { switch (dataFormat.SdmxDataFormat.BaseDataFormat.EnumType) { case BaseDataFormatEnumType.Compact: return new CompactDataReaderEngine(sourceData, retrievalManager, null, null); case BaseDataFormatEnumType.Generic: return new GenericDataReaderEngine(sourceData, retrievalManager, null, null); case BaseDataFormatEnumType.CrossSectional: return new CrossSectionalDataReaderEngine(sourceData, retrievalManager, null, null); case BaseDataFormatEnumType.Edi: var ediParseManager = this._ediParseManager; if (ediParseManager != null) { return ediParseManager.ParseEdiMessage(sourceData).GetDataReader(retrievalManager); } break; default: _log.WarnFormat("SdmxDataReaderFactory encountered unsupported SDMX format: {0} ", dataFormat); break; } } return null; }
/// <summary> /// Parse the specified <paramref name="query"/>. /// </summary> /// <param name="query"> /// The REST data query. /// </param> /// <param name="beanRetrievalManager"> /// The <c>SDMX</c> object retrieval manager. /// </param> /// <returns> /// The <see cref="IDataQuery"/> from <paramref name="query"/>. /// </returns> public virtual IDataQuery ParseRestQuery(string query, ISdmxObjectRetrievalManager beanRetrievalManager) { // NOTE fixed MT bug Data -> data if (!query.ToLower().StartsWith("data/")) { throw new SdmxSemmanticException("Expecting REST Query for Data to start with 'Data/'"); } string[] split = Regex.Split(query, "\\?"); //Everything one split[1] this point are query parameters IDictionary<string, string> queryParameters = new Dictionary<string, string>(StringComparer.Ordinal); if (split.Length > 1) { string[] queryParametersSplit = Regex.Split(split[1], "&"); for (int i = 0; i < queryParametersSplit.Length; i++) { string[] queryParam = Regex.Split(queryParametersSplit[i], "="); if (queryParam.Length != 2) { throw new SdmxSemmanticException("Missing equals '=' in query parameters '" + split[i] + "'"); } queryParameters.Add(queryParam[0], queryParam[1]); } } string queryPrefix = split[0]; var dataQuery = new RESTDataQueryCore(queryPrefix.Split('/'), queryParameters); return new DataQueryImpl(dataQuery, beanRetrievalManager); }
public IList<IComplexDataQuery> BuildComplexDataQuery(IReadableDataLocation dataQueryLocation, ISdmxObjectRetrievalManager beanRetrievalManager) { _log.Debug("DataParseManagerImpl.buildComplexDataQuery"); SdmxSchemaEnumType schemaVersion = SdmxMessageUtil.GetSchemaVersion(dataQueryLocation); LoggingUtil.Debug(_log, "Schema Version Determined to be : " + schemaVersion); XMLParser.ValidateXml(dataQueryLocation, schemaVersion); using (Stream inputStream = dataQueryLocation.InputStream) using (var textReader = new StreamReader(inputStream)) { switch (schemaVersion) { case SdmxSchemaEnumType.VersionOne: throw new ArgumentException("Build Complex Data Query concerns sdmx messages of schema version 2.1 "); case SdmxSchemaEnumType.VersionTwo: throw new ArgumentException("Build Complex Data Query concerns sdmx messages of schema version 2.1 "); case SdmxSchemaEnumType.VersionTwoPointOne: IList<QueryMessageEnumType> queryMessageTypes = SdmxMessageUtil.GetQueryMessageTypes(dataQueryLocation); QueryMessageEnumType queryMessageType = queryMessageTypes[0]; if (queryMessageType.Equals(QueryMessageEnumType.GenericDataQuery)) { GenericDataQuery queryV21 = GenericDataQuery.Load(textReader); return this._dataQueryBuilder.BuildComplexDataQuery(queryV21.Content.BaseDataQueryType, beanRetrievalManager); } else if (queryMessageType.Equals(QueryMessageEnumType.GenericTimeseriesDataQuery)) { GenericTimeSeriesDataQuery queryV21 = GenericTimeSeriesDataQuery.Load(textReader); return this._dataQueryBuilder.BuildComplexDataQuery(queryV21.Content.BaseDataQueryType, beanRetrievalManager); } else if (queryMessageType.Equals(QueryMessageEnumType.StructureSpecificDataQuery)) { StructureSpecificDataQuery queryV21 = StructureSpecificDataQuery.Load(textReader); return this._dataQueryBuilder.BuildComplexDataQuery(queryV21.Content.BaseDataQueryType, beanRetrievalManager); } else //if (queryMessageType.Equals(QueryMessageEnumType.StructureSpecificTimeSeriesDataQuery)) { StructureSpecificTimeSeriesDataQuery queryV21 = StructureSpecificTimeSeriesDataQuery.Load(textReader); return this._dataQueryBuilder.BuildComplexDataQuery(queryV21.Content.BaseDataQueryType, beanRetrievalManager); } default: throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "buildComplexDataQuery in version " + schemaVersion); } } }
/// <summary> /// Initializes a new instance of the <see cref="RestStructureQueryManager"/> class. /// </summary> /// <param name="structureWritingManager"> /// The structure writer manager. /// </param> /// /// <param name="structureSearchManager"> /// The structure search manager. /// </param> public RestStructureQueryManager(IStructureWriterManager structureWritingManager, ISdmxObjectRetrievalManager beanRetrievalManager) { _structureWritingManager = structureWritingManager; _beanRetrievalManager = beanRetrievalManager; }
/// <summary> /// Initializes a new instance of the <see cref="AbstractDataReaderEngine"/> class. /// </summary> /// <param name="dataLocation"> /// The data Location. /// </param> /// <param name="objectRetrieval"> /// The SDMX Object Retrieval. giving the ability to retrieve DSDs for the datasets this /// reader engine is reading. This can be null if there is only one relevant DSD - in which case the /// <paramref name="defaultDsd"/> should be provided. /// </param> /// <param name="defaultDataflow"> /// The default Dataflow. (Optional) /// </param> /// <param name="defaultDsd"> /// The default DSD. The default DSD to use if the <paramref name="objectRetrieval"/> is null, or /// if the bean retrieval does not return the DSD for the given dataset. /// </param> /// <exception cref="System.ArgumentException"> /// AbstractDataReaderEngine expects either a ISdmxObjectRetrievalManager or a /// IDataStructureObject to be able to interpret the structures /// </exception> protected AbstractDataReaderEngine(IReadableDataLocation dataLocation, ISdmxObjectRetrievalManager objectRetrieval, IDataflowObject defaultDataflow, IDataStructureObject defaultDsd) { this._dataLocation = dataLocation; this._objectRetrieval = objectRetrieval; this._defaultDataflow = defaultDataflow; this._defaultDsd = defaultDsd; if (objectRetrieval == null && defaultDsd == null) { throw new ArgumentException("AbstractDataReaderEngine expects either a ISdmxObjectRetrievalManager or a IDataStructureObject to be able to interpret the structures"); } }
/// <summary> /// Initializes a new instance of the <see cref="TestWsRetrieverFactory" /> class. /// </summary> public TestWsRetrieverFactory() { ISdmxObjects sdmxObjects = new SdmxObjectsImpl(); using (var stream = GetResource("ESTAT+STS+2.0.xml")) { Merge(stream, sdmxObjects); } using (var stream = GetResource("ESTAT+DEMOGRAPHY+2.1.xml")) { Merge(stream, sdmxObjects); } var sts = sdmxObjects.GetDataStructures(new MaintainableRefObjectImpl(null, "STS", null)).Select(o => o.AsReference).FirstOrDefault(); var demo = sdmxObjects.GetDataStructures(new MaintainableRefObjectImpl(null, "DEMOGRAPHY", null)).Select(o => o.AsReference).FirstOrDefault(); sdmxObjects.AddDataflow(BuildDataflow(Dataflows.NoResults, sts)); sdmxObjects.AddDataflow(BuildDataflow(Dataflows.ResponseExceedsLimit, sts)); sdmxObjects.AddDataflow(BuildDataflow(Dataflows.ResponseTooLarge, sts)); sdmxObjects.AddDataflow(BuildDataflow(Dataflows.Semantic, sts)); sdmxObjects.AddDataflow(BuildDataflow(Dataflows.TimeSeries, sts)); sdmxObjects.AddDataflow(BuildDataflow(Dataflows.CrossV20Only, demo)); InMemoryRetrievalManager retrievalManager = new InMemoryRetrievalManager(sdmxObjects); retrievalManager.CrossReferenceRetrievalManager = new CrossReferencedRetrievalManager(retrievalManager); this._sdmxObjectRetrievalManager = retrievalManager; this._mutableStructureSearchManager = new SampleStructureSearchManager(this._sdmxObjectRetrievalManager); this._sampleAdvancedMutableStructureSearchManager = new SampleAdvancedMutableStructureSearchManager(this._mutableStructureSearchManager); this._sampleAuthAdvancedStructureSearchManager = new SampleAuthAdvancedStructureSearchManager(this._sampleAdvancedMutableStructureSearchManager); }
/// <summary> /// Obtains a DataReaderEngine that is capable of reading the data which is exposed via the ReadableDataLocation /// </summary> /// <param name="sourceData"> /// SourceData - giving access to an InputStream of the data /// </param> /// <param name="retrievalManager"> /// RetrievalManager - used to obtain the DataStructure(s) that describe the data /// </param> /// <returns> /// The data reader engine /// </returns> /// throws SdmxNotImplementedException if ReadableDataLocation or DataStructureBean is null, also if additioanlInformation is not of the expected type public IDataReaderEngine GetDataReaderEngine(IReadableDataLocation sourceData, ISdmxObjectRetrievalManager retrievalManager) { foreach (var currentFactory in this._engines) { IDataReaderEngine dre = currentFactory.GetDataReaderEngine(sourceData, retrievalManager); if (dre != null) { return dre; } } throw new SdmxNotImplementedException("Data format is either not supported, or has an invalid syntax"); }
/// <summary> /// Gets the data reader. /// </summary> /// <param name="retrievalManager"> /// The retrieval manager. /// </param> /// <returns> /// The <see cref="IDataReaderEngine"/> if this <see cref="IEdiWorkspace.HasData"/> is <c>True</c>; otherwise null. /// </returns> public IDataReaderEngine GetDataReader(ISdmxObjectRetrievalManager retrievalManager) { IList<IEdiDataReader> engines = new List<IEdiDataReader>(); foreach (var dataDocument in this._dataDocuments) { engines.Add(dataDocument.DataReader); } return new EdiDataReaderEngine(this._headerBean, retrievalManager, engines); }
/// <summary> /// Returns the set of cross referenced structures. /// </summary> /// <param name="retrievalManager"> /// The retrieval manager /// </param> /// <param name="constraintBean"> /// The constraint object /// </param> /// <returns> /// The cross references set. /// </returns> private ISet<ICrossReference> GetCrossReferences(ISdmxObjectRetrievalManager retrievalManager, IContentConstraintObject constraintBean) { ISet<ICrossReference> returnReferences = constraintBean.CrossReferences; IDictionary<string, IComponent> componentMap = new Dictionary<String, IComponent>(); foreach (ICrossReference crossRef in constraintBean.ConstraintAttachment.StructureReference) { switch (crossRef.TargetReference.EnumType) { case SdmxStructureEnumType.ProvisionAgreement: case SdmxStructureEnumType.Dataflow: case SdmxStructureEnumType.Dsd: AddComponenents(retrievalManager, crossRef, componentMap); break; case SdmxStructureEnumType.DataProvider: //Important: //It is important to get this from the BeanRetrievalManager and not the ProvisionRetrievalManager //As the ProvisionRetrievalManager relies on CrossReferecnce retrieval, which may not have been built yet (as //This class is responsible for aiding the building of cross references foreach (IProvisionAgreementObject currentProv in _beanRetrievalManager.GetMaintainableObjects<IProvisionAgreementObject>()) { if (currentProv.DataproviderRef.TargetUrn.Equals(crossRef.TargetUrn)) { AddComponenents(retrievalManager, currentProv.StructureUseage, componentMap); } } foreach (IProvisionAgreementObject currentProv in retrievalManager.GetMaintainableObjects<IProvisionAgreementObject>()) { if (currentProv.DataproviderRef.TargetUrn.Equals(crossRef.TargetUrn)) { AddComponenents(retrievalManager, currentProv.StructureUseage, componentMap); } } break; } } AddCrossReferencesForCubeRegion(constraintBean, returnReferences, componentMap, constraintBean.IncludedCubeRegion); AddCrossReferencesForCubeRegion(constraintBean, returnReferences, componentMap, constraintBean.ExcludedCubeRegion); AddCrossReferencesForConstraintKey(constraintBean, returnReferences, componentMap, constraintBean.IncludedSeriesKeys); AddCrossReferencesForConstraintKey(constraintBean, returnReferences, componentMap, constraintBean.ExcludedSeriesKeys); return returnReferences; }
/// <summary> /// Adds components to the component map. /// </summary> /// <param name="retrievalManager"> /// The retrieval manager /// </param> /// <param name="crossRef"> /// The cross reference object /// </param> /// <param name="componentMap"> /// The components map /// </param> private void AddComponenents(ISdmxObjectRetrievalManager retrievalManager, ICrossReference crossRef, IDictionary<String, IComponent> componentMap) { switch (crossRef.TargetReference.EnumType) { case SdmxStructureEnumType.ProvisionAgreement: IProvisionAgreementObject prov = retrievalManager.GetMaintainableObject<IProvisionAgreementObject>(crossRef); if (prov == null) { prov = _beanRetrievalManager.GetMaintainableObject<IProvisionAgreementObject>(crossRef); if (prov == null) throw new CrossReferenceException(crossRef); } crossRef = prov.StructureUseage; //Drop through to the next switch statement break; case SdmxStructureEnumType.Dataflow: IDataflowObject flow = retrievalManager.GetMaintainableObject<IDataflowObject>(crossRef); if (flow == null) { flow = _beanRetrievalManager.GetMaintainableObject<IDataflowObject>(crossRef); if (flow == null) throw new CrossReferenceException(crossRef); } crossRef = flow.DataStructureRef; //Drop through to the next switch statement break; case SdmxStructureEnumType.Dsd: IDataStructureObject dsd = retrievalManager.GetMaintainableObject<IDataStructureObject>(crossRef); if (dsd == null) { dsd = _beanRetrievalManager.GetMaintainableObject<IDataStructureObject>(crossRef); if (dsd == null) throw new CrossReferenceException(crossRef); } foreach (IComponent currentComponent in dsd.Components) componentMap.Add(currentComponent.Id, currentComponent); break; } }
/// <summary> /// Initializes a new instance of the <see cref="CrossSectionalDataReaderEngine"/> class. /// </summary> /// <param name="dataLocation"> /// The data location. /// </param> /// <param name="objectRetrieval"> /// The object retrieval. /// </param> /// <param name="defaultDsd"> /// The DSD. giving the ability to retrieve DSDs for the datasets this reader engine is reading. This /// can be null if there is only one relevant DSD - in which case the default DSD should be provided /// </param> /// <param name="dataflow"> /// The dataflow. /// </param> public CrossSectionalDataReaderEngine(IReadableDataLocation dataLocation, ISdmxObjectRetrievalManager objectRetrieval, ICrossSectionalDataStructureObject defaultDsd, IDataflowObject dataflow) { this._xmlBuilder = new XmlReaderBuilder(); if (objectRetrieval == null && defaultDsd == null) { throw new ArgumentException("AbstractDataReaderEngine expects either a ISdmxObjectRetrievalManager or a IDataStructureObject to be able to interpret the structures"); } this._objectRetrieval = objectRetrieval; this._dataLocation = dataLocation; this._defaultDsd = defaultDsd; this._dataflow = dataflow; this.Reset(); }
/// <summary> /// Sets the object retrieval manager. /// </summary> /// <param name="value">The value.</param> public void SetObjectRetrievalManager(ISdmxObjectRetrievalManager value) { this._beanRetrievalManager = value; }
/// <summary> /// Initializes a new instance of the <see cref="AbstractSdmxDataReaderEngine"/> class. /// </summary> /// <param name="dataLocation"> /// The data Location. /// </param> /// <param name="objectRetrieval"> /// The SDMX Object Retrieval. giving the ability to retrieve DSDs for the datasets this /// reader engine is reading. This can be null if there is only one relevant DSD - in which case the /// <paramref name="defaultDsd"/> should be provided. /// </param> /// <param name="defaultDataflow"> /// The default Dataflow. (Optional) /// </param> /// <param name="defaultDsd"> /// The default DSD. The default DSD to use if the <paramref name="objectRetrieval"/> is null, or /// if the bean retrieval does not return the DSD for the given dataset. /// </param> /// <exception cref="System.ArgumentException"> /// AbstractDataReaderEngine expects either a ISdmxObjectRetrievalManager or a /// IDataStructureObject to be able to interpret the structures /// </exception> protected AbstractSdmxDataReaderEngine(IReadableDataLocation dataLocation, ISdmxObjectRetrievalManager objectRetrieval, IDataflowObject defaultDataflow, IDataStructureObject defaultDsd) : base(dataLocation, objectRetrieval, defaultDataflow, defaultDsd) { this._isTwoPointOne = SdmxMessageUtil.GetSchemaVersion(dataLocation) == SdmxSchemaEnumType.VersionTwoPointOne; }
/// <summary> /// Builds a <see cref="IDataQuery"/> list from a message that contains one or more data queries /// </summary> /// <param name="dataQueryLocation"> /// The data location /// </param> /// <param name="beanRetrievalManager"> /// optional, if given will retrieve the key family bean the query is for /// </param> /// <returns> /// a <see cref="IDataQuery"/> list /// </returns> public IList<IDataQuery> BuildDataQuery( ISdmxXmlStream dataQueryLocation, ISdmxObjectRetrievalManager beanRetrievalManager) { if (!dataQueryLocation.HasReader) { throw new ArgumentException("ISdmxXmlStream doesnt have a Reader", "dataQueryLocation"); } this._log.Debug("DataParseManagerImpl.buildDataQuery"); switch (dataQueryLocation.SdmxVersion) { case SdmxSchemaEnumType.VersionOne: QueryMessage queryV1 = MessageFactory.Load<QueryMessage, QueryMessageType>(dataQueryLocation.Reader); return this._dataQueryBuilder.BuildDataQuery(queryV1.Query, beanRetrievalManager); case SdmxSchemaEnumType.VersionTwo: Org.Sdmx.Resources.SdmxMl.Schemas.V20.message.QueryMessage queryV2 = Org.Sdmx.Resources.SdmxMl.Schemas.V20.message.QueryMessage.Load(dataQueryLocation.Reader); return this._dataQueryBuilder.BuildDataQuery(queryV2.Query, beanRetrievalManager); case SdmxSchemaEnumType.VersionTwoPointOne: throw new ArgumentException("Build Data Query concerns sdmx messages of schema version 1.0 and 2.0 "); default: throw new SdmxNotImplementedException( ExceptionCode.Unsupported, "buildDataQuery in version " + dataQueryLocation.SdmxVersion); } }
/// <summary> /// Initializes a new instance of the <see cref="CompactDataReaderEngine"/> class. /// Initializes a new instance of the <see cref="AbstractSdmxDataReaderEngine"/> class. /// </summary> /// <param name="dataLocation"> /// The data Location. /// </param> /// <param name="objectRetrieval"> /// The SDMX Object Retrieval. giving the ability to retrieve DSDs for the datasets this /// reader engine is reading. This can be null if there is only one relevant DSD - in which case the /// <paramref name="defaultDsd"/> should be provided. /// </param> /// <param name="defaultDataflow"> /// The default Dataflow. (Optional) /// </param> /// <param name="defaultDsd"> /// The default DSD. The default DSD to use if the <paramref name="objectRetrieval"/> is null, or /// if the bean retrieval does not return the DSD for the given dataset. /// </param> /// <exception cref="System.ArgumentException"> /// AbstractDataReaderEngine expects either a ISdmxObjectRetrievalManager or a /// IDataStructureObject to be able to interpret the structures /// </exception> public CompactDataReaderEngine(IReadableDataLocation dataLocation, ISdmxObjectRetrievalManager objectRetrieval, IDataflowObject defaultDataflow, IDataStructureObject defaultDsd) : base(dataLocation, objectRetrieval, defaultDataflow, defaultDsd) { this.Reset(); }
/// <summary> /// Initializes a new instance of the <see cref="DataControllerBase"/> class. /// </summary> /// <param name="principal"> /// The principal. /// </param> /// <exception cref="SdmxSemmanticException"> /// Operation not accepted with query used /// </exception> protected DataControllerBase(DataflowPrincipal principal) { this._principal = principal; this._sdmxRetrievalManager = new MappingStoreSdmxObjectRetrievalManager(SettingsManager.MappingStoreConnectionSettings); }