HasVersion() public static method

public static HasVersion ( IKey key ) : void
key IKey
return void
コード例 #1
0
        //public FhirResponse Search(string type, IEnumerable<Tuple<string, string>> parameters, int pageSize, string sortby)
        //{
        //    Validate.TypeName(type);
        //    Uri link = localhost.Uri(type);

        //    IEnumerable<string> keys = store.List(type);
        //    var snapshot = pager.CreateSnapshot(Bundle.BundleType.Searchset, link, keys, );
        //    Bundle bundle = pager.GetFirstPage(snapshot);
        //    return Respond.WithBundle(bundle, localhost.Base);
        // DSTU2: search

        /*
         * Query query = FhirParser.ParseQueryFromUriParameters(collection, parameters);
         * ICollection<string> includes = query.Includes;
         *
         * SearchResults results = index.Search(query);
         *
         * if (results.HasErrors)
         * {
         *  throw new SparkException(HttpStatusCode.BadRequest, results.Outcome);
         * }
         *
         * Uri link = localhost.Uri(type).AddPath(results.UsedParameters);
         *
         * Bundle bundle = pager.GetFirstPage(link, keys, sortby);
         *
         * /*
         * if (results.HasIssues)
         * {
         *  var outcomeEntry = BundleEntryFactory.CreateFromResource(results.Outcome, new Uri("outcome/1", UriKind.Relative), DateTimeOffset.Now);
         *  outcomeEntry.SelfLink = outcomeEntry.Id;
         *  bundle.Entries.Add(outcomeEntry);
         * }
         * return Respond.WithBundle(bundle);
         */
        //}

        //public FhirResponse Update(IKey key, Resource resource)
        //{
        //    Validate.HasTypeName(key);
        //    Validate.HasNoVersion(key);
        //    Validate.ResourceType(key, resource);

        //    Interaction original = store.Get(key);

        //    if (original == null)
        //    {
        //        return Respond.WithError(HttpStatusCode.MethodNotAllowed,
        //            "Cannot update resource {0}/{1}, because it doesn't exist on this server",
        //            key.TypeName, key.ResourceId);
        //    }

        //    Interaction interaction = Interaction.PUT(key, resource);
        //    interaction.Resource.AffixTags(original.Resource);

        //    transfer.Internalize(interaction);
        //    Store(interaction);

        //    // todo: does this require a response?
        //    transfer.Externalize(interaction);
        //    return Respond.WithEntry(HttpStatusCode.OK, interaction);
        //}

        public FhirResponse VersionSpecificUpdate(IKey versionedkey, Resource resource)
        {
            Validate.HasTypeName(versionedkey);
            Validate.HasVersion(versionedkey);

            Key   key     = versionedkey.WithoutVersion();
            Entry current = fhirStore.Get(key);

            Validate.IsSameVersion(current.Key, versionedkey);

            return(this.Put(key, resource));
        }
コード例 #2
0
 private static void ValidateKey(Key key, bool includeVersion = false)
 {
     Validate.HasTypeName(key);
     Validate.HasResourceId(key);
     if (includeVersion)
     {
         Validate.HasVersion(key);
     }
     else
     {
         Validate.HasNoVersion(key);
     }
     Validate.Key(key);
 }
コード例 #3
0
        /// <summary>
        /// Read the state of a specific version of the resource.
        /// </summary>
        /// <param name="collectionName">The resource type, in lowercase</param>
        /// <param name="id">The id part of a version-specific reference</param>
        /// <param name="vid">The version part of a version-specific reference</param>
        /// <returns>A Result containing the resource, or an Issue</returns>
        /// <remarks>
        /// If the version referred to is actually one where the resource was deleted, the server should return a
        /// 410 status code.
        /// </remarks>
        public FhirResponse VersionRead(Key key)
        {
            Validate.HasTypeName(key);
            Validate.HasResourceId(key);
            Validate.HasVersion(key);
            Validate.Key(key);

            Interaction interaction = store.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }

            else if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            transfer.Externalize(interaction);
            return(Respond.WithResource(interaction));
        }