public void StorageAllegroGraphDeleteGraph2()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();
            Uri graphUri = null;

            agraph.DeleteGraph(graphUri);

            Graph g = new Graph();

            FileLoader.Load(g, "resources\\InferenceTest.ttl");
            g.BaseUri = graphUri;

            agraph.SaveGraph(g);

            Graph h = new Graph();

            agraph.LoadGraph(h, graphUri);
            Assert.False(h.IsEmpty, "Graph should not be empty after loading");

            Assert.Equal(g, h);

            agraph.DeleteGraph(graphUri);
            h = new Graph();
            agraph.LoadGraph(h, graphUri);
            Assert.True(h.IsEmpty, "Graph should be equal after deletion");
            Assert.NotEqual(g, h);
        }
        public void StorageAllegroGraphDeleteTriples()
        {
            Graph g = new Graph();

            FileLoader.Load(g, "resources\\InferenceTest.ttl");
            g.BaseUri = new Uri("http://example.org/AllegroGraphTest");

            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();

            agraph.SaveGraph(g);

            Console.WriteLine("Graph before deletion");
            TestTools.ShowGraph(g);

            //Delete all Triples about the Ford Fiesta
            agraph.UpdateGraph(g.BaseUri, null, g.GetTriplesWithSubject(new Uri("http://example.org/vehicles/FordFiesta")));

            Graph h = new Graph();

            agraph.LoadGraph(h, g.BaseUri);

            Console.WriteLine("Graph after deletion");
            TestTools.ShowGraph(h);

            Assert.False(h.IsEmpty, "Graph should not be completely empty");
            Assert.True(g.HasSubGraph(h), "Graph retrieved with missing Triples should be a sub-graph of the original Graph");
            Assert.False(g.Equals(h), "Graph retrieved should not be equal to original Graph");

            Object results = agraph.Query("ASK WHERE { GRAPH <http://example.org/AllegroGraphTest> { <http://example.org/vehicles/FordFiesta> ?p ?o } }");

            if (results is SparqlResultSet)
            {
                Assert.False(((SparqlResultSet)results).Result, "There should no longer be any triples about the Ford Fiesta present");
            }
        }
