Ejemplo n.º 1
0
 private Task DelayedDataRead(FileInfo srcFile, IRdfData rdf, int id)
 {
     return(new Task(() =>
     {
         var g = rdf.GetSelfGraph(rdf.BlankSelf($"g{id}"));
         using var rd = srcFile.OpenText();
         NTripleFile.Read(g, rd).Wait();
     }, TaskCreationOptions.LongRunning));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize the <see cref="AppData"/> singleton.
        /// </summary>
        /// <exception cref="FactoryAlreadyInitialized"></exception>
        public static IRdfData Init(IRdfData data)
        {
            if (_instance != null && _instance != data)
            {
                throw new FactoryAlreadyInitialized();
            }

            _instance = data;
            return(_instance);
        }
Ejemplo n.º 3
0
        public RdfDataFetcher(IRdfData rdf)
        {
            _rdf        = rdf;
            BackingFile = _rdf.Uri("sys:/backingFile");

            if (!_rdf.Stats().Mappings.Any(x => x is FileInfoNodeMap))
            {
                throw new Exception(
                          $"Must include node map {nameof(FileInfoNodeMap)}");
            }
        }
Ejemplo n.º 4
0
        private void LoadSettings(IRdfData rdf)
        {
            var baseSettings = rdf.GetBlankGraph("baseSettings");

            new NTripleFile(Files.TestData.Settings)
            .Read(baseSettings).Wait();

            var debugSettings = rdf.GetBlankGraph("debugSettings");

            new NTripleFile(Files.TestData.SettingsDebug)
            .Read(debugSettings).Wait();
        }
Ejemplo n.º 5
0
        /// <summary>Create graph with Id and data from other graphs</summary>
        public Graph(IRdfData rdf,
                     Node <UriOrBlank> id,
                     IEnumerable <Node <UriOrBlank> > other)
        {
            _rdf = rdf;

            Id    = id;
            Other = other.Distinct()
                    .Where(x => x != id)
                    .ToArray();

            _includedQuads = rdf.GraphData(Other);
        }
Ejemplo n.º 6
0
        private Node <UriOrBlank> LoadSampleData(IRdfData data, Node <UriOrBlank> g)
        {
            var me   = data.Uri("x:me");
            var link = data.Uri("a:linkTo");
            var name = data.Uri("a:name");

            data.Update.From(g)
            .For(me)
            .With(link)
            .Add(data.Uri("http://my.blog"))
            .Then()
            .With(name).Add(data.New("My Name"));

            return(g);
        }
Ejemplo n.º 7
0
        public void CreateRdfStore()
        {
            //create default thread-locked version.
            IRdfData rdf = RdfDataFactory.CreateDefault();

            Assert.IsTrue(rdf is RdfDataThreadLock);

            //create basic version.
            rdf = RdfDataFactory.CreateNoLock();
            Assert.IsTrue(rdf is RdfData);

            //setup app singleton
            RdfDataFactory.Init(RdfDataFactory.CreateNoLock());

            //use singleton
            rdf = RdfDataFactory.AppData;

            Assert.IsNotNull(rdf);
        }
Ejemplo n.º 8
0
 /// <summary>Get new blank graph; has all the current data</summary>
 public static Graph GetBlankGraph(this IRdfData store, string?id = null)
 => store.GetGraph(store.BlankSelf(id), store.GraphIds);
Ejemplo n.º 9
0
 /// <summary>
 /// Create new RDF builder for fluent updates.
 /// </summary>
 public RdfBuilder(IRdfData data)
 {
     _owner = data;
 }
Ejemplo n.º 10
0
 /// <summary>Assert / add a quad.</summary>
 public static IRdfData Assert(this IRdfData rdf, Node <UriOrBlank> graph,
                               Node <UriOrBlank> sub,
                               UriNode predicate, Node val)
 => rdf.Assert(graph, sub, predicate, val, out _);
Ejemplo n.º 11
0
 /// <summary>Retract a set of quads</summary>
 /// <returns>The number of quads actually removed</returns>
 public static int Retract(this IRdfData self, IEnumerable <Quad> quads)
 => self.Retract(quads.ToArray());
Ejemplo n.º 12
0
 /// <summary>Get default graph with all data</summary>
 public static Graph GetDefault(this IRdfData store)
 => store.GetGraph(store.Default, store.GraphIds);
Ejemplo n.º 13
0
 /// <summary>Get system graph with all data</summary>
 public static Graph GetSystem(this IRdfData store)
 => store.GetGraph(store.System, store.GraphIds);
Ejemplo n.º 14
0
 /// <summary>
 /// A set of quads ordered by graph.
 /// Includes data from the specified additional graph(s)
 /// </summary>
 public static Graph GetGraph(this IRdfData store,
                              Node <UriOrBlank> graphId, IEnumerable <Node <UriOrBlank> > other)
 => store.GetGraph(graphId, other.ToArray());
Ejemplo n.º 15
0
 /// <summary>Get self graph: graph contains only its own quads</summary>
 public static Graph GetSelfGraph(this IRdfData rdf, string graphUri)
 => rdf.GetGraph(rdf.Uri(graphUri), Enumerable.Empty <Node <UriOrBlank> >());
Ejemplo n.º 16
0
 /// <summary>Get self graph: graph contains only its own quads</summary>
 public static Graph GetSelfGraph(this IRdfData store, Node <UriOrBlank> graphId)
 => store.GetGraph(graphId, Enumerable.Empty <Node <UriOrBlank> >());
Ejemplo n.º 17
0
 /// <summary>Get full graph: graph contains all current quads.</summary>
 public static Graph GetFullGraph(this IRdfData store, Node <UriOrBlank> graphUri)
 => store.GetGraph(graphUri, store.GraphIds);
Ejemplo n.º 18
0
 /// <summary>Get full graph: graph contains all current quads.</summary>
 public static Graph GetFullGraph(this IRdfData rdf, string graphUri)
 => rdf.GetGraph(rdf.Uri(graphUri), rdf.GraphIds);