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 void EnsureTestData(String testFile)
        {
            if (!File.Exists(testFile))
            {
                TriGParser parser = new TriGParser();
                TripleStore store = new TripleStore();
                parser.Load(store, new TextReaderParams(new StringReader(TestFragment)));

                store.SaveToFile(testFile);
            }
        }
        private void EnsureTestData(String testFile)
        {
            if (!File.Exists(testFile))
            {
                TripleStore store = new TripleStore();
                Graph       g     = new Graph();
                g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                store.Add(g);
                Graph h = new Graph();
                h.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.LeviathanFunctionLibrary.ttl");
                store.Add(h);

                store.SaveToFile(testFile);
            }
        }
        private void EnsureTestData(String testFile)
        {
            if (!File.Exists(testFile))
            {
                TripleStore store = new TripleStore();
                Graph g = new Graph();
                g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                store.Add(g);
                Graph h = new Graph();
                h.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.Functions.LeviathanFunctionLibrary.ttl");
                store.Add(h);

                store.SaveToFile(testFile);
            }
        }
Esempio n. 5
0
        public void SparqlUpdateLoadQuads5()
        {
            var tripleStore = new TripleStore();

            tripleStore.LoadFromFile(@"resources\core-421\test.nq");
            Assert.Equal(3, tripleStore.Triples.Count());
            Assert.Equal(2, tripleStore.Graphs.Count);

            tripleStore.SaveToFile("core-421.nq", new NQuadsWriter());

            var newStore = new TripleStore();

            newStore.LoadFromFile("core-421.nq", new NQuadsParser());

            Assert.Equal(3, newStore.Triples.Count());
            Assert.Equal(2, newStore.Graphs.Count);
        }
Esempio n. 6
0
        public void SparqlUpdateLoadQuads5()
        {
            var tripleStore = new TripleStore();

            tripleStore.LoadFromFile(@"resources\core-421\test.nq");
            Assert.That(tripleStore.Triples.ToList(), Has.Count.EqualTo(3));
            Assert.That(tripleStore.Graphs, Has.Count.EqualTo(2));

            tripleStore.SaveToFile("core-421.nq", new NQuadsWriter());

            var newStore = new TripleStore();

            newStore.LoadFromFile("core-421.nq", new NQuadsParser());

            Assert.That(newStore.Triples.ToList(), Has.Count.EqualTo(3));
            Assert.That(newStore.Graphs, Has.Count.EqualTo(2));
        }
Esempio n. 7
0
        public void SparqlUpdateLoadQuads3()
        {
            var tripleStore             = new TripleStore();
            SparqlUpdateCommandSet cmds = this._parser.ParseFromFile(@"resources\core-421\test3.ru");

            tripleStore.ExecuteUpdate(cmds);
            Assert.Equal(3, tripleStore.Triples.Count());
            Assert.Equal(3, tripleStore.Graphs.Count);

            tripleStore.SaveToFile("core-421.nq", new NQuadsWriter());

            var newStore = new TripleStore();

            newStore.LoadFromFile("core-421.nq", new NQuadsParser());

            Assert.Equal(3, newStore.Triples.Count());
            Assert.Equal(2, newStore.Graphs.Count);
        }
Esempio n. 8
0
        public void SparqlUpdateLoadQuads2()
        {
            var tripleStore             = new TripleStore();
            SparqlUpdateCommandSet cmds = this._parser.ParseFromFile(@"resources\core-421\test2.ru");

            tripleStore.ExecuteUpdate(cmds);
            Assert.That(tripleStore.Triples.ToList(), Has.Count.EqualTo(3));
            Assert.That(tripleStore.Graphs, Has.Count.EqualTo(3));

            tripleStore.SaveToFile("core-421.nq", new NQuadsWriter());

            var newStore = new TripleStore();

            newStore.LoadFromFile("core-421.nq", new NQuadsParser());

            Assert.That(newStore.Triples.ToList(), Has.Count.EqualTo(3));
            Assert.That(newStore.Graphs, Has.Count.EqualTo(2));
        }
Esempio n. 9
0
        public void SparqlUpdateLoadQuads4()
        {
            var tripleStore = new TripleStore();

            String g1 = Path.GetFullPath(@"resources\core-421\g1.nq").Replace('\\', '/');
            String g2 = Path.GetFullPath(@"resources\core-421\g2.nq").Replace('\\', '/');

            tripleStore.ExecuteUpdate("LOAD <file:///" + g1 + "> into graph <http://test.org/user>");
            tripleStore.ExecuteUpdate("LOAD <file:///" + g2 + "> into graph <http://test.org/prodList/>");
            Assert.Equal(3, tripleStore.Triples.Count());
            Assert.Equal(3, tripleStore.Graphs.Count);

            tripleStore.SaveToFile("core-421.nq", new NQuadsWriter());

            var newStore = new TripleStore();

            newStore.LoadFromFile("core-421.nq", new NQuadsParser());

            Assert.Equal(3, newStore.Triples.Count());
            Assert.Equal(2, newStore.Graphs.Count);
        }
Esempio n. 10
0
    static void Main()
    {
        ITripleStore store = new TripleStore();

        store.LoadFromFile("input.trig");
        var factory = new EntityContextFactory();

        // it is also possible to add fluent/attribute mappings separately
        factory.WithMappings(mb => mb.FromAssemblyOf <IPerson>());

        // this is necessary to tell where entities' data is stored in named graphs
        // see the input.trig file to find out how it does that
        factory.WithMetaGraphUri(new Uri("http://romanticweb.net/samples"));

        // this API bound to change in the future so that custom
        // namespaces can be added easily
        factory.WithOntology(new DefaultOntologiesProvider(BuiltInOntologies.DCTerms |
                                                           BuiltInOntologies.FOAF));

        factory.WithDotNetRDF(store);

        var context = factory.CreateContext();

        foreach (var person in context.AsQueryable <IPerson>().Where(p => p.Name != "Karol"))
        {
            var pubId = "http://romanticweb.net/samples/publication/" + Guid.NewGuid();
            var pub   = context.Create <IPublication>(pubId);
            pub.Title = string.Format("Publication about RDF by {0} {1}",
                                      person.Name, person.LastName);
            pub.DatePublished = DateTime.Now;

            person.Publications.Add(pub);
        }

        context.Commit();

        store.SaveToFile("output.trig", new TriGWriter());
    }