Skip to content
peacekeeper edited this page Nov 17, 2014 · 5 revisions
package test;

import xdi2.core.ContextNode;
import xdi2.core.Graph;
import xdi2.core.impl.json.redis.RedisJSONGraphFactory;
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 {

        RedisJSONGraphFactory graphFactory = new RedisJSONGraphFactory();
        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("[email protected]");
        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();
    }
}
Clone this wiki locally