Search in sources :

Example 6 with EventStorage

use of org.apache.rya.indexing.geotemporal.storage.EventStorage in project incubator-rya by apache.

the class MongoEventStorageIT method create_and_get.

@Test
public void create_and_get() throws Exception {
    final Geometry geo = GF.createPoint(new Coordinate(10, 10));
    final TemporalInstant instant = new TemporalInstantRfc3339(DateTime.now());
    // An Event that will be stored.
    final Event event = Event.builder().setSubject(new RyaURI("urn:event/001")).setGeometry(geo).setTemporalInstant(instant).build();
    // Create it.
    final EventStorage storage = new MongoEventStorage(super.getMongoClient(), RYA_INSTANCE_NAME);
    storage.create(event);
    // Get it.
    final Optional<Event> storedEvent = storage.get(new RyaURI("urn:event/001"));
    // Verify the correct value was returned.
    assertEquals(event, storedEvent.get());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) RyaURI(org.apache.rya.api.domain.RyaURI) Coordinate(com.vividsolutions.jts.geom.Coordinate) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) Event(org.apache.rya.indexing.geotemporal.model.Event) TemporalInstant(org.apache.rya.indexing.TemporalInstant) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage) Test(org.junit.Test)

Example 7 with EventStorage

use of org.apache.rya.indexing.geotemporal.storage.EventStorage in project incubator-rya by apache.

the class MongoEventStorageIT method delete.

@Test
public void delete() throws Exception {
    final Geometry geo = GF.createPoint(new Coordinate(10, 10));
    final TemporalInstant instant = new TemporalInstantRfc3339(DateTime.now());
    // An Event that will be stored.
    final Event event = Event.builder().setSubject(new RyaURI("urn:event/002")).setGeometry(geo).setTemporalInstant(instant).build();
    // Create it.
    final EventStorage storage = new MongoEventStorage(super.getMongoClient(), RYA_INSTANCE_NAME);
    storage.create(event);
    // Delete it.
    final boolean deleted = storage.delete(new RyaURI("urn:event/002"));
    // Verify a document was deleted.
    assertTrue(deleted);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) RyaURI(org.apache.rya.api.domain.RyaURI) Coordinate(com.vividsolutions.jts.geom.Coordinate) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) Event(org.apache.rya.indexing.geotemporal.model.Event) TemporalInstant(org.apache.rya.indexing.TemporalInstant) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage) Test(org.junit.Test)

Example 8 with EventStorage

use of org.apache.rya.indexing.geotemporal.storage.EventStorage in project incubator-rya by apache.

the class MongoEventStorageIT method update_differentSubjects.

@Test(expected = EventStorageException.class)
public void update_differentSubjects() throws Exception {
    final EventStorage storage = new MongoEventStorage(super.getMongoClient(), RYA_INSTANCE_NAME);
    final Geometry geo = GF.createPoint(new Coordinate(10, 10));
    final TemporalInstant instant = new TemporalInstantRfc3339(DateTime.now());
    // Two objects that do not have the same Subjects.
    final Event old = Event.builder().setSubject(new RyaURI("urn:event/001")).setGeometry(geo).setTemporalInstant(instant).build();
    final Event updated = Event.builder().setSubject(new RyaURI("urn:event/002")).setGeometry(geo).setTemporalInstant(instant).build();
    // The update will fail.
    storage.update(old, updated);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) RyaURI(org.apache.rya.api.domain.RyaURI) Coordinate(com.vividsolutions.jts.geom.Coordinate) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) Event(org.apache.rya.indexing.geotemporal.model.Event) TemporalInstant(org.apache.rya.indexing.TemporalInstant) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage) Test(org.junit.Test)

Example 9 with EventStorage

use of org.apache.rya.indexing.geotemporal.storage.EventStorage in project incubator-rya by apache.

the class MongoEventStorageIT method get_noneExisting.

@Test
public void get_noneExisting() throws Exception {
    // Get a Type that hasn't been created.
    final EventStorage storage = new MongoEventStorage(super.getMongoClient(), RYA_INSTANCE_NAME);
    final Optional<Event> storedEvent = storage.get(new RyaURI("urn:event/000"));
    // Verify nothing was returned.
    assertFalse(storedEvent.isPresent());
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) Event(org.apache.rya.indexing.geotemporal.model.Event) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage) Test(org.junit.Test)

Example 10 with EventStorage

use of org.apache.rya.indexing.geotemporal.storage.EventStorage in project incubator-rya by apache.

the class MongoEventStorageIT method can_not_create_with_same_subject.

@Test
public void can_not_create_with_same_subject() throws Exception {
    final Geometry geo = GF.createPoint(new Coordinate(10, 10));
    final TemporalInstant instant = new TemporalInstantRfc3339(DateTime.now());
    // An Event that will be stored.
    final Event event = Event.builder().setSubject(new RyaURI("urn:event/001")).setGeometry(geo).setTemporalInstant(instant).build();
    // Create it.
    final EventStorage storage = new MongoEventStorage(super.getMongoClient(), RYA_INSTANCE_NAME);
    storage.create(event);
    // Try to create it again. This will fail.
    boolean failed = false;
    try {
        storage.create(event);
    } catch (final EventAlreadyExistsException e) {
        failed = true;
    }
    assertTrue(failed);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) RyaURI(org.apache.rya.api.domain.RyaURI) Coordinate(com.vividsolutions.jts.geom.Coordinate) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) Event(org.apache.rya.indexing.geotemporal.model.Event) TemporalInstant(org.apache.rya.indexing.TemporalInstant) EventAlreadyExistsException(org.apache.rya.indexing.geotemporal.storage.EventStorage.EventAlreadyExistsException) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage) Test(org.junit.Test)

Aggregations

EventStorage (org.apache.rya.indexing.geotemporal.storage.EventStorage)15 RyaURI (org.apache.rya.api.domain.RyaURI)14 Test (org.junit.Test)13 TemporalInstant (org.apache.rya.indexing.TemporalInstant)11 TemporalInstantRfc3339 (org.apache.rya.indexing.TemporalInstantRfc3339)11 Geometry (com.vividsolutions.jts.geom.Geometry)10 Event (org.apache.rya.indexing.geotemporal.model.Event)10 Coordinate (com.vividsolutions.jts.geom.Coordinate)9 MongoEventStorage (org.apache.rya.indexing.geotemporal.mongo.MongoEventStorage)4 BindingSet (org.openrdf.query.BindingSet)4 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)4 MapBindingSet (org.openrdf.query.impl.MapBindingSet)4 ParseException (com.vividsolutions.jts.io.ParseException)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 RyaStatement (org.apache.rya.api.domain.RyaStatement)2 TemporalInterval (org.apache.rya.indexing.TemporalInterval)2 GmlParser (org.apache.rya.indexing.mongodb.geo.GmlParser)2 URI (org.openrdf.model.URI)2 IOException (java.io.IOException)1