/// <summary> /// Processes a POST operation /// </summary> /// <param name="context">HTTP Context</param> public override void ProcessPost(IHttpContext context) { // Get the payload assuming there is one IGraph g = ParsePayload(context); if (g == null) { // Q: What should the behaviour be when the payload is null for a POST? Assuming a 200 OK response return; } // Get the Graph URI of the Graph to be added Uri graphUri = ResolveGraphUri(context, g); // First we need a // Generate an INSERT DATA command for the POST StringBuilder insert = new StringBuilder(); if (graphUri != null) { insert.AppendLine("INSERT DATA { GRAPH @graph {"); } else { insert.AppendLine("INSERT DATA {"); } TurtleFormatter formatter = new TurtleFormatter(g.NamespaceMap); foreach (Triple t in g.Triples) { insert.AppendLine(t.ToString(formatter)); } if (graphUri != null) { insert.AppendLine("} }"); } else { insert.AppendLine("}"); } // Parse and evaluate the command SparqlParameterizedString insertCmd = new SparqlParameterizedString(insert.ToString()); insertCmd.Namespaces = g.NamespaceMap; if (graphUri != null) { insertCmd.SetUri("graph", graphUri); } SparqlUpdateCommandSet cmds = _parser.ParseFromString(insertCmd); _updateProcessor.ProcessCommandSet(cmds); _updateProcessor.Flush(); }
/// <summary> /// Executes a query on the store which does not expect a result. /// </summary> /// <param name="query">The update query</param> /// <param name="transaction">An associated transaction</param> public override void ExecuteNonQuery(SparqlUpdate query, ITransaction transaction = null) { string q = query.ToString(); Log?.Invoke(q); SparqlUpdateCommandSet cmds = _parser.ParseFromString(q); _updateProcessor.ProcessCommandSet(cmds); }
/// <summary> /// Executes this command as an update /// </summary> public void ExecuteUpdate() { if (_updateProcessor == null) { throw new SparqlUpdateException("Cannot call ExecuteUpdate() when the UpdateProcessor property has not been set"); } SparqlUpdateParser parser = new SparqlUpdateParser(); SparqlUpdateCommandSet cmds = parser.ParseFromString(ToString()); _updateProcessor.ProcessCommandSet(cmds); }
public void ApplyTransaction(IList <Triple> preconditions, IList <Triple> deletePatterns, IList <Triple> inserts, string updateGraphUri) { if (preconditions.Count > 0) { throw new NotSupportedException("SparqlDataObjectStore does not support conditional updates"); } var deleteOp = FormatDeletePatterns(deletePatterns, updateGraphUri); var insertOp = FormatInserts(inserts, updateGraphUri); var parser = new SparqlUpdateParser(); var cmds = parser.ParseFromString(deleteOp + "\n" + insertOp); _updateProcessor.ProcessCommandSet(cmds); }
public void ApplyTransaction(IEnumerable <ITriple> existencePreconditions, IEnumerable <ITriple> nonexistencePreconditions, IEnumerable <ITriple> deletePatterns, IEnumerable <ITriple> inserts, string updateGraphUri) { if (existencePreconditions.Any()) { throw new NotSupportedException("SparqlDataObjectStore does not support conditional updates"); } if (nonexistencePreconditions.Any()) { // NOTE: At the moment this is ignored because if you use key properties, // non-existence preconditions will get generated and we want to support // using key properties with SPARQL update endpoints. } var deleteOp = FormatDeletePatterns(deletePatterns.ToList(), updateGraphUri); var insertOp = FormatInserts(inserts, updateGraphUri); var parser = new SparqlUpdateParser(); var cmds = parser.ParseFromString(deleteOp + "\n" + insertOp); _updateProcessor.ProcessCommandSet(cmds); }
private void RunUpdate(SparqlUpdateCommandSet cmds, ISparqlUpdateProcessor processor) { processor.ProcessCommandSet(cmds); }
/// <summary> /// Processes the Command Set using the given Update Processor. /// </summary> /// <param name="processor">Update Processor.</param> public void Process(ISparqlUpdateProcessor processor) { processor.ProcessCommandSet(this); }
private void RunUpdate(SparqlUpdateCommandSet cmds, ISparqlUpdateProcessor processor) { processor.ProcessCommandSet(cmds); }
/// <summary> /// Processes the Command Set using the given Update Processor /// </summary> /// <param name="processor">Update Processor</param> public void Process(ISparqlUpdateProcessor processor) { processor.ProcessCommandSet(this); }
public void ExecuteNonQuery(SparqlUpdate query, ITransaction transaction = null) { SparqlUpdateCommandSet cmds = _parser.ParseFromString(query.ToString()); _updateProcessor.ProcessCommandSet(cmds); }