-
Notifications
You must be signed in to change notification settings - Fork 3
Code Example
peacekeeper edited this page Nov 17, 2014
·
2 revisions
package test;
import xdi2.core.ContextNode;
import xdi2.core.Graph;
import xdi2.core.impl.json.mongodb.MongoDBJSONGraphFactory;
import xdi2.core.io.XDIWriterRegistry;
import xdi2.core.syntax.XDIAddress;
import xdi2.core.syntax.XDIArc;
public class Test {
public static void main(String[] args) throws Exception {
MongoDBJSONGraphFactory graphFactory = new MongoDBJSONGraphFactory();
graphFactory.setHost("localhost");
Graph graph = graphFactory.openGraph("([=]!:uuid:1111)");
graph.clear();
ContextNode contextNode = graph.getRootContextNode().setContextNode(XDIArc.create("=markus"));
contextNode.setDeepContextNode(XDIAddress.create("<#email>&")).setLiteral("markus@projectdanube.org");
contextNode.setDeepContextNode(XDIAddress.create("<#name>&")).setLiteral("Markus");
contextNode.setRelation(XDIAddress.create("#friend"), XDIAddress.create("=shrey"));
contextNode.setRelation(XDIAddress.create("#friend"), XDIAddress.create("=animesh"));
contextNode.setRelation(XDIAddress.create("$is#founder"), XDIAddress.create("+projectdanube"));
XDIWriterRegistry.forFormat("XDI DISPLAY", null).write(graph, System.out);
graph.close();
}
}
This work is licensed under a Creative Commons Attribution 4.0 International License.