コード例 #1
0
ファイル: Index.cs プロジェクト: TonyAbell/spark
 public void Delete(DeletedEntry entry)
 {
     lock (transaction)
     {
         indexer.Delete(entry);
     }
 }
コード例 #2
0
ファイル: BundleTests.cs プロジェクト: wdebeau1/fhir-net-api
 private static DeletedEntry createTestDeletedEntry()
 {
     DeletedEntry e2 = new DeletedEntry();
     e2.Id = new Uri("http://test.com/fhir/patient/@233");
     e2.Links.SelfLink = new Uri("http://test.com/fhir/patient/@233/history/@2");
     e2.When = new DateTimeOffset(2012, 11, 01, 13, 15, 30, TimeSpan.Zero);
     return e2;
 }
コード例 #3
0
        private static BundleEntry loadEntry(XElement entry)
        {
            BundleEntry result;

            try
            {
                if (entry.Name == XTOMBSTONE + XATOM_DELETED_ENTRY)
                {
                    result = new DeletedEntry();
                    result.Id = SerializationUtil.UriValueOrNull(entry.Attribute(XATOM_DELETED_REF));
                }
                else
                {
                    XElement content = entry.Element(XATOMNS + XATOM_CONTENT);
                    var id = SerializationUtil.UriValueOrNull(entry.Element(XATOMNS + XATOM_ID));

                    if (content != null)
                    {
                        var parsed = getContents(content);
                        if (parsed != null)
                            result = ResourceEntry.Create(parsed);
                        else
                            throw Error.Format("BundleEntry has a content element without content", XmlDomFhirReader.GetLineInfo(content));
                    }
                    else
                    {
                        result = SerializationUtil.CreateResourceEntryFromId(id);
                    }
                  
                    result.Id = id;
                }

                result.Links = getLinks(entry.Elements(XATOMNS + XATOM_LINK));
                result.Tags = TagListParser.ParseTags(entry.Elements(XATOMNS + XATOM_CATEGORY));

                if (result is DeletedEntry)
                {
                    ((DeletedEntry)result).When = SerializationUtil.InstantOrNull(entry.Attribute(XATOM_DELETED_WHEN));
                }
                else
                {
                    ResourceEntry re = (ResourceEntry)result;
                    re.Title = SerializationUtil.StringValueOrNull(entry.Element(XATOMNS + XATOM_TITLE));
                    re.LastUpdated = SerializationUtil.InstantOrNull(entry.Element(XATOMNS + XATOM_UPDATED));
                    re.Published = SerializationUtil.InstantOrNull(entry.Element(XATOMNS + XATOM_PUBLISHED));
                    re.AuthorName = entry.Elements(XATOMNS + XATOM_AUTHOR).Count() == 0 ? null :
                                SerializationUtil.StringValueOrNull(entry.Element(XATOMNS + XATOM_AUTHOR)
                                    .Element(XATOMNS + XATOM_AUTH_NAME));
                    re.AuthorUri = entry.Elements(XATOMNS + XATOM_AUTHOR).Count() == 0 ? null :
                                SerializationUtil.StringValueOrNull(entry.Element(XATOMNS + XATOM_AUTHOR)
                                    .Element(XATOMNS + XATOM_AUTH_URI));                  
                }
            }
            catch (Exception exc)
            {
                throw Error.Format("Exception while reading entry: " + exc.Message, XmlDomFhirReader.GetLineInfo(entry));
            }

            return result;
        }