Exemple #3
0
        public void StorageAllegroGraphDeleteGraph1()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();
            Uri graphUri = new Uri("http://example.org/AllegroGraph/delete");

            Graph g = new Graph();

            FileLoader.Load(g, "resources\\InferenceTest.ttl");
            g.BaseUri = graphUri;

            agraph.SaveGraph(g);

            Graph h = new Graph();

            agraph.LoadGraph(h, graphUri);
            Assert.IsFalse(h.IsEmpty, "Graph should not be empty after loading");

            Assert.AreEqual(g, h, "Graphs should have been equal");

            agraph.DeleteGraph(graphUri);
            h = new Graph();
            agraph.LoadGraph(h, graphUri);
            Assert.IsTrue(h.IsEmpty, "Graph should be equal after deletion");
            Assert.AreNotEqual(g, h, "Graphs should not be equal after deletion");
        }
        public void StorageAllegroGraphSparqlUpdate()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();

            String updates = "INSERT DATA { GRAPH <http://example.org/new-graph> { <http://subject> <http://predicate> <http://object> } }";

            agraph.Update(updates);

            SparqlResultSet results = agraph.Query("SELECT * WHERE { GRAPH <http://example.org/new-graph> { ?s ?p ?o } }") as SparqlResultSet;

            Assert.NotNull(results);
            Assert.Equal(1, results.Count);
        }
        public void StorageAllegroGraphDescribe()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();

            String describe = "DESCRIBE <http://example.org/Vehicles/FordFiesta>";

            Object results = agraph.Query(describe);

            Assert.IsAssignableFrom <IGraph>(results);
            if (results is IGraph)
            {
                TestTools.ShowGraph((IGraph)results);
            }
        }
        public void StorageAllegroGraphAsk()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();

            String ask = "ASK WHERE { ?s ?p ?o }";

            Object results = agraph.Query(ask);

            Assert.IsAssignableFrom <SparqlResultSet>(results);
            if (results is SparqlResultSet)
            {
                TestTools.ShowResults(results);
            }
        }
        public void StorageAllegroGraphSaveEmptyGraph1()
        {
            Graph g = new Graph();

            g.BaseUri = new Uri("http://example.org/AllegroGraph/empty");

            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();

            agraph.SaveGraph(g);

            Graph h = new Graph();

            agraph.LoadGraph(h, "http://example.org/AllegroGraph/empty");
            Assert.True(h.IsEmpty, "Graph should be empty after loading");

            Assert.Equal(g, h);
        }
        public void StorageAllegroGraphDescribe()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();

            String describe = "DESCRIBE <http://example.org/Vehicles/FordFiesta>";

            Object results = agraph.Query(describe);

            if (results is IGraph)
            {
                TestTools.ShowGraph((IGraph)results);
            }
            else
            {
                Assert.Fail("Failed to get a Graph as expected");
            }
        }
        public void StorageAllegroGraphAsk()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();

            String ask = "ASK WHERE { ?s ?p ?o }";

            Object results = agraph.Query(ask);

            if (results is SparqlResultSet)
            {
                TestTools.ShowResults(results);
            }
            else
            {
                Assert.Fail("Failed to get a Result Set as expected");
            }
        }
        public void StorageAllegroGraphSaveLoad()
        {
            Graph g = new Graph();

            FileLoader.Load(g, "resources\\InferenceTest.ttl");
            g.BaseUri = new Uri("http://example.org/AllegroGraphTest");

            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();

            agraph.SaveGraph(g);

            Graph h = new Graph();

            agraph.LoadGraph(h, "http://example.org/AllegroGraphTest");
            Assert.False(h.IsEmpty, "Graph should not be empty after loading");

            Assert.Equal(g, h);
        }
        public void StorageAllegroGraphSaveLoad()
        {
            try
            {
                Graph g = new Graph();
                FileLoader.Load(g, "InferenceTest.ttl");
                g.BaseUri = new Uri("http://example.org/AllegroGraphTest");

                AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875", "test", "unit-test");
                agraph.SaveGraph(g);

                Graph h = new Graph();
                agraph.LoadGraph(h, "http://example.org/AllegroGraphTest");
                Assert.IsFalse(h.IsEmpty, "Graph should not be empty after loading");

                Assert.AreEqual(g, h, "Graphs should have been equal");
            }
            catch (Exception ex)
            {
                TestTools.ReportError("Error", ex, true);
            }
        }
        public void StorageAllegroGraphDeleteTriples()
        {
            try
            {
                Graph g = new Graph();
                FileLoader.Load(g, "InferenceTest.ttl");
                g.BaseUri = new Uri("http://example.org/AllegroGraphTest");

                AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875", "test", "unit-test");
                agraph.SaveGraph(g);

                Console.WriteLine("Graph before deletion");
                TestTools.ShowGraph(g);

                //Delete all Triples about the Ford Fiesta
                agraph.UpdateGraph(g.BaseUri, null, g.GetTriplesWithSubject(new Uri("http://example.org/vehicles/FordFiesta")));

                Graph h = new Graph();
                agraph.LoadGraph(h, g.BaseUri);

                Console.WriteLine("Graph after deletion");
                TestTools.ShowGraph(h);

                Assert.IsFalse(h.IsEmpty, "Graph should not be completely empty");
                Assert.IsTrue(g.HasSubGraph(h), "Graph retrieved with missing Triples should be a sub-graph of the original Graph");
                Assert.IsFalse(g.Equals(h), "Graph retrieved should not be equal to original Graph");

                Object results = agraph.Query("ASK WHERE { GRAPH <http://example.org/AllegroGraphTest> { <http://example.org/vehicles/FordFiesta> ?p ?o } }");
                if (results is SparqlResultSet)
                {
                    Assert.IsFalse(((SparqlResultSet)results).Result, "There should no longer be any triples about the Ford Fiesta present");
                }
            }
            catch (Exception ex)
            {
                TestTools.ReportError("Error", ex, true);
            }
        }
        public void StorageAllegroGraphSaveEmptyGraph2()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();
            Uri graphUri = new Uri("http://example.org/AllegroGraph/empty2");

            Console.WriteLine("Deleting any existing graph");
            agraph.DeleteGraph(graphUri);
            Console.WriteLine("Existing graph deleted");

            // First create a non-empty graph
            Graph g = new Graph();

            g.BaseUri = graphUri;
            g.Assert(g.CreateBlankNode(), g.CreateUriNode("rdf:type"), g.CreateUriNode(new Uri("http://example.org/BNode")));
            Console.WriteLine("Saving non-empty graph");
            agraph.SaveGraph(g);
            Console.WriteLine("Non-empty graph saved");

            Graph h = new Graph();

            agraph.LoadGraph(h, graphUri);
            Assert.False(h.IsEmpty, "Graph should not be empty after loading");

            Assert.Equal(g, h);

            // Now attempt to save an empty graph as well
            g         = new Graph();
            g.BaseUri = graphUri;
            Console.WriteLine("Attempting to save empty graph with same name");
            agraph.SaveGraph(g);
            Console.WriteLine("Empty graph saved");

            h = new Graph();
            agraph.LoadGraph(h, graphUri);
            Assert.True(h.IsEmpty, "Graph should be empty after loading");

            Assert.Equal(g, h);
        }
        public void StorageAllegroGraphSaveEmptyGraph3()
        {
            AllegroGraphConnector agraph = AllegroGraphTests.GetConnection();
            Uri graphUri = null;

            Console.WriteLine("Deleting any existing graph");
            agraph.DeleteGraph(graphUri);
            Console.WriteLine("Existing graph deleted");

            // First create a non-empty graph
            Graph g = new Graph();

            g.BaseUri = graphUri;
            g.Assert(g.CreateBlankNode(), g.CreateUriNode("rdf:type"), g.CreateUriNode(new Uri("http://example.org/BNode")));
            Console.WriteLine("Saving non-empty graph");
            agraph.SaveGraph(g);
            Console.WriteLine("Non-empty graph saved");

            Graph h = new Graph();

            agraph.LoadGraph(h, graphUri);
            Assert.False(h.IsEmpty, "Graph should not be empty after loading");

            Assert.Equal(g, h);

            // Now attempt to overwrite with an empty graph
            g         = new Graph();
            g.BaseUri = graphUri;
            Console.WriteLine("Attempting to save empty graph with same name");
            agraph.SaveGraph(g);
            Console.WriteLine("Empty graph saved");

            h = new Graph();
            agraph.LoadGraph(h, graphUri);

            // Since saving to default graph does not overwrite the graph we've just retrieved must contain the empty graph as a sub-graph
            Assert.True(h.HasSubGraph(g));
        }
        public void StorageAllegroGraphAsk()
        {
            try
            {
                AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875", "test", "unit-test");

                String ask = "ASK WHERE { ?s ?p ?o }";

                Object results = agraph.Query(ask);
                if (results is SparqlResultSet)
                {
                    TestTools.ShowResults(results);
                }
                else
                {
                    Assert.Fail("Failed to get a Result Set as expected");
                }
            }
            catch (Exception ex)
            {
                TestTools.ReportError("Error", ex, true);
            }
        }
        public void StorageAllegroGraphDescribe()
        {
            try
            {
                AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875", "test", "unit-test");

                String describe = "DESCRIBE <http://example.org/Vehicles/FordFiesta>";

                Object results = agraph.Query(describe);
                if (results is IGraph)
                {
                    TestTools.ShowGraph((IGraph)results);
                }
                else
                {
                    Assert.Fail("Failed to get a Graph as expected");
                }
            }
            catch (Exception ex)
            {
                TestTools.ReportError("Error", ex, true);
            }
        }
