use of org.openrdf.query.Update in project incubator-rya by apache.
the class InferenceExamples method testSomeValuesFromInference.
public static void testSomeValuesFromInference(final SailRepositoryConnection conn, final Sail sail) throws MalformedQueryException, RepositoryException, UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException, InferenceEngineException {
final String lubm = "http://swat.cse.lehigh.edu/onto/univ-bench.owl#";
log.info("Adding Data");
String insert = "PREFIX lubm: <" + lubm + ">\n" + "INSERT DATA { GRAPH <http://updated/test> {\n" + " <urn:Department0> a lubm:Department; lubm:subOrganizationOf <urn:University0> .\n" + " <urn:ResearchGroup0> a lubm:ResearchGroup; lubm:subOrganizationOf <urn:Department0> .\n" + " <urn:Alice> lubm:headOf <urn:Department0> .\n" + " <urn:Bob> lubm:headOf <urn:ResearchGroup0> .\n" + " <urn:Carol> lubm:worksFor <urn:Department0> .\n" + "}}";
Update update = conn.prepareUpdate(QueryLanguage.SPARQL, insert);
update.execute();
final String inferQuery = "select distinct ?x { GRAPH <http://updated/test> { ?x a <" + lubm + "Chair> }}";
final String explicitQuery = "prefix lubm: <" + lubm + ">\n" + "select distinct ?x { GRAPH <http://updated/test> {\n" + " { ?x a lubm:Chair }\n" + " UNION\n" + " { ?x lubm:headOf [ a lubm:Department ] }\n" + "}}";
log.info("Running Explicit Query");
final CountingResultHandler resultHandler = new CountingResultHandler();
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, explicitQuery);
tupleQuery.evaluate(resultHandler);
log.info("Result count : " + resultHandler.getCount());
Validate.isTrue(resultHandler.getCount() == 1);
log.info("Running Inference-dependent Query");
resultHandler.resetCount();
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, inferQuery);
tupleQuery.evaluate(resultHandler);
log.info("Result count : " + resultHandler.getCount());
Validate.isTrue(resultHandler.getCount() == 0);
log.info("Adding owl:someValuesFrom Schema");
insert = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX owl: <" + OWL.NAMESPACE + ">\n" + "PREFIX lubm: <" + lubm + ">\n" + "INSERT DATA\n" + "{ GRAPH <http://updated/test> {\n" + " lubm:Chair owl:equivalentClass [ owl:onProperty lubm:headOf ; owl:someValuesFrom lubm:Department ] ." + "}}";
update = conn.prepareUpdate(QueryLanguage.SPARQL, insert);
update.execute();
log.info("Refreshing InferenceEngine");
((RdfCloudTripleStore) sail).getInferenceEngine().refreshGraph();
log.info("Re-running Inference-dependent Query");
resultHandler.resetCount();
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, inferQuery);
tupleQuery.evaluate(resultHandler);
log.info("Result count : " + resultHandler.getCount());
Validate.isTrue(resultHandler.getCount() == 1);
}
use of org.openrdf.query.Update in project incubator-rya by apache.
the class RyaDirectExample method testDeleteTemporalData.
// private static void testAddPointAndWithinSearchWithPCJ(
// final SailRepositoryConnection conn) throws Exception {
//
// final String update = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
// + "INSERT DATA { " //
// + " <urn:feature> a geo:Feature ; " //
// + " geo:hasGeometry [ " //
// + " a geo:Point ; " //
// + " geo:asWKT \"Point(-77.03524 38.889468)\"^^geo:wktLiteral "//
// + " ] . " //
// + "}";
//
// final Update u = conn.prepareUpdate(QueryLanguage.SPARQL, update);
// u.execute();
//
// String queryString;
// TupleQuery tupleQuery;
// CountingResultHandler tupleHandler;
//
// // point outside search ring
// queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
// + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
// + "SELECT ?feature ?point ?wkt " //
// + "{" //
// + " ?feature a geo:Feature . "//
// + " ?feature geo:hasGeometry ?point . "//
// + " ?point a geo:Point . "//
// + " ?point geo:asWKT ?wkt . "//
// + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-77 39, -76 39, -76 38, -77 38, -77 39))\"^^geo:wktLiteral)) " //
// + "}";//
// tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
// tupleHandler = new CountingResultHandler();
// tupleQuery.evaluate(tupleHandler);
// log.info("Result count : " + tupleHandler.getCount());
// Validate.isTrue(tupleHandler.getCount() == 0);
//
// // point inside search ring
// queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
// + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
// + "SELECT ?feature ?point ?wkt ?e ?l ?o" //
// + "{" //
// + " ?feature a ?e . "//
// + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
// + " ?e <uri:talksTo> ?o . "//
// + " ?feature a geo:Feature . "//
// + " ?feature geo:hasGeometry ?point . "//
// + " ?point a geo:Point . "//
// + " ?point geo:asWKT ?wkt . "//
// + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " //
// + "}";//
//
// tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
// tupleHandler = new CountingResultHandler();
// tupleQuery.evaluate(tupleHandler);
// log.info("Result count : " + tupleHandler.getCount());
// Validate.isTrue(tupleHandler.getCount() == 1);
//
// // point inside search ring with Pre-Computed Join
// queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
// + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
// + "SELECT ?feature ?point ?wkt ?e ?l ?o" //
// + "{" //
// + " ?feature a ?e . "//
// + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
// + " ?e <uri:talksTo> ?o . "//
// + " ?feature a geo:Feature . "//
// + " ?feature geo:hasGeometry ?point . "//
// + " ?point a geo:Point . "//
// + " ?point geo:asWKT ?wkt . "//
// + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " //
// + "}";//
//
// tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
// tupleHandler = new CountingResultHandler();
// tupleQuery.evaluate(tupleHandler);
// log.info("Result count : " + tupleHandler.getCount());
// Validate.isTrue(tupleHandler.getCount() >= 1); // may see points from
// // during previous runs
//
// // point outside search ring with PCJ
// queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
// + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
// + "SELECT ?feature ?point ?wkt ?e ?l ?o " //
// + "{" //
// + " ?feature a ?e . "//
// + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
// + " ?e <uri:talksTo> ?o . "//
// + " ?feature a geo:Feature . "//
// + " ?feature geo:hasGeometry ?point . "//
// + " ?point a geo:Point . "//
// + " ?point geo:asWKT ?wkt . "//
// + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-77 39, -76 39, -76 38, -77 38, -77 39))\"^^geo:wktLiteral)) " //
// + "}";//
// tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
// tupleHandler = new CountingResultHandler();
// tupleQuery.evaluate(tupleHandler);
// log.info("Result count : " + tupleHandler.getCount());
// Validate.isTrue(tupleHandler.getCount() == 0);
//
// // point inside search ring with different Pre-Computed Join
// queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
// + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
// + "SELECT ?feature ?point ?wkt ?e ?c ?l ?o " //
// + "{" //
// + " ?e a ?c . "//
// + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
// + " ?e <uri:talksTo> ?o . "//
// + " ?feature a geo:Feature . "//
// + " ?feature geo:hasGeometry ?point . "//
// + " ?point a geo:Point . "//
// + " ?point geo:asWKT ?wkt . "//
// + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " //
// + "}";//
// tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
// tupleHandler = new CountingResultHandler();
// tupleQuery.evaluate(tupleHandler);
// log.info("Result count : " + tupleHandler.getCount());
// Validate.isTrue(tupleHandler.getCount() == 1);
// }
//
// private static void testTemporalFreeGeoSearch(
// final SailRepositoryConnection conn)
// throws MalformedQueryException, RepositoryException,
// UpdateExecutionException, TupleQueryResultHandlerException,
// QueryEvaluationException {
//
// String queryString;
// TupleQuery tupleQuery;
// CountingResultHandler tupleHandler;
//
// // ring containing point
// queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
// + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
// + "PREFIX time: <http://www.w3.org/2006/time#> "//
// + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> "//
// + "PREFIX fts: <http://rdf.useekm.com/fts#> "//
// + "SELECT ?feature ?point ?wkt ?event ?time ?person ?match" //
// + "{" //
// + " ?event a time:Instant . \n"//
// + " ?event time:inXSDDateTime ?time . \n"//
// + " FILTER(tempo:after(?time, '2001-01-01T01:01:03-08:00') ) \n"// after
// // 3
// // seconds
// + " ?feature a geo:Feature . "//
// + " ?feature geo:hasGeometry ?point . "//
// + " ?point a geo:Point . "//
// + " ?point geo:asWKT ?wkt . "//
// + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)). " //
// + " ?person a <http://example.org/ontology/Person> . "//
// + " ?person <http://www.w3.org/2000/01/rdf-schema#label> ?match . "//
// + " FILTER(fts:text(?match, \"pal*\")) " //
// + "}";//
//
// tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
//
// tupleHandler = new CountingResultHandler();
// tupleQuery.evaluate(tupleHandler);
// log.info("Result count : " + tupleHandler.getCount());
// Validate.isTrue(tupleHandler.getCount() == 5);
//
// }
//
// private static void testGeoFreetextWithPCJSearch(
// final SailRepositoryConnection conn)
// throws MalformedQueryException, RepositoryException,
// TupleQueryResultHandlerException, QueryEvaluationException {
// // ring outside point
// final String queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
// + "PREFIX fts: <http://rdf.useekm.com/fts#> "//
// + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
// + "SELECT ?feature ?point ?wkt ?e ?c ?l ?o ?person ?match " //
// + "{" //
// + " ?person a <http://example.org/ontology/Person> . "//
// + " ?person <http://www.w3.org/2000/01/rdf-schema#label> ?match . "//
// + " FILTER(fts:text(?match, \"!alice & hose\")) " //
// + " ?e a ?c . "//
// + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
// + " ?e <uri:talksTo> ?o . "//
// + " ?feature a geo:Feature . "//
// + " ?feature geo:hasGeometry ?point . "//
// + " ?point a geo:Point . "//
// + " ?point geo:asWKT ?wkt . "//
// + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " //
// + "}";//
// final TupleQuery tupleQuery = conn.prepareTupleQuery(
// QueryLanguage.SPARQL, queryString);
// final CountingResultHandler tupleHandler = new CountingResultHandler();
// tupleQuery.evaluate(tupleHandler);
// log.info("Result count : " + tupleHandler.getCount());
// Validate.isTrue(tupleHandler.getCount() == 1);
// }
private static void testDeleteTemporalData(final SailRepositoryConnection conn) throws Exception {
// Delete all stored dates
final String sparqlDelete = "PREFIX time: <http://www.w3.org/2006/time#>\n" + //
"PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n" + //
"DELETE {\n" + " ?event time:inXSDDateTime ?time . \n" + "}\n" + "WHERE { \n" + //
" ?event time:inXSDDateTime ?time . \n" + //
"}";
final Update deleteUpdate = conn.prepareUpdate(QueryLanguage.SPARQL, sparqlDelete);
deleteUpdate.execute();
// Find all stored dates.
final String queryString = //
"PREFIX time: <http://www.w3.org/2006/time#> \n" + //
"PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n" + //
"SELECT ?event ?time \n" + "WHERE { \n" + //
" ?event time:inXSDDateTime ?time . \n" + // after
" FILTER(tempo:after(?time, '2001-01-01T01:01:03-08:00') ) \n" + // seconds
"}";
//
final CountingResultHandler tupleHandler = new CountingResultHandler();
final TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleQuery.evaluate(tupleHandler);
log.info("Result count : " + tupleHandler.getCount());
Validate.isTrue(tupleHandler.getCount() == 0);
}
use of org.openrdf.query.Update in project incubator-rya by apache.
the class RyaGeoDirectExample method testAddPointAndWithinSearchWithPCJ.
private static void testAddPointAndWithinSearchWithPCJ(final SailRepositoryConnection conn) throws Exception {
final String update = //
"PREFIX geo: <http://www.opengis.net/ont/geosparql#> " + //
"INSERT DATA { " + //
" <urn:feature> a geo:Feature ; " + //
" geo:hasGeometry [ " + //
" a geo:Point ; " + //
" geo:asWKT \"Point(-77.03524 38.889468)\"^^geo:wktLiteral " + //
" ] . " + "}";
final Update u = conn.prepareUpdate(QueryLanguage.SPARQL, update);
u.execute();
String queryString;
TupleQuery tupleQuery;
CountingResultHandler tupleHandler;
// point outside search ring
queryString = //
"PREFIX geo: <http://www.opengis.net/ont/geosparql#> " + //
"PREFIX geof: <http://www.opengis.net/def/function/geosparql/> " + //
"SELECT ?feature ?point ?wkt " + //
"{" + //
" ?feature a geo:Feature . " + //
" ?feature geo:hasGeometry ?point . " + //
" ?point a geo:Point . " + //
" ?point geo:asWKT ?wkt . " + //
" FILTER(geof:sfWithin(?wkt, \"POLYGON((-77 39, -76 39, -76 38, -77 38, -77 39))\"^^geo:wktLiteral)) " + //
"}";
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleHandler = new CountingResultHandler();
tupleQuery.evaluate(tupleHandler);
log.info("point outside search ring, Result count : " + tupleHandler.getCount());
Validate.isTrue(tupleHandler.getCount() == 0);
// point inside search ring
queryString = //
"PREFIX geo: <http://www.opengis.net/ont/geosparql#> " + //
"PREFIX geof: <http://www.opengis.net/def/function/geosparql/> " + // ?e ?l ?o" //
"SELECT ?feature ?point ?wkt " + //
"{" + // + " ?e <uri:talksTo> ?o . "//
" ?feature a geo:Feature . " + //
" ?feature geo:hasGeometry ?point . " + //
" ?point a geo:Point . " + //
" ?point geo:asWKT ?wkt . " + //
" FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " + //
"}";
//
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleHandler = new CountingResultHandler();
tupleQuery.evaluate(tupleHandler);
log.info("point inside search ring, Result count : " + tupleHandler.getCount());
Validate.isTrue(tupleHandler.getCount() == 1);
// point inside search ring with Pre-Computed Join
queryString = //
"PREFIX geo: <http://www.opengis.net/ont/geosparql#> " + //
"PREFIX geof: <http://www.opengis.net/def/function/geosparql/> " + // ?e ?l ?o" //
"SELECT ?feature ?point ?wkt " + //
"{" + // + " ?e <uri:talksTo> ?o . "//
" ?feature a geo:Feature . " + //
" ?feature geo:hasGeometry ?point . " + //
" ?point a geo:Point . " + //
" ?point geo:asWKT ?wkt . " + //
" FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " + //
"}";
//
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleHandler = new CountingResultHandler();
tupleQuery.evaluate(tupleHandler);
log.info("point inside search ring with Pre-Computed Join, Result count : " + tupleHandler.getCount());
// may see points from
Validate.isTrue(tupleHandler.getCount() >= 1);
// during previous runs
// point outside search ring with PCJ
queryString = //
"PREFIX geo: <http://www.opengis.net/ont/geosparql#> " + //
"PREFIX geof: <http://www.opengis.net/def/function/geosparql/> " + // ?e ?l ?o " //
"SELECT ?feature ?point ?wkt " + //
"{" + // + " ?e <uri:talksTo> ?o . "//
" ?feature a geo:Feature . " + //
" ?feature geo:hasGeometry ?point . " + //
" ?point a geo:Point . " + //
" ?point geo:asWKT ?wkt . " + //
" FILTER(geof:sfWithin(?wkt, \"POLYGON((-77 39, -76 39, -76 38, -77 38, -77 39))\"^^geo:wktLiteral)) " + //
"}";
//
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleHandler = new CountingResultHandler();
tupleQuery.evaluate(tupleHandler);
log.info("point outside search ring with PCJ, Result count : " + tupleHandler.getCount());
Validate.isTrue(tupleHandler.getCount() == 0);
// point inside search ring with different Pre-Computed Join
queryString = //
"PREFIX geo: <http://www.opengis.net/ont/geosparql#> " + //
"PREFIX geof: <http://www.opengis.net/def/function/geosparql/> " + // ?wkt ?e ?c ?l ?o " //
"SELECT ?feature ?point " + //
"{" + // + " ?feature a geo:Feature . "//
" ?feature geo:hasGeometry ?point . " + //
" ?point a geo:Point . " + //
" ?point geo:asWKT ?wkt . " + //
" FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " + //
"}";
//
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleHandler = new CountingResultHandler();
tupleQuery.evaluate(tupleHandler);
log.info("point inside search ring with different Pre-Computed Join, Result count : " + tupleHandler.getCount());
Validate.isTrue(tupleHandler.getCount() == 1);
}
use of org.openrdf.query.Update in project incubator-rya by apache.
the class RyaMongoGeoDirectExample method testAddPointAndWithinSearch.
/**
* Try out some geospatial data and queries
* @param repository
*/
private static void testAddPointAndWithinSearch(SailRepositoryConnection conn) throws Exception {
String update = //
"PREFIX geo: <http://www.opengis.net/ont/geosparql#> " + //
"INSERT DATA { " + //
" <urn:feature> a geo:Feature ; " + //
" geo:hasGeometry [ " + //
" a geo:Point ; " + //
" geo:asWKT \"Point(-77.03524 38.889468)\"^^geo:wktLiteral " + //
" ] . " + "}";
Update u = conn.prepareUpdate(QueryLanguage.SPARQL, update);
u.execute();
String queryString;
TupleQuery tupleQuery;
CountingResultHandler tupleHandler;
// ring containing point
queryString = //
"PREFIX geo: <http://www.opengis.net/ont/geosparql#> " + //
"PREFIX geof: <http://www.opengis.net/def/function/geosparql/> " + //
"SELECT ?feature ?point ?wkt " + //
"{" + //
" ?feature a geo:Feature . " + //
" ?feature geo:hasGeometry ?point . " + //
" ?point a geo:Point . " + //
" ?point geo:asWKT ?wkt . " + //
" FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " + //
"}";
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleHandler = new CountingResultHandler();
tupleQuery.evaluate(tupleHandler);
log.info("Result count -- ring containing point: " + tupleHandler.getCount());
// may see points from during previous runs
Validate.isTrue(tupleHandler.getCount() >= 1);
// ring outside point
queryString = //
"PREFIX geo: <http://www.opengis.net/ont/geosparql#> " + //
"PREFIX geof: <http://www.opengis.net/def/function/geosparql/> " + //
"SELECT ?feature ?point ?wkt " + //
"{" + //
" ?feature a geo:Feature . " + //
" ?feature geo:hasGeometry ?point . " + //
" ?point a geo:Point . " + //
" ?point geo:asWKT ?wkt . " + //
" FILTER(geof:sfWithin(?wkt, \"POLYGON((-77 39, -76 39, -76 38, -77 38, -77 39))\"^^geo:wktLiteral)) " + //
"}";
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleHandler = new CountingResultHandler();
tupleQuery.evaluate(tupleHandler);
log.info("Result count -- ring outside point: " + tupleHandler.getCount());
Validate.isTrue(tupleHandler.getCount() == 0);
}
use of org.openrdf.query.Update in project incubator-rya by apache.
the class RdfCloudTripleStoreConnectionTest method testClearGraph.
public void testClearGraph() throws Exception {
RepositoryConnection conn = repository.getConnection();
String insert = "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n" + "PREFIX ex: <http://example/addresses#>\n" + "INSERT DATA\n" + "{ GRAPH ex:G1 {\n" + "<http://example/book3> dc:title \"A new book\" ;\n" + " dc:creator \"A.N.Other\" .\n" + "}\n" + "}";
Update update = conn.prepareUpdate(QueryLanguage.SPARQL, insert);
update.execute();
insert = "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n" + "PREFIX ex: <http://example/addresses#>\n" + "INSERT DATA\n" + "{ GRAPH ex:G2 {\n" + "<http://example/book3> dc:title \"A new book\" ;\n" + " dc:creator \"A.N.Other\" .\n" + "}\n" + "}";
update = conn.prepareUpdate(QueryLanguage.SPARQL, insert);
update.execute();
String query = "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n" + "select * where { <http://example/book3> ?p ?o. }";
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
CountTupleHandler tupleHandler = new CountTupleHandler();
tupleQuery.evaluate(tupleHandler);
assertEquals(4, tupleHandler.getCount());
tupleHandler = new CountTupleHandler();
conn.clear(new URIImpl("http://example/addresses#G2"));
tupleQuery.evaluate(tupleHandler);
assertEquals(2, tupleHandler.getCount());
tupleHandler = new CountTupleHandler();
conn.clear(new URIImpl("http://example/addresses#G1"));
tupleQuery.evaluate(tupleHandler);
assertEquals(0, tupleHandler.getCount());
conn.close();
}
Aggregations