public void SparqlUpdateGenericCreateInsertDeleteData()
        {
            IGenericIOManager manager = this.GetManager();
            GenericUpdateProcessor processor = new GenericUpdateProcessor(manager);
            SparqlUpdateCommandSet cmds = this._parser.ParseFromString("CREATE GRAPH <http://example.org/sparqlUpdate/created>; INSERT DATA { GRAPH <http://example.org/sparqlUpdate/created> { <http://example.org/s> <http://example.org/p> <http://example.org/o> } }");

            processor.ProcessCommandSet(cmds);

            Graph g = new Graph();
            manager.LoadGraph(g, "http://example.org/sparqlUpdate/created");

            TestTools.ShowGraph(g);

            Assert.IsFalse(g.IsEmpty, "[" + manager.ToString() + "] Graph should not be empty");
            Assert.AreEqual(1, g.Triples.Count, "[" + manager.ToString() + "] Graph should have 1 Triple");

            cmds = this._parser.ParseFromString("DELETE DATA { GRAPH <http://example.org/sparqlUpdate/created> { <http://example.org/s> <http://example.org/p> <http://example.org/o> } }");
            processor.ProcessCommandSet(cmds);

            Graph h = new Graph();
            manager.LoadGraph(h, "http://example.org/sparqlUpdate/created");

            TestTools.ShowGraph(h);

            Assert.IsTrue(h.IsEmpty, "[" + manager.ToString() + "] Graph should be empty");
        }
    /// <summary>
    /// Execute insert or delete SPARQL queries against Stardog;
    /// separate multiple statements with a semicolon
    /// </summary>
    /// <param name="command"></param>
    /// <returns></returns>
    public static bool Update(string command)
    {
        using (StardogConnector dog = new StardogConnector(ConnectionString(), ConnectionDatabase(), ConnectionUser(), ConnectionPassword()))
        {

            try
            {

                dog.Begin(); // wrap all the statements in this command into one transaction; otherwise stardog will run them as separate transactions

                GenericUpdateProcessor processor = new GenericUpdateProcessor(dog);

                SparqlUpdateParser parser = new SparqlUpdateParser();

                processor.ProcessCommandSet(parser.ParseFromString(Prefixes() + command));

                dog.Commit();

                return true;

            }
            catch (Exception err)
            {

                try
                {
                    dog.Rollback();
                }
                catch { }

                throw err;

            }

        }
    }
예제 #3
0
 /// <summary>
 /// Executes a set of SPARQL Update commands on the Store
 /// </summary>
 /// <param name="updates">SPARQL Update Commands</param>
 /// <remarks>
 /// <para>
 /// If the underlying Manager is an <see cref="IUpdateableGenericIOManager">IUpdateableGenericIOManager</see> then the managers own Update implementation will be used, otherwise dotNetRDF's approximated implementation for generic stores will be used.  In the case of approximation exact feature support will vary depending on the underlying manager being used.
 /// </para>
 /// </remarks>
 public void ExecuteUpdate(SparqlUpdateCommandSet updates)
 {
     GenericUpdateProcessor processor = new GenericUpdateProcessor(this._manager);
     processor.ProcessCommandSet(updates);
 }
예제 #4
0
    /// <summary>
    /// Execute insert or delete SPARQL queries against Stardog;
    /// separate multiple statements with a semicolon
    /// </summary>
    /// <param name="command"></param>
    /// <returns></returns>
    public static bool Update(string command)
    {
        using (StardogConnector dog = new StardogConnector(ConnectionString(), ConnectionDatabase(), ConnectionUser(), ConnectionPassword()))
        {

            GenericUpdateProcessor processor = new GenericUpdateProcessor(dog);

            SparqlUpdateParser parser = new SparqlUpdateParser();

            processor.ProcessCommandSet(parser.ParseFromString(Prefixes() + command));

        }

        return true;
    }