This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.jena.playground; | |
import org.apache.jena.atlas.io.IndentedWriter; | |
import com.hp.hpl.jena.graph.Node; | |
import com.hp.hpl.jena.graph.NodeFactory; | |
import com.hp.hpl.jena.graph.Triple; | |
import com.hp.hpl.jena.sparql.algebra.AlgebraQuad; | |
import com.hp.hpl.jena.sparql.algebra.Op; | |
import com.hp.hpl.jena.sparql.algebra.Transform; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume we already have a StardogConnector in the variable Stardog | |
// Firstly need to parse our updates | |
SparqlUpdateCommandSet updates = new SparqlUpdateParser().ParseFromString(@" | |
INSERT DATA { GRAPH <http://example.org/graph> { <http://s> <http://p> <http://o } } | |
"); | |
// Then we can create an update processor and execute the updates | |
GenericUpdateProcessor processor = new GenericUpdateProcessor(stardog); | |
processor.ProcessCommandSet(updates); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume we have a StardogConnector in the variable stardog | |
// Create the update | |
SparqlParameterizedString updateString = new SparqlParameterizedString(); | |
updateString.CommandText = @"DELETE WHERE | |
{ | |
?s a @type . | |
}"; | |
// Set the parameter | |
updateString.SetUri("type", new Uri("http://example.org/myType")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume we already have a StardogConnector in the variable Stardog | |
stardog.Update(@" | |
INSERT DATA { GRAPH <http://example.org/graph> { <http://s> <http://p> <http://o } } | |
"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume we have a StardogConnector in the variable stardog | |
// Create the query | |
SparqlParameterizedString queryString = new SparqlParameterizedString(); | |
queryString.CommandText = @"SELECT * WHERE | |
{ | |
?s a @type . | |
}"; | |
// Set the parameter | |
queryString.SetUri("type", new Uri("http://example.org/myType")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume we already have a StardogConnector in the variable stardog | |
// Deleting a graph simply requires the URI of the graph to delete | |
stardog.DeleteGraph(new Uri("http://example.org/name")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume we already have a StardogConnector in the variable Stardog | |
SparqlResultSet results = stardog.Query(@" | |
SELECT DISTINCT ?type WHERE { [] a ?type } LIMIT 10 | |
") as SparqlResultSet; | |
// Now work with the SPARQL Results as desired... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assumes we already have a StardogConnector in the variable stardog | |
// Create the Triples we want to remove | |
NodeFactory factory = new NodeFactory(); | |
List<Triple> toRemove = new List<Triple>(); | |
toRemove.Add(new Triple(factory.CreateUriNode(new Uri("http://subject")), | |
factory.createUriNode(new Uri("http://predicate")), | |
factory.CreateUriNode(new Uri("http://object")) | |
); | |
// And so forth... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assuming we already have a StardogConnector in the variable Stardog | |
// Define a Graph that will receive our data | |
IGraph g = new Graph(); | |
// Load from Stardog | |
stardog.LoadGraph(g, new Uri("http://example.org/name")); |
NewerOlder