private void ParsingStoreHandlerTriGExplicitActual() { this.EnsureTestData("test.trig"); TripleStore store = new TripleStore(); TriGParser parser = new TriGParser(); parser.Load(new StoreHandler(store), "test.trig"); Assert.IsTrue(store.HasGraph(new Uri("http://www.dotnetrdf.org/configuration#")), "Configuration Vocab Graph should have been parsed from Dataset"); Graph configOrig = new Graph(); configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); IGraph config = store[new Uri("http://www.dotnetrdf.org/configuration#")]; Assert.AreEqual(configOrig, config, "Configuration Vocab Graphs should have been equal"); Assert.IsTrue(store.HasGraph(new Uri("http://www.dotnetrdf.org/leviathan#")), "Leviathan Function Library Graph should have been parsed from Dataset"); Graph lvnOrig = new Graph(); lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl"); IGraph lvn = store[new Uri("http://www.dotnetrdf.org/leviathan#")]; Assert.AreEqual(lvnOrig, lvn, "Leviathan Function Library Graphs should have been equal"); }
private Uri ReadQuadFormat(TextReader reader, Uri graph, RdfSerializationFormat format, bool update) { using (VirtuosoManager manager = new VirtuosoManager(CreateConnectionString())) { using (VDS.RDF.ThreadSafeTripleStore store = new VDS.RDF.ThreadSafeTripleStore()) { VDS.RDF.Parsing.TriGParser parser = new TriGParser(); parser.Load(store, reader); foreach (var g in store.Graphs) { if (update) { manager.UpdateGraph(g.BaseUri, g.Triples, new Triple[] { }); } else { manager.SaveGraph(g); } } } } return(graph); }
public void ParsingStoreHandlerTriGExplicit() { this.EnsureTestData("test.trig"); TripleStore store = new TripleStore(); TriGParser parser = new TriGParser(); parser.Load(new StoreHandler(store), "test.trig"); Assert.True(store.HasGraph(new Uri("http://graphs/1")), "Configuration Vocab Graph should have been parsed from Dataset"); Graph configOrig = new Graph(); configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); IGraph config = store[new Uri("http://graphs/1")]; Assert.Equal(configOrig, config); Assert.True(store.HasGraph(new Uri("http://graphs/2")), "Leviathan Function Library Graph should have been parsed from Dataset"); Graph lvnOrig = new Graph(); lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl"); IGraph lvn = store[new Uri("http://graphs/2")]; Assert.Equal(lvnOrig, lvn); }
public static Object LoadFromFile(java.io.File f, string baseUri, org.openrdf.rio.RDFFormat rdff) { Object obj; if (rdff == dotSesameFormats.RDFFormat.N3) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } FileLoader.Load((IGraph)obj, f.getPath(), new Notation3Parser()); } else if (rdff == dotSesameFormats.RDFFormat.NTRIPLES) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } FileLoader.Load((IGraph)obj, f.getPath(), new NTriplesParser()); } else if (rdff == dotSesameFormats.RDFFormat.RDFXML) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } FileLoader.Load((IGraph)obj, f.getPath(), new RdfXmlParser()); } else if (rdff == dotSesameFormats.RDFFormat.TRIG) { obj = new TripleStore(); TriGParser trig = new TriGParser(); trig.Load((ITripleStore)obj, new StreamParams(f.getPath())); } else if (rdff == dotSesameFormats.RDFFormat.TRIX) { obj = new TripleStore(); TriXParser trix = new TriXParser(); trix.Load((ITripleStore)obj, new StreamParams(f.getPath())); } else if (rdff == dotSesameFormats.RDFFormat.TURTLE) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } FileLoader.Load((IGraph)obj, f.getPath(), new TurtleParser()); } else { throw new RdfParserSelectionException("The given Input Format is not supported by dotNetRDF"); } return(obj); }
protected void ParsingStoreHandlerBlankNodesTriGActual() { EnsureTestData("test-bnodes.trig"); TriGParser parser = new TriGParser(); TripleStore store = new TripleStore(); parser.Load(store, "test-bnodes.trig"); EnsureTestResults(store); }
private void EnsureTestData(String testFile) { if (!File.Exists(testFile)) { TriGParser parser = new TriGParser(); TripleStore store = new TripleStore(); parser.Load(store, new StringReader(TestFragment)); store.SaveToFile(testFile); } }
private IGraph LoadTestData(TripleStore ts) { TriGParser trigparser = new TriGParser(); trigparser.Load(ts, Path.Combine("..", "..", "..", "..", "test-data", "sample-metadata", "20200218T1100-tracking-metadata.trig")); var g = ts.Graphs[new Uri("http://industrialinference.com/migrations/0.1#migrations")]; return(g); }
private void ParsingStoreHandlerTriGCountingActual() { this.EnsureTestData("test.trig"); TriGParser parser = new TriGParser(); StoreCountHandler counter = new StoreCountHandler(); parser.Load(counter, "test.trig"); Graph configOrig = new Graph(); configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); Graph lvnOrig = new Graph(); lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl"); Assert.AreEqual(2, counter.GraphCount, "Expected 2 Graphs to be counted"); Assert.AreEqual(configOrig.Triples.Count + lvnOrig.Triples.Count, counter.TripleCount, "Expected Triple Count to be sum of Triple Counts in two input Graphs"); }
public void ParsingStoreHandlerTriGCounting() { this.EnsureTestData("test.trig"); TriGParser parser = new TriGParser(); StoreCountHandler counter = new StoreCountHandler(); parser.Load(counter, "test.trig"); Graph configOrig = new Graph(); configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); Graph lvnOrig = new Graph(); lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl"); Assert.Equal(2, counter.GraphCount); Assert.Equal(configOrig.Triples.Count + lvnOrig.Triples.Count, counter.TripleCount); }