/// <summary> /// Initializes a new instance of the <see cref="ReferenceSearchValue"/> class. /// </summary> /// <param name="referenceKind">The kind of reference.</param> /// <param name="baseUri">The base URI of the resource.</param> /// <param name="resourceType">The resource type.</param> /// <param name="resourceId">The resource id.</param> public ReferenceSearchValue(ReferenceKind referenceKind, Uri baseUri, string resourceType, string resourceId) { if (baseUri != null) { EnsureArg.IsNotNullOrWhiteSpace(resourceType, nameof(resourceType)); } EnsureArg.IsNotNullOrWhiteSpace(resourceId, nameof(resourceId)); ModelInfoProvider.EnsureValidResourceType(resourceType, nameof(resourceType)); Kind = referenceKind; BaseUri = baseUri; ResourceType = resourceType; ResourceId = resourceId; }
/// <inheritdoc /> public ReferenceSearchValue Parse(string s) { EnsureArg.IsNotNullOrWhiteSpace(s, nameof(s)); Match match = ReferenceRegex.Match(s); if (match.Success) { string resourceTypeInString = match.Groups[ResourceTypeCapture].Value; ModelInfoProvider.EnsureValidResourceType(resourceTypeInString, nameof(s)); string resourceId = match.Groups[ResourceIdCapture].Value; int resourceTypeStartIndex = match.Groups[ResourceTypeCapture].Index; if (resourceTypeStartIndex == 0) { // This is relative URL. return(new ReferenceSearchValue( ReferenceKind.InternalOrExternal, null, resourceTypeInString, resourceId)); } Uri baseUri = null; try { baseUri = new Uri(s.Substring(0, resourceTypeStartIndex), UriKind.RelativeOrAbsolute); if (baseUri == _fhirRequestContextAccessor.FhirRequestContext.BaseUri) { // This is an absolute URL pointing to an internal resource. return(new ReferenceSearchValue( ReferenceKind.Internal, null, resourceTypeInString, resourceId)); } else if (baseUri.IsAbsoluteUri && SupportedSchemes.Contains(baseUri.Scheme, StringComparer.OrdinalIgnoreCase)) { // This is an absolute URL pointing to an external resource. return(new ReferenceSearchValue( ReferenceKind.External, baseUri, resourceTypeInString, resourceId)); } } catch (UriFormatException) { // The reference is not a relative reference but is not a valid absolute reference either. } } return(new ReferenceSearchValue( ReferenceKind.InternalOrExternal, baseUri: null, resourceType: null, resourceId: s)); }
public ReindexJobRecord( IReadOnlyDictionary <string, string> searchParametersHash, IReadOnlyCollection <string> targetResourceTypes, ushort maxiumumConcurrency = 1, uint maxResourcesPerQuery = 100, int queryDelayIntervalInMilliseconds = 500, ushort?targetDataStoreUsagePercentage = null) { EnsureArg.IsNotNull(searchParametersHash, nameof(searchParametersHash)); EnsureArg.IsNotNull(targetResourceTypes, nameof(targetResourceTypes)); // Default values SchemaVersion = 1; Id = Guid.NewGuid().ToString(); Status = OperationStatus.Queued; QueuedTime = Clock.UtcNow; LastModified = Clock.UtcNow; ResourceTypeSearchParameterHashMap = searchParametersHash; // check for MaximumConcurrency boundary if (maxiumumConcurrency < MinMaximumConcurrency || maxiumumConcurrency > MaxMaximumConcurrency) { throw new BadRequestException(string.Format(Fhir.Core.Resources.InvalidReIndexParameterValue, nameof(MaximumConcurrency), MinMaximumConcurrency.ToString(), MaxMaximumConcurrency.ToString())); } else { MaximumConcurrency = maxiumumConcurrency; } // check for MaximumNumberOfResourcesPerQuery boundary if (maxResourcesPerQuery < MinMaximumNumberOfResourcesPerQuery || maxResourcesPerQuery > MaxMaximumNumberOfResourcesPerQuery) { throw new BadRequestException(string.Format(Fhir.Core.Resources.InvalidReIndexParameterValue, nameof(MaximumNumberOfResourcesPerQuery), MinMaximumNumberOfResourcesPerQuery.ToString(), MaxMaximumNumberOfResourcesPerQuery.ToString())); } else { MaximumNumberOfResourcesPerQuery = maxResourcesPerQuery; } // check for QueryDelayIntervalInMilliseconds boundary if (queryDelayIntervalInMilliseconds < MinQueryDelayIntervalInMilliseconds || queryDelayIntervalInMilliseconds > MaxQueryDelayIntervalInMilliseconds) { throw new BadRequestException(string.Format(Fhir.Core.Resources.InvalidReIndexParameterValue, nameof(QueryDelayIntervalInMilliseconds), MinQueryDelayIntervalInMilliseconds.ToString(), MaxQueryDelayIntervalInMilliseconds.ToString())); } else { QueryDelayIntervalInMilliseconds = queryDelayIntervalInMilliseconds; } // check for TargetDataStoreUsagePercentage boundary if (targetDataStoreUsagePercentage < MinTargetDataStoreUsagePercentage || targetDataStoreUsagePercentage > MaxTargetDataStoreUsagePercentage) { throw new BadRequestException(string.Format(Fhir.Core.Resources.InvalidReIndexParameterValue, nameof(TargetDataStoreUsagePercentage), MinTargetDataStoreUsagePercentage.ToString(), MaxTargetDataStoreUsagePercentage.ToString())); } else { TargetDataStoreUsagePercentage = targetDataStoreUsagePercentage; } // check for TargetResourceTypes boundary foreach (var type in targetResourceTypes) { ModelInfoProvider.EnsureValidResourceType(type, nameof(type)); } TargetResourceTypes = targetResourceTypes; }