AGTemporalLoading.java
package com.franz.agbase.examples;
import com.franz.agbase.*;
public class AGTemporalLoading {
@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("temporal", AGPaths.TRIPLE_STORES);
String[] map = new String[3];
map[0] = "http://www.w3.org/2000/01/XMLSchema#dateTime";
map[1] = "date-time";
map[2] = "datatype";
ts.addDataMapping(map);
AGLoadNtriples.loadNTriplesWithTiming(ts, AGPaths.dataSources("temporal.nt"));
AGIndexAllTriples.indexAllTriplesWithTiming(ts);
ts.registerNamespace("ex", "http://example.org/");
ts.registerNamespace("t", "http://franz.com/ns/allegrograph/3.0/temporal/");
PrologSelectQuery q = new PrologSelectQuery();
q.setTripleStore(ts);
q.setDistinct(true);
String pquery = "(q ?pt !t:time ?dt)";
q.setVariables(new String[]{"pt","dt"});
q.setQuery(pquery);
ValueSetIterator it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
pquery = "(q ?i !t:startpoint ?pt)";
q.setVariables(new String[]{"i","pt"});
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
pquery = "(q ?i !t:endpoint ?pt)";
q.setVariables(new String[]{"i","pt"});
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
pquery = "(q ?i !t:starttime ?dt)";
q.setVariables(new String[]{"i","dt"});
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
pquery = "(q ?i !t:endtime ?dt)";
q.setVariables(new String[]{"i","dt"});
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next