////// PRIVATE CONSTRUCTOR ///// TODO java 0.9.1 has private ctor that is not accessed anywhere ////#region Constructors and Destructors /////// <summary> /////// Prevents a default instance of the <see cref="SubmitStructureResponseBuilderV2"/> class from being created. /////// </summary> ////private SubmitStructureResponseBuilderV2() ////{ ////} ////#endregion #region Public Methods and Operators /// <summary> /// The build error response. /// </summary> /// <param name="exception"> /// The exception. /// </param> /// <param name="errorBean"> /// The error bean. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildErrorResponse(Exception exception, IStructureReference errorBean) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; V2Helper.Header = regInterface; var returnType = new SubmitStructureResponseType(); regInterface.SubmitStructureResponse = returnType; ProcessMaintainable(returnType, errorBean, exception); return responseType; }
/// <summary> /// Build error response. /// </summary> /// <param name="th"> /// The exception. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildErrorResponse(Exception th) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new QueryProvisioningResponseType(); regInterface.QueryProvisioningResponse = returnType; V2Helper.Header = regInterface; returnType.StatusMessage = new StatusMessageType(); this.AddStatus(returnType.StatusMessage, th); return responseType; }
/// <summary> /// The build error response. /// </summary> /// <param name="exception"> /// The exception. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildErrorResponse(Exception exception) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new SubmitProvisioningResponseType(); regInterface.SubmitProvisioningResponse = returnType; V2Helper.Header = regInterface; var statusType = new ProvisioningStatusType(); returnType.ProvisioningStatus.Add(statusType); var statusMessage = new StatusMessageType(); statusType.StatusMessage = statusMessage; this.AddStatus(statusMessage, exception); return responseType; }
/// <summary> /// Builds error response. /// </summary> /// <param name="ex"> /// The exception. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildErrorResponse(Exception ex) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new QueryRegistrationResponseType(); regInterface.QueryRegistrationResponse = returnType; V2Helper.Header = regInterface; var queryResult = new QueryResultType(); returnType.QueryResult.Add(queryResult); queryResult.timeSeriesMatch = false; var statusMessage = new StatusMessageType(); queryResult.StatusMessage = statusMessage; this.AddStatus(statusMessage, ex); return responseType; }
/// <summary> /// The build success response. /// </summary> /// <param name="provisions"> /// The provisions. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildSuccessResponse(ICollection<IProvisionAgreementObject> provisions) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new QueryProvisioningResponseType(); regInterface.QueryProvisioningResponse = returnType; V2Helper.Header = regInterface; var statusMessage = new StatusMessageType(); returnType.StatusMessage = statusMessage; this.AddStatus(returnType.StatusMessage, null); if (!ObjectUtil.ValidCollection(provisions)) { statusMessage.status = StatusTypeConstants.Warning; var tt = new TextType(); statusMessage.MessageText.Add(tt); tt.TypedValue = "No Provisions Match The Query Parameters"; } else { statusMessage.status = StatusTypeConstants.Success; var provTypes = new ProvisionAgreementType[provisions.Count]; int i = 0; /* foreach */ foreach (IProvisionAgreementObject currentProv in provisions) { provTypes[i] = this._provBuilder.Build(currentProv); i++; } returnType.ProvisionAgreement = provTypes; } return responseType; }
/// <summary> /// The build response. /// </summary> /// <param name="response"> /// The response. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildResponse(ICollection<IProvisionAgreementObject> response) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new SubmitProvisioningResponseType(); regInterface.SubmitProvisioningResponse = returnType; V2Helper.Header = regInterface; /* foreach */ foreach (IProvisionAgreementObject provisionAgreement in response) { this.ProcessResponse(returnType, provisionAgreement); } return responseType; }
/// <summary> /// The build success response. /// </summary> /// <param name="registrations"> /// The registrations. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildSuccessResponse(ICollection<IRegistrationObject> registrations) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new QueryRegistrationResponseType(); regInterface.QueryRegistrationResponse = returnType; V2Helper.Header = regInterface; if (!ObjectUtil.ValidCollection(registrations)) { var queryResult = new QueryResultType(); returnType.QueryResult.Add(queryResult); queryResult.timeSeriesMatch = false; var statusMessage = new StatusMessageType(); queryResult.StatusMessage = statusMessage; statusMessage.status = StatusTypeConstants.Warning; var tt = new TextType(); statusMessage.MessageText.Add(tt); tt.TypedValue = "No Registrations Match The Query Parameters"; } else { /* foreach */ foreach (IRegistrationObject currentRegistration in registrations) { var queryResult0 = new QueryResultType(); returnType.QueryResult.Add(queryResult0); var statusMessage1 = new StatusMessageType(); queryResult0.StatusMessage = statusMessage1; this.AddStatus(statusMessage1, null); queryResult0.timeSeriesMatch = false; // FUNC 1 - when is this true? Also We need MetadataResult var resultType = new ResultType(); queryResult0.DataResult = resultType; if (currentRegistration.DataSource != null) { IDataSource datasourceBean = currentRegistration.DataSource; var datasourceType = new DatasourceType(); resultType.Datasource = datasourceType; if (datasourceBean.SimpleDatasource) { datasourceType.SimpleDatasource = datasourceBean.DataUrl; } else { var queryableDatasource = new QueryableDatasourceType(); datasourceType.QueryableDatasource = queryableDatasource; queryableDatasource.isRESTDatasource = datasourceBean.RESTDatasource; queryableDatasource.isWebServiceDatasource = datasourceBean.WebServiceDatasource; queryableDatasource.DataUrl = datasourceBean.DataUrl; if (datasourceBean.WsdlUrl != null) { queryableDatasource.WSDLUrl = datasourceBean.WsdlUrl; } } } if (currentRegistration.ProvisionAgreementRef != null) { WriteProvisionAgreementRef(currentRegistration.ProvisionAgreementRef, resultType); } } } return responseType; }
/// <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> /// The build error response. /// </summary> /// <param name="exception"> /// The exception. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildErrorResponse(Exception exception) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new QueryStructureResponseType(); regInterface.QueryStructureResponse = returnType; V2Helper.Header = regInterface; var statusMessage = new StatusMessageType(); returnType.StatusMessage = statusMessage; statusMessage.status = StatusTypeConstants.Failure; var tt = new TextType(); statusMessage.MessageText.Add(tt); var uncheckedException = exception as SdmxException; tt.TypedValue = uncheckedException != null ? uncheckedException.FullMessage : exception.Message; return responseType; }
/// <summary> /// Build from a Registry Document, this can be either a submit structure request, or a query structure response /// </summary> /// <param name="rid"> /// The registryInterface. /// </param> /// <returns> /// The <see cref="ISdmxObjects"/>. /// </returns> public virtual ISdmxObjects Build(RegistryInterface rid) { return this._sdmxObjectsV2RegDocBuilder.Build(rid); }
/// <summary> /// The build success response. /// </summary> /// <param name="beans"> /// The beans. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildSuccessResponse(ISdmxObjects beans) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; HeaderType headerType; if (beans.Header != null) { headerType = this._headerXmlsBuilder.Build(beans.Header); regInterface.Header = headerType; } else { headerType = new HeaderType(); regInterface.Header = headerType; V2Helper.SetHeader(headerType, beans); } var returnType = new SubmitStructureResponseType(); regInterface.SubmitStructureResponse = returnType; ProcessMaintainables(returnType, beans.GetAllMaintainables()); return responseType; }
/// <summary> /// Build error response. /// </summary> /// <param name="exception"> /// The exception. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildErrorResponse(Exception exception) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; V2Helper.Header = regInterface; var returnType = new SubmitRegistrationResponseType(); regInterface.SubmitRegistrationResponse = returnType; var registrationStatusType = new RegistrationStatusType(); returnType.RegistrationStatus.Add(registrationStatusType); registrationStatusType.StatusMessage = new StatusMessageType(); this.AddStatus(registrationStatusType.StatusMessage, exception); return responseType; }
/// <summary> /// The build response. /// </summary> /// <param name="response"> /// The response. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildResponse(IDictionary<IRegistrationObject, Exception> response) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; var returnType = new SubmitRegistrationResponseType(); regInterface.SubmitRegistrationResponse = returnType; V2Helper.Header = regInterface; /* foreach */ foreach (KeyValuePair<IRegistrationObject, Exception> registration in response) { this.ProcessResponse(returnType, registration.Key, registration.Value); } return responseType; }