Exemple #17
0
        public void SparqlViewNativeAllegroGraph()
        {
            try
            {
                AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875", "test", "unit-test");
                NativeTripleStore store = new NativeTripleStore(agraph);

                //Load a Graph into the Store to ensure there is some data for the view to retrieve
                Graph g = new Graph();
                FileLoader.Load(g, "InferenceTest.ttl");
                agraph.SaveGraph(g);

                //Create the SPARQL View
                NativeSparqlView view = new NativeSparqlView("CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(IsLiteral(?o)) }", store);

                Console.WriteLine("SPARQL View Populated");
                TestTools.ShowGraph(view);
                Console.WriteLine();
            }
            catch (RdfQueryException queryEx)
            {
                TestTools.ReportError("Query Error", queryEx, true);
            }
            catch (RdfException ex)
            {
                TestTools.ReportError("Error", ex, true);
            }
        }
 public void ParsingWriteToStoreHandlerAllegroGraph()
 {
     AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875", "test", "unittest");
     this.TestWriteToStoreHandler(agraph);
 }
 public void ParsingWriteToStoreHandlerBNodesAcrossBatchesAllegroGraph()
 {
     AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875", "test", "unittest");
     this.TestWriteToStoreHandlerWithBNodes(agraph);
 }
Exemple #20
0
        static void Main(string[] args)
        {
            String server, catalog, repository;
            char op;

            Console.WriteLine("AllegroGraph Indexer Utility");
            Console.WriteLine("----------------------------");

            Console.Write("Server URI: ");
            server = Console.ReadLine();
            if (server.Equals(String.Empty))
            {
                Console.WriteLine("Aborted - you must enter a valid Server URI");
                return;
            }

            Console.Write("Catalog: ");
            catalog = Console.ReadLine();
            if (catalog.Equals(String.Empty))
            {
                Console.WriteLine("Aborted - you must enter a valid Catalog");
                return;
            }

            Console.Write("Repository: ");
            repository = Console.ReadLine();
            if (repository.Equals(String.Empty))
            {
                Console.WriteLine("Aborted - you must enter a valid Repository");
                return;
            }

            Console.WriteLine("Which operation would you like to perform?");
            Console.WriteLine("i - Index Store (combine indices)");
            Console.WriteLine("I - Index Store (do not combine indices)");
            Console.WriteLine("d - Delete Store");
            op = (char)Console.Read();
            if (op != 'i' && op != 'd' && op != 'I')
            {
                Console.WriteLine("Aborted - not a valid operation");
                return;
            }

            Console.WriteLine();
            Console.Write("Are you sure you want to proceed, this operation may take a very long time? [y/n]");
            ConsoleKeyInfo key = Console.ReadKey();
            Console.WriteLine();
            if (key.KeyChar != 'y' && key.KeyChar != 'Y')
            {
                Console.WriteLine("Aborted - user aborted");
                return;
            }
            Console.WriteLine("Making the request - this may take a very long time...");
            
            try
            {
                AllegroGraphConnector agraph = new AllegroGraphConnector(server, catalog, repository);
                DateTime start = DateTime.Now;
                switch (op)
                {
                    case 'i':
                        agraph.IndexStore(true);
                        break;
                    case 'I':
                        agraph.IndexStore(false);
                        break;
                    case 'd':
                        agraph.DeleteStore(repository);
                        break;
                }
                DateTime end = DateTime.Now;

                Console.WriteLine("Operation Completed - took " + (end - start).ToString());
            }
            catch (RdfStorageException storeEx)
            {
                Console.WriteLine("Error occurred connecting to AllegroGraph:");
                Console.WriteLine(storeEx.Message);
            }
            catch (WebException webEx)
            {
                Console.WriteLine("Error occurred during the Indexing request:");
                Console.WriteLine(webEx.Message);
            }
        }
