private void Replace(IGraph graph, IUriNode parent, Uri predicate, string jsonField)
        {
            JToken token = null;
            if (_galleryPage.TryGetValue(jsonField, out token))
            {
                JArray array = token as JArray;
                JValue val = token as JValue;

                if (array != null || val != null)
                {
                    var pred = graph.CreateUriNode(predicate);

                    var old = graph.GetTriplesWithSubjectPredicate(parent, pred).ToArray();

                    // remove the old values
                    foreach (var triple in old)
                    {
                        graph.Retract(triple);
                    }

                    if (array != null)
                    {
                        foreach (var child in array)
                        {
                            graph.Assert(parent, pred, graph.CreateLiteralNode(child.ToString()));
                        }
                    }
                    else
                    {
                        graph.Assert(parent, pred, graph.CreateLiteralNode(val.ToString()));
                    }
                }
            }
        }
예제 #2
0
 private void AddStats(IGraph g, IEnumerable<KeyValuePair<INode, long>> stats, INode statsProperty)
 {
     foreach (KeyValuePair<INode, long> kvp in stats)
     {
         g.Assert(kvp.Key.CopyNode(g), statsProperty, kvp.Value.ToLiteral(g));
     }
 }
예제 #3
0
 public void Apply(IGraph g)
 {
     g.BaseUri = this._baseUri;
     g.Assert(this._triples);
     foreach (KeyValuePair<String, String> ns in this._namespaces)
     {
         g.NamespaceMap.AddNamespace(ns.Key, UriFactory.Create(ns.Value));
     }
 }
예제 #4
0
 public static void FromJena(Model m, JenaMapping mapping, IGraph g)
 {
     StmtIterator iter = m.listStatements();
     while (iter.hasNext())
     {
         Statement stmt = iter.nextStatement();
         g.Assert(FromJena(stmt, mapping));
     }
 }
        public static void MaterializeInference(IGraph graph)
        {
            //  hard code some type inference

            //  nuget:ApiAppPackage rdfs:subClassOf nuget:PackageDetails

            foreach (Triple triple in graph.GetTriplesWithPredicateObject(graph.CreateUriNode(Schema.Predicates.Type), graph.CreateUriNode(Schema.DataTypes.ApiAppPackage)))
            {
                graph.Assert(triple.Subject, triple.Predicate, graph.CreateUriNode(Schema.DataTypes.PackageDetails));
            }

            //  nuget:PowerShellPackage rdfs:subClassOf nuget:PackageDetails

            foreach (Triple triple in graph.GetTriplesWithPredicateObject(graph.CreateUriNode(Schema.Predicates.Type), graph.CreateUriNode(Schema.DataTypes.PowerShellPackage)))
            {
                graph.Assert(triple.Subject, triple.Predicate, graph.CreateUriNode(Schema.DataTypes.PackageDetails));
            }
        }
        /// <summary>
        /// Add data from nuget.packed.json
        /// </summary>
        public override void ApplyToGraph(IGraph graph, IUriNode mainNode)
        {
            Uri mainUri = mainNode.Uri;
            IUriNode typeNode = graph.CreateUriNode(Schema.Predicates.Type);

            // supported frameworks
            if (SupportedFrameworks != null)
            {
                foreach (string framework in SupportedFrameworks)
                {
                    graph.Assert(new Triple(mainNode, graph.CreateUriNode(Schema.Predicates.SupportedFramework), graph.CreateLiteralNode(framework)));
                }
            }

            // assets
            //if (AssetGroups != null)
            //{
            //    int groupId = 0;
            //    foreach (var group in AssetGroups)
            //    {
            //        // group type and id
            //        var groupNode = GetSubNode(graph, mainUri, "assetGroup", "" + groupId);
            //        graph.Assert(groupNode, typeNode, graph.CreateUriNode(PackageAssetGroupType));
            //        graph.Assert(mainNode, graph.CreateUriNode(AssetGroupPredicate), groupNode);
            //        groupId++;

            //        int propId = 0;

            //        // group properties
            //        foreach (var prop in group.Properties)
            //        {
            //            var propNode = GetSubNode(graph, groupNode, "property", "" + propId);
            //            propId++;
            //            graph.Assert(propNode, typeNode, graph.CreateUriNode(PackageAssetGroupPropertyType));
            //            graph.Assert(groupNode, graph.CreateUriNode(AssetGroupPropertyPredicate), propNode);
            //            graph.Assert(propNode, graph.CreateUriNode(AssetKeyPredicate), graph.CreateLiteralNode(prop.Key));
            //            graph.Assert(propNode, graph.CreateUriNode(AssetValuePredicate), graph.CreateLiteralNode(prop.Value));
            //        }

            //        int assetId = 0;

            //        // group items
            //        foreach (var item in group.Items)
            //        {
            //            var itemNode = GetSubNode(graph, groupNode, "asset", "" + assetId);
            //            assetId++;
            //            graph.Assert(itemNode, typeNode, graph.CreateUriNode(PackageAssetType));
            //            graph.Assert(groupNode, graph.CreateUriNode(AssetPredicate), itemNode);

            //            graph.Assert(itemNode, graph.CreateUriNode(AssetTypePredicate), graph.CreateLiteralNode(item.ArtifactType));
            //            graph.Assert(itemNode, graph.CreateUriNode(AssetPathPredicate), graph.CreateLiteralNode(item.Path));
            //        }
            //    }
            //}
        }
예제 #7
0
        internal IResource CreateResource(INode rdfType = null)
        {
            // TODO put that in another graph to not overflow the configuration with temporary requests ?
            INode resource = _currentSparqlGraph.CreateBlankNode();

            if (rdfType != null)
            {
                _currentSparqlGraph.Assert(resource, Tools.CopyNode(RDF.PropertyType, _currentSparqlGraph), Tools.CopyNode(rdfType, _currentSparqlGraph));
            }
            return(Resource.Get(resource, this));
        }
예제 #8
0
        /// <summary>
        /// Gets the template graph.
        /// </summary>
        /// <returns></returns>
        public override IGraph GetTemplateGraph()
        {
            IGraph g    = GetBaseTemplateGraph();
            INode  impl = g.CreateBlankNode();

            g.Assert(ContextNode, g.CreateUriNode("rep:repositoryImpl"), impl);
            g.Assert(impl, g.CreateUriNode("rep:repositoryType"), g.CreateLiteralNode("openrdf:HTTPRepository"));

            String url = RemoteServer;

            if (!url.EndsWith("/"))
            {
                url += "/";
            }
            url += "repositories/";
            url += RemoteRepositoryID;

            g.Assert(impl, g.CreateUriNode("hr:repositoryURL"), g.CreateUriNode(UriFactory.Create(url)));
            return(g);
        }
