static int Main(string[] args) { Options options; try { var parser = new OptionsParser(); options = parser.Parse(args); } catch (ArgumentException ex) { Console.Error.WriteLine(ex.Message); return(-1); } EnsureRepository(options.RepoDirectory); var repo = new DynamicFileStore(options.RepoDirectory, 1000); var graph = new Graph { BaseUri = options.GraphUri }; graph.LoadFromFile(options.ImportFile); var sw = Stopwatch.StartNew(); repo.Assert(graph); repo.Flush(); sw.Stop(); Console.WriteLine($"Imported {graph.Triples.Count} triples in {sw.ElapsedMilliseconds} ms"); return(0); }
private void ReadConfiguration() { ConfigGraph.NamespaceMap.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#")); ConfigGraph.NamespaceMap.AddNamespace("q", new Uri("http://networkedplanet.com/ns/quince/")); ConfigGraph.NamespaceMap.AddNamespace("sd", new Uri("http://www.w3.org/ns/sparql-service-description#")); RepositoryConfigurationNode = GetRepositoryNode(ConfigGraph); if (RepositoryConfigurationNode == null) { Log.LogError("Could not find a repository node in the configuration"); throw new RepositoryConfigurationException("Could not find a repository node in the configuration."); } QuinceStore = new DynamicFileStore(_repositoryPath, _cacheThreshold); }
public void CanGenerateRdfFromRepository() { var repoDir = Path.Combine(_tmpDir, "quince"); Directory.CreateDirectory(repoDir); var repo = new DynamicFileStore(repoDir, 100); var defaultGraph = new Graph(); var parser = new NQuadsParser(); using (var reader = File.OpenText(Path.Join("data", "test1.nq"))) { parser.Parse(reader, t => repo.Assert(t.Subject, t.Predicate, t.Object, t.GraphUri), defaultGraph); } repo.Flush(); var mockQuinceFactory = new Mock <IQuinceStoreFactory>(); mockQuinceFactory.Setup(x => x.MakeQuinceStore(It.IsAny <string>())).Returns(repo); var rdfGeneratorMock = new Mock <ITripleCollectionHandler>(); rdfGeneratorMock.Setup(x => x.HandleTripleCollection(It.Is <IList <Triple> >(c => c.All(t => (t.Subject as IUriNode).Uri.ToString().Equals("http://example.org/id/resource/s/s0"))))).Verifiable(); var fileGeneratorFactoryMock = new Mock <IFileGeneratorFactory>(); fileGeneratorFactoryMock.Setup(x => x.MakeRdfFileGenerator(It.IsAny <IResourceFileMapper>(), It.IsAny <IEnumerable <Uri> >(), It.IsAny <IProgressLog>(), It.IsAny <int>())).Returns(rdfGeneratorMock.Object); var rdfResourceFileMapper = new ResourceFileMapper( new ResourceMapEntry(new Uri("http://example.org/id/"), "data")); var htmlResourceFileMapper = new ResourceFileMapper( new ResourceMapEntry(new Uri("http://example.org/id/"), "doc")); var ddRepository = new DataDockRepository( _tmpDir, new Uri("http://example.org/"), new MockProgressLog(), mockQuinceFactory.Object, fileGeneratorFactoryMock.Object, rdfResourceFileMapper, htmlResourceFileMapper, _uriService); ddRepository.GenerateRdf(new[] { new Uri("http://example.org/g/g1") }); // Should be invoked to generate files for subject IRIs rdfGeneratorMock.Verify(x => x.HandleTripleCollection(It.Is <IList <Triple> >(c => c.All(t => (t.Subject as IUriNode).Uri.ToString().Equals("http://example.org/id/resource/s/s0")))), Times.Once); // Should not be invoked to generate files for object IRIs rdfGeneratorMock.Verify(x => x.HandleTripleCollection(It.Is <IList <Triple> >( c => c.Any(t => (t.Subject as IUriNode).Uri.ToString().Equals("http://example.org/id/resource/o/o0")))), Times.Never); }
public RepositoryFixture(string prefix) { _baseDirectory = Directory.CreateDirectory("tmp\\" + prefix + "-" + DateTime.UtcNow.Ticks); Store = new DynamicFileStore(_baseDirectory.FullName, 1000, 10); }