/// <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  structure sets.
 /// </summary>
 /// <param name="structureSetsType">
 /// The structure sets type.
 /// </param>
 /// <param name="beans">
 /// The sdmxObjects.
 /// </param>
 /// <param name="urns">
 /// The URN.
 /// </param>
 /// <exception cref="MaintainableObjectException">
 /// Duplicate URN
 /// </exception>
 protected void ProcessStructureSets(StructureSetsType structureSetsType, ISdmxObjects beans, ISet<Uri> urns)
 {
     if (structureSetsType != null && structureSetsType.StructureSet != null)
     {
         /* foreach */
         foreach (StructureSetType currentType18 in structureSetsType.StructureSet)
         {
             try
             {
                 this.AddIfNotDuplicateURN(beans, urns, new StructureSetObjectCore(currentType18));
             }
             catch (Exception th19)
             {
                 throw new MaintainableObjectException(
                     th19,
                     SdmxStructureType.GetFromEnum(SdmxStructureEnumType.StructureSet),
                     currentType18.agencyID,
                     currentType18.id,
                     currentType18.version);
             }
         }
     }
 }
 /// <summary>
 /// Creates StructureSets based on the input StructureSets
 /// </summary>
 /// <param name="structureSets">
 /// - if null will not add anything to the beans container
 /// </param>
 /// <param name="beans">
 /// - to add concepts to
 /// </param>
 private void ProcessStructureSets(StructureSetsType structureSets, ISdmxObjects beans)
 {
     var urns = new HashSet<Uri>();
     if (structureSets != null && structureSets.StructureSet != null)
     {
         /* foreach */
         foreach (StructureSetType currentType in structureSets.StructureSet)
         {
             try
             {
                 this.AddIfNotDuplicateURN(beans, urns, new StructureSetObjectCore(currentType));
             }
             catch (Exception th)
             {
                 throw new MaintainableObjectException(
                     th, 
                     SdmxStructureType.GetFromEnum(SdmxStructureEnumType.StructureSet), 
                     currentType.agencyID, 
                     currentType.id, 
                     currentType.version);
             }
         }
     }
 }