コード例 #4
0
        private static BundleEntry loadEntry(XElement entry, ErrorList errors)
        {
            BundleEntry result;

            errors.DefaultContext = "An atom entry";

            try
            {
                if (entry.Name == XTOMBSTONE + XATOM_DELETED_ENTRY)
                {
                    result = new DeletedEntry();
                    result.Id = Util.UriValueOrNull(entry.Attribute(XATOM_DELETED_REF));
                    if (result.Id != null) errors.DefaultContext = String.Format("Entry '{0}'", result.Id.ToString());
                }
                else
                {
                    XElement content = entry.Element(XATOMNS + XATOM_CONTENT);
                    var id = Util.UriValueOrNull(entry.Element(XATOMNS + XATOM_ID));

                    if (id != null) errors.DefaultContext = String.Format("Entry '{0}'", id.ToString());

                    if (content != null)
                    {
                        var parsed = getContents(content, errors);
                        if (parsed != null)
                            result = ResourceEntry.Create(parsed);
                        else
                            return null;
                    }
                    else
                        throw new InvalidOperationException("BundleEntry has empty content: cannot determine Resource type in parser.");

                    result.Id = id;
                }

                result.Links = getLinks(entry.Elements(XATOMNS + XATOM_LINK));
                result.Tags = TagListParser.ParseTags(entry.Elements(XATOMNS + XATOM_CATEGORY));

                if (result is DeletedEntry)
                {
                    ((DeletedEntry)result).When = Util.InstantOrNull(entry.Attribute(XATOM_DELETED_WHEN));
                }
                else
                {
                    ResourceEntry re = (ResourceEntry)result;
                    re.Title = Util.StringValueOrNull(entry.Element(XATOMNS + XATOM_TITLE));
                    re.LastUpdated = Util.InstantOrNull(entry.Element(XATOMNS + XATOM_UPDATED));
                    re.Published = Util.InstantOrNull(entry.Element(XATOMNS + XATOM_PUBLISHED));
                    re.AuthorName = entry.Elements(XATOMNS + XATOM_AUTHOR).Count() == 0 ? null :
                                Util.StringValueOrNull(entry.Element(XATOMNS + XATOM_AUTHOR)
                                    .Element(XATOMNS + XATOM_AUTH_NAME));
                    re.AuthorUri = entry.Elements(XATOMNS + XATOM_AUTHOR).Count() == 0 ? null :
                                Util.StringValueOrNull(entry.Element(XATOMNS + XATOM_AUTHOR)
                                    .Element(XATOMNS + XATOM_AUTH_URI));

                }
            }
            catch (Exception exc)
            {
                errors.Add("Exception while reading entry: " + exc.Message);
                return null;
            }
            finally
            {
                errors.DefaultContext = null;
            }

            return result;
        }
コード例 #5
0
ファイル: MongoIndexer.cs プロジェクト: TonyAbell/spark
 public void Delete(DeletedEntry entry)
 {
     string id = entry.Id.ToString();
     IMongoQuery query = MongoDB.Driver.Builders.Query.EQ(InternalField.ID, id);
     collection.Remove(query);
 }
コード例 #6
0
        private static BundleEntry loadEntry(JObject entry)
        {
            BundleEntry result;

            try
            {
                if (entry[JATOM_DELETED] != null)
                {
                    result = new DeletedEntry();
                    result.Id = SerializationUtil.UriValueOrNull(entry[BundleXmlParser.XATOM_ID]);
                }
                else
                {
                    var content = entry[BundleXmlParser.XATOM_CONTENT];

                    var id = SerializationUtil.UriValueOrNull(entry[BundleXmlParser.XATOM_ID]);
                    if (id == null) throw Error.Format("BundleEntry found without an id", null);

                    if (content != null)
                    {
                        var parsed = getContents(content);
                        if (parsed != null)
                            result = ResourceEntry.Create(parsed);
                        else
                            throw Error.Format("BundleEntry {0} has a content element without content", null, id);
                    }
                    else
                    {
                        result = SerializationUtil.CreateResourceEntryFromId(id);
                    }

                    result.Id = id;
                }
                
                result.Links = getLinks(entry[BundleXmlParser.XATOM_LINK]);
                result.Tags = TagListParser.ParseTags(entry[BundleXmlParser.XATOM_CATEGORY]);

                if (result is DeletedEntry)
                    ((DeletedEntry)result).When = instantOrNull(entry[JATOM_DELETED]);
                else
                {
                    var re = (ResourceEntry)result;
                    re.Title = entry.Value<string>(BundleXmlParser.XATOM_TITLE);
                    re.LastUpdated = instantOrNull(entry[BundleXmlParser.XATOM_UPDATED]);
                    re.Published = instantOrNull(entry[BundleXmlParser.XATOM_PUBLISHED]);
                    re.AuthorName = entry[BundleXmlParser.XATOM_AUTHOR] as JArray != null ?
                        entry[BundleXmlParser.XATOM_AUTHOR]
                            .Select(auth => auth.Value<string>(BundleXmlParser.XATOM_AUTH_NAME))
                            .FirstOrDefault() : null;
                    re.AuthorUri = entry[BundleXmlParser.XATOM_AUTHOR] as JArray != null ?
                        entry[BundleXmlParser.XATOM_AUTHOR]
                            .Select(auth => auth.Value<string>(BundleXmlParser.XATOM_AUTH_URI))
                            .FirstOrDefault() : null;
                }
            }
            catch (Exception exc)
            {
                throw Error.Format("Exception while reading entry: " + exc.Message, null);
            }

            return result;
        }