use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class MongoGeoTemporalIndexerIT method ensureEvent.
@Test
public void ensureEvent() throws Exception {
final RyaStatement geoStmnt = statement(point(0, 0));
final RyaStatement timeStmnt = statement(makeInstant(0));
final EventStorage store = indexer.getEventStorage();
indexer.storeStatement(geoStmnt);
Optional<Event> evnt = store.get(geoStmnt.getSubject());
assertTrue(evnt.isPresent());
Event expected = Event.builder().setSubject(geoStmnt.getSubject()).setGeometry(point(0, 0)).build();
assertEquals(expected, evnt.get());
indexer.storeStatement(timeStmnt);
evnt = store.get(timeStmnt.getSubject());
assertTrue(evnt.isPresent());
expected = Event.builder().setSubject(geoStmnt.getSubject()).setGeometry(point(0, 0)).setTemporalInstant(makeInstant(0)).build();
assertEquals(expected, evnt.get());
indexer.deleteStatement(geoStmnt);
evnt = store.get(timeStmnt.getSubject());
assertTrue(evnt.isPresent());
expected = Event.builder().setSubject(timeStmnt.getSubject()).setTemporalInstant(makeInstant(0)).build();
assertEquals(expected, evnt.get());
indexer.deleteStatement(timeStmnt);
evnt = store.get(timeStmnt.getSubject());
assertTrue(evnt.isPresent());
expected = Event.builder().setSubject(timeStmnt.getSubject()).build();
assertEquals(expected, evnt.get());
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class MongoIndexerDeleteIT method populateRya.
private void populateRya(final SailRepositoryConnection conn) throws Exception {
final ValueFactory VF = new ValueFactoryImpl();
// geo 2x2 points
final GeometryFactory GF = new GeometryFactory();
for (int x = 0; x <= 1; x++) {
for (int y = 0; y <= 1; y++) {
final Geometry geo = GF.createPoint(new Coordinate(x + .5, y + .5));
final RyaStatement stmnt = statement(geo);
final Statement statement = RyaToRdfConversions.convertStatement(stmnt);
conn.add(statement);
}
}
// freetext
final URI person = VF.createURI("http://example.org/ontology/Person");
String uuid;
uuid = "urn:people";
conn.add(VF.createURI(uuid), RDF.TYPE, person);
conn.add(VF.createURI(uuid), RDFS.LABEL, VF.createLiteral("Alice Palace Hose", VF.createURI("http://www.w3.org/2001/XMLSchema#string")));
conn.add(VF.createURI(uuid), RDFS.LABEL, VF.createLiteral("Bob Snob Hose", "en"));
// temporal
final TemporalInstant instant = new TemporalInstantRfc3339(1, 2, 3, 4, 5, 6);
conn.add(VF.createURI("foo:time"), VF.createURI("Property:atTime"), VF.createLiteral(instant.toString()));
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class RyaEdgeReader method getCurrentEdge.
@Override
public Edge<Text, RyaStatementWritable> getCurrentEdge() throws IOException, InterruptedException {
RyaStatementWritable currentStatement = reader.getCurrentValue();
RyaStatement ryaStatement = currentStatement.getRyaStatement();
Edge<Text, RyaStatementWritable> edge = EdgeFactory.create(new Text(ryaStatement.toString()), currentStatement);
return edge;
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class MongoGeoTemporalIndexer method updateEvent.
private void updateEvent(final RyaURI subject, final RyaStatement statement) throws IndexingException, ParseException {
final EventStorage eventStore = events.get();
checkState(events != null, "Must set this indexers configuration before storing statements.");
new EventUpdater(eventStore).update(subject, old -> {
final Event.Builder updated;
if (!old.isPresent()) {
updated = Event.builder().setSubject(subject);
} else {
updated = Event.builder(old.get());
}
final URI pred = statement.getObject().getDataType();
if (pred.equals(GeoConstants.GEO_AS_WKT) || pred.equals(GeoConstants.GEO_AS_GML) || pred.equals(GeoConstants.XMLSCHEMA_OGC_WKT) || pred.equals(GeoConstants.XMLSCHEMA_OGC_GML)) {
// is geo
try {
final Statement geoStatement = RyaToRdfConversions.convertStatement(statement);
final Geometry geometry = GeoParseUtils.getGeometry(geoStatement, new GmlParser());
updated.setGeometry(geometry);
} catch (final ParseException e) {
LOG.error(e.getMessage(), e);
}
} else {
// is time
final String dateTime = statement.getObject().getData();
final Matcher matcher = TemporalInstantRfc3339.PATTERN.matcher(dateTime);
if (matcher.find()) {
final TemporalInterval interval = TemporalInstantRfc3339.parseInterval(dateTime);
updated.setTemporalInterval(interval);
} else {
final TemporalInstant instant = new TemporalInstantRfc3339(DateTime.parse(dateTime));
updated.setTemporalInstant(instant);
}
}
return Optional.of(updated.build());
});
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class EntityCentricIndexTest method testDeserializeObjectRow.
@Test
public void testDeserializeObjectRow() throws RyaTypeResolverException, IOException {
RyaStatement deserialized = EntityCentricIndex.deserializeStatement(objectCentricKey, value);
Assert.assertEquals("Deserialization of object-centric row failed to produce equivalent RyaStatement.", ryaStatement, deserialized);
}
Aggregations