AGFederationOfFederations.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGFederationOfFederations {
@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);
}
ags.registerNamespace("ex", "http://example.org/");
AllegroGraph ts1 = ags.renew("store1", AGPaths.TRIPLE_STORES);
AllegroGraph ts2 = ags.renew("store2", AGPaths.TRIPLE_STORES);
AllegroGraph ts3 = ags.renew("store3", AGPaths.TRIPLE_STORES);
AllegroGraph[] parts1 = {ts1,ts2};
AllegroGraph fed1 = ags.federate("federation1", parts1, true);
AllegroGraph[] parts2 = {fed1,ts3};
AllegroGraph fed2 = ags.federate("federation2", parts2, true);
AllegroGraph[] stores1 = fed1.getStores();
AGUtils.printObjectArray("federation1 stores:", stores1);
AllegroGraph[] stores2 = fed2.getStores();
AGUtils.printObjectArray("federation2 stores:", stores2);
ts1.addStatement("!ex:A", "!rdfs:subClassOf", "!ex:B");
ts2.addStatement("!ex:B", "!rdfs:subClassOf", "!ex:C");
ts3.addStatement("!ex:a", "!rdf:type", "!ex:A");
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 = ts3.getStatements(null, null, null);
System.out.println("Showing all triples in the default graph of store3:");
AGUtils.showTriplesWithGraph(cc);
cc = fed2.getStatements(null, null, null, null);
System.out.println("Retrieving all triples in federation2:");
AGUtils.showTriplesWithGraph(cc);
cc = fed2.getStatements(true, null, null, null, null);
System.out.println("Showing all triples inferred from federation2:");
AGUtils.showTriplesWithGraph(cc);
fed2.closeTripleStore();
fed1.closeTripleStore();
ts1.closeTripleStore();
ts2.closeTripleStore();
ags.disable();
}
}
Up |
Next