AGJenaGraphMakerInterface.java
package com.franz.agjena.examples;
import com.franz.agbase.AllegroGraph;
import com.franz.agbase.AllegroGraphConnection;
import com.franz.agbase.AllegroGraphException;
import com.franz.agbase.examples.AGPaths;
import com.franz.agjena.AllegroGraphGraphMaker;
import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.graph.GraphMaker;
import com.hp.hpl.jena.shared.ReificationStyle;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
public class AGJenaGraphMakerInterface {
@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 ts1 = ags.renew("store1", AGPaths.TRIPLE_STORES);
AllegroGraph ts2 = ags.renew("store2", AGPaths.TRIPLE_STORES);
GraphMaker maker1 = new AllegroGraphGraphMaker(ts1);
GraphMaker maker2 = new AllegroGraphGraphMaker(ts2);
Graph defaultGraph1 = maker1.getGraph();
showGraphName(defaultGraph1);
Graph defaultGraph2 = maker2.getGraph();
showGraphName(defaultGraph2);
Graph anonGraph1a = maker1.createGraph();
showGraphName(anonGraph1a);
Graph anonGraph1b = maker1.createGraph();
showGraphName(anonGraph1b);
Graph anonGraph2a = maker2.createGraph();
showGraphName(anonGraph2a);
Graph anonGraph2b = maker2.createGraph();
showGraphName(anonGraph2b);
Graph foo1 = maker1.createGraph("http://example.org/foo", true);
showGraphName(foo1);
Graph foo2 = maker2.createGraph("http://example.org/foo", true);
showGraphName(foo2);
ExtendedIterator it1 = maker1.listGraphs();
while (it1.hasNext()) {
System.out.println(it1.next());
}
ExtendedIterator it2 = maker2.listGraphs();
while (it2.hasNext()) {
System.out.println(it2.next());
}
ReificationStyle rs = maker1.getReificationStyle();
System.out.println("ReificationStyle: " + rs.toString());
ts1.closeTripleStore();
ts2.closeTripleStore();
ags.disable();
}
public static void showGraphName(Graph g) {
System.out.println(g.toString());
}
}
Up |
Next