AGTemporalPointPointRelations.java
package com.franz.agbase.examples;
import com.franz.agbase.*;
public class AGTemporalPointPointRelations {
@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 = "(point-simultaneous ?pt !ex:pt3)";
q.setVariables(new String[]{"pt"});
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
pquery = "(point-before ?pt !ex:pt3)";
q.setVariables(new String[]{"pt"});
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
pquery = "(point-before !ex:pt3 ?pt)";
q.setVariables(new String[]{"pt"});
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
pquery = "(point-after ?pt !ex:pt6)";
q.setVariables(new String[]{"pt"});
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
pquery = "(point-after !ex:pt6 ?pt)";
q.setVariables(new String[]{"pt"});
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next