public void Delete(DeletedEntry entry) { lock (transaction) { indexer.Delete(entry); } }
public void Delete(DeletedEntry entry) { string id = entry.Id.ToString(); IMongoQuery query = MongoDB.Driver.Builders.Query.EQ(InternalField.ID, id); collection.Remove(query); }
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); }
public void StartListener() { entryListener = instance.AddEntryListener("", (in RefEntryNotification notification) => { if (notification.Flags.HasFlag(NotifyFlags.New)) { NewEntry?.Invoke(notification.Name, notification.Entry, notification.Value.ToValue()); } else if (notification.Flags.HasFlag(NotifyFlags.Delete)) { DeletedEntry?.Invoke(notification.Name); } }, NotifyFlags.New | NotifyFlags.Delete | NotifyFlags.Immediate | NotifyFlags.Local);
private static Bundle createTestBundle() { Bundle b = new Bundle(); b.Title = "Updates to resource 233"; b.Id = new Uri("urn:uuid:0d0dcca9-23b9-4149-8619-65002224c3"); b.LastUpdated = new DateTimeOffset(2012, 11, 2, 14, 17, 21, TimeSpan.Zero); b.AuthorName = "Ewout Kramer"; b.TotalResults = 20; b.Links.SelfLink = new Uri("http://test.com/fhir/patient/@233/history?format=json"); b.Links.LastLink = new Uri("http://test.com/fhir/patient/@233"); ResourceEntry e1 = createTestResourceEntry(); DeletedEntry e2 = createTestDeletedEntry(); ResourceEntry e3 = createTestBinaryEntry(); b.Entries.Add(e1); b.Entries.Add(e2); b.Entries.Add(e3); return(b); }
private static JObject createEntry(BundleEntry entry, bool summary) { JObject result = new JObject(); if (entry is ResourceEntry) { ResourceEntry re = (ResourceEntry)entry; if (!String.IsNullOrEmpty(re.Title)) { result.Add(new JProperty(BundleXmlParser.XATOM_TITLE, re.Title)); } if (SerializationUtil.UriHasValue(entry.Id)) { result.Add(new JProperty(BundleXmlParser.XATOM_ID, entry.Id.ToString())); } if (re.LastUpdated != null) { result.Add(new JProperty(BundleXmlParser.XATOM_UPDATED, re.LastUpdated)); } if (re.Published != null) { result.Add(new JProperty(BundleXmlParser.XATOM_PUBLISHED, re.Published)); } if (!String.IsNullOrWhiteSpace(re.AuthorName)) { result.Add(jsonCreateAuthor(re.AuthorName, re.AuthorUri)); } } else { DeletedEntry de = (DeletedEntry)entry; if (de.When != null) { result.Add(new JProperty(BundleJsonParser.JATOM_DELETED, de.When)); } if (SerializationUtil.UriHasValue(entry.Id)) { result.Add(new JProperty(BundleXmlParser.XATOM_ID, entry.Id.ToString())); } } if (entry.Links != null && entry.Links.Count() > 0) { result.Add(new JProperty(BundleXmlParser.XATOM_LINK, jsonCreateLinkArray(entry.Links))); } if (entry.Tags != null && entry.Tags.Count() > 0) { result.Add(TagListSerializer.CreateTagCategoryPropertyJson(entry.Tags)); } if (entry is ResourceEntry) { ResourceEntry re = (ResourceEntry)entry; if (re.Resource != null) { result.Add(new JProperty(BundleXmlParser.XATOM_CONTENT, getContentsAsJObject(re.Resource, summary))); } // Note: this is a read-only property, so it is serialized but never parsed if (entry.Summary != null) { result.Add(new JProperty(BundleXmlParser.XATOM_SUMMARY, entry.Summary)); } } return(result); }
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); }
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); }
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); }
private static BundleEntry loadEntry(JToken entry, ErrorList errors) { BundleEntry result; errors.DefaultContext = "An atom entry"; try { if (entry.Value <DateTimeOffset?>(JATOM_DELETED) != null) { result = new DeletedEntry(); } else { var content = entry[BundleXmlParser.XATOM_CONTENT]; 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 = Util.UriValueOrNull(entry[BundleXmlParser.XATOM_ID]); if (result.Id != null) { errors.DefaultContext = String.Format("Entry '{0}'", result.Id.ToString()); } 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) { errors.Add("Exception while reading entry: " + exc.Message); return(null); } finally { errors.DefaultContext = null; } return(result); }
public void RaiseDeleted(Object entity, TDbContext dbc) { var entry = new DeletedEntry((TEntity)entity, dbc); RaiseDeletedInner(entry); }
public void RaiseDeleted(IServiceProvider sp, Object entity, TDbContext dbc) { var entry = new DeletedEntry <TEntity, TDbContext>((TEntity)entity, dbc, sp); RaiseDeletedActions(entry, sp); }