public void Add(Interaction interaction) { if (interaction.State == InteractionState.Undefined) { interactions.Add(interaction); } }
public void Delete(Interaction entry) { string location = entry.Key.ToRelativeUri().ToString(); string id = entry.Key.ToOperationPath(); IMongoQuery query = MongoDB.Driver.Builders.Query.EQ(InternalField.ID, id); Collection.Remove(query); }
public void Inform(Uri location, Interaction interaction) { foreach(IServiceListener listener in listeners) { Inform(listener, location, interaction); } }
public static FhirResponse Gone(Interaction entry) { var message = String.Format( "A {0} resource with id {1} existed, but was deleted on {2} (version {3}).", entry.Key.TypeName, entry.Key.ResourceId, entry.When, entry.Key.ToRelativeUri()); return Respond.WithError(HttpStatusCode.Gone, message); }
public static FhirResponse WithMeta(Interaction interaction) { if (interaction.Resource != null && interaction.Resource.Meta != null) { return Respond.WithMeta(interaction.Resource.Meta); } else { return Respond.WithError(HttpStatusCode.InternalServerError, "Could not retrieve meta. Meta was not present on the resource"); } }
public void Add(Interaction interaction) { if (interaction.State == InteractionState.Undefined) { interactions.Add(interaction); } else { // no need to import again. // interaction.State.Assert(InteractionState.Undefined); } }
public void Process(Interaction interaction) { if (interaction.HasResource()) { IndexResource(interaction.Resource, interaction.Key); } else { if (interaction.IsDeleted()) { _indexStore.Delete(interaction); } else throw new Exception("Entry is neither resource nor deleted"); } }
public void Process(Interaction interaction) { if (interaction.HasResource()) { put(interaction); } else { if (interaction.IsDeleted()) { store.Delete(interaction); } else throw new Exception("Entry is neither resource nor deleted"); } }
public FhirResponse GetFhirResponse(Interaction interaction, IEnumerable<object> parameters = null) { if (interaction.IsDeleted()) { return Respond.Gone(interaction); } FhirResponse response = null; if (parameters != null) { response = interceptorRunner.RunInterceptors(interaction, parameters); } return response ?? Respond.WithResource(interaction); }
public static Bundle Append(this Bundle bundle, Interaction interaction) { // API: The api should have a function for this. AddResourceEntry doesn't cut it. // Might TransactionBuilder be better suitable? Bundle.BundleEntryComponent entry; switch (bundle.Type) { case Bundle.BundleType.History: entry = interaction.ToTransactionEntry(); break; case Bundle.BundleType.Searchset: entry = interaction.TranslateToSparseEntry(); break; default: entry = interaction.TranslateToSparseEntry(); break; } bundle.Entry.Add(entry); return bundle; }
public FhirResponse GetFhirResponse(Interaction interaction, object input) { ConditionalHeaderParameters parameters = ConvertInput(input); if (parameters == null) return null; bool? matchTags = parameters.IfNoneMatchTags.Any() ? parameters.IfNoneMatchTags.Any(t => t == ETag.Create(interaction.Key.VersionId).Tag) : (bool?)null; bool? matchModifiedDate = parameters.IfModifiedSince.HasValue ? parameters.IfModifiedSince.Value < interaction.Resource.Meta.LastUpdated : (bool?) null; if (!matchTags.HasValue && !matchModifiedDate.HasValue) { return null; } if ((matchTags ?? true) && (matchModifiedDate ?? true)) { return Respond.WithCode(HttpStatusCode.NotModified); } return null; }
public void Externalize(Interaction interaction) { Export export = new Export(this.localhost); export.Add(interaction); export.Externalize(); }
public static FhirResponse WithEntry(HttpStatusCode code, Interaction entry) { return new FhirResponse(code, entry.Key, entry.Resource); }
public static void AddMetaData(BsonDocument document, Interaction interaction) { document[Field.METHOD] = interaction.Method; document[Field.PRIMARYKEY] = interaction.Key.ToOperationPath(); document[Field.REFERENCE] = interaction.Key.ToBsonReferenceKey(); AddMetaData(document, interaction.Key); }
public static FhirResponse WithResource(Interaction entry) { return new FhirResponse(HttpStatusCode.OK, entry.Key, entry.Resource); }
public static FhirResponse WithEntry(HttpStatusCode code, Interaction entry) { return(new FhirResponse(code, entry.Key, entry.Resource)); }
private void put(Interaction interaction) { put(interaction.Key, 0, interaction.Resource); }
private void Store(Interaction interaction) { fhirStore.Add(interaction); //CK: try the new indexing service. if (_indexService != null) { _indexService.Process(interaction); } else if (fhirIndex != null) { //TODO: If IndexService is working correctly, remove the reference to fhirIndex. fhirIndex.Process(interaction); } if (serviceListener != null) { Uri location = localhost.GetAbsoluteUri(interaction.Key); // todo: what we want is not to send localhost to the listener, but to add the Resource.Base. But that is not an option in the current infrastructure. // It would modify interaction.Resource, while serviceListener.Inform(location, interaction); } }
public static void AddVersionDate(Interaction entry, DateTime when) { entry.When = when; if (entry.Resource != null) { ensureMeta(entry.Resource); entry.Resource.Meta.LastUpdated = when; } }
public FhirResponse GetFhirResponse(Interaction interaction, params object[] parameters) { return GetFhirResponse(interaction, parameters.ToList()); }
public void Internalize(Interaction interaction) { var import = new Import(this.localhost, this.generator); import.Add(interaction); import.Internalize(); }
private void Inform(IServiceListener listener, Uri location, Interaction interaction) { listener.Inform(location, interaction); }
private void Store(Interaction interaction) { store.Add(interaction); if (index != null) { index.Process(interaction); } if (listener != null) { Uri location = localhost.GetAbsoluteUri(interaction.Key); // todo: what we want is not to send localhost to the listener, but to add the Resource.Base. But that is not an option in the current infrastructure. // It would modify interaction.Resource, while listener.Inform(location, interaction); } }
void InternalizeKey(Interaction interaction) { if (interaction.IsDeleted) return; Key key = interaction.Key.Clone(); switch (localhost.GetKeyKind(key)) { case KeyKind.Foreign: { interaction.Key = Remap(key); return; } case KeyKind.Temporary: { interaction.Key = Remap(key); return; } case KeyKind.Local: case KeyKind.Internal: { if (interaction.Method == Bundle.HTTPVerb.PUT) { interaction.Key = RemapHistoryOnly(key); } else { interaction.Key = Remap(key); } return; } default: { // switch can never get here. throw Error.Internal("Unexpected key for resource: " + interaction.Key.ToString()); } } }
// Deprecated: only used for Mailbox //public static void SaveBody(this HttpRequestMessage request, string contentType, byte[] data) //{ // Binary b = new Binary { Content = data, ContentType = contentType }; // request.Properties.Add(Const.UNPARSED_BODY, b); //} // Deprecated: only used for Mailbox //public static Binary GetBody(this HttpRequestMessage request) //{ // if (request.Properties.ContainsKey(Const.UNPARSED_BODY)) // return request.Properties[Const.UNPARSED_BODY] as Binary; // else // return null; //} /// <summary> /// Temporary hack! /// Adds a resourceEntry to the request property bag. To be picked up by the MediaTypeFormatters for adding http headers. /// </summary> /// <param name="entry">The resource entry with information to generate headers</param> /// <remarks> /// The SendAsync is called after the headers are set. The SetDefaultHeaders have no access to the content object. /// The only solution is to give the information through the Request Property Bag. /// </remarks> public static void SaveEntry(this HttpRequestMessage request, Interaction entry) { request.Properties.Add(Const.RESOURCE_ENTRY, entry); }
public void Delete(Interaction entry) { string id = entry.Key.WithoutVersion().ToOperationPath(); IMongoQuery query = MongoDB.Driver.Builders.Query.EQ(InternalField.ID, id); Collection.Remove(query); }
public FhirResponse HandleInteraction(Interaction interaction) { switch (interaction.Method) { case Bundle.HTTPVerb.PUT: return this.Update(interaction.Key, interaction.Resource); case Bundle.HTTPVerb.POST: return this.Create(interaction.Key, interaction.Resource); case Bundle.HTTPVerb.DELETE: return this.Delete(interaction.Key); default: return Respond.Success; } }
public FhirResponse RunInterceptors(Interaction interaction, IEnumerable<object> parameters) { FhirResponse response = null; parameters.FirstOrDefault(p => (response = RunInterceptors(interaction, (object) p)) != null); return response; }
public void Process(Interaction interaction) { _indexer.Process(interaction); }
private FhirResponse RunInterceptors(Interaction interaction, object input) { FhirResponse response = null; GetResponseInterceptors(input).FirstOrDefault(f => (response = f.GetFhirResponse(interaction, input)) != null); return response; }
void ExternalizeKey(Interaction interaction) { interaction.SupplementBase(localhost.DefaultBase); }
public static FhirResponse WithResource(Interaction entry) { return(new FhirResponse(HttpStatusCode.OK, entry.Key, entry.Resource)); }