AGTripleIds.java
package com.franz.ag.examples;
import com.franz.ag.*;
import org.openrdf.model.Literal;
public class AGTripleIds {
@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("tripleids", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex","http://example.org/");
Triple tr1 = ts.newTriple("!ex:Dog","!rdf:type","!owl:Class");
Triple tr2 = ts.newTriple("!ex:Dog","!rdfs:subClassOf","!ex:Mammal");
System.out.println("Created and added the following triples to the store:");
AGUtils.showTriple(tr1);
AGUtils.showTriple(tr2);
long tr2_id = tr2.queryAGId();
Literal lit = ts.createEncodedLiteral(tr2_id,"triple-id");
Triple tr3 = ts.newTriple("!ex:person1", "!ex:believes", lit);
AGUtils.showTriple(tr3);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next