AGSparqlGraphs.java
package com.franz.ag.examples;
import com.franz.ag.*;
import org.openrdf.model.URI;
public class AGSparqlGraphs {
@param
@throws
public static void main(String[] args) throws AllegroGraphException {
AllegroGraphConnection ags = new AllegroGraphConnection();
try {
ags.enable();
} catch (Exception e) {
throw new AllegroGraphException("Server connection problem", e);
}
AllegroGraph ts = ags.renew("sparqlnamedgraphs", AGPaths.TRIPLE_STORES);
URI g = ts.createURI("http://example.org/kennedy/");
long n = ts.loadNTriples(AGPaths.dataSources("kennedy.ntriples"), g);
System.out.println("Loaded " + n + " triples.");
Cursor cc = ts.getStatements(null, null, ts.createLiteral("Arnold"), g);
AGUtils.showTriples(cc);
String query =
"PREFIX ex: <http://example.org/kennedy/> " +
"SELECT ?name " +
"FROM NAMED <http://example.org/kennedy/> " +
"WHERE { GRAPH ex: { " +
"?place ex:name ?name " +
"}} " +
"ORDER BY ?name " +
"LIMIT 20";
AGUtils.doSparqlSelect(ts, query);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next