Search in sources :

Example 11 with MongoEntityStorage

use of org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage in project incubator-rya by apache.

the class MongoEntityIndexerIT method addStatement_setsProperty.

@Test
public void addStatement_setsProperty() throws Exception {
    try (MongoEntityIndexer indexer = new MongoEntityIndexer()) {
        indexer.setConf(conf);
        indexer.init();
        // Load the types into the TypeStorage.
        final TypeStorage types = new MongoTypeStorage(getMongoClient(), conf.getRyaInstanceName());
        types.create(PERSON_TYPE);
        types.create(EMPLOYEE_TYPE);
        // Index a RyaStatement that will create an Entity with two implicit types.
        final RyaStatement statement = new RyaStatement(new RyaURI("urn:SSN/111-11-1111"), new RyaURI("urn:name"), new RyaType(XMLSchema.STRING, "Alice"));
        indexer.storeStatement(statement);
        // Fetch the Entity from storage and ensure it looks correct.
        final EntityStorage entities = new MongoEntityStorage(getMongoClient(), conf.getRyaInstanceName());
        final Entity entity = entities.get(new RyaURI("urn:SSN/111-11-1111")).get();
        final Entity expected = Entity.builder().setSubject(new RyaURI("urn:SSN/111-11-1111")).setProperty(new RyaURI("urn:person"), new Property(new RyaURI("urn:name"), new RyaType(XMLSchema.STRING, "Alice"))).setProperty(new RyaURI("urn:employee"), new Property(new RyaURI("urn:name"), new RyaType(XMLSchema.STRING, "Alice"))).build();
        assertEquals(expected, entity);
    }
}
Also used : MongoTypeStorage(org.apache.rya.indexing.entity.storage.mongo.MongoTypeStorage) TypeStorage(org.apache.rya.indexing.entity.storage.TypeStorage) RyaURI(org.apache.rya.api.domain.RyaURI) Entity(org.apache.rya.indexing.entity.model.Entity) MongoTypeStorage(org.apache.rya.indexing.entity.storage.mongo.MongoTypeStorage) MongoEntityStorage(org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage) EntityStorage(org.apache.rya.indexing.entity.storage.EntityStorage) MongoEntityStorage(org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaType(org.apache.rya.api.domain.RyaType) Property(org.apache.rya.indexing.entity.model.Property) Test(org.junit.Test)

Example 12 with MongoEntityStorage

use of org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage in project incubator-rya by apache.

the class MongoEntityIndexerIT method addStatement_setsType.

@Test
public void addStatement_setsType() throws Exception {
    try (MongoEntityIndexer indexer = new MongoEntityIndexer()) {
        indexer.setConf(conf);
        indexer.init();
        // Load a type into the TypeStorage.
        final TypeStorage types = new MongoTypeStorage(getMongoClient(), conf.getRyaInstanceName());
        types.create(PERSON_TYPE);
        // Index a RyaStatement that will create an Entity with an explicit type.
        final RyaStatement statement = new RyaStatement(new RyaURI("urn:SSN/111-11-1111"), new RyaURI(RDF.TYPE.toString()), new RyaType(XMLSchema.ANYURI, "urn:person"));
        indexer.storeStatement(statement);
        // Fetch the Entity from storage and ensure it looks correct.
        final EntityStorage entities = new MongoEntityStorage(getMongoClient(), conf.getRyaInstanceName());
        final Entity entity = entities.get(new RyaURI("urn:SSN/111-11-1111")).get();
        final Entity expected = Entity.builder().setSubject(new RyaURI("urn:SSN/111-11-1111")).setExplicitType(new RyaURI("urn:person")).build();
        assertEquals(expected, entity);
    }
}
Also used : MongoTypeStorage(org.apache.rya.indexing.entity.storage.mongo.MongoTypeStorage) TypeStorage(org.apache.rya.indexing.entity.storage.TypeStorage) RyaURI(org.apache.rya.api.domain.RyaURI) Entity(org.apache.rya.indexing.entity.model.Entity) MongoTypeStorage(org.apache.rya.indexing.entity.storage.mongo.MongoTypeStorage) MongoEntityStorage(org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage) EntityStorage(org.apache.rya.indexing.entity.storage.EntityStorage) MongoEntityStorage(org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaType(org.apache.rya.api.domain.RyaType) Test(org.junit.Test)

Aggregations

MongoEntityStorage (org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage)12 Entity (org.apache.rya.indexing.entity.model.Entity)11 EntityStorage (org.apache.rya.indexing.entity.storage.EntityStorage)11 Test (org.junit.Test)11 Property (org.apache.rya.indexing.entity.model.Property)10 RyaURI (org.apache.rya.api.domain.RyaURI)9 RyaType (org.apache.rya.api.domain.RyaType)8 TypeStorage (org.apache.rya.indexing.entity.storage.TypeStorage)8 MongoTypeStorage (org.apache.rya.indexing.entity.storage.mongo.MongoTypeStorage)8 RyaStatement (org.apache.rya.api.domain.RyaStatement)6 ValueFactory (org.openrdf.model.ValueFactory)3 BindingSet (org.openrdf.query.BindingSet)3 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)3 StatementPattern (org.openrdf.query.algebra.StatementPattern)3 MapBindingSet (org.openrdf.query.impl.MapBindingSet)3 ImmutableList (com.google.common.collect.ImmutableList)2 Date (java.util.Date)2 List (java.util.List)2 ReflectionToStringBuilder (org.apache.commons.lang.builder.ReflectionToStringBuilder)2 RyaTypeUtils.booleanRyaType (org.apache.rya.api.domain.RyaTypeUtils.booleanRyaType)2