/// <summary> /// Build success response. /// </summary> /// <param name="buildFrom"> /// The source sdmx objects. /// </param> /// <param name="warningMessage"> /// The warning message. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildSuccessResponse(ISdmxObjects buildFrom, string warningMessage) { // PLEASE NOTE. The code here is slightly different than in Java. // That is because of the differences between Java XmlBeans and .NET Linq2Xsd generated classes. // Please consult GIT log before making any changes. var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; HeaderType headerType; if (buildFrom.Header != null) { headerType = this._headerXmlsBuilder.Build(buildFrom.Header); regInterface.Header = headerType; } else { headerType = new HeaderType(); regInterface.Header = headerType; V2Helper.SetHeader(headerType, buildFrom); } var returnType = new QueryStructureResponseType(); regInterface.QueryStructureResponse = returnType; var statusMessage = new StatusMessageType(); returnType.StatusMessage = statusMessage; if (!string.IsNullOrWhiteSpace(warningMessage) || !ObjectUtil.ValidCollection(buildFrom.GetAllMaintainables())) { statusMessage.status = StatusTypeConstants.Warning; var tt = new TextType(); statusMessage.MessageText.Add(tt); tt.TypedValue = !string.IsNullOrWhiteSpace(warningMessage) ? warningMessage : "No Structures Match The Query Parameters"; } else { statusMessage.status = StatusTypeConstants.Success; } ISet<ICategorisationObject> categorisations = buildFrom.Categorisations; // GET CATEGORY SCHEMES if (buildFrom.CategorySchemes.Count > 0) { var catSchemesType = new CategorySchemesType(); returnType.CategorySchemes = catSchemesType; /* foreach */ foreach (ICategorySchemeObject cateogrySchemeBean in buildFrom.CategorySchemes) { ISet<ICategorisationObject> matchingCategorisations = new HashSet<ICategorisationObject>(); /* foreach */ foreach (ICategorisationObject cat in categorisations) { if (MaintainableUtil<ICategorySchemeObject>.Match(cateogrySchemeBean, cat.CategoryReference)) { matchingCategorisations.Add(cat); } } catSchemesType.CategoryScheme.Add( this._categorySchemeXmlBuilder.Build(cateogrySchemeBean, categorisations)); } } // GET CODELISTS if (buildFrom.Codelists.Count > 0) { CodeListsType codeListsType = new CodeListsType(); returnType.CodeLists = codeListsType; //CodeListsType codeListsType = returnType.CodeLists; /* foreach */ foreach (ICodelistObject codelistBean in buildFrom.Codelists) { codeListsType.CodeList.Add(this._codelistXmlBuilder.Build(codelistBean)); } } // CONCEPT SCHEMES if (buildFrom.ConceptSchemes.Count > 0) { ConceptsType conceptsType = new ConceptsType(); returnType.Concepts = conceptsType; /* foreach */ foreach (IConceptSchemeObject conceptSchemeBean in buildFrom.ConceptSchemes) { conceptsType.ConceptScheme.Add(this._conceptSchemeXmlBuilder.Build(conceptSchemeBean)); } } // DATAFLOWS if (buildFrom.Dataflows.Count > 0) { var dataflowsType = new DataflowsType(); returnType.Dataflows = dataflowsType; /* foreach */ foreach (IDataflowObject currentBean in buildFrom.Dataflows) { dataflowsType.Dataflow.Add( this._dataflowXmlBuilder.Build(currentBean, GetCategorisations(currentBean, categorisations))); } } // HIERARCIC CODELIST if (buildFrom.HierarchicalCodelists.Count > 0) { HierarchicalCodelistsType hierarchicalCodelistsType = new HierarchicalCodelistsType(); returnType.HierarchicalCodelists = hierarchicalCodelistsType; /* foreach */ foreach (IHierarchicalCodelistObject currentBean0 in buildFrom.HierarchicalCodelists) { hierarchicalCodelistsType.HierarchicalCodelist.Add( this._hierarchicalCodelistXmlBuilder.Build(currentBean0)); } } // KEY FAMILY if (buildFrom.DataStructures.Count > 0) { var keyFamiliesType = new KeyFamiliesType(); returnType.KeyFamilies = keyFamiliesType; /* foreach */ foreach (IDataStructureObject currentBean1 in buildFrom.DataStructures) { keyFamiliesType.KeyFamily.Add(this._dataStructureXmlBuilder.Build(currentBean1)); } } // METADATA FLOW if (buildFrom.Metadataflows.Count > 0) { var metadataflowsType = new MetadataflowsType(); returnType.Metadataflows = metadataflowsType; /* foreach */ foreach (IMetadataFlow currentBean2 in buildFrom.Metadataflows) { metadataflowsType.Metadataflow.Add( this._metadataflowXmlBuilder.Build( currentBean2, GetCategorisations(currentBean2, categorisations))); } } // METADATA STRUCTURE if (buildFrom.MetadataStructures.Count > 0) { var msdsType = new MetadataStructureDefinitionsType(); returnType.MetadataStructureDefinitions = msdsType; /* foreach */ foreach (IMetadataStructureDefinitionObject currentBean3 in buildFrom.MetadataStructures) { msdsType.MetadataStructureDefinition.Add( this._metadataStructureDefinitionXmlsBuilder.Build(currentBean3)); } } OrganisationSchemesType orgSchemesType = null; // AGENCY SCHEMES if (buildFrom.AgenciesSchemes.Count > 0) { orgSchemesType = new OrganisationSchemesType(); returnType.OrganisationSchemes = orgSchemesType; /* foreach */ foreach (IAgencyScheme currentBean4 in buildFrom.AgenciesSchemes) { orgSchemesType.OrganisationScheme.Add(this._organisationSchemeXmlBuilder.Build(currentBean4)); } } // DATA CONSUMER SCHEMES if (buildFrom.DataConsumerSchemes.Count > 0) { if (orgSchemesType == null) { orgSchemesType = new OrganisationSchemesType(); returnType.OrganisationSchemes = orgSchemesType; } /* foreach */ foreach (IDataConsumerScheme currentBean5 in buildFrom.DataConsumerSchemes) { orgSchemesType.OrganisationScheme.Add(this._organisationSchemeXmlBuilder.Build(currentBean5)); } } // DATA PROVIDER SCHEMES if (buildFrom.DataProviderSchemes.Count > 0) { if (orgSchemesType == null) { orgSchemesType = new OrganisationSchemesType(); returnType.OrganisationSchemes = orgSchemesType; } /* foreach */ foreach (IDataProviderScheme currentBean6 in buildFrom.DataProviderSchemes) { orgSchemesType.OrganisationScheme.Add(this._organisationSchemeXmlBuilder.Build(currentBean6)); } } // PROCESSES if (buildFrom.Processes.Count > 0) { var processesType = new ProcessesType(); returnType.Processes = processesType; /* foreach */ foreach (IProcessObject currentBean7 in buildFrom.Processes) { processesType.Process.Add(this._processXmlBuilder.Build(currentBean7)); } } // STRUCTURE SETS if (buildFrom.StructureSets.Count > 0) { var structureSetsType = new StructureSetsType(); returnType.StructureSets = structureSetsType; /* foreach */ foreach (IStructureSetObject currentBean8 in buildFrom.StructureSets) { structureSetsType.StructureSet.Add(this._structureSetXmlBuilder.Build(currentBean8)); } } // REPORTING TAXONOMIES if (buildFrom.ReportingTaxonomys.Count > 0) { var reportingTaxonomiesType = new ReportingTaxonomiesType(); returnType.ReportingTaxonomies = reportingTaxonomiesType; /* foreach */ foreach (IReportingTaxonomyObject currentBean9 in buildFrom.ReportingTaxonomys) { reportingTaxonomiesType.ReportingTaxonomy.Add(this._reportingTaxonomyXmlBuilder.Build(currentBean9)); } } if (buildFrom.AttachmentConstraints.Count > 0) { throw new SdmxNotImplementedException( ExceptionCode.Unsupported, "Attachment Constraint at SMDX v2.0 - please use SDMX v2.1"); } if (buildFrom.ContentConstraintObjects.Count > 0) { throw new SdmxNotImplementedException( ExceptionCode.Unsupported, "Content Constraint at SMDX v2.0 - please use SDMX v2.1"); } return responseType; }
/// <summary> /// Process the organisation schemes. /// </summary> /// <param name="organisationSchemesType"> /// The organisation schemes type. /// </param> /// <param name="beans"> /// The sdmxObjects. /// </param> /// <param name="urns"> /// The URN. /// </param> /// <exception cref="MaintainableObjectException"> /// Duplicate URN /// </exception> protected void ProcessOrganisationSchemes( OrganisationSchemesType organisationSchemesType, ISdmxObjects beans, ISet<Uri> urns) { if (organisationSchemesType != null) { /* foreach */ foreach (OrganisationSchemeType currentType10 in organisationSchemesType.OrganisationScheme) { if (ObjectUtil.ValidCollection(currentType10.Agencies)) { try { this.AddIfNotDuplicateURN(beans, urns, new AgencySchemeCore(currentType10)); } catch (Exception th11) { throw new MaintainableObjectException( th11, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.AgencyScheme), currentType10.agencyID, currentType10.id, currentType10.version); } } if (ObjectUtil.ValidCollection(currentType10.DataConsumers)) { try { this.AddIfNotDuplicateURN(beans, urns, new DataConsumerSchemeCore(currentType10)); } catch (Exception th12) { throw new MaintainableObjectException( th12, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DataConsumerScheme), currentType10.agencyID, currentType10.id, currentType10.version); } } if (ObjectUtil.ValidCollection(currentType10.DataProviders)) { try { this.AddIfNotDuplicateURN(beans, urns, new DataProviderSchemeCore(currentType10)); } catch (Exception th13) { throw new MaintainableObjectException( th13, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DataProviderScheme), currentType10.agencyID, currentType10.id, currentType10.version); } } // If the organisation scheme contains no elements, then this is an error if (currentType10.Agencies.Count == 0 && currentType10.DataConsumers.Count == 0 && currentType10.DataProviders.Count == 0) { throw new SdmxSemmanticException(ExceptionCode.StructureInvalidOrganisationSchemeNoContent, currentType10.agencyID, currentType10.id); } } } }
/// <summary> /// Creates organisation schemes and agencies based on the input organisation schemes /// </summary> /// <param name="orgSchemesType"> /// - if null will not add anything to the beans container /// </param> /// <param name="beans"> /// - to add organisation schemes and agencies to /// </param> private void ProcessOrganisationSchemes(OrganisationSchemesType orgSchemesType, ISdmxObjects beans) { var urns = new HashSet<Uri>(); if (orgSchemesType != null) { if (ObjectUtil.ValidCollection(orgSchemesType.AgencyScheme)) { /* foreach */ foreach (AgencySchemeType currentType in orgSchemesType.AgencyScheme) { try { this.AddIfNotDuplicateURN(beans, urns, new AgencySchemeCore(currentType)); } catch (Exception th) { throw new MaintainableObjectException( th, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.AgencyScheme), currentType.agencyID, currentType.id, currentType.version); } } } if (ObjectUtil.ValidCollection(orgSchemesType.DataProviderScheme)) { /* foreach */ foreach (DataProviderSchemeType currentType0 in orgSchemesType.DataProviderScheme) { try { this.AddIfNotDuplicateURN(beans, urns, new DataProviderSchemeCore(currentType0)); } catch (Exception th1) { throw new MaintainableObjectException( th1, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DataProviderScheme), currentType0.agencyID, currentType0.id, currentType0.version); } } } if (ObjectUtil.ValidCollection(orgSchemesType.DataConsumerScheme)) { /* foreach */ foreach (DataConsumerSchemeType currentType2 in orgSchemesType.DataConsumerScheme) { try { this.AddIfNotDuplicateURN(beans, urns, new DataConsumerSchemeCore(currentType2)); } catch (Exception th3) { throw new MaintainableObjectException( th3, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DataConsumerScheme), currentType2.agencyID, currentType2.id, currentType2.version); } } } if (ObjectUtil.ValidCollection(orgSchemesType.OrganisationUnitScheme)) { /* foreach */ foreach (OrganisationUnitSchemeType currentType4 in orgSchemesType.OrganisationUnitScheme) { try { this.AddIfNotDuplicateURN(beans, urns, new OrganisationUnitSchemeObjectCore(currentType4)); } catch (Exception th5) { throw new MaintainableObjectException( th5, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.OrganisationUnitScheme), currentType4.agencyID, currentType4.id, currentType4.version); } } } } }