Search in sources :

Example 71 with URIImpl

use of org.openrdf.model.impl.URIImpl in project blueprints by tinkerpop.

the class GraphSailTest method testAddVertex.

@Test
public void testAddVertex() throws Exception {
    GraphSail gSail = (GraphSail) sail;
    Value toAdd = new URIImpl("http://example.org/thelarch");
    assertNull(gSail.getVertex(toAdd));
    int count = countVertices();
    Vertex added = gSail.addVertex(toAdd);
    assertNotNull(added);
    assertEquals(1 + count, countVertices());
    assertEquals("http://example.org/thelarch", added.getProperty(GraphSail.VALUE));
    // also test that we get the vertex through getVertex
    added = gSail.getVertex(toAdd);
    assertNotNull(added);
    assertEquals("http://example.org/thelarch", added.getProperty(GraphSail.VALUE));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) Value(org.openrdf.model.Value) URIImpl(org.openrdf.model.impl.URIImpl) Test(org.junit.Test)

Example 72 with URIImpl

use of org.openrdf.model.impl.URIImpl in project blueprints by tinkerpop.

the class SailVertex method setProperty.

public void setProperty(final String key, final Object value) {
    if (this.rawVertex instanceof Resource) {
        throw new RuntimeException(URI_BLANK_NODE_PROPERTIES);
    } else {
        boolean update = false;
        final Literal oldLiteral = (Literal) this.rawVertex;
        if (key.equals(SailTokens.DATATYPE)) {
            this.rawVertex = new LiteralImpl(oldLiteral.getLabel(), new URIImpl(this.graph.expandPrefix(value.toString())));
            update = true;
        } else if (key.equals(SailTokens.LANGUAGE)) {
            this.rawVertex = new LiteralImpl(oldLiteral.getLabel(), value.toString());
            update = true;
        }
        if (update) {
            this.updateLiteral(oldLiteral, (Literal) this.rawVertex);
        }
    }
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) Literal(org.openrdf.model.Literal) Resource(org.openrdf.model.Resource) URIImpl(org.openrdf.model.impl.URIImpl)

Example 73 with URIImpl

use of org.openrdf.model.impl.URIImpl in project blueprints by tinkerpop.

the class SailGraphSpecificTestSuite method testTypeConversion.

public void testTypeConversion() {
    assertEquals(SailVertex.castLiteral(new LiteralImpl("marko", new URIImpl("http://www.w3.org/2001/XMLSchema#string"))).getClass(), String.class);
    assertEquals(SailVertex.castLiteral(new LiteralImpl("marko")).getClass(), String.class);
    assertEquals(SailVertex.castLiteral(new LiteralImpl("27", new URIImpl("http://www.w3.org/2001/XMLSchema#int"))).getClass(), Integer.class);
    assertEquals(SailVertex.castLiteral(new LiteralImpl("27", new URIImpl("http://www.w3.org/2001/XMLSchema#float"))).getClass(), Float.class);
    assertEquals(SailVertex.castLiteral(new LiteralImpl("27.0134", new URIImpl("http://www.w3.org/2001/XMLSchema#double"))).getClass(), Double.class);
    assertEquals(SailVertex.castLiteral(new LiteralImpl("hello", "en")), "hello");
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) URIImpl(org.openrdf.model.impl.URIImpl)

Example 74 with URIImpl

use of org.openrdf.model.impl.URIImpl in project wikidata-query-rdf by wikimedia.

the class T213375_UnitTest method test_value_inlining.

@SuppressWarnings("rawtypes")
@Test
public void test_value_inlining() {
    // Prepare value URI
    String value = "http://www.wikidata.org/value/";
    String id = "0123456789abcdef0123456789abcdef01234567";
    String uri = value + id;
    // Pass URI to the journal for inlining
    IV<?, ?> iv = this.store.addTerm(new URIImpl(uri));
    // Test IV type
    assertEquals(URIExtensionIV.class, iv.getClass());
    // Test prefix is inlined as vocabulary IV
    IV extensionIV = ((URIExtensionIV) iv).getExtensionIV();
    assertEquals(VocabURIByteIV.class, extensionIV.getClass());
    // Test prefix encoded correctly in lexicon
    assertEquals(value, extensionIV.asValue(this.store.getLexiconRelation()).stringValue());
    // Test local name is xsd:integer
    assertEquals(XSDIntegerIV.class, ((URIExtensionIV) iv).getLocalNameIV().getClass());
    // Test local name is encoded as hex BigInteger
    assertEquals(new BigInteger(id, 16), ((URIExtensionIV) iv).getLocalNameIV().integerValue());
    // Test string representation of the IV matches to reference URI
    assertEquals(uri, iv.asValue(this.store.getLexiconRelation()).stringValue());
}
Also used : URIExtensionIV(com.bigdata.rdf.internal.impl.uri.URIExtensionIV) BigInteger(java.math.BigInteger) URIImpl(org.openrdf.model.impl.URIImpl) IV(com.bigdata.rdf.internal.IV) XSDIntegerIV(com.bigdata.rdf.internal.impl.literal.XSDIntegerIV) VocabURIByteIV(com.bigdata.rdf.internal.impl.uri.VocabURIByteIV) URIExtensionIV(com.bigdata.rdf.internal.impl.uri.URIExtensionIV) Test(org.junit.Test)

Example 75 with URIImpl

use of org.openrdf.model.impl.URIImpl in project wikidata-query-rdf by wikimedia.

the class WikibasePrefixesUnitTest method testPrefixesRFDSandSchema.

@Test
public void testPrefixesRFDSandSchema() {
    add("wd:Q123", SchemaDotOrg.ABOUT, SKOS.ALT_LABEL);
    TupleQueryResult res = query("SELECT * WHERE { ?x schema:about skos:altLabel }");
    assertResult(res, binds("x", new URIImpl(uris().entityIdToURI("Q123"))));
}
Also used : URIImpl(org.openrdf.model.impl.URIImpl) TupleQueryResult(org.openrdf.query.TupleQueryResult) Test(org.junit.Test)

Aggregations

URIImpl (org.openrdf.model.impl.URIImpl)170 Test (org.junit.Test)120 LiteralImpl (org.openrdf.model.impl.LiteralImpl)62 URI (org.openrdf.model.URI)58 BindingSet (org.openrdf.query.BindingSet)50 MapBindingSet (org.openrdf.query.impl.MapBindingSet)36 RyaURI (org.apache.rya.api.domain.RyaURI)33 HashSet (java.util.HashSet)31 Statement (org.openrdf.model.Statement)30 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)30 ArrayList (java.util.ArrayList)29 RyaType (org.apache.rya.api.domain.RyaType)25 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)24 RyaStatement (org.apache.rya.api.domain.RyaStatement)23 Value (org.openrdf.model.Value)22 NumericLiteralImpl (org.openrdf.model.impl.NumericLiteralImpl)22 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)21 StatementPattern (org.openrdf.query.algebra.StatementPattern)20 StatementImpl (org.openrdf.model.impl.StatementImpl)19 PcjMetadata (org.apache.rya.indexing.pcj.storage.PcjMetadata)16