Search in sources :

Example 1 with BNodeImpl

use of org.openrdf.model.impl.BNodeImpl in project stanbol by apache.

the class RdfRepresentationTest method testBNodeFiltering.

/**
     * Test for STANBOL-1301
     */
@Test
public void testBNodeFiltering() {
    URI concept = new URIImpl("http://example.org/mySkos#Concept123");
    Representation r = createRepresentation(concept.stringValue());
    assertTrue(r instanceof RdfRepresentation);
    RdfRepresentation rep = (RdfRepresentation) r;
    //add the example as listed in STANBOL-1301 to directly to the
    //Sesame Model backing the created Representation
    Model m = rep.getModel();
    m.add(concept, RDF.TYPE, SKOS.CONCEPT);
    m.add(concept, DCTERMS.IDENTIFIER, new LiteralImpl("123"));
    m.add(concept, SKOS.PREF_LABEL, new LiteralImpl("Concept123", "en"));
    BNode note1 = new BNodeImpl("5d8580be71044a88bcfe9852d1e9cfb6node17c4j452vx19576");
    m.add(concept, SKOS.SCOPE_NOTE, note1);
    m.add(note1, DCTERMS.CREATOR, new LiteralImpl("User1"));
    m.add(note1, DCTERMS.CREATED, new LiteralImpl("2013-03-03T02:02:02Z", XMLSchema.DATETIME));
    m.add(note1, RDFS.COMMENT, new LiteralImpl("The scope of this example global", "en"));
    BNode note2 = new BNodeImpl("5d8580be71044a88bcfe9852d1e9cfb6node17c4j452vx19634");
    m.add(concept, SKOS.SCOPE_NOTE, note2);
    m.add(note2, DCTERMS.CREATOR, new LiteralImpl("User2"));
    m.add(note2, DCTERMS.CREATED, new LiteralImpl("2013-03-03T04:04:04Z", XMLSchema.DATETIME));
    m.add(note2, RDFS.COMMENT, new LiteralImpl("Der Geltungsbereich ist Global", "de"));
    //now assert that BNodes are not reported via the Representation API
    Iterator<Object> scopeNotes = rep.get(SKOS.SCOPE_NOTE.stringValue());
    assertFalse(scopeNotes.hasNext());
    Iterator<Reference> scopeNoteRefs = rep.getReferences(SKOS.SCOPE_NOTE.stringValue());
    assertFalse(scopeNoteRefs.hasNext());
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) BNode(org.openrdf.model.BNode) Reference(org.apache.stanbol.entityhub.servicesapi.model.Reference) Model(org.openrdf.model.Model) URIImpl(org.openrdf.model.impl.URIImpl) Representation(org.apache.stanbol.entityhub.servicesapi.model.Representation) URI(org.openrdf.model.URI) BNodeImpl(org.openrdf.model.impl.BNodeImpl) RepresentationTest(org.apache.stanbol.entityhub.test.model.RepresentationTest) Test(org.junit.Test)

Aggregations

Reference (org.apache.stanbol.entityhub.servicesapi.model.Reference)1 Representation (org.apache.stanbol.entityhub.servicesapi.model.Representation)1 RepresentationTest (org.apache.stanbol.entityhub.test.model.RepresentationTest)1 Test (org.junit.Test)1 BNode (org.openrdf.model.BNode)1 Model (org.openrdf.model.Model)1 URI (org.openrdf.model.URI)1 BNodeImpl (org.openrdf.model.impl.BNodeImpl)1 LiteralImpl (org.openrdf.model.impl.LiteralImpl)1 URIImpl (org.openrdf.model.impl.URIImpl)1