AGSparqlOrderBy.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGSparqlOrderBy {
@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("sparqlorderby", AGPaths.TRIPLE_STORES);
AGUtils.loadNTriplesWithTiming(ts,AGPaths.dataSources("kennedy.ntriples"));
ts.indexAllTriples(true);
String query =
"PREFIX ex: <http://example.org/kennedy/> " +
"SELECT ?fname ?lname ?year " +
"WHERE { ?person ex:last-name ?lname . " +
"?person ex:first-name ?fname . " +
"?person ex:birth-year ?year " +
"}" +
"ORDER BY ?year ";
AGUtils.doSparqlSelect(ts, query);
query =
"PREFIX ex: <http://example.org/kennedy/> " +
"SELECT ?fname ?lname ?year " +
"WHERE { ?person ex:last-name ?lname . " +
"?person ex:first-name ?fname . " +
"?person ex:birth-year ?year " +
"}" +
"ORDER BY ?lname DESC(?year) ";
AGUtils.doSparqlSelect(ts, query);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next