예제 #9
0
        private static void FillGraph(IGraph graph)
        {
            graph.NamespaceMap.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
            graph.NamespaceMap.AddNamespace("ex", new Uri("http://example.org"));
            graph.NamespaceMap.AddNamespace("med", new Uri("http://med.org"));

            IUriNode rdfTypeNode = graph.CreateUriNode("rdf:type");
            IUriNode patienSubjectNode = graph.CreateUriNode(UriFactory.Create("http://ex-hospital-DB/patients/ID98765"));
            IUriNode patientTypeNode = graph.CreateUriNode(UriFactory.Create("http://ex-hospital#patient"));
            IUriNode hasVitalsPredicateNode = graph.CreateUriNode("ex:hasVitals");

            IUriNode odfElementSubjectNode = graph.CreateUriNode(new Uri("med:Sect1"));
            IUriNode odfElementTypeNode = graph.CreateUriNode(UriFactory.Create("http://docs.oasis-open.org/ns/office/1.2/meta/odf#Element"));
            IUriNode vitalDataTypeNode = graph.CreateUriNode("med:vitalData");

            graph.Assert(new Triple(odfElementSubjectNode, rdfTypeNode, vitalDataTypeNode));
            graph.Assert(new Triple(odfElementSubjectNode, rdfTypeNode, odfElementTypeNode));

            graph.Assert(new Triple(patienSubjectNode, rdfTypeNode, patientTypeNode));
            graph.Assert(new Triple(patienSubjectNode, hasVitalsPredicateNode, odfElementSubjectNode));
        }
        public static void Collect(IGraph source, INode subject, IGraph destination, ISet<string> exclude)
        {
            foreach (Triple triple in source.GetTriplesWithSubject(subject))
            {
                destination.Assert(triple.CopyTriple(destination));

                if (triple.Object is IUriNode && !exclude.Contains(((IUriNode)triple.Object).Uri.ToString()))
                {
                    Collect(source, triple.Object, destination, exclude);
                }
            }
        }
        /// <summary>
        /// Applies inference to the Input Graph and outputs the inferred information to the Output Graph.
        /// </summary>
        /// <param name="input">Graph to apply inference to.</param>
        /// <param name="output">Graph inferred information is output to.</param>
        public virtual void Apply(IGraph input, IGraph output)
        {
            // Infer information
            List <Triple> inferences = new List <Triple>();

            foreach (Triple t in input.Triples)
            {
                // Apply class/property hierarchy inferencing
                if (t.Predicate.Equals(_rdfType))
                {
                    if (!t.Object.Equals(_rdfsClass) && !t.Object.Equals(_rdfProperty))
                    {
                        InferClasses(t, input, output, inferences);
                    }
                }
                else if (t.Predicate.Equals(_rdfsSubClass))
                {
                    // Assert that this thing is a Class
                    inferences.Add(new Triple(t.Subject.CopyNode(output), _rdfType.CopyNode(output), _rdfsClass.CopyNode(output)));
                }
                else if (t.Predicate.Equals(_rdfsSubProperty))
                {
                    // Assert that this thing is a Property
                    inferences.Add(new Triple(t.Subject.CopyNode(output), _rdfType.CopyNode(output), _rdfProperty.CopyNode(output)));
                }
                else if (_propertyMappings.ContainsKey(t.Predicate))
                {
                    INode property = t.Predicate;

                    // Navigate up the property hierarchy asserting additional properties if able
                    while (_propertyMappings.ContainsKey(property))
                    {
                        if (_propertyMappings[property] != null)
                        {
                            // Assert additional properties
                            inferences.Add(new Triple(t.Subject.CopyNode(output), _propertyMappings[property].CopyNode(output), t.Object.CopyNode(output)));
                            property = _propertyMappings[property];
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            // Assert the inferred information
            inferences.RemoveAll(t => t.Subject.NodeType == NodeType.Literal);
            if (inferences.Count > 0)
            {
                output.Assert(inferences);
            }
        }
예제 #12
0
        public static void Collect(IGraph source, INode subject, IGraph destination, ISet <string> exclude)
        {
            foreach (Triple triple in source.GetTriplesWithSubject(subject))
            {
                destination.Assert(triple.CopyTriple(destination));

                if (triple.Object is IUriNode && !exclude.Contains(((IUriNode)triple.Object).Uri.ToString()))
                {
                    Collect(source, triple.Object, destination, exclude);
                }
            }
        }
예제 #13
0
        public void GraphAssert01()
        {
            IGraph g = this.GetInstance();

            g.NamespaceMap.AddNamespace(String.Empty, UriFactory.Create("http://example/"));

            Triple t = new Triple(g.CreateUriNode(":s"), g.CreateUriNode(":p"), g.CreateBlankNode(":o"));

            g.Assert(t);
            Assert.False(g.IsEmpty);
            Assert.True(g.ContainsTriple(t));
        }
예제 #14
0
        protected static void thingOneOf(IGraph graph, IUriNode[] listInds)
        {
            IBlankNode oneOfNode     = graph.CreateBlankNode();
            IBlankNode chainA        = graph.CreateBlankNode();
            IUriNode   rdfType       = graph.CreateUriNode(new Uri(RdfSpecsHelper.RdfType));
            IUriNode   rdfFirst      = graph.CreateUriNode(new Uri(RdfSpecsHelper.RdfListFirst));
            IUriNode   rdfRest       = graph.CreateUriNode(new Uri(RdfSpecsHelper.RdfListRest));
            IUriNode   rdfNil        = graph.CreateUriNode(new Uri(RdfSpecsHelper.RdfListNil));
            IUriNode   owlClass      = graph.CreateUriNode(new Uri(NamespaceMapper.OWL + "Class"));
            IUriNode   owlOneOf      = graph.CreateUriNode(new Uri(NamespaceMapper.OWL + "oneOf"));
            IUriNode   owlThing      = graph.CreateUriNode(new Uri(NamespaceMapper.OWL + "Thing"));
            IUriNode   owlEquivClass = graph.CreateUriNode(new Uri(NamespaceMapper.OWL + "equivalentClass"));

            graph.Assert(new Triple(oneOfNode, rdfType, owlClass));
            graph.Assert(new Triple(oneOfNode, owlOneOf, chainA));
            graph.Assert(new Triple(owlThing, owlEquivClass, oneOfNode));

            for (int i = 0; i < listInds.Length; i++)
            {
                graph.Assert(new Triple(chainA, rdfFirst, listInds[i]));
                IBlankNode chainB = graph.CreateBlankNode();

                if (i < listInds.Length - 1)
                {
                    graph.Assert(new Triple(chainA, rdfRest, chainB));
                    chainA = chainB;
                }
            }
            graph.Assert(new Triple(chainA, rdfRest, rdfNil));
        }
        public void InsertImorTag(ImorTag tag)
        {
            var node = graph.CreateUriNode(new Uri(tag.Uri));

            var typeNode = graph.GetUriNode(new Uri(ImorEnum.RdfType));

            var tagNode = graph.GetUriNode(new Uri(ImorEnum.Tag));

            var t = new Triple(node, typeNode, tagNode);

            if (!string.IsNullOrEmpty(tag.Description))
            {
                var descriptionNode = graph.GetUriNode(new Uri(ImorEnum.Description));

                var descriptionTriple = new Triple(node, descriptionNode, graph.CreateLiteralNode(tag.Description));

                graph.Assert(descriptionTriple);
            }

            if (!string.IsNullOrEmpty(tag.Label))
            {
                var label = graph.GetUriNode(new Uri(ImorEnum.TagLabel));

                var contenTriple = new Triple(node, label, graph.CreateLiteralNode(tag.Label));

                graph.Assert(contenTriple);
            }

            graph.Assert(t);

            try
            {
                graph.SaveToFile(DatabaseInitializer.ontology);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public DataDockRepositoryUpdateSpec()
        {
            _insertGraph = new Graph();
            _insertGraph.Assert(_insertGraph.CreateUriNode(new Uri("http://example.org/s")),
                                _insertGraph.CreateUriNode(new Uri("http://example.org/p")),
                                _insertGraph.CreateUriNode(new Uri("http://example.org/o")));
            _datasetGraphIri = new Uri("http://datadock.io/test/repo/example");
            _metadataGraph   = new Graph();
            _metadataGraph.Assert(
                _metadataGraph.CreateUriNode(_datasetGraphIri),
                _metadataGraph.CreateUriNode(new Uri("http://example.org/properties/foo")),
                _metadataGraph.CreateLiteralNode("foo"));
            _metadataGraphIri = new Uri("http://datadock.io/test/repo/example/metadata");
            _definitionsGraph = new Graph();
            _definitionsGraph.Assert(
                _definitionsGraph.CreateUriNode(_datasetGraphIri),
                _definitionsGraph.CreateUriNode(new Uri("http://example.org/properties/bar")),
                _definitionsGraph.CreateLiteralNode("bar"));
            _definitionsGraphIri = new Uri("http://datadock.io/test/repo/example/definitions");
            _publisherIri        = new Uri("http://datadock.io/test/publisher");
            _publisherInfo       = new ContactInfo {
                Label = "Test Publisher"
            };
            _repositoryTitle       = "Test Repository";
            _repositoryDescription = "Test Repository Description";
            _rootMetadataGraphIri  = new Uri("http://datadock.io/test/repo/metadata");

            // Create some existing triples that we will expect to be retracted
            var initGraph = new Graph();

            initGraph.NamespaceMap.AddNamespace("test", new Uri("http://datadock.io/test/"));
            initGraph.NamespaceMap.AddNamespace("dcterms", new Uri("http://purl.org/dc/terms/"));
            initGraph.NamespaceMap.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
            var repo      = initGraph.CreateUriNode(BaseUri);
            var publisher = initGraph.CreateUriNode(_publisherIri);

            QuinceStore.Assert(
                repo,
                initGraph.CreateUriNode("dcterms:title"),
                initGraph.CreateLiteralNode("Old Title"),
                _rootMetadataGraphIri);
            QuinceStore.Assert(
                repo,
                initGraph.CreateUriNode("dcterms:description"),
                initGraph.CreateLiteralNode("Old Description"),
                _rootMetadataGraphIri);
            QuinceStore.Assert(
                publisher,
                initGraph.CreateUriNode("rdfs:label"),
                initGraph.CreateLiteralNode("Old Publisher"),
                _rootMetadataGraphIri);
        }
예제 #17
0
        /// <summary>
        /// Handles Triples by asserting them into the appropriate Graph creating the Graph if necessary
        /// </summary>
        /// <param name="t">Triple</param>
        /// <returns></returns>
        protected override bool HandleTripleInternal(Triple t)
        {
            if (!_store.HasGraph(t.GraphUri))
            {
                Graph g = new Graph();
                g.BaseUri = t.GraphUri;
                _store.Add(g);
            }
            IGraph target = _store[t.GraphUri];

            target.Assert(t.CopyTriple(target));
            return(true);
        }
예제 #18
0
 private bool AddGraph(IGraph g)
 {
     if (this._store.HasGraph(g.BaseUri))
     {
         IGraph target = this._store.Graphs[g.BaseUri];
         target.Assert(g.Triples.Select(t => t.CopyTriple(target)));
     }
     else
     {
         this._store.Add(g);
     }
     return(true);
 }
예제 #19
0
        public void AddTriples(IGraph graph, INode parent, INode predicate)
        {
            if (graph == null)
            {
                throw new ArgumentNullException(nameof(graph));
            }
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            string name     = IdGenerator.NewId("Information");
            var    thisNode = RdfHelpers.CreateEntity(RdfNS.SALModel, name);


            //Defining type of this object
            graph.Assert(RdfHelpers.CreateTriple(
                             thisNode,
                             RdfNS.RDFUri, "type",
                             RdfNS.SALUri, "Information"
                             ));
            //Define relationship to parent
            graph.Assert(RdfHelpers.CreateTriple(
                             parent,
                             predicate,
                             thisNode
                             ));
            //Set Data property location
            graph.Assert(RdfHelpers.CreateTriple(
                             thisNode,
                             RdfNS.SALUri, "location",
                             this.Location
                             ));
            //set object property Unit
            graph.Assert(RdfHelpers.CreateTriple(
                             thisNode,
                             RdfNS.SALUri, "hasUnit",
                             RdfNS.SALIUri, Enum.GetName(typeof(Unit), this.HasUnit)
                             ));
            //set object property Modality
            graph.Assert(RdfHelpers.CreateTriple(
                             thisNode,
                             RdfNS.SALUri, "hasModality",
                             RdfNS.SALIUri, Enum.GetName(typeof(Modality), this.HasModality)
                             ));
            //set object property TemporalAspect
            graph.Assert(RdfHelpers.CreateTriple(
                             thisNode,
                             RdfNS.SALUri, "hasTemporalAspect",
                             RdfNS.SALIUri, Enum.GetName(typeof(TemporalAspect), this.HasTemporalAspect)
                             ));

            this.HasLocation?.AddTriples(graph, thisNode, RdfHelpers.CreateEntity(RdfNS.SALUri, "hasLocation"));
        }
        private static void ExpandGraphs(this ITripleStore store, TripleStore targetStore, Uri metaGraphUri)
        {
            IGraph metaGraph = store.AddGraph(metaGraphUri);

            foreach (Triple triple in targetStore.Triples)
            {
                IUriNode subject = (triple.Subject is IBlankNode ? targetStore.FindOwningSubject((IBlankNode)triple.Subject) : (IUriNode)triple.Subject);
                if (subject != null)
                {
                    IGraph graph = store.GetGraph(metaGraphUri, subject.Uri);
                    graph.Assert(graph.Import(triple));
                }
            }
        }
        public override StorageContent CreateContent(CatalogContext context)
        {
            //  metadata from nuspec

            using (IGraph graph = CreateContentGraph(context))
            {
                //  catalog infrastructure fields
                INode rdfTypePredicate   = graph.CreateUriNode(Schema.Predicates.Type);
                INode timeStampPredicate = graph.CreateUriNode(Schema.Predicates.CatalogTimeStamp);
                INode commitIdPredicate  = graph.CreateUriNode(Schema.Predicates.CatalogCommitId);

                Triple resource = graph.GetTriplesWithPredicateObject(rdfTypePredicate, graph.CreateUriNode(GetItemType())).First();
                graph.Assert(resource.Subject, timeStampPredicate, graph.CreateLiteralNode(TimeStamp.ToString("O"), Schema.DataTypes.DateTime));
                graph.Assert(resource.Subject, commitIdPredicate, graph.CreateLiteralNode(CommitId.ToString()));

                //  create JSON content
                JObject frame = context.GetJsonLdContext("context.PackageDetails.json", GetItemType());

                StorageContent content = new StringStorageContent(Utils.CreateArrangedJson(graph, frame), "application/json", "no-store");

                return(content);
            }
        }
예제 #22
0
        public static IGraph addTrippleToFHKB(IGraph FHKB, String subject, String predicate, String objec)
        {
            INode  sub  = FHKB.CreateUriNode(UriFactory.Create("http://bedrock/" + subject));
            INode  pred = FHKB.CreateUriNode(UriFactory.Create("http://bedrock/" + predicate));
            INode  obj  = FHKB.CreateUriNode(UriFactory.Create("http://bedrock/" + objec));
            Triple t    = new Triple(sub, pred, obj);

            FHKB.Assert(t);
            //foreach (Triple k in g.Triples)
            //{
            //    Console.WriteLine(k.ToString());
            //}
            return(FHKB);
        }
예제 #23
0
        /// <summary>
        /// Adds Description of Features for the given Handler Configuration
        /// </summary>
        /// <param name="g">Service Description Graph</param>
        /// <param name="queryNode">Node for the SPARQL Query service</param>
        /// <param name="updateNode">Node for the SPARQL Update service</param>
        /// <param name="protocolNode">Node for the SPARQL Graph Store HTTP Protocol service</param>
        public virtual void AddFeatureDescription(IGraph g, INode queryNode, INode updateNode, INode protocolNode)
        {
            IUriNode extensionFunction  = g.CreateUriNode("sd:" + SparqlServiceDescriber.PropertyExtensionFunction);
            IUriNode extensionAggregate = g.CreateUriNode("sd:" + SparqlServiceDescriber.PropertyExtensionAggregate);

            if (queryNode != null)
            {
                //Add Local Extension Function definitions
                foreach (ISparqlCustomExpressionFactory factory in this._expressionFactories)
                {
                    foreach (Uri u in factory.AvailableExtensionFunctions)
                    {
                        g.Assert(queryNode, extensionFunction, g.CreateUriNode(u));
                    }
                    foreach (Uri u in factory.AvailableExtensionAggregates)
                    {
                        g.Assert(queryNode, extensionAggregate, g.CreateUriNode(u));
                    }
                }
            }

            if (updateNode != null)
            {
                //Add Local Extension Function definitions
                foreach (ISparqlCustomExpressionFactory factory in this._expressionFactories)
                {
                    foreach (Uri u in factory.AvailableExtensionFunctions)
                    {
                        g.Assert(updateNode, extensionFunction, g.CreateUriNode(u));
                    }
                    foreach (Uri u in factory.AvailableExtensionAggregates)
                    {
                        g.Assert(updateNode, extensionAggregate, g.CreateUriNode(u));
                    }
                }
            }
        }
예제 #24
0
        private void NormalizeDatatypes(IGraph g)
        {
            var xsdString = new Uri(XmlSpecsHelper.XmlSchemaDataTypeString);

            foreach (var t in g.Triples.Where(t => t.Object is ILiteralNode).ToList())
            {
                var lit = (ILiteralNode)t.Object;
                if (lit.DataType == null && string.IsNullOrEmpty(lit.Language))
                {
                    // literal with no datatype should be xsd:string in the RDF 1.1 data model
                    g.Retract(t);
                    g.Assert(new Triple(t.Subject, t.Predicate, g.CreateLiteralNode(lit.Value, xsdString)));
                }
            }
        }
예제 #25
0
        public void ToGraph(IGraph g, IDocument <Document, Document> document)
        {
            Document mongoDoc = document.BeginRead();
            Document lookup   = new Document();

            lookup["graphuri"] = mongoDoc["uri"];
            document.EndRead();

            IEnumerable <Triple> ts = new MongoDBTripleCentricEnumerable(this._manager, lookup);

            foreach (Triple t in ts)
            {
                g.Assert(Tools.CopyTriple(t, g));
            }
        }
예제 #26
0
        private bool SubPropertyOf(IGraph graph, IGraph meta)
        {
            var any   = false;
            var rules = meta.P(Constants.SubPropertyOf);

            foreach (var rule in rules)
            {
                var triples = graph.P(rule.Subject);
                foreach (var t in triples)
                {
                    any |= graph.Assert(t.Subject, rule.Object.ToValue(), t.Object);
                }
            }
            return(any);
        }
예제 #27
0
        /// <summary>
        /// Takes the contents of a SemWeb Statement Source and inputs it into a dotNetRDF Graph
        /// </summary>
        /// <param name="source">Statement Source</param>
        /// <param name="g">Graph</param>
        public static void FromSemWeb(StatementSource source, IGraph g)
        {
            SemWebMapping mapping = new SemWebMapping(g);
            Triple        t;

            MemoryStore mem = new MemoryStore();

            source.Select(mem);

            foreach (Statement stmt in mem)
            {
                t = FromSemWeb(stmt, mapping);
                g.Assert(t);
            }
        }
예제 #28
0
        public static void CopyCatalogContentGraph(INode sourceNode, IGraph source, IGraph target)
        {
            if (IsCatalogNode(sourceNode, source))
            {
                return;
            }

            foreach (Triple triple in source.GetTriplesWithSubject(sourceNode))
            {
                if (target.Assert(triple.CopyTriple(target)) && triple.Object is IUriNode)
                {
                    CopyCatalogContentGraph(triple.Object, source, target);
                }
            }
        }
        static void SetTimestamp(Uri resourceUri, IGraph graph)
        {
            INode subject = graph.CreateUriNode(resourceUri);

            Triple triple = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.CatalogTimeStamp)).FirstOrDefault();

            if (triple != null)
            {
                graph.Retract(triple);
            }

            DateTime timestamp = DateTime.UtcNow;

            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.CatalogTimeStamp), graph.CreateLiteralNode(timestamp.ToString("O")));
        }
예제 #30
0
        public static void Reverse(IGraph graph, Uri existingProperty, Uri reverseProperty)
        {
            var existingTriples = graph
                                  .GetTriplesWithPredicate(graph.CreateUriNode(existingProperty))
                                  .ToList();

            graph.Retract(existingTriples);

            INode predicate = graph.CreateUriNode(reverseProperty);

            foreach (var existingTriple in existingTriples)
            {
                graph.Assert(existingTriple.Object, predicate, existingTriple.Subject);
            }
        }
예제 #31
0
        private bool SubClassOf(IGraph graph, IGraph meta)
        {
            var any   = false;
            var rules = meta.P(Constants.SubClassOf);

            foreach (var rule in rules)
            {
                var triples = graph.PO(Constants.Type, TripleObject.FromData(rule.Subject));
                foreach (var t in triples)
                {
                    any |= graph.Assert(t.Subject, Constants.Type, TripleObject.FromData(rule.Object.ToValue()));
                }
            }
            return(any);
        }
예제 #32
0
        public static void Add(string s, string p, string o, IInMemoryQueryableStore ms)
        {
            if (!string.IsNullOrEmpty(s) && !string.IsNullOrEmpty(p) && !string.IsNullOrEmpty(o))
            {
                IGraph g = ms.GetDefaultGraph();
                g.Assert(g.CreateUriNode(new Uri(s)), g.CreateUriNode(new Uri(p)), g.CreateLiteralNode(o));
                #region Tracing
#line hidden
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("Added <{0}> <{1}> <{2}>.", s, p, o);
                }
#line default
                #endregion
            }
        }
예제 #33
0
        private static void ApplyTransitiveProperty(IGraph g, string p)
        {
            var triples = new List <Triple>();

            foreach (var t1 in g.GetByPredicate(p).Where(t => t.Object.IsID))
            {
                foreach (var t2 in g.GetBySubjectPredicate(t1.Object.Id, p))
                {
                    triples.Add(new Triple(t1.Subject, p, t2.Object));
                }
            }
            foreach (var t in triples)
            {
                g.Assert(t);
            }
        }
예제 #34
0
 private bool AddGraphToContext(Uri u, IGraph g)
 {
     if (this._store.HasGraph(u))
     {
         IGraph target = this._store.Graphs[u];
         target.Assert(g.Triples.Select(t => t.CopyTriple(target)));
     }
     else
     {
         Graph copy = new Graph();
         copy.BaseUri = u;
         copy.Assert(g.Triples.Select(t => t.CopyTriple(copy)));
         this.AddGraph(copy);
     }
     return(true);
 }
예제 #35
0
        private void AssertGraph(IGraph resourceGraph, IGraph graph)
        {
            var graphNode = _metaGraph.CreateUriNode(graph.BaseUri);

            foreach (var triple in resourceGraph.Triples)
            {
                if (triple.Subject is IUriNode)
                {
                    var uriNode = (IUriNode)triple.Subject;
                    _metaGraph.Assert(graphNode, _predicateNode, _metaGraph.CreateUriNode(uriNode.Uri));
                    _dereferencedResources.Add(uriNode.Uri.AbsoluteUri);
                }

                graph.Assert(triple);
            }
        }
예제 #36
0
        public bool Assert(Triple t)
        {
            bool previouslyRetracted = Retracted.Remove(t);

            if (_innerGraph.Assert(t))
            {
                if (!previouslyRetracted)
                {
                    Asserted.Add(t);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #37
0
        private void TestDeleteDataThenInsertDataCommit()
        {
            ISparqlDataset dataset = this.GetNonEmptyDataset();
            IGraph         g       = dataset.GetModifiableGraph(TestGraphUri);

            g.Assert(new Triple(g.CreateUriNode(new Uri("ex:subj")), g.CreateUriNode(new Uri("ex:pred")), g.CreateUriNode(new Uri("ex:obj"))));
            dataset.Flush();

            String updates = "DELETE DATA { GRAPH <" + TestGraphUri.ToString() + "> { <ex:subj> <ex:pred> <ex:obj> } }; INSERT DATA { GRAPH <" + TestGraphUri.ToString() + "> { <ex:subj> <ex:pred> <ex:obj> } }";

            SparqlUpdateCommandSet cmds = this._parser.ParseFromString(updates);

            LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset);

            processor.ProcessCommandSet(cmds);

            Assert.False(dataset[TestGraphUri].IsEmpty, "Graph should not be empty as the Flush() should persist first the delete then the insert so the end results should be the triple still being in the Graph");
        }
예제 #38
0
 public static void Add(this IInMemoryQueryableStore ms, OwlInstanceSupertype oc)
 {
     using (var ls = new LoggingScope("MemoryStoreExtensions.Add"))
     {
         Type t = oc.GetType();
         Console.WriteLine(oc.InstanceUri);
         PropertyInfo[] pia = t.GetProperties();
         IGraph         g   = ms.GetDefaultGraph();
         g.Assert(g.CreateUriNode(new Uri(oc.InstanceUri)), g.CreateUriNode(new Uri(RdfSpecsHelper.RdfType)), g.CreateUriNode(new Uri(OwlClassSupertype.GetOwlClassUri(t))));
         foreach (PropertyInfo pi in pia)
         {
             if (pi.IsOntologyResource())
             {
                 AddPropertyToStore(oc, pi, ms);
             }
         }
     }
 }
        public static void ReplaceIRI(IGraph graph, Uri oldIRI, Uri newIRI)
        {
            // replace the local IRI with the NuGet IRI
            string localUri = oldIRI.AbsoluteUri;

            var triples = graph.Triples.ToArray();

            string mainIRI = newIRI.AbsoluteUri;

            foreach (var triple in triples)
            {
                IUriNode subject = triple.Subject as IUriNode;
                IUriNode objNode = triple.Object as IUriNode;
                INode newSubject = triple.Subject;
                INode newObject = triple.Object;

                bool replace = false;

                if (subject != null && subject.Uri.AbsoluteUri.StartsWith(localUri))
                {
                    // TODO: store these mappings in a dictionary
                    Uri iri = new Uri(String.Format(CultureInfo.InvariantCulture, "{0}{1}", mainIRI, subject.Uri.AbsoluteUri.Substring(localUri.Length)));
                    newSubject = graph.CreateUriNode(iri);
                    replace = true;
                }

                if (objNode != null && objNode.Uri.AbsoluteUri.StartsWith(localUri))
                {
                    // TODO: store these mappings in a dictionary
                    Uri iri = new Uri(String.Format(CultureInfo.InvariantCulture, "{0}{1}", mainIRI, objNode.Uri.AbsoluteUri.Substring(localUri.Length)));
                    newObject = graph.CreateUriNode(iri);
                    replace = true;
                }

                if (replace)
                {
                    graph.Assert(newSubject, triple.Predicate, newObject);
                    graph.Retract(triple);
                }
            }
        }
예제 #40
0
        public static void Load(IGraph output, JObject flattened)
        {
            JObject context = (JObject)flattened["@context"];

            IDictionary<string, string> types = new Dictionary<string, string>();

            foreach (JProperty term in context.Properties())
            {
                if (term.Value.Type == JTokenType.Object)
                {
                    types.Add(term.Name, (((JObject)term.Value)["@type"]).ToString());
                }
                else
                {
                    output.NamespaceMap.AddNamespace(term.Name, new Uri(term.Value.ToString()));
                }
            }

            JArray graph = (JArray)flattened["@graph"];

            foreach (JObject item in graph)
            {
                string id = item["@id"].ToString();

                INode s = id.StartsWith("_:")
                    ?
                    (INode)output.CreateBlankNode(id.Substring(2)) : (INode)output.CreateUriNode(new Uri(id));

                foreach (JProperty prop in ((JObject)item).Properties())
                {
                    if (prop.Name == "@id")
                    {
                        continue;
                    }

                    if (prop.Name == "@type")
                    {
                        INode p = output.CreateUriNode(new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"));

                        if (prop.Value.Type == JTokenType.Array)
                        {
                            foreach (JToken type in (JArray)prop.Value)
                            {
                                INode o = output.CreateUriNode(type.ToString());
                                output.Assert(s, p, o);
                            }
                        }
                        else
                        {
                            INode o = output.CreateUriNode(prop.Value.ToString());
                            output.Assert(s, p, o);
                        }
                    }
                    else
                    {
                        INode p = output.CreateUriNode(prop.Name);

                        if (prop.Value.Type == JTokenType.Object)
                        {
                            string pid = ((JObject)prop.Value)["@id"].ToString();

                            INode o = pid.StartsWith("_:")
                                ?
                                (INode)output.CreateBlankNode(pid.Substring(2)) : (INode)output.CreateUriNode(new Uri(pid));

                            output.Assert(s, p, o);
                        }
                        else
                        {
                            string type = "string";
                            types.TryGetValue(prop.Name, out type);

                            INode o;
                            if (type == "@id")
                            {
                                string pv = prop.Value.ToString();

                                o = pv.StartsWith("http:") ? output.CreateUriNode(new Uri(pv)) : output.CreateUriNode(pv);
                            }
                            else
                            {
                                o = output.CreateLiteralNode(prop.Value.ToString());
                            }

                            output.Assert(s, p, o);
                        }
                    }
                }
            }
        }
 protected override void AddCustomContent(INode resource, IGraph graph)
 {
     if (_commitUserData != null)
     {
         string baseAddress = ((IUriNode)resource).Uri.ToString();
         INode commitUserData = graph.CreateUriNode(new Uri(baseAddress + "#commitUserData"));
         graph.Assert(resource, graph.CreateUriNode(Schema.Predicates.CatalogCommitUserData), commitUserData);
         foreach (KeyValuePair<string, string> item in _commitUserData)
         {
             graph.Assert(
                 commitUserData, 
                 graph.CreateUriNode(Schema.Predicates.CatalogPropertyPrefix + item.Key), 
                 graph.CreateLiteralNode(item.Value));
         }
     }
 }
 /// <summary>
 /// Adds Description of Features for the given Handler Configuration
 /// </summary>
 /// <param name="g">Service Description Graph</param>
 /// <param name="descripNode">Description Node for the Service</param>
 public virtual void AddFeatureDescription(IGraph g, INode descripNode)
 {
     //Add Local Extension Function definitions
     IUriNode extensionFunction = g.CreateUriNode("sd:" + SparqlServiceDescriber.PropertyExtensionFunction);
     IUriNode extensionAggregate = g.CreateUriNode("sd:" + SparqlServiceDescriber.PropertyExtensionAggregate);
     foreach (ISparqlCustomExpressionFactory factory in this._expressionFactories)
     {
         foreach (Uri u in factory.AvailableExtensionFunctions)
         {
             g.Assert(descripNode, extensionFunction, g.CreateUriNode(u));
         }
         foreach (Uri u in factory.AvailableExtensionAggregates)
         {
             g.Assert(descripNode, extensionAggregate, g.CreateUriNode(u));
         }
     }
 }
예제 #43
0
        public static void Reverse(IGraph graph, Uri existingProperty, Uri reverseProperty)
        {
            var existingTriples = graph
                .GetTriplesWithPredicate(graph.CreateUriNode(existingProperty))
                .ToList();

            graph.Retract(existingTriples);

            INode predicate = graph.CreateUriNode(reverseProperty);
            foreach (var existingTriple in existingTriples)
            {
                graph.Assert(existingTriple.Object, predicate, existingTriple.Subject);
            }
        }
예제 #44
0
        /// <summary>
        /// Takes the contents of a SemWeb Statement Source and inputs it into a dotNetRDF Graph
        /// </summary>
        /// <param name="source">Statement Source</param>
        /// <param name="g">Graph</param>
        public static void FromSemWeb(StatementSource source, IGraph g)
        {
            SemWebMapping mapping = new SemWebMapping(g);
            Triple t;
            
            MemoryStore mem = new MemoryStore();
            source.Select(mem);

            foreach (Statement stmt in mem)
            {
                t = FromSemWeb(stmt, mapping);
                g.Assert(t);
            }
        }
예제 #45
0
        /// <summary>
        /// Applies inference to the Input Graph and outputs the inferred information to the Output Graph
        /// </summary>
        /// <param name="input">Graph to apply inference to</param>
        /// <param name="output">Graph inferred information is output to</param>
        public virtual void Apply(IGraph input, IGraph output)
        {
            List<Triple> inferences = new List<Triple>();
            lock (this._conceptMappings)
            {
                foreach (Triple t in input.Triples)
                {
                    if (!(t.Predicate.Equals(this._skosBroader) || t.Predicate.Equals(this._skosNarrower)) && this._conceptMappings.ContainsKey(t.Object))
                    {
                        INode concept = t.Object;
                        while (this._conceptMappings.ContainsKey(concept))
                        {
                            if (this._conceptMappings[concept] != null)
                            {
                                //Assert additional information
                                inferences.Add(new Triple(t.Subject.CopyNode(output), t.Predicate.CopyNode(output), this._conceptMappings[concept].CopyNode(output)));
                                concept = this._conceptMappings[concept];
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }

            if (inferences.Count > 0)
            {
                output.Assert(inferences);
            }
        }
예제 #46
0
        /// <summary>
        /// Applies inference to the Input Graph and outputs the inferred information to the Output Graph
        /// </summary>
        /// <param name="input">Graph to apply inference to</param>
        /// <param name="output">Graph inferred information is output to</param>
        public virtual void Apply(IGraph input, IGraph output)
        {
            //Infer information
            List<Triple> inferences = new List<Triple>();
            foreach (Triple t in input.Triples)
            {
                //Apply class/property hierarchy inferencing
                if (t.Predicate.Equals(this._rdfType))
                {
                    if (!t.Object.Equals(this._rdfsClass) && !t.Object.Equals(this._rdfProperty))
                    {
                        this.InferClasses(t, input, output, inferences);
                    }
                }
                else if (t.Predicate.Equals(this._rdfsSubClass))
                {
                    //Assert that this thing is a Class
                    inferences.Add(new Triple(t.Subject.CopyNode(output), this._rdfType.CopyNode(output), this._rdfsClass.CopyNode(output)));
                }
                else if (t.Predicate.Equals(this._rdfsSubProperty))
                {
                    //Assert that this thing is a Property
                    inferences.Add(new Triple(t.Subject.CopyNode(output), this._rdfType.CopyNode(output), this._rdfProperty.CopyNode(output)));
                }
                else if (this._propertyMappings.ContainsKey(t.Predicate))
                {
                    INode property = t.Predicate;

                    //Navigate up the property hierarchy asserting additional properties if able
                    while (this._propertyMappings.ContainsKey(property))
                    {
                        if (this._propertyMappings[property] != null)
                        {
                            //Assert additional properties
                            inferences.Add(new Triple(t.Subject.CopyNode(output), this._propertyMappings[property].CopyNode(output), t.Object.CopyNode(output)));
                            property = this._propertyMappings[property];
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                //Apply Domain and Range inferencing on Predicates
                if (this._rangeMappings.ContainsKey(t.Predicate))
                {
                    //Assert additional type information
                    foreach (INode n in this._rangeMappings.GetValues(t.Predicate))
                    {
                        inferences.Add(new Triple(t.Object.CopyNode(output), this._rdfType.CopyNode(output), n.CopyNode(output)));
                    }

                    //Call InferClasses to get extra type information
                    this.InferClasses(inferences[inferences.Count - 1], input, output, inferences);
                }
                if (this._domainMappings.ContainsKey(t.Predicate))
                {
                    //Assert additional type information
                    foreach (INode n in this._domainMappings.GetValues(t.Predicate))
                    {
                        inferences.Add(new Triple(t.Subject.CopyNode(output), this._rdfType.CopyNode(output), n.CopyNode(output)));
                    }
                    
                    //Call InferClasses to get extra type information
                    this.InferClasses(inferences[inferences.Count - 1], input, output, inferences);
                }
            }

            //Assert the inferred information
            inferences.RemoveAll(t => t.Subject.NodeType == NodeType.Literal);
            if (inferences.Count > 0)
            {
                output.Assert(inferences);
            }
        }
예제 #47
0
        /// <summary>
        /// Loads a Graph from the Quad Store
        /// </summary>
        /// <param name="g">Graph to load into</param>
        /// <param name="graphUri">Uri of the Graph to Load</param>
        public void LoadGraph(IGraph g, Uri graphUri)
        {
            if (graphUri == null) throw new RdfStorageException("Cannot load an unnamed Graph from Virtuoso as this would require loading the entirety of the Virtuoso Quad Store into memory!");

            if (!g.IsEmpty)
            {
                //Do the load into a new Empty Graph and then do a merge
                Graph h = new Graph();
                this.LoadGraph(h, graphUri);
                g.Merge(h);
                return;
            }

            try
            {
                g.BaseUri = graphUri;

                //Need to keep Database Open as Literals require extra trips to the Database to get additional
                //information about Language and Type
                this.Open(false);

                DataTable data = this.LoadTriples(graphUri);

                foreach (DataRow row in data.Rows)
                {
                    Object s, p, o;
                    INode subj, pred, obj;

                    //Get Data
                    s = row["S"];
                    p = row["P"];
                    o = row["O"];

                    //Create Nodes
                    subj = this.LoadNode(g, s);
                    pred = this.LoadNode(g, p);
                    obj = this.LoadNode(g, o);

                    //Assert Triple
                    g.Assert(new Triple(subj, pred, obj));
                }
                this.Close(false);
            }
            catch
            {
                this.Close(true);
                throw;
            }
        }
예제 #48
0
        public static void thingOneOf(IGraph graph, IUriNode[] listInds)
        {
            IBlankNode oneOfNode = graph.CreateBlankNode();
            IBlankNode chainA = graph.CreateBlankNode();
            IUriNode rdfType = graph.CreateUriNode(new Uri(RdfSpecsHelper.RdfType));
            IUriNode rdfFirst = graph.CreateUriNode(new Uri(RdfSpecsHelper.RdfListFirst));
            IUriNode rdfRest = graph.CreateUriNode(new Uri(RdfSpecsHelper.RdfListRest));
            IUriNode rdfNil = graph.CreateUriNode(new Uri(RdfSpecsHelper.RdfListNil));
            IUriNode owlClass = graph.CreateUriNode(new Uri(NamespaceMapper.OWL + "Class"));
            IUriNode owlOneOf = graph.CreateUriNode(new Uri(NamespaceMapper.OWL + "oneOf"));
            IUriNode owlThing = graph.CreateUriNode(new Uri(NamespaceMapper.OWL + "Thing"));
            IUriNode owlEquivClass = graph.CreateUriNode(new Uri(NamespaceMapper.OWL + "equivalentClass"));

            graph.Assert(new Triple(oneOfNode, rdfType, owlClass));
            graph.Assert(new Triple(oneOfNode, owlOneOf, chainA));
            graph.Assert(new Triple(owlThing, owlEquivClass, oneOfNode));

            for (int i = 0; i < listInds.Length; i++)
            {
                graph.Assert(new Triple(chainA, rdfFirst, listInds[i]));
                IBlankNode chainB = graph.CreateBlankNode();

                if (i < listInds.Length - 1)
                {
                    graph.Assert(new Triple(chainA, rdfRest, chainB));
                    chainA = chainB;
                }
            }
            graph.Assert(new Triple(chainA, rdfRest, rdfNil));
        }
예제 #49
0
        /// <summary>
        /// Loads Triples for the Graph with the given ID into the given Graph object
        /// </summary>
        /// <param name="g">Graph to load into</param>
        /// <param name="graphID">Database Graph ID</param>
        public override void LoadTriples(IGraph g, string graphID)
        {
            //Build the SQL for getting the Triples
            String getTriples = "SELECT * FROM GRAPH_TRIPLES G INNER JOIN TRIPLES T ON G.tripleID=T.tripleID WHERE G.graphID=" + graphID;

            //Get the Data
            this.Open(true);
            DataTable data = this.ExecuteQuery(getTriples);

            //Load the Triples
            String s, p, o;
            INode subj, pred, obj;
            foreach (DataRow r in data.Rows)
            {
                //Get the IDs
                s = r["tripleSubject"].ToString();
                p = r["triplePredicate"].ToString();
                o = r["tripleObject"].ToString();

                //Get the Nodes from these IDs
                subj = this.LoadNode(g, s);
                pred = this.LoadNode(g, p);
                obj = this.LoadNode(g, o);

                Triple t = new Triple(subj, pred, obj);
                g.Assert(t);

                //Store ID for later
                try
                {
                    Monitor.Enter(this._tripleIDs);
                    if (!this._tripleIDs.ContainsKey(t.GetHashCode()))
                    {
                        int id = Int32.Parse(r["tripleID"].ToString());
                        this._tripleIDs.Add(t.GetHashCode(), id);
                    }
                }
                finally
                {
                    Monitor.Exit(this._tripleIDs);
                }
            }

            //Close the Database Connection
            this.Close(true);
        }
        public static void Rebase(IGraph source, IGraph destination, Uri sourceUri, Uri destinationUri)
        {
            Uri modifiedDestinationUri = new Uri(destinationUri.ToString().Replace('#', '/'));

            foreach (Triple triple in source.Triples)
            {
                Uri subjectUri;
                if (triple.Subject.ToString() == destinationUri.ToString())
                {
                    subjectUri = modifiedDestinationUri;
                }
                else
                {
                    subjectUri = RebaseUri(((IUriNode)triple.Subject).Uri, sourceUri, modifiedDestinationUri);
                }

                INode subjectNode = destination.CreateUriNode(subjectUri);
                INode predicateNode = triple.Predicate.CopyNode(destination);

                INode objectNode;
                if (triple.Object is IUriNode)
                {
                    Uri objectUri = RebaseUri(((IUriNode)triple.Object).Uri, sourceUri, modifiedDestinationUri);
                    objectNode = destination.CreateUriNode(objectUri);
                }
                else
                {
                    objectNode = triple.Object.CopyNode(destination);
                }

                destination.Assert(subjectNode, predicateNode, objectNode);
            }
        }
예제 #51
0
 /// <summary>
 /// Converts a Sesame Graph to a dotNetRDF Graph
 /// </summary>
 /// <param name="source">Sesame Graph</param>
 /// <param name="mapping">Blank Node Mapping</param>
 /// <param name="target">dotNetRDF Graph</param>
 public static void FromSesame(dotSesame.Graph source, SesameMapping mapping, IGraph target)
 {
     Iterator iter = source.iterator();
     while (iter.hasNext())
     {
         dotSesame.Statement stmt = (dotSesame.Statement)iter.next();
         target.Assert(FromSesame(stmt, mapping));
     }
 }
 public override void ApplyToGraph(IGraph graph, IUriNode parent)
 {
     graph.Assert(parent, graph.CreateUriNode(new Uri(CantonConstants.CantonSchema + "origin")), graph.CreateLiteralNode(_origin));
     graph.Assert(parent, graph.CreateUriNode(new Uri(CantonConstants.CantonSchema + "commitId")), graph.CreateLiteralNode("" + _commitId));
 }
예제 #53
0
 /// <summary>
 /// Applies the reasoner to the given input Graph outputting inferences into the output Graph
 /// </summary>
 /// <param name="input">Input Graph</param>
 /// <param name="output">Output Graph</param>
 public virtual void Apply(IGraph input, IGraph output)
 {
     output.Assert(this._reasoner.Extract(OwlHelper.OwlExtractMode.AllStatements));
 }