/// <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> /// Build <see cref="ProvisionAgreementType"/> from <paramref name="buildFrom"/>. /// </summary> /// <param name="buildFrom"> /// The build from. /// </param> /// <returns> /// The <see cref="ProvisionAgreementType"/> from <paramref name="buildFrom"/> . /// </returns> public ProvisionAgreementType Build(IProvisionAgreementObject buildFrom) { var builtObj = new ProvisionAgreementType(); string value = buildFrom.Id; if (!string.IsNullOrWhiteSpace(value)) { builtObj.id = buildFrom.Id; } if (buildFrom.Uri != null) { builtObj.uri = buildFrom.Uri; } else if (buildFrom.StructureUrl != null) { builtObj.uri = buildFrom.StructureUrl; } else if (buildFrom.ServiceUrl != null) { builtObj.uri = buildFrom.StructureUrl; } if (ObjectUtil.ValidString(buildFrom.Urn)) { builtObj.urn = buildFrom.Urn; } IList<ITextTypeWrapper> names = buildFrom.Names; if (ObjectUtil.ValidCollection(names)) { builtObj.Name = this.GetTextType(names); } IList<ITextTypeWrapper> descriptions = buildFrom.Descriptions; if (ObjectUtil.ValidCollection(descriptions)) { builtObj.Description = this.GetTextType(descriptions); } if (this.HasAnnotations(buildFrom)) { builtObj.Annotations = this.GetAnnotationsType(buildFrom); } if (buildFrom.StructureUseage != null) { if (buildFrom.StructureUseage.TargetReference.EnumType == SdmxStructureEnumType.Dataflow) { DataflowRefType dataflowRef = builtObj.DataflowRef = new DataflowRefType(); this.PopulateDataflowRef(buildFrom.StructureUseage, dataflowRef); } else if (buildFrom.StructureUseage.TargetReference.EnumType == SdmxStructureEnumType.MetadataFlow) { MetadataflowRefType metadataflowRef = builtObj.MetadataflowRef = new MetadataflowRefType(); this.PopulateMetadataflowRef(buildFrom.StructureUseage, metadataflowRef); } } if (buildFrom.DataproviderRef != null) { DataProviderRefType dataProviderRef = builtObj.DataProviderRef = new DataProviderRefType(); this.PopulateDataproviderRef(buildFrom.DataproviderRef, dataProviderRef); } return builtObj; }