Exemple #21
0
        /// <summary>
        /// Tries to load a Generic IO Manager based on information from the Configuration Graph
        /// </summary>
        /// <param name="g">Configuration Graph</param>
        /// <param name="objNode">Object Node</param>
        /// <param name="targetType">Target Type</param>
        /// <param name="obj">Output Object</param>
        /// <returns></returns>
        public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj)
        {
            IGenericIOManager manager = null;
            obj = null;

            String server, user, pwd, store;
            bool isAsync;

            Object temp;
            INode storeObj;

            //Create the URI Nodes we're going to use to search for things
            INode propServer = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServer),
                  propDb = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDatabase),
                  propStore = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyStore),
                  propAsync = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyAsync);

            switch (targetType.FullName)
            {
                case AllegroGraph:
                    //Get the Server, Catalog and Store
                    server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer);
                    if (server == null) return false;
                    String catalog = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyCatalog));
                    store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore);
                    if (store == null) return false;

                    //Get User Credentials
                    ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd);

                    if (user != null && pwd != null)
                    {
                        manager = new AllegroGraphConnector(server, catalog, store, user, pwd);
                    }
                    else
                    {
                        manager = new AllegroGraphConnector(server, catalog, store);
                    }
                    break;

                case DatasetFile:
                    //Get the Filename and whether the loading should be done asynchronously
                    String file = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyFromFile));
                    if (file == null) return false;
                    file = ConfigurationLoader.ResolvePath(file);
                    isAsync = ConfigurationLoader.GetConfigurationBoolean(g, objNode, propAsync, false);
                    manager = new DatasetFileManager(file, isAsync);
                    break;

                case Dydra:
                    //Get the Account Name and Store
                    String account = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyCatalog));
                    if (account == null) return false;
                    store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore);
                    if (store == null) return false;

                    //Get User Credentials
                    ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd);

                    if (user != null)
                    {
                        manager = new DydraConnector(account, store, user);
                    }
                    else
                    {
                        manager = new DydraConnector(account, store);
                    }
                    break;

                case FourStore:
                    //Get the Server and whether Updates are enabled
                    server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer);
                    if (server == null) return false;
                    bool enableUpdates = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyEnableUpdates), true);
                    manager = new FourStoreConnector(server, enableUpdates);
                    break;

                case Fuseki:
                    //Get the Server URI
                    server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer);
                    if (server == null) return false;
                    manager = new FusekiConnector(server);
                    break;

                case InMemory:
                    //Get the Dataset/Store
                    INode datasetObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUsingDataset));
                    if (datasetObj != null)
                    {
                        temp = ConfigurationLoader.LoadObject(g, datasetObj);
                        if (temp is ISparqlDataset)
                        {
                            manager = new InMemoryManager((ISparqlDataset)temp);
                        }
                        else
                        {
                            throw new DotNetRdfConfigurationException("Unable to load the In-Memory Manager identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:usingDataset property points to an Object that cannot be loaded as an object which implements the ISparqlDataset interface");
                        }
                    }
                    else
                    {
                        //If no dnr:usingDataset try dnr:usingStore instead
                        storeObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUsingStore));
                        if (storeObj != null)
                        {
                            temp = ConfigurationLoader.LoadObject(g, storeObj);
                            if (temp is IInMemoryQueryableStore)
                            {
                                manager = new InMemoryManager((IInMemoryQueryableStore)temp);
                            }
                            else
                            {
                                throw new DotNetRdfConfigurationException("Unable to load the In-Memory Manager identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:usingStore property points to an Object that cannot be loaded as an object which implements the IInMemoryQueryableStore interface");
                            }
                        }
                        else
                        {
                            //If no dnr:usingStore either then create a new empty store
                            manager = new InMemoryManager();
                        }
                    }
                    break;

                case Joseki:
                    //Get the Query and Update URIs
                    server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer);
                    if (server == null) return false;
                    String queryService = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyQueryPath));
                    if (queryService == null) return false;
                    String updateService = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUpdatePath));
                    if (updateService == null)
                    {
                        manager = new JosekiConnector(server, queryService);
                    }
                    else
                    {
                        manager = new JosekiConnector(server, queryService, updateService);
                    }
                    break;

                case ReadOnly:
                    //Get the actual Manager we are wrapping
                    storeObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyGenericManager));
                    temp = ConfigurationLoader.LoadObject(g, storeObj);
                    if (temp is IGenericIOManager)
                    {
                        manager = new ReadOnlyConnector((IGenericIOManager)temp);
                    }
                    else
                    {
                        throw new DotNetRdfConfigurationException("Unable to load the Read-Only Connector identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:genericManager property points to an Object which cannot be loaded as an object which implements the required IGenericIOManager interface");
                    }
                    break;

                case ReadOnlyQueryable:
                    //Get the actual Manager we are wrapping
                    storeObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyGenericManager));
                    temp = ConfigurationLoader.LoadObject(g, storeObj);
                    if (temp is IQueryableGenericIOManager)
                    {
                        manager = new QueryableReadOnlyConnector((IQueryableGenericIOManager)temp);
                    }
                    else
                    {
                        throw new DotNetRdfConfigurationException("Unable to load the Queryable Read-Only Connector identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:genericManager property points to an Object which cannot be loaded as an object which implements the required IQueryableGenericIOManager interface");
                    }
                    break;

                case Sesame:
                case SesameV5:
                case SesameV6:
                    //Get the Server and Store ID
                    server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer);
                    if (server == null) return false;
                    store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore);
                    if (store == null) return false;
                    ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd);
                    if (user != null && pwd != null)
                    {
                        manager = (IGenericIOManager)Activator.CreateInstance(targetType, new Object[] { server, store, user, pwd });
                    }
                    else
                    {
                        manager = (IGenericIOManager)Activator.CreateInstance(targetType, new Object[] { server, store });
                    }
                    break;

                case Sparql:
                    //Get the Endpoint URI or the Endpoint
                    server = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyEndpointUri));

                    //What's the load mode?
                    String loadModeRaw = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyLoadMode));
                    SparqlConnectorLoadMethod loadMode = SparqlConnectorLoadMethod.Construct;
                    if (loadModeRaw != null)
                    {
                        try
                        {
#if SILVERLIGHT
                            loadMode = (SparqlConnectorLoadMethod)Enum.Parse(typeof(SparqlConnectorLoadMethod), loadModeRaw, false);
#else
                            loadMode = (SparqlConnectorLoadMethod)Enum.Parse(typeof(SparqlConnectorLoadMethod), loadModeRaw);
#endif
                        }
                        catch
                        {
                            throw new DotNetRdfConfigurationException("Unable to load the SparqlConnector identified by the Node '" + objNode.ToString() + "' as the value given for the property dnr:loadMode is not valid");
                        }
                    }

                    if (server == null)
                    {
                        INode endpointObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyEndpoint));
                        if (endpointObj == null) return false;
                        temp = ConfigurationLoader.LoadObject(g, endpointObj);
                        if (temp is SparqlRemoteEndpoint)
                        {
                            manager = new SparqlConnector((SparqlRemoteEndpoint)temp, loadMode);
                        }
                        else
                        {
                            throw new DotNetRdfConfigurationException("Unable to load the SparqlConnector identified by the Node '" + objNode.ToString() + "' as the value given for the property dnr:endpoint points to an Object which cannot be loaded as an object which is of the type SparqlRemoteEndpoint");
                        }
                    }
                    else
                    {
                        //Are there any Named/Default Graph URIs
                        IEnumerable<Uri> defGraphs = from def in ConfigurationLoader.GetConfigurationData(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultGraphUri))
                                                     where def.NodeType == NodeType.Uri
                                                     select ((IUriNode)def).Uri;
                        IEnumerable<Uri> namedGraphs = from named in ConfigurationLoader.GetConfigurationData(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyNamedGraphUri))
                                                       where named.NodeType == NodeType.Uri
                                                       select ((IUriNode)named).Uri;
                        if (defGraphs.Any() || namedGraphs.Any())
                        {
                            manager = new SparqlConnector(new SparqlRemoteEndpoint(new Uri(server), defGraphs, namedGraphs), loadMode);
                        }
                        else
                        {
                            manager = new SparqlConnector(new Uri(server), loadMode);
                        }                        
                    }
                    break;

                case SparqlHttpProtocol:
                    //Get the Service URI
                    server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer);
                    if (server == null) return false;
                    manager = new SparqlHttpProtocolConnector(new Uri(server));
                    break;

                case Stardog:
                    //Get the Server and Store
                    server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer);
                    if (server == null) return false;
                    store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore);
                    if (store == null) return false;

                    //Get User Credentials
                    ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd);

                    //Get Reasoning Mode
                    StardogReasoningMode reasoning = StardogReasoningMode.None;
                    String mode = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyLoadMode));
                    if (mode != null)
                    {
                        try
                        {
                            reasoning = (StardogReasoningMode)Enum.Parse(typeof(StardogReasoningMode), mode);
                        }
                        catch
                        {
                            reasoning = StardogReasoningMode.None;
                        }
                    }

                    if (user != null && pwd != null)
                    {
                        manager = new StardogConnector(server, store, reasoning, user, pwd);
                    }
                    else
                    {
                        manager = new StardogConnector(server, store, reasoning);
                    }
                    break;

                case Talis:
                    //Get the Store Name and User credentials
                    store = ConfigurationLoader.GetConfigurationString(g, objNode, propStore);
                    if (store == null) return false;
                    ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd);
                    if (user != null && pwd != null)
                    {
                        manager = new TalisPlatformConnector(store, user, pwd);
                    }
                    else
                    {
                        manager = new TalisPlatformConnector(store);
                    }
                    break;
            }

            obj = manager;
            return (manager != null);
        }
        public static void Main(String[] args)
        {
            StreamWriter output  = new StreamWriter("AllegroGraphTest.txt");
            Console.SetOut(output);
            try
            {
                Console.WriteLine("## AllegroGraph Test");
                Console.WriteLine();

                //Load the Graph we want to use as a Test
                Graph g = new Graph();
                TurtleParser ttlparser = new TurtleParser();
                ttlparser.Load(g, "InferenceTest.ttl");
                Console.WriteLine("Test Graph contains the following Triples:");
                ShowGraph(g);
                Console.WriteLine();

                //Load another Graph
                Graph h = new Graph();
                h.BaseUri = new Uri("http://example.org/test");
                Notation3Parser n3parser = new Notation3Parser();
                n3parser.Load(h, "test.n3");
                Console.WriteLine("Second Test Graph contains the following Triples:");
                ShowGraph(h);
                Console.WriteLine();

                Console.WriteLine("Trying to create a test store in the test catalog");
                AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875/", "test", "test");
                Console.WriteLine("Store Created OK");
                Console.WriteLine();

                Console.WriteLine("Trying to add data to the Store");
                agraph.SaveGraph(g);
                agraph.SaveGraph(h);
                Console.WriteLine("Saved OK");
                Console.WriteLine();

                Console.WriteLine("Trying to load data from the Store");
                Graph i = new Graph();
                agraph.LoadGraph(i, String.Empty);
                ShowGraph(i);
                Console.WriteLine();
                i = new Graph();
                agraph.LoadGraph(i, new Uri("http://example.org/test"));
                ShowGraph(i);
                Console.WriteLine("Loaded OK");
                Console.WriteLine();

                Console.WriteLine("Trying to update data in the Store");
                List<Triple> toRemove = g.GetTriplesWithPredicate(g.CreateUriNode("rdf:type")).ToList();
                Triple toAdd = new Triple(g.CreateUriNode(new Uri("http://example.org/")), g.CreateUriNode("rdf:type"), g.CreateLiteralNode("Added Triple Test"));
                agraph.UpdateGraph(String.Empty, new List<Triple>() { toAdd }, toRemove);
                Console.WriteLine("Updated OK");
                Console.WriteLine();

                Console.WriteLine("Trying a SPARQL ASK query against the store");
                Object results = agraph.Query("ASK WHERE {?s ?p ?o}");
                Console.WriteLine("Got results OK");
                ShowResults(results);
                Console.WriteLine();

                Console.WriteLine("Trying a SPARQL SELECT query against the store");
                results = agraph.Query("SELECT * WHERE {?s ?p ?o}");
                Console.WriteLine("Got results OK");
                ShowResults(results);
                Console.WriteLine();

            }
            catch (RdfStorageException storeEx)
            {
                reportError(output, "RDF Storage Error", storeEx);
            }
            catch (RdfParseException parseEx)
            {
                reportError(output, "RDF Parsing Error", parseEx);
            }
            catch (RdfQueryException queryEx)
            {
                reportError(output, "RDF Query Error", queryEx);
            }
            catch (RdfException rdfEx)
            {
                reportError(output, "RDF Error", rdfEx);
            }
            catch (WebException webEx)
            {
                reportError(output, "HTTP Error", webEx);
            }
            catch (Exception ex)
            {
                reportError(output, "Error", ex);
            }
            finally
            {
                output.Close();
            }
        }