Search in sources :

Example 1 with SailGraph

use of com.tinkerpop.blueprints.impls.sail.SailGraph in project frames by tinkerpop.

the class SailFramesTest method setUp.

@Before
public void setUp() throws Exception {
    sail = new MemoryStore();
    sailGraph = new SailGraph(sail);
}
Also used : MemoryStore(org.openrdf.sail.memory.MemoryStore) SailGraph(com.tinkerpop.blueprints.impls.sail.SailGraph) Before(org.junit.Before)

Example 2 with SailGraph

use of com.tinkerpop.blueprints.impls.sail.SailGraph in project frames by tinkerpop.

the class SailFramesTest method testAll.

@Test
public void testAll() throws Exception {
    URI planet = new URIImpl("http://example.org/terms/planet");
    URI gasGiant = new URIImpl("http://example.org/terms/gasGiant");
    URI narrower = new URIImpl("http://www.w3.org/2004/02/skos/core#narrower");
    SailConnection sc = sail.getConnection();
    try {
        sc.begin();
        sc.addStatement(planet, RDFS.LABEL, new LiteralImpl("planet", "en"));
        sc.addStatement(gasGiant, RDFS.LABEL, new LiteralImpl("gas giant", "en"));
        sc.addStatement(planet, narrower, gasGiant);
        sc.commit();
    } finally {
        sc.close();
    }
    Vertex p = sailGraph.getVertex(planet.stringValue());
    FramedGraph<SailGraph> framedGraph = new FramedGraphFactory().create(sailGraph);
    Concept planetFrame = framedGraph.frame(p, Concept.class);
    assertNotNull(planetFrame);
    assertEquals("uri", planetFrame.getKind());
    //assertEquals("...", planetFrame.getValue());
    RDFFrame label = planetFrame.getLabel();
    assertNotNull(label);
    assertEquals("literal", label.getKind());
    assertEquals("en", label.getLang());
    assertEquals("planet", label.getValue());
    Iterable<Concept> narrowerConcepts = planetFrame.getNarrower();
    int counter = 0;
    for (Concept c : narrowerConcepts) {
        counter++;
    }
    assertEquals(counter, 1);
    Concept gasGiantFrame = narrowerConcepts.iterator().next();
    label = gasGiantFrame.getLabel();
    assertEquals("literal", label.getKind());
    assertEquals("en", label.getLang());
    assertEquals("gas giant", label.getValue());
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) Vertex(com.tinkerpop.blueprints.Vertex) SailConnection(org.openrdf.sail.SailConnection) SailGraph(com.tinkerpop.blueprints.impls.sail.SailGraph) URIImpl(org.openrdf.model.impl.URIImpl) URI(org.openrdf.model.URI) Test(org.junit.Test)

Aggregations

SailGraph (com.tinkerpop.blueprints.impls.sail.SailGraph)2 Vertex (com.tinkerpop.blueprints.Vertex)1 Before (org.junit.Before)1 Test (org.junit.Test)1 URI (org.openrdf.model.URI)1 LiteralImpl (org.openrdf.model.impl.LiteralImpl)1 URIImpl (org.openrdf.model.impl.URIImpl)1 SailConnection (org.openrdf.sail.SailConnection)1 MemoryStore (org.openrdf.sail.memory.MemoryStore)1