예제 #1
0
        public void StorageStardogTransactionTest()
        {
            StardogConnector stardog = StardogTests.GetConnection();

            stardog.Begin();
            stardog.Commit();
            stardog.Dispose();
        }
예제 #2
0
        public void StorageStardogTransactionTest()
        {
            try
            {
                Options.HttpDebugging = true;

                StardogConnector stardog = StardogTests.GetConnection();;
                stardog.Begin();
                stardog.Commit();
                stardog.Dispose();
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
예제 #3
0
        public void StorageStardogSparqlUpdate5()
        {
            StardogConnector stardog = StardogTests.GetConnection();
            IGraph           g;

            // Begin a transaction
            stardog.Begin();

            // Try to make an update
            stardog.Update(
                "DROP SILENT GRAPH <http://example.org/stardog/update/5>; INSERT DATA { GRAPH <http://example.org/stardog/update/5> { <http://x> <http://y> <http://z> } }");

            // Rollback the transaction
            stardog.Rollback();

            g = new Graph();
            stardog.LoadGraph(g, "http://example.org/stardog/update/5");
            Assert.False(g.IsEmpty, "Graph should not be empty after update");
            Assert.Equal(1, g.Triples.Count);

            stardog.Dispose();
        }
    /// <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;

            }

        }
    }