/// <summary> /// Retrieve the structures referenced by <paramref name="structureQuery" /> and populate the /// <paramref name="mutableObjects" /> /// </summary> /// <param name="retrievalManager">The retrieval manager.</param> /// <param name="mutableObjects">The mutable objects.</param> /// <param name="structureQuery">The structure query.</param> /// <param name="allowedDataflows">The allowed Dataflows.</param> /// <param name="crossReferenceMutableRetrievalManager">The cross reference mutable retrieval manager.</param> protected virtual void PopulateMutables( IAuthAdvancedSdmxMutableObjectRetrievalManager retrievalManager, IMutableObjects mutableObjects, IComplexStructureQuery structureQuery, IList<IMaintainableRefObject> allowedDataflows, IAuthCrossReferenceMutableRetrievalManager crossReferenceMutableRetrievalManager) { //// changes here might also apply to AuthMutableStructureSearchManagerBase and/or AuthStructureRetrieverV21 var complexStructureQueryDetail = structureQuery.StructureQueryMetadata != null ? structureQuery.StructureQueryMetadata.StructureQueryDetail : ComplexStructureQueryDetail.GetFromEnum(ComplexStructureQueryDetailEnumType.Full); mutableObjects.AddIdentifiables(retrievalManager.GetMutableMaintainables(structureQuery.StructureReference, complexStructureQueryDetail, allowedDataflows)); }
/// <summary> /// Initializes a new instance of the <see cref="AuthCrossReferenceRetrievalManager"/> class. /// </summary> /// <param name="retrievalAdvancedManager">The retrieval advanced manager.</param> /// <param name="connectionStringSettings">The connection string settings.</param> /// <exception cref="System.ArgumentNullException"> /// retrievalAdvancedManager /// or /// connectionStringSettings /// </exception> public AuthCrossReferenceRetrievalManager(IAuthAdvancedSdmxMutableObjectRetrievalManager retrievalAdvancedManager, ConnectionStringSettings connectionStringSettings) { if (retrievalAdvancedManager == null) { throw new ArgumentNullException("retrievalAdvancedManager"); } if (connectionStringSettings == null) { throw new ArgumentNullException("connectionStringSettings"); } this._retrievalAdvancedManager = retrievalAdvancedManager; this._retrievalEngineContainer = new RetrievalEngineContainer(new Database(connectionStringSettings)); this._fromMutable = new StructureReferenceFromMutableBuilder(); }
/// <summary> /// Initializes a new instance of the <see cref="AuthCrossReferenceRetrievalManager"/> class. /// </summary> /// <param name="retrievalAdvancedManager">The retrieval advanced manager.</param> /// <param name="mappingStoreDatabase">The mapping store database.</param> /// <exception cref="System.ArgumentNullException"> /// retrievalAdvancedManager /// or /// mappingStoreDatabase /// </exception> public AuthCrossReferenceRetrievalManager(IAuthAdvancedSdmxMutableObjectRetrievalManager retrievalAdvancedManager, Database mappingStoreDatabase) { if (retrievalAdvancedManager == null) { throw new ArgumentNullException("retrievalAdvancedManager"); } if (mappingStoreDatabase == null) { throw new ArgumentNullException("mappingStoreDatabase"); } this._retrievalAdvancedManager = retrievalAdvancedManager; this._retrievalEngineContainer = new RetrievalEngineContainer(mappingStoreDatabase); this._fromMutable = new StructureReferenceFromMutableBuilder(); }
/// <summary> /// Returns an instance of <see cref="IAuthAdvancedSdmxMutableObjectRetrievalManager"/> created using the specified <paramref name="settings"/> /// </summary> /// <typeparam name="T"> /// The type of settings /// </typeparam> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// The <see cref="IAuthAdvancedSdmxMutableObjectRetrievalManager"/>. /// </returns> public IAuthAdvancedSdmxMutableObjectRetrievalManager GetRetrievalManager <T>(T settings) { IAuthAdvancedSdmxMutableObjectRetrievalManager manager = null; if (this._factoryMethod != null) { manager = this._factoryMethod(settings); } Func <object, IAuthAdvancedSdmxMutableObjectRetrievalManager> method; if (_factoryMethods.TryGetValue(typeof(T), out method)) { manager = method(settings); } return(manager); }
/// <summary> /// Retrieve the <paramref name="queries"/> and populate the <paramref name="mutableObjects"/> /// </summary> /// <param name="retrievalManager"> /// The retrieval manager. /// </param> /// <param name="mutableObjects"> /// The mutable objects. /// </param> /// <param name="queries"> /// The structure queries /// </param> /// <param name="returnLatest"> /// Set to <c>true</c> to retrieve the latest; otherwise set to <c>false</c> to retrieve all versions /// </param> /// <param name="returnStub"> /// Set to <c>true</c> to retrieve artefacts as stubs; otherwise set to <c>false</c> to retrieve full artefacts. /// </param> /// <param name="allowedDataflows"> /// The allowed dataflows. /// </param> /// <param name="crossReferenceMutableRetrievalManager"> /// The cross-reference manager /// </param> protected override void PopulateMutables(IAuthAdvancedSdmxMutableObjectRetrievalManager retrievalManager, IMutableObjects mutableObjects, IList<IStructureReference> queries, bool returnLatest, StructureQueryDetailEnumType returnStub, IList<IMaintainableRefObject> allowedDataflows, IAuthCrossReferenceMutableRetrievalManager crossReferenceMutableRetrievalManager) { var dataflowLessQueries = new List<IStructureReference>(); var dataflowQueries = new List<IStructureReference>(); foreach (var query in queries) { if (query.MaintainableStructureEnumType.EnumType == SdmxStructureEnumType.Dataflow) { dataflowQueries.Add(query); } else { dataflowLessQueries.Add(query); } } base.PopulateMutables(retrievalManager, mutableObjects, dataflowLessQueries, returnLatest, returnStub, allowedDataflows, crossReferenceMutableRetrievalManager); // get the latest for dataflows to emulate the intermediate SR behavior. base.PopulateMutables(retrievalManager, mutableObjects, dataflowQueries, true, returnStub, allowedDataflows, crossReferenceMutableRetrievalManager); if (queries.NeedsCategorisation()) { _log.Info("SDMX v2.0 structure search manager used. Trying to retrieve categorisations all dataflows and categorisations."); IMutableObjects objects = new MutableObjectsImpl(mutableObjects.Dataflows); objects.AddIdentifiables(mutableObjects.CategorySchemes); // get categorisations IResolverFactory factory = new ResolverFactory(); var resolver = factory.GetResolver(StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Parents), crossReferenceMutableRetrievalManager); resolver.ResolveReferences(objects, returnStub == StructureQueryDetailEnumType.AllStubs, allowedDataflows); // add them to mutable objects mutableObjects.AddIdentifiables(objects.Categorisations); } }
/// <summary> /// Retrieve the structures referenced by <paramref name="queries"/> and populate the /// <paramref name="mutableObjects"/> /// </summary> /// <param name="retrievalManager"> /// The retrieval manager. /// </param> /// <param name="mutableObjects"> /// The mutable objects. /// </param> /// <param name="queries"> /// The queries. /// </param> /// <param name="returnLatest"> /// The return Latest. /// </param> /// <param name="returnStub"> /// The return Stub. /// </param> /// <param name="allowedDataflows"> /// The allowed Dataflows. /// </param> /// <param name="crossReferenceMutableRetrievalManager"> /// The cross reference mutable retrieval manager. /// </param> protected virtual void PopulateMutables(IAuthAdvancedSdmxMutableObjectRetrievalManager retrievalManager, IMutableObjects mutableObjects, IList<IStructureReference> queries, bool returnLatest, StructureQueryDetailEnumType returnStub, IList<IMaintainableRefObject> allowedDataflows, IAuthCrossReferenceMutableRetrievalManager crossReferenceMutableRetrievalManager) { //// changes here might also apply to AuthAdvancedMutableStructureSearchManagerBase for (int i = 0; i < queries.Count; i++) { var structureReference = queries[i]; IRestStructureQuery restStructureQuery = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(returnStub), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.None), null, structureReference, returnLatest); var complexStructureQuery = _complexQueryBuilder.Build(restStructureQuery); base.PopulateMutables(retrievalManager, mutableObjects, complexStructureQuery, allowedDataflows, crossReferenceMutableRetrievalManager); } }
/// <summary> /// Initializes a new instance of the <see cref="AuthMutableStructureSearchManagerBase"/> class. /// </summary> /// <param name="connectionStringSettings"> /// The connection string settings. /// </param> protected AuthMutableStructureSearchManagerBase(ConnectionStringSettings connectionStringSettings) { this._database = new Database(connectionStringSettings); this._crossReferenceManager = new AuthCrossMutableRetrievalManagerFactory(); // advanced this._advancedMutableRetrievalManagerFactory = new AuthAdvancedMutableRetrievalManagerFactory(); this._retrievalAdvancedManager = this._advancedMutableRetrievalManagerFactory.GetRetrievalManager(this._database); }
/// <summary> /// Retrieve the <paramref name="queries"/> and populate the <paramref name="mutableObjects"/> /// </summary> /// <param name="retrievalManager"> /// The retrieval manager. /// </param> /// <param name="mutableObjects"> /// The mutable objects. /// </param> /// <param name="queries"> /// The structure queries /// </param> /// <param name="returnLatest"> /// Set to <c>true</c> to retrieve the latest; otherwise set to <c>false</c> to retrieve all versions /// </param> /// <param name="returnStub"> /// Set to <c>true</c> to retrieve artefacts as stubs; otherwise set to <c>false</c> to retrieve full artefacts. /// </param> /// <param name="allowedDataflows"> /// The allowed dataflows. /// </param> /// <param name="crossReferenceMutableRetrievalManager"> /// The cross-reference manager /// </param> protected override void PopulateMutables(IAuthAdvancedSdmxMutableObjectRetrievalManager retrievalManager, IMutableObjects mutableObjects, IList<IStructureReference> queries, bool returnLatest, StructureQueryDetailEnumType returnStub, IList<IMaintainableRefObject> allowedDataflows, IAuthCrossReferenceMutableRetrievalManager crossReferenceMutableRetrievalManager) { try { // try get the codelist reference IMaintainableRefObject codelistReference = queries.Where(structureReference => structureReference.TargetReference.EnumType == SdmxStructureEnumType.CodeList) .Select(structureReference => structureReference.MaintainableReference) .FirstOrDefault(); // try get the dataflow ref var dataflowRef = queries.FirstOrDefault(structureReference => structureReference.TargetReference.EnumType == SdmxStructureEnumType.Dataflow) as IConstrainableStructureReference; // check if it is special if (codelistReference != null && dataflowRef != null && dataflowRef.ConstraintObject != null && queries.Count == 2) { // get the dataflow base.PopulateMutables( retrievalManager, mutableObjects, new IStructureReference[] { dataflowRef }, returnLatest, returnStub, allowedDataflows, crossReferenceMutableRetrievalManager); // get the partial codelist StructureRetrievalInfo structureRetrievalInfo = _structureRetrievalInfoBuilder.Build(dataflowRef, this._connectionStringSettings, allowedDataflows); if (!ProcessReference(structureRetrievalInfo, codelistReference, mutableObjects)) { string message = string.Format(CultureInfo.InvariantCulture, "No codes found for {0}", codelistReference); _logger.Error(message); throw new SdmxNoResultsException(message); } } else { // not special requests base.PopulateMutables(retrievalManager, mutableObjects, queries, returnLatest, returnStub, allowedDataflows, crossReferenceMutableRetrievalManager); } } catch (SdmxException) { throw; } catch (StructureRetrieverException e) { _logger.Error(e.Message, e); switch (e.ErrorType) { case StructureRetrieverErrorTypes.ParsingError: throw new SdmxSyntaxException(e, ExceptionCode.XmlParseException); case StructureRetrieverErrorTypes.MissingStructure: case StructureRetrieverErrorTypes.MissingStructureRef: throw new SdmxNoResultsException(e.Message); default: throw new SdmxInternalServerException(e.Message); } } catch (DbException e) { string mesage = "Mapping Store connection error." + e.Message; _logger.Error(mesage, e); throw new SdmxInternalServerException(mesage); } catch (Exception e) { string mesage = e.Message; _logger.Error(mesage, e); throw new SdmxInternalServerException(mesage); } }
/// <summary> /// Initializes a new instance of the <see cref="AuthAdvancedStructureRetriever"/> class. /// </summary> /// <param name="mutableRetrievalManagerFactory"> /// The mutable retrieval manager factory. /// </param> /// <param name="crossReferenceManagerFactory"> /// The cross reference manager factory. /// </param> /// <param name="connectionStringSettings"> /// The connection string settings. /// </param> public AuthAdvancedStructureRetriever( IAuthAdvancedMutableRetrievalManagerFactory mutableRetrievalManagerFactory, IAuthCrossRetrievalManagerFactory crossReferenceManagerFactory, ConnectionStringSettings connectionStringSettings) { this._crossReferenceManagerFactory = crossReferenceManagerFactory ?? new AuthCrossMutableRetrievalManagerFactory(); this._retrievalFactory = mutableRetrievalManagerFactory ?? new AuthAdvancedMutableRetrievalManagerFactory(); this._database = new Database(connectionStringSettings); this._retrievalManager = this._retrievalFactory.GetRetrievalManager(this._database); }