Esempio n. 1
0
        private static void GetRecord(string leiCode, TextWriter output, AllegroGraphConnector allegroGraphConnector)
        {
            var g = new Graph();

            allegroGraphConnector.LoadGraph(g, "graph://lei.info/" + leiCode);
            var ts = new TripleStore();

            ts.Add(g);
            var nqw = new NQuadsWriter();
            var s   = VDS.RDF.Writing.StringWriter.Write(ts, nqw);

            output.Write(s);
            output.Flush();
            ts.Remove(g.BaseUri);
            g.Clear();
            ts.Dispose();
            g.Dispose();
        }
 public void ShutDown()
 {
     _logger.LogInformation("[CONFIG] Shutting down the triple store repository...");
     _repository.Dispose();
 }
 /// <summary>
 /// Disposes of the Manager.
 /// </summary>
 public override void Dispose()
 {
     _store.Dispose();
 }
Esempio n. 4
0
 public void Dispose()
 {
     _updateProcessor.Discard();
     _store.Dispose();
 }
Esempio n. 5
0
 /// <summary>
 /// Closes the store. It is not usable after this call.
 /// </summary>
 public override void Dispose()
 {
     IsReady = false;
     _updateProcessor.Discard();
     _store.Dispose();
 }
Esempio n. 6
0
        public void Dispose()
        {
            //Create all of the directories required for the file
            var f = new FileInfo(_outputPath);

            f.Directory.Create();

            if (this._outputFormat == ERdfFormat.RdfXml)
            {
                using (XmlTextWriter xmlWriter = new XmlTextWriter(_outputPath, new UTF8Encoding(false)))
                //Set encoding
                {
                    _output.Save(xmlWriter);
                }
            }
            else if (this._outputFormat == ERdfFormat.TriG)
            {
                string fileNameAsTrig = GetFilePathBasedOnFormat();
                var    outparams      = new StreamParams(fileNameAsTrig);
                outparams.Encoding = Encoding.UTF8;
                var writer = new TriGWriter();

                if (_store == null)
                {
                    var g = GetXmlDocumentAsGraph();
                    _store = new TripleStore();
                    _store.Add(g, true);
                }

                writer.Save(_store, outparams);
            }
            else if (this._outputFormat == ERdfFormat.Turtle)
            {
                var    g = GetXmlDocumentAsGraph();
                string filePathForFormat = GetFilePathBasedOnFormat();
                var    writer            = new TurtleWriter(TurtleSyntax.W3C);
                writer.Save(g, filePathForFormat);
            }
            else if (this._outputFormat == ERdfFormat.NTriples)
            {
                var    g = GetXmlDocumentAsGraph();
                string filePathForFormat = GetFilePathBasedOnFormat();
                var    writer            = new NTriplesWriter();
                writer.Save(g, filePathForFormat);
            }
            else if (this._outputFormat == ERdfFormat.N3)
            {
                var    g = GetXmlDocumentAsGraph();
                string filePathForFormat = GetFilePathBasedOnFormat();
                var    writer            = new Notation3Writer();
                writer.Save(g, filePathForFormat);
            }
            else if (this._outputFormat == ERdfFormat.NQuads)
            {
                string filePathForFormat = GetFilePathBasedOnFormat();
                var    outparams         = new StreamParams(filePathForFormat);
                outparams.Encoding = Encoding.UTF8;

                if (_store == null)
                {
                    var g = GetXmlDocumentAsGraph();
                    _store = new TripleStore();
                    _store.Add(g, true);
                }

                var writer = new NQuadsWriter();
                writer.Save(_store, outparams);
            }

            //make sure it's not null - can happen if no graphs have yet to be asserted!!
            if (_store != null)
            {
                foreach (var graph in _store.Graphs)
                {
                    graph.Dispose();
                }
                _store.Dispose();
                GC.Collect();
            }
        }