/// <summary> /// The handle structure request. /// </summary> /// <param name="request"> /// The request. /// </param> /// <param name="sdmxStructure"> /// The sdmx structure. /// </param> /// <returns> /// The <see cref="Message"/>. /// </returns> private Message HandleStructureRequest(Message request, SdmxStructureEnumType sdmxStructure) { var soapOperation = StructureOutputFormatEnumType.SdmxV21StructureDocument.GetSoapOperation(SdmxSchemaEnumType.VersionTwoPointOne, sdmxStructure); var responseElement = soapOperation.GetResponse().ToString(); var controller = this._controllerBuilder.BuildAdvancedQueryStructureV21(HttpContext.Current.User as DataflowPrincipal, soapOperation); return(HandleRequest(request, controller, new XmlQualifiedName(responseElement, Ns), soapOperation)); }
public ComplexComponentValueImpl(string value, OrderedOperator orderedOperator, SdmxStructureEnumType componentType) { if (componentType.Equals(SdmxStructureEnumType.TimeDimension) && orderedOperator.Equals(OrderedOperatorEnumType.NotEqual)) throw new SdmxSemmanticException(ExceptionCode.QuerySelectionIllegalOperator); this._value =value; if (orderedOperator!=null) this._orderedOperator = orderedOperator; else this._orderedOperator = OrderedOperator.GetFromEnum(OrderedOperatorEnumType.Equal); }
public ComplexComponentValueImpl(string value, TextSearch textOperator, SdmxStructureEnumType componentType) { if(componentType.Equals(SdmxStructureEnumType.Dimension) || componentType.Equals(SdmxStructureEnumType.TimeDimension)) throw new SdmxSemmanticException(ExceptionCode.QuerySelectionIllegalOperator); this._value = value; if (textOperator != null) this._textOperator = textOperator; else this._textOperator = TextSearch.GetFromEnum(TextSearchEnumType.Equal); }
/// <summary> /// Returns the referenced from inner joins to use with <see cref="ArtefactParentsSqlBuilder"/> /// </summary> /// <param name="structureEnumType"> /// The structure type. /// </param> /// <returns> /// The referenced from inner joins /// </returns> protected override string GetReferencedFromInnerJoins(SdmxStructureEnumType structureEnumType) { string innerJoin = null; switch (structureEnumType) { case SdmxStructureEnumType.CodeList: innerJoin = CodeListConstant.ReferencingFromHcl; break; } return(innerJoin); }
/// <summary> /// Returns the referenced from inner joins to use with <see cref="ArtefactParentsSqlBuilder"/> /// </summary> /// <param name="structureEnumType"> /// The structure type. /// </param> /// <returns> /// The referenced from inner joins /// </returns> protected override string GetReferencedFromInnerJoins(SdmxStructureEnumType structureEnumType) { string innerJoin = null; switch (structureEnumType) { case SdmxStructureEnumType.Dsd: innerJoin = DsdConstant.ReferencedByDataflow; break; } return(innerJoin); }
/// <summary> /// Check if <paramref name="structureType"/> is one of <paramref name="structureTypes"/>. /// </summary> /// <param name="structureType"> /// The structure type. /// </param> /// <param name="structureTypes"> /// The structure types. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsOneOf(this SdmxStructureEnumType structureType, params SdmxStructureEnumType[] structureTypes) { if (structureTypes != null) { for (int i = 0; i < structureTypes.Length; i++) { if (structureType == structureTypes[i]) { return(true); } } } return(false); }
public void TestQueryCodelistUsedByDsd(SdmxStructureEnumType sdmxStructure) { var structureSearchManager = this._mutableStructureSearchManagerFactory.GetStructureSearchManager(this._connectionString, SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwoPointOne)); foreach (var codelistMutableObject in this.GetCodelistUsedByDsd()) { var specificStructureReference = SdmxStructureType.GetFromEnum(sdmxStructure); var mutableObjects = structureSearchManager.GetMaintainables( new RESTStructureQueryCore( StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific), specificStructureReference, codelistMutableObject.ImmutableInstance.AsReference, false)); Assert.IsNotEmpty(mutableObjects.GetMaintainables(specificStructureReference), _fromMutable.Build(codelistMutableObject).ToString()); } }
/// <summary> /// Returns the referenced from inner joins to use with <see cref="ArtefactParentsSqlBuilder"/> /// </summary> /// <param name="structureEnumType"> /// The structure type. /// </param> /// <returns> /// The referenced from inner joins /// </returns> protected override string GetReferencedFromInnerJoins(SdmxStructureEnumType structureEnumType) { string innerJoin = null; switch (structureEnumType) { case SdmxStructureEnumType.Category: case SdmxStructureEnumType.CategoryScheme: innerJoin = CategorySchemeConstant.ReferencedByCategorisation; break; default: if (SdmxStructureType.GetFromEnum(structureEnumType).IsMaintainable) { innerJoin = CategorisationConstant.ReferencedByCategorisation; } break; } return(innerJoin); }
public void TestDetail(SdmxStructureEnumType sdmxStructure, StructureReferenceDetailEnumType detail) { var agency = new ComplexTextReferenceCore(null, TextSearch.GetFromEnum(TextSearchEnumType.Equal), "TEST"); var id = new ComplexTextReferenceCore(null, TextSearch.GetFromEnum(TextSearchEnumType.Equal), "TEST"); IComplexVersionReference versionRef = new ComplexVersionReferenceCore(TertiaryBool.ParseBoolean(false), "1.0", null, null); var complexStructureReferenceCore = new ComplexStructureReferenceCore(agency, id, versionRef, SdmxStructureType.GetFromEnum(sdmxStructure), null, null, null, null); var complexStructureQueryMetadataCore = new ComplexStructureQueryMetadataCore( true, ComplexStructureQueryDetail.GetFromEnum(ComplexStructureQueryDetailEnumType.Full), ComplexMaintainableQueryDetail.GetFromEnum(ComplexMaintainableQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(detail), new [] { SdmxStructureType.GetFromEnum(sdmxStructure) }); IComplexStructureQuery complexStructureQuery = new ComplexStructureQueryCore(complexStructureReferenceCore, complexStructureQueryMetadataCore); var builder = new ComplexStructureQueryBuilderV21(); var structureQuery = builder.BuildComplexStructureQuery(complexStructureQuery); var fileName = string.Format("test-ComplexStructureQueryBuilderV21-{0}-{1}.xml", sdmxStructure.ToString(), detail.ToString()); structureQuery.Save(fileName); using (var readable = new FileReadableDataLocation(fileName)) { XMLParser.ValidateXml(readable, SdmxSchemaEnumType.VersionTwoPointOne); } }
/// <summary> /// Returns the <c>ITEM.ITEM_ID</c> value from Mapping Store for <paramref name="artefactId"/> /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="sdmxStructure"> /// The SDMX Structure. /// </param> /// <param name="artefactId"> /// The artefact primary key. <c>ARTEFACT.ART_ID</c>. /// </param> /// <returns> /// The <c>ITEM.ITEM_ID</c> value from Mapping Store for <paramref name="artefactId"/> /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="state"/> is null /// </exception> /// <exception cref="ArgumentException"> /// At <paramref name="sdmxStructure"/>, unsupported structure /// </exception> public static ItemStatusCollection GetId(DbTransactionState state, SdmxStructureEnumType sdmxStructure, long artefactId) { if (state == null) { throw new ArgumentNullException("state"); } var tableInfo = _tableInfoBuilder.Build(sdmxStructure); if (tableInfo == null) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.ExceptionUnsupportedStructureReferenceFormat1, sdmxStructure), "sdmxStructure"); } var itemIdQueryBuilder = new ItemIdQueryBuilder(state.Database); var query = itemIdQueryBuilder.Build(tableInfo); return(new ItemStatusCollection(state.Connection.Query <ItemStatus>( query, new { id = artefactId }, state.Transaction, false))); }
/// <summary> /// The handle structure request. /// </summary> /// <param name="request"> /// The request. /// </param> /// <param name="sdmxStructure"> /// The sdmx structure. /// </param> /// <returns> /// The <see cref="Message"/>. /// </returns> private Message HandleStructureRequest(Message request, SdmxStructureEnumType sdmxStructure) { var soapOperation = StructureOutputFormatEnumType.SdmxV21StructureDocument.GetSoapOperation(sdmxStructure); try { var controller = this._requestController.ParseRequest(request, sdmxStructure); return this.WriteResponse(soapOperation, controller); } catch (Exception e) { var responseElement = soapOperation.GetResponse().ToString(); var xmlQualifiedName = new XmlQualifiedName(responseElement, Ns); _log.Error(xmlQualifiedName, e); throw _messageFaultBuilder.BuildException(e, soapOperation.ToString()); } }
/// <summary> /// Initializes a new instance of the <see cref="CrossReferenceImpl"/> class. /// </summary> /// <param name="referencedFrom"> /// The referenced from. /// </param> /// <param name="agencyId"> /// The agency id. /// </param> /// <param name="maintainableId"> /// The maintainable id. /// </param> /// <param name="version"> /// The version. /// </param> /// <param name="structureType"> /// The structure type. /// </param> /// <param name="identifiableIds"> /// The identifiable ids. /// </param> public CrossReferenceImpl( ISdmxObject referencedFrom, string agencyId, string maintainableId, string version, SdmxStructureEnumType structureType, params string[] identifiableIds) : base(agencyId, maintainableId, version, structureType, identifiableIds) { this._referencedFrom = referencedFrom; this.ValidateReference(); }
public void TestValidateURN(string urn, SdmxStructureEnumType structure) { UrnUtil.ValidateURN(urn, SdmxStructureType.GetFromEnum(structure)); }
/// <summary> /// Initializes a new instance of the <see cref="ReferenceInfo"/> class. /// </summary> /// <param name="sdmxStructure"> /// The sdmx structure. /// </param> public ReferenceInfo(SdmxStructureEnumType sdmxStructure) { this.SdmxStructure = sdmxStructure; }
/// <summary> /// Check if the specified <paramref name="structureEnumType"/> is in <paramref name="sdmxStructureTypes"/>. /// </summary> /// <param name="sdmxStructureTypes"> /// The SDMX structure types. /// </param> /// <param name="structureEnumType"> /// The structure type as an ENUM. /// </param> /// <returns> /// True if <paramref name="structureEnumType"/> is in <paramref name="sdmxStructureTypes"/> or if <paramref name="sdmxStructureTypes"/> is empty; otherwise false. /// </returns> public static bool HasStructure(this ISet <SdmxStructureType> sdmxStructureTypes, SdmxStructureEnumType structureEnumType) { return(sdmxStructureTypes.Count == 0 || sdmxStructureTypes.Contains(SdmxStructureType.GetFromEnum(structureEnumType))); }
/// <summary> /// The handle structure request. /// </summary> /// <param name="request"> /// The request. /// </param> /// <param name="sdmxStructure"> /// The sdmx structure. /// </param> /// <returns> /// The <see cref="Message"/>. /// </returns> private Message HandleStructureRequest(Message request, SdmxStructureEnumType sdmxStructure) { var soapOperation = StructureOutputFormatEnumType.SdmxV21StructureDocument.GetSoapOperation(SdmxSchemaEnumType.VersionTwoPointOne, sdmxStructure); var responseElement = soapOperation.GetResponse().ToString(); var controller = this._controllerBuilder.BuildAdvancedQueryStructureV21(HttpContext.Current.User as DataflowPrincipal, soapOperation); return HandleRequest(request, controller, new XmlQualifiedName(responseElement, Ns), soapOperation); }
public void TestStructureReference(string urn, SdmxStructureEnumType expectedResult, bool hasChildReference) { var impl = new StructureReferenceImpl(urn); Assert.AreEqual(urn, impl.TargetUrn.ToString()); Assert.AreEqual(expectedResult, impl.TargetStructureType.EnumType); Assert.IsTrue(impl.HasAgencyId()); Assert.IsTrue(impl.HasTargetUrn()); Assert.IsTrue(impl.HasMaintainableId()); Assert.AreEqual(hasChildReference, impl.HasChildReference()); Assert.AreEqual(hasChildReference, impl.IdentifiableIds.Count > 0); Assert.AreEqual(impl.TargetUrn, impl.CreateCopy().TargetUrn); Assert.AreEqual(impl.TargetReference, impl.CreateCopy().TargetReference); }
/// <summary> /// Creates the child reference. /// </summary> /// <param name="structureReference">The structure reference.</param> /// <param name="structureType">Type of the structure.</param> /// <param name="ids">The ids.</param> /// <returns>The <see cref="IStructureReference"/> for <paramref name="ids"/> of type <paramref name="structureReference"/></returns> public static IStructureReference CreateChildReference(this IStructureReference structureReference, SdmxStructureEnumType structureType, params string[] ids) { return(new StructureReferenceImpl(structureReference.AgencyId, structureReference.MaintainableId, structureReference.Version, structureType, ids)); }
/// <summary> /// Return the latest artefact of type <typeparamref name="T" /> that matches the <paramref name="xref" />. /// </summary> /// <typeparam name="T">The type of the requested artefact</typeparam> /// <param name="xref">The maintainable reference. The version must be null.</param> /// <param name="returnLatest">if set to <c>true</c> [return latest].</param> /// <param name="returnStub">The return Stub.</param> /// <param name="sdmxStructure">The SDMX structure type.</param> /// <param name="getter">The getter method to retrieve the artefact if <see cref="_requestToLatestArtefacts" /> doesn't not contain it.</param> /// <returns> /// The <see cref="IMaintainableMutableObject" /> of type <typeparamref name="T" />; otherwise null /// </returns> private T GetLatest <T>(IMaintainableRefObject xref, bool returnLatest, bool returnStub, SdmxStructureEnumType sdmxStructure, Func <IMaintainableRefObject, bool, bool, T> getter) where T : class, IMaintainableMutableObject { IMaintainableMutableObject mutableObject; IStructureReference structureReference = new StructureReferenceImpl(xref, sdmxStructure); if (!this._requestToLatestArtefacts.TryGetValue(structureReference, out mutableObject)) { _log.DebugFormat(CultureInfo.InvariantCulture, "Cache miss: {0}", structureReference); T retrievedObject = getter(xref, returnLatest, returnStub); if (retrievedObject != null) { this._requestToLatestArtefacts.Add(structureReference, retrievedObject); this._requestToArtefacts.AddToSet(_fromMutable.Build(retrievedObject), retrievedObject); return(retrievedObject); } return(null); } return(mutableObject as T); }
/// <summary> /// Returns the artefacts of <typeparamref name="T"/> that match <paramref name="xref"/> /// </summary> /// <param name="xref"> /// The maintainable reference. ID, Agency and/or Version can have a value or null. Null is considered a wildcard. /// </param> /// <param name="returnLatest"> /// The return Latest. /// </param> /// <param name="returnStub"> /// The return Stub. /// </param> /// <param name="sdmxStructure"> /// The SDMX structure type. /// </param> /// <param name="getter"> /// The getter method to retrieve the artefacts if <see cref="_requestToArtefacts"/> doesn't not contain them. /// </param> /// <typeparam name="T"> /// The type of the returned artefacts. /// </typeparam> /// <returns> /// The <see cref="ISet{T}"/>. /// </returns> private ISet <T> GetArtefacts <T>(IMaintainableRefObject xref, bool returnLatest, bool returnStub, SdmxStructureEnumType sdmxStructure, Func <IMaintainableRefObject, bool, bool, ISet <T> > getter) where T : class, IMaintainableMutableObject { ISet <IMaintainableMutableObject> mutableObjects; ISet <T> retrievedObjects; IStructureReference structureReference = new StructureReferenceImpl(xref, sdmxStructure); if (!this._requestToArtefacts.TryGetValue(structureReference, out mutableObjects)) { _log.DebugFormat(CultureInfo.InvariantCulture, "Cache miss: {0}", structureReference); retrievedObjects = getter(xref, returnLatest, returnStub); this._requestToArtefacts.Add(structureReference, new HashSet <IMaintainableMutableObject>(retrievedObjects)); foreach (T retrievedObject in retrievedObjects) { var reference = _fromMutable.Build(retrievedObject); this._requestToArtefacts.AddToSet(reference, retrievedObject); } } else { retrievedObjects = new HashSet <T>(mutableObjects.Cast <T>()); } return(retrievedObjects); }
/// <summary> /// Initializes a new instance of the <see cref="ItemTableInfo"/> class. /// </summary> /// <param name="structureType">Type of the structure.</param> public ItemTableInfo(SdmxStructureEnumType structureType) : base(structureType) { }
/// <summary> /// Gets the SOAP operation. /// </summary> /// <param name="structureOutputFormat"> /// The structure output format. /// </param> /// <param name="structure"> /// Type of the structure requested. (Only in SDMX v2.1 ). /// </param> /// <returns> /// The <see cref="SoapOperation"/>. /// </returns> public static SoapOperation GetSoapOperation(this StructureOutputFormatEnumType structureOutputFormat, SdmxStructureEnumType structure) { switch (structureOutputFormat) { case StructureOutputFormatEnumType.Null: break; case StructureOutputFormatEnumType.SdmxV1StructureDocument: break; case StructureOutputFormatEnumType.SdmxV2StructureDocument: break; case StructureOutputFormatEnumType.SdmxV2RegistrySubmitDocument: break; case StructureOutputFormatEnumType.SdmxV2RegistryQueryResponseDocument: return SoapOperation.QueryStructure; case StructureOutputFormatEnumType.SdmxV21StructureDocument: switch (structure) { case SdmxStructureEnumType.Dataflow: return SoapOperation.GetDataflow; case SdmxStructureEnumType.CodeList: return SoapOperation.GetCodelist; case SdmxStructureEnumType.Categorisation: return SoapOperation.GetCategorisation; case SdmxStructureEnumType.CategoryScheme: return SoapOperation.GetCategoryScheme; case SdmxStructureEnumType.ConceptScheme: return SoapOperation.GetConceptScheme; case SdmxStructureEnumType.Dsd: return SoapOperation.GetDataStructure; case SdmxStructureEnumType.HierarchicalCodelist: return SoapOperation.GetHierarchicalCodelist; case SdmxStructureEnumType.ReportingTaxonomy: return SoapOperation.GetReportingTaxonomy; case SdmxStructureEnumType.OrganisationScheme: return SoapOperation.GetOrganisationScheme; case SdmxStructureEnumType.Constraint: return SoapOperation.GetConstraint; case SdmxStructureEnumType.Process: return SoapOperation.GetProcess; case SdmxStructureEnumType.ProvisionAgreement: return SoapOperation.GetProvisionAgreement; case SdmxStructureEnumType.StructureSet: return SoapOperation.GetStructureSet; case SdmxStructureEnumType.MetadataFlow: return SoapOperation.GetMetadataflow; case SdmxStructureEnumType.Msd: return SoapOperation.GetMetadataStructure; default: return SoapOperation.GetStructures; } case StructureOutputFormatEnumType.SdmxV21RegistrySubmitDocument: break; case StructureOutputFormatEnumType.SdmxV21QueryResponseDocument: break; case StructureOutputFormatEnumType.Edi: break; case StructureOutputFormatEnumType.Csv: break; default: return SoapOperation.Null; } return SoapOperation.Null; }
/// <summary> /// Initializes a new instance of the <see cref="TableInfo"/> class. /// </summary> /// <param name="structureType">Type of the structure.</param> public TableInfo(SdmxStructureEnumType structureType) { this._structureType = structureType; }
/// <summary> /// Processes the structure reference preference. /// </summary> /// <param name="sdmxStructureEnumType"> /// Type of the SDMX structure. /// </param> /// <param name="parser"> /// The parser. /// </param> /// <returns> /// The <see cref="IStructureReference"/>. /// </returns> /// <exception cref="SdmxSemmanticException"> /// DataSet structure reference incomplete, missing agencyId /// or /// Dataset structure reference incomplete, missing maintainableParentId /// </exception> private static IStructureReference ProcessStructureReferenceRef(SdmxStructureEnumType sdmxStructureEnumType, XmlReader parser) { string agencyId = parser.GetAttribute(AttributeNameTable.agencyID); string id = parser.GetAttribute(AttributeNameTable.id); string maintainableId = parser.GetAttribute(AttributeNameTable.maintainableParentID); string version = parser.GetAttribute(AttributeNameTable.version); if (string.IsNullOrWhiteSpace(agencyId)) { throw new SdmxSemmanticException("DataSet structure reference incomplete, missing agencyId"); } if (!SdmxStructureType.GetFromEnum(sdmxStructureEnumType).IsMaintainable) { if (!string.IsNullOrWhiteSpace(maintainableId)) { throw new SdmxSemmanticException("Dataset structure reference incomplete, missing maintainableParentId"); } return new StructureReferenceImpl(agencyId, maintainableId, version, sdmxStructureEnumType, id); } return new StructureReferenceImpl(agencyId, id, version, sdmxStructureEnumType); // Maintainable Reference }
/// <summary> /// Returns the referenced from inner joins to use with <see cref="ArtefactParentsSqlBuilder"/> /// </summary> /// <param name="structureEnumType"> /// The structure type. /// </param> /// <returns> /// The referenced from inner joins /// </returns> protected virtual string GetReferencedFromInnerJoins(SdmxStructureEnumType structureEnumType) { return(null); }
protected void Page_Load(object sender, EventArgs e) { if (ucCodelist != null) _structureType = SdmxStructureEnumType.CodeList; else if (ucConceptScheme != null) _structureType = SdmxStructureEnumType.ConceptScheme; else if (ucCategoryScheme != null) _structureType = SdmxStructureEnumType.CategoryScheme; else return; if (!IsPostBack) { Utils.PopulateCmbLanguages(cmbLanguageForCsv, AVAILABLE_MODES.MODE_FOR_ADD_TEXT); cmbLanguageForCsv.SelectedValue = Session[SESSION_KEYS.KEY_LANG].ToString(); } }
/// <summary> /// Generic method for retrieving <see cref="IStructureReference"/> based objects /// </summary> /// <param name="outList"> /// The output list /// </param> /// <param name="command"> /// The current <see cref="DbCommand"/> /// </param> /// <param name="structureType"> /// The structure Type. /// </param> protected void RetrieveRef(ICollection <IStructureReference> outList, DbCommand command, SdmxStructureEnumType structureType) { _log.DebugFormat("RetrieveRef of {0} SQL : {1}", structureType, command.CommandText); using (IDataReader dataReader = this._mappingStoreDb.ExecuteReader(command)) { int idField = dataReader.GetOrdinal("ID"); int agencyField = dataReader.GetOrdinal("AGENCY"); int versionField = dataReader.GetOrdinal("VERSION"); while (dataReader.Read()) { var item = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(structureType)) { MaintainableId = DataReaderHelper.GetString(dataReader, idField), Version = DataReaderHelper.GetString(dataReader, versionField), AgencyId = DataReaderHelper.GetString(dataReader, agencyField) }; outList.Add(item); } } }
/// <summary> /// Gets the SOAP operation. /// </summary> /// <param name="structureOutputFormat"> /// The structure output format. /// </param> /// <param name="sdmxSchema"> /// The SDMX schema. /// </param> /// <param name="structure"> /// Type of the structure requested. (Only in SDMX v2.1 ). /// </param> /// <returns> /// The <see cref="SoapOperation"/>. /// </returns> public static SoapOperation GetSoapOperation(this StructureOutputFormatEnumType structureOutputFormat, SdmxSchemaEnumType sdmxSchema, SdmxStructureEnumType structure) { switch (structureOutputFormat) { case StructureOutputFormatEnumType.Null: break; case StructureOutputFormatEnumType.SdmxV1StructureDocument: break; case StructureOutputFormatEnumType.SdmxV2StructureDocument: break; case StructureOutputFormatEnumType.SdmxV2RegistrySubmitDocument: break; case StructureOutputFormatEnumType.SdmxV2RegistryQueryResponseDocument: return(SoapOperation.QueryStructure); case StructureOutputFormatEnumType.SdmxV21StructureDocument: switch (structure) { case SdmxStructureEnumType.Constraint: return(SoapOperation.GetConstraint); case SdmxStructureEnumType.OrganisationScheme: return(SoapOperation.GetOrganisationScheme); case SdmxStructureEnumType.StructureSet: return(SoapOperation.GetStructureSet); case SdmxStructureEnumType.Dataflow: return(SoapOperation.GetDataflow); case SdmxStructureEnumType.CodeList: return(SoapOperation.GetCodelist); case SdmxStructureEnumType.Categorisation: return(SoapOperation.GetCategorisation); case SdmxStructureEnumType.CategoryScheme: return(SoapOperation.GetCategoryScheme); case SdmxStructureEnumType.ConceptScheme: return(SoapOperation.GetConceptScheme); case SdmxStructureEnumType.Dsd: return(SoapOperation.GetDataStructure); case SdmxStructureEnumType.HierarchicalCodelist: return(SoapOperation.GetHierarchicalCodelist); default: return(SoapOperation.GetStructures); } case StructureOutputFormatEnumType.SdmxV21RegistrySubmitDocument: break; case StructureOutputFormatEnumType.SdmxV21QueryResponseDocument: break; case StructureOutputFormatEnumType.Edi: break; case StructureOutputFormatEnumType.Csv: break; default: return(SoapOperation.Null); } return(SoapOperation.Null); }
public void TestGetMaintainablesAuthResult(SdmxStructureEnumType structureEnumType, StructureQueryDetailEnumType detail, StructureReferenceDetailEnumType refDetailEnum) { var mutableSearchManager = this.GetAuthMutableSearchManager(this._connectionString); var refDetail = StructureReferenceDetail.GetFromEnum(refDetailEnum); var structureType = SdmxStructureType.GetFromEnum(structureEnumType); IStructureReference reference = new StructureReferenceImpl(new MaintainableRefObjectImpl(), structureType); switch (structureType.EnumType) { case SdmxStructureEnumType.Dataflow: case SdmxStructureEnumType.Dsd: var allowedDataflows = (from x in this._fullRetrievalManager.GetMutableDataflowObjects(new MaintainableRefObjectImpl(), false, false) select _fromMutable.Build(x).MaintainableReference).ToArray(); var list = this._fullRetrievalManager.GetMutableMaintainables(reference, false, false); var queryMetadataMock = new Mock<IStructureQueryMetadata>(); queryMetadataMock.Setup(query => query.IsReturnLatest).Returns(false); queryMetadataMock.Setup(query => query.SpecificStructureReference).Returns((SdmxStructureType)null); queryMetadataMock.Setup(query => query.StructureReferenceDetail).Returns(refDetail); queryMetadataMock.Setup(query => query.StructureQueryDetail).Returns(StructureQueryDetail.GetFromEnum(detail)); var mockQuery = new Mock<IRestStructureQuery>(); mockQuery.Setup(query => query.StructureReference).Returns(reference); mockQuery.Setup(query => query.StructureQueryMetadata).Returns(() => queryMetadataMock.Object); _log.DebugFormat(CultureInfo.InvariantCulture, "Structure type: {0}, Detail: {1}, Reference : {2}", structureType, detail, refDetail); foreach (var maintainableMutableObject in list) { switch (refDetail.EnumType) { case StructureReferenceDetailEnumType.Null: break; case StructureReferenceDetailEnumType.None: { var mutableObject = mutableSearchManager.GetMaintainables(mockQuery.Object, allowedDataflows); Assert.IsNotNull(mutableObject, _fromMutable.Build(maintainableMutableObject).ToString()); Assert.IsNotEmpty(mutableObject.AllMaintainables, _fromMutable.Build(maintainableMutableObject).ToString()); } break; case StructureReferenceDetailEnumType.Parents: { var mutableObject = mutableSearchManager.GetMaintainables(mockQuery.Object, allowedDataflows); Assert.IsNotNull(mutableObject, _fromMutable.Build(maintainableMutableObject).ToString()); Assert.IsNotEmpty(mutableObject.AllMaintainables, _fromMutable.Build(maintainableMutableObject).ToString()); } break; case StructureReferenceDetailEnumType.ParentsSiblings: break; case StructureReferenceDetailEnumType.Children: { var mutableObject = mutableSearchManager.GetMaintainables(mockQuery.Object, allowedDataflows); Assert.IsNotNull(mutableObject, _fromMutable.Build(maintainableMutableObject).ToString()); Assert.IsNotEmpty(mutableObject.AllMaintainables, _fromMutable.Build(maintainableMutableObject).ToString()); } break; case StructureReferenceDetailEnumType.Descendants: break; case StructureReferenceDetailEnumType.All: break; case StructureReferenceDetailEnumType.Specific: { queryMetadataMock.Setup(query => query.StructureReferenceDetail).Returns(StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.None)); var mutableObject = mutableSearchManager.GetMaintainables(mockQuery.Object, allowedDataflows); queryMetadataMock.Setup(query => query.StructureReferenceDetail).Returns(refDetail); Assert.IsNotNull(mutableObject, _fromMutable.Build(maintainableMutableObject).ToString()); Assert.IsNotEmpty(mutableObject.AllMaintainables, _fromMutable.Build(maintainableMutableObject).ToString()); } break; default: throw new ArgumentOutOfRangeException(); } } break; } }
public void TestGetLatestAuthNoResult(SdmxStructureEnumType structureEnumType) { var structureType = SdmxStructureType.GetFromEnum(structureEnumType); var mutableSearchManager = this.GetAuthMutableSearchManager(this._connectionString); IStructureReference reference = new StructureReferenceImpl(new MaintainableRefObjectImpl(), structureType); switch (structureType.EnumType) { case SdmxStructureEnumType.Dataflow: var list = this._fullRetrievalManager.GetMutableMaintainables(reference, false, false); foreach (var maintainableMutableObject in list) { var mutableObject = mutableSearchManager.GetLatest(maintainableMutableObject, new IMaintainableRefObject[0]); Assert.IsNull(mutableObject, _fromMutable.Build(maintainableMutableObject).ToString()); } break; } }
public void TestQueryParserManagerV20Deep(string file, SdmxStructureEnumType[] requests, bool resolveRefs) { using (var fileReadableDataLocation = new FileReadableDataLocation(file)) { IQueryParsingManager queryParsingManager = new QueryParsingManager(SdmxSchemaEnumType.VersionTwo); IQueryWorkspace queryWorkspace = queryParsingManager.ParseQueries(fileReadableDataLocation); Assert.IsNotNull(queryWorkspace); Assert.IsTrue(queryWorkspace.HasStructureQueries()); Assert.IsNotEmpty(queryWorkspace.SimpleStructureQueries); Assert.AreEqual(requests.Length, queryWorkspace.SimpleStructureQueries.Count); var expectedRequests = new LinkedList<SdmxStructureEnumType>(requests); Assert.AreEqual(resolveRefs, queryWorkspace.ResolveReferences); foreach (IStructureReference query in queryWorkspace.SimpleStructureQueries) { Assert.IsTrue(expectedRequests.Remove(query.MaintainableStructureEnumType.EnumType)); } } }
/// <summary> /// Gets the SOAP operation. /// </summary> /// <param name="structureOutputFormat"> /// The structure output format. /// </param> /// <param name="sdmxSchema"> /// The SDMX schema. /// </param> /// <param name="structure"> /// Type of the structure requested. (Only in SDMX v2.1 ). /// </param> /// <returns> /// The <see cref="SoapOperation"/>. /// </returns> public static SoapOperation GetSoapOperation(this StructureOutputFormatEnumType structureOutputFormat, SdmxSchemaEnumType sdmxSchema, SdmxStructureEnumType structure) { switch (structureOutputFormat) { case StructureOutputFormatEnumType.Null: break; case StructureOutputFormatEnumType.SdmxV1StructureDocument: break; case StructureOutputFormatEnumType.SdmxV2StructureDocument: break; case StructureOutputFormatEnumType.SdmxV2RegistrySubmitDocument: break; case StructureOutputFormatEnumType.SdmxV2RegistryQueryResponseDocument: return SoapOperation.QueryStructure; case StructureOutputFormatEnumType.SdmxV21StructureDocument: switch (structure) { case SdmxStructureEnumType.Dataflow: return SoapOperation.GetDataflow; case SdmxStructureEnumType.CodeList: return SoapOperation.GetCodelist; case SdmxStructureEnumType.Categorisation: return SoapOperation.GetCategorisation; case SdmxStructureEnumType.CategoryScheme: return SoapOperation.GetCategoryScheme; case SdmxStructureEnumType.ConceptScheme: return SoapOperation.GetConceptScheme; case SdmxStructureEnumType.Dsd: return SoapOperation.GetDataStructure; case SdmxStructureEnumType.HierarchicalCodelist: return SoapOperation.GetHierarchicalCodelist; default: return SoapOperation.GetStructures; } case StructureOutputFormatEnumType.SdmxV21RegistrySubmitDocument: break; case StructureOutputFormatEnumType.SdmxV21QueryResponseDocument: break; case StructureOutputFormatEnumType.Edi: break; case StructureOutputFormatEnumType.Csv: break; default: return SoapOperation.Null; } return SoapOperation.Null; }
public void TestGetIdentifiableType(string urn, SdmxStructureEnumType expectedResult) { SdmxStructureType sdmxStructureType = UrnUtil.GetIdentifiableType(urn); Assert.NotNull(sdmxStructureType); Assert.AreEqual(expectedResult, sdmxStructureType.EnumType); }
/// <summary> /// The get number of maintainables. /// </summary> /// <param name="structureType"> /// The structure type. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> public int GetNumberOfMaintainables(SdmxStructureEnumType structureType) { if (this._structureMap.ContainsKey(structureType)) { return this._structureMap[structureType]; } return 0; }
/// <summary> /// /// </summary> /// <param name="structureType"></param> /// <param name="num"></param> public void SetStructure(SdmxStructureEnumType structureType, int num) { this._structureMap.Add(structureType, num); }
/// <summary> /// Returns the <c>ITEM.ITEM_ID</c> value from Mapping Store for <paramref name="artefactId"/> /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="sdmxStructure"> /// The SDMX Structure. /// </param> /// <param name="artefactId"> /// The artefact primary key. <c>ARTEFACT.ART_ID</c>. /// </param> /// <returns> /// The <c>ITEM.ITEM_ID</c> value from Mapping Store for <paramref name="artefactId"/> /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="state"/> is null /// </exception> /// <exception cref="ArgumentException"> /// At <paramref name="sdmxStructure"/>, unsupported structure /// </exception> public static ItemStatusCollection GetId(DbTransactionState state, SdmxStructureEnumType sdmxStructure, long artefactId) { if (state == null) { throw new ArgumentNullException("state"); } var tableInfo = _tableInfoBuilder.Build(sdmxStructure); if (tableInfo == null) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.ExceptionUnsupportedStructureReferenceFormat1, sdmxStructure), "sdmxStructure"); } var itemIdQueryBuilder = new ItemIdQueryBuilder(state.Database); var query = itemIdQueryBuilder.Build(tableInfo); return new ItemStatusCollection(state.Connection.Query<ItemStatus>( query, new { id = artefactId }, state.Transaction, false)); }
/// <summary> /// Handles the structure request SOAP V21. /// </summary> /// <param name="request">The request.</param> /// <param name="sdmxStructure">The SDMX structure.</param> /// <returns>The <see cref="IStreamController{XmlWriter}" />.</returns> public IStreamController<XmlWriter> ParseRequest(Message request, SdmxStructureEnumType sdmxStructure) { var structureOutputFormat = StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV21StructureDocument); var sdmxSchema = structureOutputFormat.OutputVersion; var soapOperation = structureOutputFormat.EnumType.GetSoapOperation(sdmxStructure); var rootElement = soapOperation.GetQueryRootElementV21(); var sdmxObjects = this.GetStructureResponse(request, rootElement, sdmxSchema); return this.GetStreamController(WebServiceEndpoint.StandardEndpoint, structureOutputFormat, sdmxObjects); }
/// <summary> /// Parses the structure reference. /// </summary> /// <param name="rootElementName"> /// Name of the root element. /// </param> /// <param name="sdmxStructureEnumType"> /// Type of the SDMX structure. /// </param> /// <param name="parser"> /// The parser. /// </param> /// <returns> /// The <see cref="IStructureReference"/>. /// </returns> /// <exception cref="SdmxSemmanticException"> /// DataSet structure reference incomplete, missing agencyId /// or /// Dataset structure reference incomplete, missing maintainableParentId /// or /// Dataset Structure reference invalid, reference does not match <paramref name="sdmxStructureEnumType"/> /// or /// Dataset structure reference invalid, could not process reference, no Ref node or URN node found /// </exception> private static IStructureReference ParseStructureReference(ElementNameTable rootElementName, SdmxStructureEnumType sdmxStructureEnumType, XmlReader parser) { IStructureReference structureReference = null; string text = null; while (parser.Read()) { if (parser.NodeType == XmlNodeType.Element) { ElementNameTable elementName; if (Enum.TryParse(parser.LocalName, out elementName)) { switch (elementName) { case ElementNameTable.Ref: { structureReference = ProcessStructureReferenceRef(sdmxStructureEnumType, parser); } break; } } } else if (parser.NodeType == XmlNodeType.Text) { text = parser.Value; } else if (parser.NodeType == XmlNodeType.EndElement) { string localname = parser.LocalName; if (rootElementName.Is(localname)) { return structureReference; } if (ElementNameTable.URN.Is(localname)) { structureReference = ProcessStructureReferenceUrn(sdmxStructureEnumType, text); } } } throw new SdmxSemmanticException("Dataset structure reference invalid, could not process reference, no Ref node or URN node found"); }
/// <summary> /// Check if <paramref name="structureType"/> requires authentication /// </summary> /// <param name="structureType"> /// The structure type. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool NeedsAuth(this SdmxStructureEnumType structureType) { return(IsOneOf(structureType, SdmxStructureEnumType.Dataflow, SdmxStructureEnumType.Categorisation)); }
/// <summary> /// Processes the structure reference urn. /// </summary> /// <param name="sdmxStructureEnumType"> /// Type of the SDMX structure. /// </param> /// <param name="text"> /// The text. /// </param> /// <returns> /// The <see cref="IStructureReference"/>. /// </returns> /// <exception cref="SdmxSemmanticException"> /// Dataset Structure reference invalid, reference does not match /// <paramref name="sdmxStructureEnumType"/> /// </exception> private static IStructureReference ProcessStructureReferenceUrn(SdmxStructureEnumType sdmxStructureEnumType, string text) { IStructureReference structureReference = null; string urn = text; if (!string.IsNullOrWhiteSpace(urn)) { structureReference = new StructureReferenceImpl(urn); if (structureReference.TargetReference != sdmxStructureEnumType) { throw new SdmxSemmanticException( string.Format( CultureInfo.InvariantCulture, "Dataset Structure reference invalid '{0}' , expecting a reference to '{1}' but got '{2}'", urn, SdmxStructureType.GetFromEnum(sdmxStructureEnumType), structureReference.TargetReference.StructureType)); } } return structureReference; }
/// <summary> /// Creates the child reference. /// </summary> /// <param name="structureReference">The structure reference.</param> /// <param name="structureType">Type of the structure.</param> /// <param name="ids">The ids.</param> /// <returns>The <see cref="IStructureReference"/> for <paramref name="ids"/> of type <paramref name="structureReference"/></returns> public static IStructureReference CreateChildReference(this IStructureReference structureReference, SdmxStructureEnumType structureType ,params string[] ids) { return new StructureReferenceImpl(structureReference.AgencyId, structureReference.MaintainableId, structureReference.Version, structureType, ids); }
/// <summary> /// Create a SdmxParsingObject instance /// </summary> /// <param name="_sdmxStructureType">Sdmx Version</param> public SdmxParsingObject(SdmxStructureEnumType _sdmxStructureType) { this.OtherRegistry = new List <ISdmxParsingObject>(); this.SdmxStructureType = _sdmxStructureType; this.ResolveReferenceSdmx20 = false; }
/// <summary> /// Initializes a new instance of the <see cref="ItemSchemeMapImportEngine{TSchemaMap,TProc,TMapItemProc}"/> class. /// </summary> /// <param name="childType"> /// Type of the child. /// </param> protected ItemSchemeMapImportEngine(SdmxStructureEnumType childType) { this._childType = childType; }
/// <summary> /// An empty Set will be returned if there are no matches to the query /// </summary> /// <param name="xType"> /// Contains sdmx structure enum type /// </param> /// <param name="maintainableReference"> /// Contains the identifiers of the structures to returns, can include widcarded values (null indicates a wildcard). /// </param> /// <param name="returnStub"> /// If true then a stub object will be returned /// </param> /// /// <param name="returnLatest"> /// If true then the latest version is returned, regardless of whether version information is supplied /// </param> /// <returns> /// The set of <see cref="IMaintainableObject"/> . /// </returns> private ISet <T> GetMaintainablesOfType <T>(SdmxStructureEnumType xType, IMaintainableRefObject maintainableReference, bool returnStub, bool returnLatest) where T : IMaintainableObject { ISet <T> returnSet; if (returnLatest) { maintainableReference = new MaintainableRefObjectImpl(maintainableReference.AgencyId, maintainableReference.MaintainableId, null); } switch (xType) { case SdmxStructureEnumType.AgencyScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IAgencyScheme>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.DataConsumerScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IDataConsumerScheme>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.AttachmentConstraint: returnSet = new HashSet <T>(GetMaintainableObjects <IAttachmentConstraintObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.ContentConstraint: returnSet = new HashSet <T>(GetMaintainableObjects <IContentConstraintObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.DataProviderScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IDataProviderScheme>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Categorisation: returnSet = new HashSet <T>(GetMaintainableObjects <ICategorisationObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.CategoryScheme: returnSet = new HashSet <T>(GetMaintainableObjects <ICategorySchemeObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.CodeList: returnSet = new HashSet <T>(GetMaintainableObjects <ICodelistObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.ConceptScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IConceptSchemeObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Dataflow: returnSet = new HashSet <T>(GetMaintainableObjects <IDataflowObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.HierarchicalCodelist: returnSet = new HashSet <T>(GetMaintainableObjects <IHierarchicalCodelistObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Dsd: returnSet = new HashSet <T>(GetMaintainableObjects <IDataStructureObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.MetadataFlow: returnSet = new HashSet <T>(GetMaintainableObjects <IMetadataFlow>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Msd: returnSet = new HashSet <T>(GetMaintainableObjects <IMetadataStructureDefinitionObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.OrganisationUnitScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IOrganisationUnitSchemeObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Process: returnSet = new HashSet <T>(GetMaintainableObjects <IProcessObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.ReportingTaxonomy: returnSet = new HashSet <T>(GetMaintainableObjects <IReportingTaxonomyObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.StructureSet: returnSet = new HashSet <T>(GetMaintainableObjects <IStructureSetObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.ProvisionAgreement: returnSet = new HashSet <T>(GetMaintainableObjects <IProvisionAgreementObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; default: throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetMaintainableFromSdmxObject, new Exception(xType.ToString())); } //if (returnStub && _serviceRetrievalManager != null) //{ // ISet<T> stubSet = new HashSet<T>(); // foreach (T returnItm in returnSet) // { // if (returnItm.IsExternalReference.IsTrue) // stubSet.Add(returnItm); // else // stubSet.Add((T)_serviceRetrievalManager.CreateStub(returnItm)); // } // returnSet = stubSet; //} return(returnSet); }
public void TestGetLatest(SdmxStructureEnumType structureEnumType) { var structureType = SdmxStructureType.GetFromEnum(structureEnumType); var mutableSearchManager = this.GetMutableSearchManager(this._connectionString); IStructureReference reference = new StructureReferenceImpl(new MaintainableRefObjectImpl(), structureType); switch (structureType.EnumType) { case SdmxStructureEnumType.CategoryScheme: case SdmxStructureEnumType.CodeList: case SdmxStructureEnumType.ConceptScheme: case SdmxStructureEnumType.Dataflow: case SdmxStructureEnumType.Dsd: case SdmxStructureEnumType.HierarchicalCodelist: var list = this._fullRetrievalManager.GetMutableMaintainables(reference, false, false); foreach (var maintainableMutableObject in list) { var mutableObject = mutableSearchManager.GetLatest(maintainableMutableObject); Assert.IsNotNull(mutableObject, _fromMutable.Build(maintainableMutableObject).ToString()); } break; } }
public void TestGetMaintainables( SdmxStructureEnumType structureEnumType, StructureQueryDetailEnumType detail, StructureReferenceDetailEnumType refDetailEnum, SdmxStructureEnumType specificStructure) { var mutableSearchManager = this.GetMutableSearchManager(this._connectionString); var refDetail = StructureReferenceDetail.GetFromEnum(refDetailEnum); var sdmxStructureType = SdmxStructureType.GetFromEnum(specificStructure == SdmxStructureEnumType.HierarchicalCodelist && structureEnumType == SdmxStructureEnumType.CodeList ? SdmxStructureEnumType.HierarchicalCodelist : SdmxStructureEnumType.Categorisation); IStructureReference reference = new StructureReferenceImpl(new MaintainableRefObjectImpl(), sdmxStructureType); SdmxStructureType structureType = SdmxStructureType.GetFromEnum(structureEnumType); IRestStructureQuery query = new RESTStructureQueryCore( StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific), structureType, reference, false); var allObjects = mutableSearchManager.GetMaintainables(query).GetMaintainables(structureType); var referenceLevel = StructureReferenceDetail.GetFromEnum(refDetailEnum); _log.DebugFormat(CultureInfo.InvariantCulture, "Structure type: {0}, Detail: {1}, Reference : {2}", structureType, detail, refDetail); foreach (var maintainableMutableObject in allObjects) { if ("MA".Equals(maintainableMutableObject.AgencyId)) { continue; } var structureReference = _fromMutable.Build(maintainableMutableObject); _log.DebugFormat(CultureInfo.InvariantCulture, "Checking maintainable : {0}", structureReference); var mockQuery = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(detail), referenceLevel, SdmxStructureType.GetFromEnum(specificStructure), structureReference, false); switch (refDetail.EnumType) { case StructureReferenceDetailEnumType.Null: break; case StructureReferenceDetailEnumType.None: { var mutableObject = GetMutables(mutableSearchManager, mockQuery, maintainableMutableObject); Assert.IsTrue(mutableObject.GetMaintainables(structureType).All(o => o.StructureType.EnumType == structureType.EnumType)); } break; case StructureReferenceDetailEnumType.Parents: { var mutableObject = GetMutables(mutableSearchManager, mockQuery, maintainableMutableObject); ValidateParents(mutableObject, structureType, detail != StructureQueryDetailEnumType.Full, structureReference); } break; case StructureReferenceDetailEnumType.ParentsSiblings: { var mutableObject = GetMutables(mutableSearchManager, mockQuery, maintainableMutableObject); ValidateParentsAndSiblings(mutableObject, structureType, detail != StructureQueryDetailEnumType.Full); } break; case StructureReferenceDetailEnumType.Children: { var mutableObject = GetMutables(mutableSearchManager, mockQuery, maintainableMutableObject); ValidateChildren(mutableObject, structureType, detail != StructureQueryDetailEnumType.Full); } break; case StructureReferenceDetailEnumType.Descendants: { var mutableObject = GetMutables(mutableSearchManager, mockQuery, maintainableMutableObject); ValidateDescendants(mutableObject, structureType, detail != StructureQueryDetailEnumType.Full); } break; case StructureReferenceDetailEnumType.All: { var mutableObject = GetMutables(mutableSearchManager, mockQuery, maintainableMutableObject); ValidateAll(mutableObject, structureType, detail != StructureQueryDetailEnumType.Full); } break; case StructureReferenceDetailEnumType.Specific: { if (specificStructure != SdmxStructureEnumType.Categorisation || detail == StructureQueryDetailEnumType.Full) { var specificStructureReference = SdmxStructureType.GetFromEnum(specificStructure); var specificQuery = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(detail), referenceLevel, specificStructureReference, structureReference, false); var mutablesWithSpecific = GetMutables(mutableSearchManager, specificQuery, maintainableMutableObject); ValidateSpecific(mutablesWithSpecific, structureType, detail != StructureQueryDetailEnumType.Full, specificStructureReference, structureReference); } } break; default: throw new ArgumentOutOfRangeException(); } } }
/// <summary> /// Parses the value types of the incoming component value type, and returns the complex component value to construct in the selection. /// </summary> /// <param name="compValue"> /// The component value. /// </param> /// <param name="compType"> /// The component type : either a dimension, time dimension, attribute or primary measure. /// </param> /// <returns> /// The set with the ComplexCompoentValue objects. /// </returns> private IList<IComplexComponentValue> GetComplexComponentValues(DataStructureComponentValueQueryType compValue, SdmxStructureEnumType compType) { IList<IComplexComponentValue> comValues = new List<IComplexComponentValue>(); IComplexComponentValue comValue = null; //Numeric Values if (compValue.NumericValue != null) { foreach (NumericValue numerValue in compValue.NumericValue) { OrderedOperator orderedOperator = OrderedOperator.ParseString([email protected]()); comValue = new ComplexComponentValueImpl(numerValue.TypedValue.ToString(CultureInfo.InvariantCulture), orderedOperator, compType); comValues.Add(comValue); } } //Time Value if (compValue.TimeValue != null) { foreach (TimeValue timeValue in compValue.TimeValue) { OrderedOperator orderedOperator = OrderedOperator.ParseString([email protected]()); comValue = new ComplexComponentValueImpl(timeValue.TypedValue.ToString(), orderedOperator, compType); comValues.Add(comValue); } } //Text Value applicable only for attribute and primary measure if (compType.Equals(SdmxStructureEnumType.PrimaryMeasure) || compType.Equals(SdmxStructureEnumType.DataAttribute)) { //It's a generic type but the type will always be one if (compValue.TextValue != null) { foreach (TextValue textValue in compValue.TextValue) { TextSearch textOperator = TextSearch.ParseString([email protected]()); comValue = new ComplexComponentValueImpl(textValue.ToString(), textOperator, compType); comValues.Add(comValue); } } } //Value if (compValue.Value != null) { OrderedOperator orderedOperator = OrderedOperator.ParseString([email protected]()); comValue = new ComplexComponentValueImpl(compValue.Value.ToString(), orderedOperator, compType); comValues.Add(comValue); } return comValues; }