forked from projectdanube/xdi2-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 0
Code Example
Markus Sabadello edited this page Sep 4, 2013
·
1 revision
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.xri3.XDI3Segment;
import xdi2.core.xri3.XDI3SubSegment;
public class Test {
public static void main(String[] args) throws Exception {
MongoDBJSONGraphFactory graphFactory = new MongoDBJSONGraphFactory();
graphFactory.setHost("localhost");
Graph graph = graphFactory.openGraph("(=!1111)");
graph.clear();
ContextNode contextNode = graph.getRootContextNode().setContextNode(XDI3SubSegment.create("=markus"));
contextNode.setDeepContextNode(XDI3Segment.create("<+email>&")).setLiteral("[email protected]");
contextNode.setDeepContextNode(XDI3Segment.create("<+name>&")).setLiteral("Markus");
contextNode.setRelation(XDI3Segment.create("+friend"), XDI3Segment.create("=shrey"));
contextNode.setRelation(XDI3Segment.create("+friend"), XDI3Segment.create("=animesh"));
contextNode.setRelation(XDI3Segment.create("+founder"), XDI3Segment.create("@projectdanube"));
XDIWriterRegistry.forFormat("XDI DISPLAY", null).write(graph, System.out);
graph.close();
}
}