AGFederationBasics.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGFederationBasics {
@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);
AllegroGraph[] parts = {ts1,ts2};
AllegroGraph fed = ags.federate("federation", parts, true);
AllegroGraph[] stores = fed.getStores();
AGUtils.printObjectArray("federation stores:", stores);
ts1.registerNamespace("ex", "http://example.org/");
ts2.registerNamespace("ex", "http://example.org/");
ts1.addStatement("!ex:A", "!rdfs:subClassOf", "!ex:B");
ts2.addStatement("!ex:B", "!rdfs:subClassOf", "!ex:C");
Cursor cc = ts1.getStatements(null, null, null);
System.out.println("Showing all triples in the default graph of store1:");
AGUtils.showTriplesWithGraph(cc);
cc = ts2.getStatements(null, null, null);
System.out.println("Showing all triples in the default graph of store2:");
AGUtils.showTriplesWithGraph(cc);
cc = fed.getStatements(null, null, null);
System.out.println("Retrieving all triples in the default graph of the federated store (should be empty):");
AGUtils.showTriplesWithGraph(cc);
cc = fed.getStatements(null, null, null, null);
System.out.println("Retrieving all triples in the federated store:");
AGUtils.showTriplesWithGraph(cc);
cc = fed.getStatements(true, null, null, null, null);
System.out.println("Showing all triples inferred from the federated store:");
AGUtils.showTriplesWithGraph(cc);
fed.closeTripleStore();
ts1.closeTripleStore();
ts2.closeTripleStore();
ags.disable();
}
}
Up |
Next